Переглянути джерело

Cleaned up processing of secondary tables (#1946)

* Cleaned up processing of secondary tables
* Fixes #1934.
* Renewal and Pre-Renewal secondary tables are now properly loaded depending on the server mode.
* Includes item, monster, and monster skill tables.
Thanks to @Lemongrass3110 and @daisyanne1380!
Aleos 8 роки тому
батько
коміт
5d22e1cf48
9 змінених файлів з 122 додано та 125 видалено
  1. 19 19
      conf/inter_athena.conf
  2. 2 2
      src/map/atcommand.c
  3. 11 11
      src/map/buyingstore.c
  4. 3 3
      src/map/cashshop.c
  5. 4 8
      src/map/itemdb.c
  6. 58 46
      src/map/map.c
  7. 11 14
      src/map/map.h
  8. 4 12
      src/map/mob.c
  9. 10 10
      src/map/vending.c

+ 19 - 19
conf/inter_athena.conf

@@ -126,27 +126,27 @@ clan_table: clan
 clan_alliance_table: clan_alliance
 
 // Map Database Tables
-buyingstore_db: buyingstores
-buyingstore_items_db: buyingstore_items
-item_db_db: item_db
-item_db_re_db: item_db_re
-item_db2_db: item_db2
-//item_db2_db: item_db2_re
-item_cash_db_db: item_cash_db
-item_cash_db2_db: item_cash_db2
-mob_db_db: mob_db
-mob_db_re_db: mob_db_re
-mob_db2_db: mob_db2
-//mob_db2_db: mob_db2_re
-mob_skill_db_db: mob_skill_db
-mob_skill_db_re_db: mob_skill_db_re
-mob_skill_db2_db: mob_skill_db2
-//mob_skill_db2_db: mob_skill_db2_re
+buyingstore_table: buyingstores
+buyingstore_items_table: buyingstore_items
+item_table: item_db
+renewal-item_table: item_db_re
+item2_table: item_db2
+renewal-item2_table: item_db2_re
+item_cash_table: item_cash_db
+item_cash2_table: item_cash_db2
+mob_table: mob_db
+renewal-mob_table: mob_db_re
+mob2_table: mob_db2
+renewal-mob2_table: mob_db2_re
+mob_skill_table: mob_skill_db
+renewal-mob_skill_table: mob_skill_db_re
+mob_skill2_table: mob_skill_db2
+renewal-mob_skill2_table: mob_skill_db2_re
 mapreg_table: mapreg
-vending_db: vendings
-vending_items_db: vending_items
+vending_table: vendings
+vending_items_table: vending_items
 market_table: market
-db_roulette_table: db_roulette
+roulette_table: db_roulette
 
 // Use SQL item_db, mob_db and mob_skill_db for the map server? (yes/no)
 use_sql_db: no

+ 2 - 2
src/map/atcommand.c

@@ -5951,11 +5951,11 @@ ACMD_FUNC(autotrade) {
 		sd->state.monster_ignore = 1;
 
 	if( sd->state.vending ){
-		if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
+		if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
 			Sql_ShowDebug( mmysql_handle );
 		}
 	}else if( sd->state.buyingstore ){
-		if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_db, sd->buyer_id ) != SQL_SUCCESS ){
+		if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
 			Sql_ShowDebug( mmysql_handle );
 		}
 	}

+ 11 - 11
src/map/buyingstore.c

@@ -228,12 +228,12 @@ int8 buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
 
 	if( Sql_Query( mmysql_handle, "INSERT INTO `%s`(`id`, `account_id`, `char_id`, `sex`, `map`, `x`, `y`, `title`, `limit`, `autotrade`, `body_direction`, `head_direction`, `sit`) "
 		"VALUES( %d, %d, %d, '%c', '%s', %d, %d, '%s', %d, %d, '%d', '%d', '%d' );",
-		buyingstores_db, sd->buyer_id, sd->status.account_id, sd->status.char_id, sd->status.sex == 0 ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->buyingstore.zenylimit, sd->state.autotrade, at ? at->dir : sd->ud.dir, at ? at->head_dir : sd->head_dir, at ? at->sit : pc_issit(sd) ) != SQL_SUCCESS ){
+		buyingstores_table, sd->buyer_id, sd->status.account_id, sd->status.char_id, sd->status.sex == 0 ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->buyingstore.zenylimit, sd->state.autotrade, at ? at->dir : sd->ud.dir, at ? at->head_dir : sd->head_dir, at ? at->sit : pc_issit(sd) ) != SQL_SUCCESS ){
 		Sql_ShowDebug(mmysql_handle);
 	}
 
 	StringBuf_Init(&buf);
-	StringBuf_Printf(&buf, "INSERT INTO `%s`(`buyingstore_id`,`index`,`item_id`,`amount`,`price`) VALUES", buyingstore_items_db);
+	StringBuf_Printf(&buf, "INSERT INTO `%s`(`buyingstore_id`,`index`,`item_id`,`amount`,`price`) VALUES", buyingstore_items_table);
 	for (i = 0; i < sd->buyingstore.slots; i++){
 		StringBuf_Printf(&buf, "(%d,%d,%hu,%d,%d)", sd->buyer_id, i, sd->buyingstore.items[i].nameid, sd->buyingstore.items[i].amount, sd->buyingstore.items[i].price);
 		if (i < sd->buyingstore.slots-1)
@@ -259,8 +259,8 @@ void buyingstore_close(struct map_session_data* sd) {
 
 	if( sd->state.buyingstore ) {
 		if( 
-			Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE buyingstore_id = %d;", buyingstore_items_db, sd->buyer_id ) != SQL_SUCCESS ||
-			Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `id` = %d;", buyingstores_db, sd->buyer_id ) != SQL_SUCCESS
+			Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE buyingstore_id = %d;", buyingstore_items_table, sd->buyer_id ) != SQL_SUCCESS ||
+			Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS
 		) {
 			Sql_ShowDebug(mmysql_handle);
 		}
@@ -452,11 +452,11 @@ void buyingstore_trade(struct map_session_data* sd, uint32 account_id, unsigned
 		pl_sd->buyingstore.items[listidx].amount-= amount;
 
 		if( pl_sd->buyingstore.items[listidx].amount > 0 ){
-			if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `amount` = %d WHERE `buyingstore_id` = %d AND `index` = %d;", buyingstore_items_db, pl_sd->buyingstore.items[listidx].amount, pl_sd->buyer_id, listidx ) != SQL_SUCCESS ){
+			if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `amount` = %d WHERE `buyingstore_id` = %d AND `index` = %d;", buyingstore_items_table, pl_sd->buyingstore.items[listidx].amount, pl_sd->buyer_id, listidx ) != SQL_SUCCESS ){
 				Sql_ShowDebug( mmysql_handle );
 			}
 		}else{
-			if( Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `buyingstore_id` = %d AND `index` = %d;", buyingstore_items_db, pl_sd->buyer_id, listidx ) != SQL_SUCCESS ){
+			if( Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `buyingstore_id` = %d AND `index` = %d;", buyingstore_items_table, pl_sd->buyer_id, listidx ) != SQL_SUCCESS ){
 				Sql_ShowDebug( mmysql_handle );
 			}
 		}
@@ -488,7 +488,7 @@ void buyingstore_trade(struct map_session_data* sd, uint32 account_id, unsigned
 	}
 	else
 	{// continue buying
-		if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `limit` = %d WHERE `id` = %d;", buyingstores_db, pl_sd->buyingstore.zenylimit, pl_sd->buyer_id ) != SQL_SUCCESS ){
+		if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `limit` = %d WHERE `id` = %d;", buyingstores_table, pl_sd->buyingstore.zenylimit, pl_sd->buyer_id ) != SQL_SUCCESS ){
 			Sql_ShowDebug( mmysql_handle );
 		}
 
@@ -656,7 +656,7 @@ void do_init_buyingstore_autotrade( void ) {
 			"FROM `%s` "
 			"WHERE `autotrade` = 1 AND `limit` > 0 AND (SELECT COUNT(`buyingstore_id`) FROM `%s` WHERE `buyingstore_id` = `id`) > 0 "
 			"ORDER BY `id`;",
-			buyingstores_db, buyingstore_items_db ) != SQL_SUCCESS )
+			buyingstores_table, buyingstore_items_table ) != SQL_SUCCESS )
 		{
 			Sql_ShowDebug(mmysql_handle);
 			return;
@@ -712,7 +712,7 @@ void do_init_buyingstore_autotrade( void ) {
 					"FROM `%s` "
 					"WHERE `buyingstore_id` = %d "
 					"ORDER BY `index` ASC;",
-					buyingstore_items_db, at->id ) )
+					buyingstore_items_table, at->id ) )
 				{
 					Sql_ShowDebug(mmysql_handle);
 					continue;
@@ -747,8 +747,8 @@ void do_init_buyingstore_autotrade( void ) {
 	}
 
 	// Everything is loaded fine, their entries will be reinserted once they are loaded
-	if (Sql_Query( mmysql_handle, "DELETE FROM `%s`;", buyingstores_db ) != SQL_SUCCESS ||
-		Sql_Query( mmysql_handle, "DELETE FROM `%s`;", buyingstore_items_db ) != SQL_SUCCESS)
+	if (Sql_Query( mmysql_handle, "DELETE FROM `%s`;", buyingstores_table ) != SQL_SUCCESS ||
+		Sql_Query( mmysql_handle, "DELETE FROM `%s`;", buyingstore_items_table ) != SQL_SUCCESS)
 	{
 		Sql_ShowDebug(mmysql_handle);
 	}

+ 3 - 3
src/map/cashshop.c

@@ -14,8 +14,8 @@
 struct cash_item_db cash_shop_items[CASHSHOP_TAB_SEARCH];
 bool cash_shop_defined = false;
 
-extern char item_cash_db_db[32];
-extern char item_cash_db2_db[32];
+extern char item_cash_table[32];
+extern char item_cash2_table[32];
 
 /*
  * Reads one line from database and assigns it to RAM.
@@ -98,7 +98,7 @@ static void cashshop_read_db_txt( void ){
  * parses line and sends them to parse_dbrow.
  */
 static int cashshop_read_db_sql( void ){
-	const char* cash_db_name[] = { item_cash_db_db, item_cash_db2_db };
+	const char* cash_db_name[] = { item_cash_table, item_cash2_table };
 	int fi;
 
 	for( fi = 0; fi < ARRAYLENGTH( cash_db_name ); ++fi ){

+ 4 - 8
src/map/itemdb.c

@@ -1069,7 +1069,7 @@ bool itemdb_parse_roulette_db(void)
 	uint32 count = 0;
 
 	// retrieve all rows from the item database
-	if (SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", db_roulette_table)) {
+	if (SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", roulette_table)) {
 		Sql_ShowDebug(mmysql_handle);
 		return false;
 	}
@@ -1149,7 +1149,7 @@ bool itemdb_parse_roulette_db(void)
 		}
 	}
 
-	ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, db_roulette_table);
+	ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, roulette_table);
 
 	return true;
 }
@@ -1490,12 +1490,8 @@ static int itemdb_readdb(void){
 static int itemdb_read_sqldb(void) {
 
 	const char* item_db_name[] = {
-#ifdef RENEWAL
-		item_db_re_db,
-#else
-		item_db_db,
-#endif
-		item_db2_db
+		item_table,
+		item2_table
 	};
 	int fi;
 

+ 58 - 46
src/map/map.c

@@ -55,23 +55,29 @@ Sql* mmysql_handle;
 Sql* qsmysql_handle; /// For query_sql
 
 int db_use_sqldbs = 0;
-char buyingstores_db[32] = "buyingstores";
-char buyingstore_items_db[32] = "buyingstore_items";
-char item_db_db[32] = "item_db";
-char item_db2_db[32] = "item_db2";
-char item_db_re_db[32] = "item_db_re";
-char item_cash_db_db[32] = "item_cash_db";
-char item_cash_db2_db[32] = "item_cash_db2";
-char mob_db_db[32] = "mob_db";
-char mob_db_re_db[32] = "mob_db_re";
-char mob_db2_db[32] = "mob_db2";
-char mob_skill_db_db[32] = "mob_skill_db";
-char mob_skill_db_re_db[32] = "mob_skill_db_re";
-char mob_skill_db2_db[32] = "mob_skill_db2";
-char vendings_db[32] = "vendings";
-char vending_items_db[32] = "vending_items";
+char buyingstores_table[32] = "buyingstores";
+char buyingstore_items_table[32] = "buyingstore_items";
+char item_cash_table[32] = "item_cash_db";
+char item_cash2_table[32] = "item_cash_db2";
+#ifdef RENEWAL
+char item_table[32] = "item_db_re";
+char item2_table[32] = "item_db2_re";
+char mob_table[32] = "mob_db_re";
+char mob2_table[32] = "mob_db2_re";
+char mob_skill_table[32] = "mob_skill_db_re";
+char mob_skill2_table[32] = "mob_skill_db2_re";
+#else
+char item_table[32] = "item_db";
+char item2_table[32] = "item_db2";
+char mob_table[32] = "mob_db";
+char mob2_table[32] = "mob_db2";
+char mob_skill_table[32] = "mob_skill_db";
+char mob_skill2_table[32] = "mob_skill_db2";
+#endif
+char vendings_table[32] = "vendings";
+char vending_items_table[32] = "vending_items";
 char market_table[32] = "market";
-char db_roulette_table[32] = "db_roulette";
+char roulette_table[32] = "db_roulette";
 
 // log database
 char log_db_ip[32] = "127.0.0.1";
@@ -3976,38 +3982,44 @@ int inter_config_read(char *cfgName)
 		if( sscanf(line,"%1023[^:]: %1023[^\r\n]",w1,w2) < 2 )
 			continue;
 
+#define RENEWALPREFIX "renewal-"
+		if (!strncmpi(w1, RENEWALPREFIX, strlen(RENEWALPREFIX))) {
+#ifdef RENEWAL
+			// Copy the original name
+			safestrncpy(w1, w1 + strlen(RENEWALPREFIX), strlen(w1) - strlen(RENEWALPREFIX));
+#else
+			// In Pre-Renewal the Renewal specific configurations can safely be ignored
+			continue;
+#endif
+		}
+#undef RENEWALPREFIX
+
 		if( strcmpi( w1, "buyingstore_db" ) == 0 )
-			strcpy( buyingstores_db, w2 );
-		else if( strcmpi( w1, "buyingstore_items_db" ) == 0 )
-			strcpy( buyingstore_items_db, w2 );
-		else if(strcmpi(w1,"item_db_db")==0)
-			strcpy(item_db_db,w2);
-		else if(strcmpi(w1,"item_db2_db")==0)
-			strcpy(item_db2_db,w2);
-		else if(strcmpi(w1,"item_db_re_db")==0)
-			strcpy(item_db_re_db,w2);
-		else if(strcmpi(w1,"mob_db_db")==0)
-			strcpy(mob_db_db,w2);
-		else if(strcmpi(w1,"mob_db_re_db")==0)
-			strcpy(mob_db_re_db,w2);
-		else if(strcmpi(w1,"mob_db2_db")==0)
-			strcpy(mob_db2_db,w2);
-		else if(strcmpi(w1,"mob_skill_db_db")==0)
-			strcpy(mob_skill_db_db,w2);
-		else if(strcmpi(w1,"mob_skill_db_re_db")==0)
-			strcpy(mob_skill_db_re_db,w2);
-		else if(strcmpi(w1,"mob_skill_db2_db")==0)
-			strcpy(mob_skill_db2_db,w2);
-		else if( strcmpi( w1, "item_cash_db_db" ) == 0 )
-			strcpy( item_cash_db_db, w2 );
-		else if( strcmpi( w1, "item_cash_db2_db" ) == 0 )
-			strcpy( item_cash_db2_db, w2 );
+			strcpy( buyingstores_table, w2 );
+		else if( strcmpi( w1, "buyingstore_items_table" ) == 0 )
+			strcpy( buyingstore_items_table, w2 );
+		else if(strcmpi(w1,"item_table")==0)
+			strcpy(item_table,w2);
+		else if(strcmpi(w1,"item2_table")==0)
+			strcpy(item2_table,w2);
+		else if(strcmpi(w1,"mob_table")==0)
+			strcpy(mob_table,w2);
+		else if(strcmpi(w1,"mob2_table")==0)
+			strcpy(mob2_table,w2);
+		else if(strcmpi(w1,"mob_skill_table")==0)
+			strcpy(mob_skill_table,w2);
+		else if(strcmpi(w1,"mob_skill2_table")==0)
+			strcpy(mob_skill2_table,w2);
+		else if( strcmpi( w1, "item_cash_table" ) == 0 )
+			strcpy( item_cash_table, w2 );
+		else if( strcmpi( w1, "item_cash2_table" ) == 0 )
+			strcpy( item_cash2_table, w2 );
 		else if( strcmpi( w1, "vending_db" ) == 0 )
-			strcpy( vendings_db, w2 );
-		else if( strcmpi( w1, "vending_items_db" ) == 0 )
-			strcpy(vending_items_db, w2);
-		else if( strcmpi(w1, "db_roulette_table") == 0)
-			strcpy(db_roulette_table, w2);
+			strcpy( vendings_table, w2 );
+		else if( strcmpi( w1, "vending_items_table" ) == 0 )
+			strcpy(vending_items_table, w2);
+		else if( strcmpi(w1, "roulette_table") == 0)
+			strcpy(roulette_table, w2);
 		else if (strcmpi(w1, "market_table") == 0)
 			strcpy(market_table, w2);
 		else

+ 11 - 14
src/map/map.h

@@ -976,21 +976,18 @@ extern Sql* mmysql_handle;
 extern Sql* qsmysql_handle;
 extern Sql* logmysql_handle;
 
-extern char buyingstores_db[32];
-extern char buyingstore_items_db[32];
-extern char item_db_db[32];
-extern char item_db2_db[32];
-extern char item_db_re_db[32];
-extern char mob_db_db[32];
-extern char mob_db_re_db[32];
-extern char mob_db2_db[32];
-extern char mob_skill_db_db[32];
-extern char mob_skill_db_re_db[32];
-extern char mob_skill_db2_db[32];
-extern char vendings_db[32];
-extern char vending_items_db[32];
+extern char buyingstores_table[32];
+extern char buyingstore_items_table[32];
+extern char item_table[32];
+extern char item2_table[32];
+extern char mob_table[32];
+extern char mob2_table[32];
+extern char mob_skill_table[32];
+extern char mob_skill2_table[32];
+extern char vendings_table[32];
+extern char vending_items_table[32];
 extern char market_table[32];
-extern char db_roulette_table[32];
+extern char roulette_table[32];
 
 void do_shutdown(void);
 

+ 4 - 12
src/map/mob.c

@@ -4172,12 +4172,8 @@ static bool mob_readdb_sub(char* fields[], int columns, int current)
 static int mob_read_sqldb(void)
 {
 	const char* mob_db_name[] = {
-#ifndef RENEWAL
-		mob_db_db,
-#else
-		mob_db_re_db,
-#endif
-		mob_db2_db };
+		mob_table,
+		mob2_table };
 	int fi;
 
 	for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi ) {
@@ -4636,12 +4632,8 @@ static void mob_readskilldb(const char* basedir, bool silent) {
 static int mob_read_sqlskilldb(void)
 {
 	const char* mob_skill_db_name[] = {
-#ifndef RENEWAL
-		mob_skill_db_db,
-#else
-		mob_skill_db_re_db,
-#endif
-		mob_skill_db2_db };
+		mob_skill_table,
+		mob_skill2_table };
 	int fi;
 
 	if( battle_config.mob_skill_rate == 0 ) {

+ 10 - 10
src/map/vending.c

@@ -51,8 +51,8 @@ void vending_closevending(struct map_session_data* sd)
 	nullpo_retv(sd);
 
 	if( sd->state.vending ) {
-		if( Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE vending_id = %d;", vending_items_db, sd->vender_id ) != SQL_SUCCESS ||
-			Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ) {
+		if( Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE vending_id = %d;", vending_items_table, sd->vender_id ) != SQL_SUCCESS ||
+			Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ) {
 				Sql_ShowDebug(mmysql_handle);
 		}
 
@@ -207,11 +207,11 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
 		z += ((double)vsd->vending[i].value * (double)amount);
 
 		if( vsd->vending[vend_list[i]].amount ) {
-			if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `amount` = %d WHERE `vending_id` = %d and `cartinventory_id` = %d", vending_items_db, vsd->vending[vend_list[i]].amount, vsd->vender_id, vsd->cart.u.items_cart[idx].id ) != SQL_SUCCESS ) {
+			if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `amount` = %d WHERE `vending_id` = %d and `cartinventory_id` = %d", vending_items_table, vsd->vending[vend_list[i]].amount, vsd->vender_id, vsd->cart.u.items_cart[idx].id ) != SQL_SUCCESS ) {
 				Sql_ShowDebug( mmysql_handle );
 			}
 		} else {
-			if( Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `vending_id` = %d and `cartinventory_id` = %d", vending_items_db, vsd->vender_id, vsd->cart.u.items_cart[idx].id ) != SQL_SUCCESS ) {
+			if( Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `vending_id` = %d and `cartinventory_id` = %d", vending_items_table, vsd->vender_id, vsd->cart.u.items_cart[idx].id ) != SQL_SUCCESS ) {
 				Sql_ShowDebug( mmysql_handle );
 			}
 		}
@@ -347,12 +347,12 @@ int8 vending_openvending(struct map_session_data* sd, const char* message, const
 
 	if( Sql_Query( mmysql_handle, "INSERT INTO `%s`(`id`, `account_id`, `char_id`, `sex`, `map`, `x`, `y`, `title`, `autotrade`, `body_direction`, `head_direction`, `sit`) "
 		"VALUES( %d, %d, %d, '%c', '%s', %d, %d, '%s', %d, '%d', '%d', '%d' );",
-		vendings_db, sd->vender_id, sd->status.account_id, sd->status.char_id, sd->status.sex == SEX_FEMALE ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->state.autotrade, at ? at->dir : sd->ud.dir, at ? at->head_dir : sd->head_dir, at ? at->sit : pc_issit(sd) ) != SQL_SUCCESS ) {
+		vendings_table, sd->vender_id, sd->status.account_id, sd->status.char_id, sd->status.sex == SEX_FEMALE ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->state.autotrade, at ? at->dir : sd->ud.dir, at ? at->head_dir : sd->head_dir, at ? at->sit : pc_issit(sd) ) != SQL_SUCCESS ) {
 		Sql_ShowDebug(mmysql_handle);
 	}
 
 	StringBuf_Init(&buf);
-	StringBuf_Printf(&buf, "INSERT INTO `%s`(`vending_id`,`index`,`cartinventory_id`,`amount`,`price`) VALUES", vending_items_db);
+	StringBuf_Printf(&buf, "INSERT INTO `%s`(`vending_id`,`index`,`cartinventory_id`,`amount`,`price`) VALUES", vending_items_table);
 	for (i = 0; i < count; i++) {
 		StringBuf_Printf(&buf, "(%d,%d,%d,%d,%d)", sd->vender_id, i, sd->cart.u.items_cart[sd->vending[i].index].id, sd->vending[i].amount, sd->vending[i].value);
 		if (i < count-1)
@@ -538,7 +538,7 @@ void do_init_vending_autotrade(void)
 			"FROM `%s` "
 			"WHERE `autotrade` = 1 AND (SELECT COUNT(`vending_id`) FROM `%s` WHERE `vending_id` = `id`) > 0 "
 			"ORDER BY `id`;",
-			vendings_db, vending_items_db ) != SQL_SUCCESS )
+			vendings_table, vending_items_table ) != SQL_SUCCESS )
 		{
 			Sql_ShowDebug(mmysql_handle);
 			return;
@@ -593,7 +593,7 @@ void do_init_vending_autotrade(void)
 					"FROM `%s` "
 					"WHERE `vending_id` = %d "
 					"ORDER BY `index` ASC;",
-					vending_items_db, at->id ) )
+					vending_items_table, at->id ) )
 				{
 					Sql_ShowDebug(mmysql_handle);
 					continue;
@@ -628,8 +628,8 @@ void do_init_vending_autotrade(void)
 	}
 
 	// Everything is loaded fine, their entries will be reinserted once they are loaded
-	if (Sql_Query( mmysql_handle, "DELETE FROM `%s`;", vendings_db ) != SQL_SUCCESS ||
-		Sql_Query( mmysql_handle, "DELETE FROM `%s`;", vending_items_db ) != SQL_SUCCESS) {
+	if (Sql_Query( mmysql_handle, "DELETE FROM `%s`;", vendings_table ) != SQL_SUCCESS ||
+		Sql_Query( mmysql_handle, "DELETE FROM `%s`;", vending_items_table ) != SQL_SUCCESS) {
 		Sql_ShowDebug(mmysql_handle);
 	}
 }