Exemple #1
0
/*==========================================
 * 傭兵削除
 *------------------------------------------
 */
bool mercdb_sql_delete(int merc_id)
{
	bool result = false;

	if( sqldbs_transaction_start(&mysql_handle) == false )
		return result;

	// try
	do
	{
		// delete merc
		if( sqldbs_query(&mysql_handle, "DELETE FROM `" MERC_TABLE "` WHERE `merc_id`='%d'", merc_id) == false )
			break;

		// success
		result = true;

		{
			// cache delete
			struct mmo_mercstatus *p = (struct mmo_mercstatus *)numdb_erase(merc_db, merc_id);
			if(p) {
				aFree(p);
			}
		}
	} while(0);

	sqldbs_transaction_end(&mysql_handle, result);

	return result;
}
Exemple #2
0
/*==========================================
 * ホム削除
 *------------------------------------------
 */
bool homundb_sql_delete(int homun_id)
{
	bool result = false;

	if( sqldbs_transaction_start(&mysql_handle) == false )
		return result;

	// try
	do
	{
		// delete homun
		if( sqldbs_query(&mysql_handle, "DELETE FROM `" HOMUN_TABLE "` WHERE `homun_id`='%d'", homun_id) == false )
			break;

		// delete homun skill
		if( sqldbs_query(&mysql_handle, "DELETE FROM `" HOMUN_SKILL_TABLE "` WHERE `homun_id`='%d'", homun_id) == false )
			break;

		// success
		result = true;

		{
			// cache delete
			struct mmo_homunstatus *p = (struct mmo_homunstatus *)numdb_erase(homun_db, homun_id);
			if(p) {
				aFree(p);
			}
		}
	} while(0);

	sqldbs_transaction_end(&mysql_handle, result);

	return result;
}
Exemple #3
0
/*==========================================
 * セーブ
 *------------------------------------------
 */
bool questdb_sql_save(struct quest *q2)
{
	const struct quest *q1;
	bool result = false;

	nullpo_retr(false, q2);

	q1 = questdb_sql_load(q2->char_id);

	if(q1 && q1->count <= 0 && q2->count <= 0) {
		// データが共に0個なので何もしない
		return true;
	}

	if( sqldbs_transaction_start(&mysql_handle) == false )
		return false;

	// try
	do {
		int i;

		if(q1 == NULL || q1->count > 0) {
			// データサーバ側にデータがあるときだけ削除クエリを発行
			if( sqldbs_query(&mysql_handle, "DELETE FROM `" QUEST_TABLE "` WHERE `char_id`='%d'", q2->char_id) == false )
				break;
		}

		for(i = 0; i < q2->count; i++) {
			if( sqldbs_query(&mysql_handle,
				"INSERT INTO `" QUEST_TABLE "` (`char_id`, `account_id`, `nameid`, `state`, `limit`, `mobid1`, `mobmax1`, `mobcnt1`, "
				"`mobid2`, `mobmax2`, `mobcnt2`, `mobid3`, `mobmax3`, `mobcnt3`) "
				"VALUES ('%d','%d','%d','%d','%u','%d','%d','%d','%d','%d','%d','%d','%d','%d')",
				q2->char_id, q2->account_id, q2->data[i].nameid, q2->data[i].state, q2->data[i].limit,
				q2->data[i].mob[0].id, q2->data[i].mob[0].max, q2->data[i].mob[0].cnt,
				q2->data[i].mob[1].id, q2->data[i].mob[1].max, q2->data[i].mob[1].cnt,
				q2->data[i].mob[2].id, q2->data[i].mob[2].max, q2->data[i].mob[2].cnt
			) == false )
				break;
		}
		if(i != q2->count)
			break;

		// success
		result = true;

		{
			// cache copy
			struct quest *q3 = (struct quest *)numdb_search(quest_db, q2->char_id);
			if(q3)
				memcpy(q3, q2, sizeof(struct quest));
		}
	} while(0);

	sqldbs_transaction_end(&mysql_handle, result);

	return result;
}
Exemple #4
0
/*==========================================
 * セーブ
 *------------------------------------------
 */
bool mercdb_sql_save(struct mmo_mercstatus *p2)
{
	char sep = ' ';
	char tmp_sql[65536];
	char *p = tmp_sql;
	const struct mmo_mercstatus *p1;
	bool result = false;

	nullpo_retr(false, p2);

	p1 = mercdb_sql_load(p2->merc_id);
	if(p1 == NULL)
		return false;

	strcpy(p, "UPDATE `" MERC_TABLE "` SET");
	p += strlen(p);

	UPDATE_NUM(class_     ,"class");
	UPDATE_NUM(account_id ,"account_id");
	UPDATE_NUM(char_id    ,"char_id");
	UPDATE_NUM(hp         ,"hp");
	UPDATE_NUM(sp         ,"sp");
	UPDATE_NUM(kill_count ,"kill_count");
	UPDATE_UNUM(limit     ,"limit");

	if( sqldbs_transaction_start(&mysql_handle) == false )
		return false;

	// try
	do {
		if(sep == ',') {
			sprintf(p, " WHERE `merc_id` = '%d'",p2->merc_id);
			if( sqldbs_simplequery(&mysql_handle, tmp_sql) == false )
				break;
		}

		// success
		result = true;

		{
			// cache copy
			struct mmo_mercstatus *p3 = (struct mmo_mercstatus *)numdb_search(merc_db, p2->merc_id);
			if(p3)
				memcpy(p3, p2, sizeof(struct mmo_mercstatus));
		}
	} while(0);

	sqldbs_transaction_end(&mysql_handle, result);

	return result;
}
Exemple #5
0
/*==========================================
 * ギルド倉庫削除
 *------------------------------------------
 */
bool gstoragedb_sql_delete(int guild_id)
{
	const struct guild_storage *s = gstoragedb_sql_load(guild_id);
	bool result = false;

	if( sqldbs_transaction_start(&mysql_handle) == false )
		return result;

	// try
	do
	{
		if(s) {
			int i;
			for(i = 0; i < s->storage_amount; i++) {
				// ペット削除
				if( s->store_item[i].card[0] == (short)0xff00) {
					if( petdb_delete(*((int *)(&s->store_item[i].card[1]))) == false )
						break;
				}
			}
			if(i != s->storage_amount)
				break;
		}

		// delete
		if( sqldbs_query(&mysql_handle, "DELETE FROM `" GUILD_STORAGE_TABLE "` WHERE `guild_id`='%d'", guild_id) == false )
			break;

		// success
		result = true;

		{
			// cache delete
			struct guild_storage *s2 = (struct guild_storage *)numdb_erase(gstorage_db, guild_id);
			if(s2) {
				aFree(s2);
			}
		}
	} while(0);

	sqldbs_transaction_end(&mysql_handle, result);

	return result;
}
Exemple #6
0
/*==========================================
 * ホム作成
 *------------------------------------------
 */
bool homundb_sql_new(struct mmo_homunstatus *p)
{
	bool result = false;

	nullpo_retr(false, p);

	if( sqldbs_transaction_start(&mysql_handle) == false )
		return false;

	// try
	do {
		int i;
		char t_name[64];

		if( sqldbs_query(&mysql_handle,
			"INSERT INTO `" HOMUN_TABLE "` (`class`,`name`,`account_id`,`char_id`,`base_level`,`base_exp`,"
			"`max_hp`,`hp`,`max_sp`,`sp`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,"
			"`f_str`,`f_agi`,`f_vit`,`f_int`,`f_dex`,`f_luk`,"
			"`status_point`,`skill_point`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`) "
			"VALUES ('%d', '%s', '%d', '%d',"
			"'%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d',"
			"'%d', '%d', '%d', '%d', '%d', '%d',"
			"'%d', '%d', '%d', '%d', '%d', '%d', '%d')",
			p->class_, strecpy(t_name, p->name), p->account_id, p->char_id, p->base_level,
			p->base_exp, p->max_hp, p->hp, p->max_sp, p->sp, p->str, p->agi, p->vit, p->int_, p->dex, p->luk,
			p->f_str, p->f_agi, p->f_vit, p->f_int, p->f_dex, p->f_luk,
			p->status_point, p->skill_point, p->equip, p->intimate,
			p->hungry, p->rename_flag, p->incubate
		) == false ) {
			p->homun_id = -1;
			break;
		}

		p->homun_id = (int)sqldbs_insert_id(&mysql_handle);

		for(i = 0; i < MAX_HOMSKILL; i++) {
			if(p->skill[i].id && p->skill[i].flag != 1) {
				int lv = (p->skill[i].flag == 0)? p->skill[i].lv: p->skill[i].flag - 2;
				if( sqldbs_query(&mysql_handle,
					"INSERT INTO `" HOMUN_SKILL_TABLE "` (`homun_id`,`id`,`lv`) VALUES ('%d','%d','%d')",
					p->homun_id, p->skill[i].id, lv
				) == false )
					break;
			}
		}
		if(i != MAX_HOMSKILL)
			break;

		// success
		result = true;

		{
			// cache copy
			struct mmo_homunstatus *p2 = (struct mmo_homunstatus*)aMalloc(sizeof(struct mmo_homunstatus));
			memcpy(p2, p, sizeof(struct mmo_homunstatus));
			numdb_insert(homun_db, p->homun_id, p2);
		}
	} while(0);

	sqldbs_transaction_end(&mysql_handle, result);

	return true;
}
Exemple #7
0
/*==========================================
 * セーブ
 *------------------------------------------
 */
bool homundb_sql_save(struct mmo_homunstatus *p2)
{
	const struct mmo_homunstatus *p1;
	char buf[64], tmp_sql[65536];
	char sep = ' ';
	char *p = tmp_sql;
	bool result = false;

	nullpo_retr(false, p2);

	p1 = homundb_sql_load(p2->homun_id);
	if(p1 == NULL)
		return 0;

	strcpy(p, "UPDATE `" HOMUN_TABLE "` SET");
	p += strlen(p);

	UPDATE_NUM(class_      ,"class");
	UPDATE_STR(name        ,"name");
	UPDATE_NUM(account_id  ,"account_id");
	UPDATE_NUM(char_id     ,"char_id");
	UPDATE_NUM(base_level  ,"base_level");
	UPDATE_NUM(base_exp    ,"base_exp");
	UPDATE_NUM(max_hp      ,"max_hp");
	UPDATE_NUM(hp          ,"hp");
	UPDATE_NUM(max_sp      ,"max_sp");
	UPDATE_NUM(sp          ,"sp");
	UPDATE_NUM(str         ,"str");
	UPDATE_NUM(agi         ,"agi");
	UPDATE_NUM(vit         ,"vit");
	UPDATE_NUM(int_        ,"int");
	UPDATE_NUM(dex         ,"dex");
	UPDATE_NUM(luk         ,"luk");
	UPDATE_NUM(f_str       ,"f_str");
	UPDATE_NUM(f_agi       ,"f_agi");
	UPDATE_NUM(f_vit       ,"f_vit");
	UPDATE_NUM(f_int       ,"f_int");
	UPDATE_NUM(f_dex       ,"f_dex");
	UPDATE_NUM(f_luk       ,"f_luk");
	UPDATE_NUM(status_point,"status_point");
	UPDATE_NUM(skill_point ,"skill_point");
	UPDATE_NUM(equip       ,"equip");
	UPDATE_NUM(intimate    ,"intimate");
	UPDATE_NUM(hungry      ,"hungry");
	UPDATE_NUM(rename_flag ,"rename_flag");
	UPDATE_NUM(incubate    ,"incubate");

	if( sqldbs_transaction_start(&mysql_handle) == false )
		return false;

	// try
	do {
		if(sep == ',') {
			sprintf(p, " WHERE `homun_id` = '%d'", p2->homun_id);
			if( sqldbs_simplequery(&mysql_handle, tmp_sql) == false )
				break;
		}

		if(memcmp(p1->skill, p2->skill, sizeof(p1->skill)) ) {
			int i;

			if( sqldbs_query(&mysql_handle, "DELETE FROM `" HOMUN_SKILL_TABLE "` WHERE `homun_id`='%d'", p2->homun_id) == false )
				break;

			for(i = 0; i < MAX_HOMSKILL; i++) {
				if(p2->skill[i].id && p2->skill[i].flag != 1) {
					int lv = (p2->skill[i].flag == 0)? p2->skill[i].lv: p2->skill[i].flag - 2;
					if( sqldbs_query(&mysql_handle,
						"INSERT INTO `" HOMUN_SKILL_TABLE "` (`homun_id`,`id`,`lv`) VALUES ('%d','%d','%d')",
						p2->homun_id, p2->skill[i].id, lv
					) == false )
						break;
				}
			}
			if(i != MAX_HOMSKILL)
				break;
		}

		// success
		result = true;

		{
			// cache copy
			struct mmo_homunstatus *p3 = (struct mmo_homunstatus *)numdb_search(homun_db, p2->homun_id);
			if(p3)
				memcpy(p3, p2, sizeof(struct mmo_homunstatus));
		}
	} while(0);

	sqldbs_transaction_end(&mysql_handle, result);

	return result;
}