From 90c8d73473f77422a2bd755951264f71514609ff Mon Sep 17 00:00:00 2001
From: panikon <panikon@zoho.com>
Date: Sat, 10 May 2014 05:31:49 -0300
Subject: Optimized THQS_TTShop.txt and corrected a minor mistake Added
 npc_market_data_db to inter-server.conf Added shop message to messages.conf
 Fixed small typo in clif_GM_kickack

---
 src/map/clif.c   |  6 +++---
 src/map/clif.h   |  2 +-
 src/map/map.c    |  2 ++
 src/map/map.h    |  1 +
 src/map/npc.c    | 15 +++++++--------
 src/map/script.c |  2 ++
 6 files changed, 16 insertions(+), 12 deletions(-)

(limited to 'src')

diff --git a/src/map/clif.c b/src/map/clif.c
index 0fc1fe044..cb2474961 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8136,7 +8136,7 @@ void clif_disp_message(struct block_list* src, const char* mes, size_t len, enum
 /// result:
 ///     0 = failure
 ///     1 = success
-void clif_GM_kickack(struct map_session_data *sd, int id)
+void clif_GM_kickack(struct map_session_data *sd, int result)
 {
 	int fd;
 
@@ -8145,7 +8145,7 @@ void clif_GM_kickack(struct map_session_data *sd, int id)
 	fd = sd->fd;
 	WFIFOHEAD(fd,packet_len(0xcd));
 	WFIFOW(fd,0) = 0xcd;
-	WFIFOB(fd,2) = id;  // FIXME: this is not account id
+	WFIFOB(fd,2) = result;
 	WFIFOSET(fd, packet_len(0xcd));
 }
 
@@ -8159,7 +8159,7 @@ void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) {
 		map->quit(tsd);
 
 	if( sd )
-		clif->GM_kickack(sd,tsd->status.account_id);
+		clif->GM_kickack(sd, 1);
 }
 
 
diff --git a/src/map/clif.h b/src/map/clif.h
index d0444f9fe..7b27e1fe6 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -926,7 +926,7 @@ struct clif_interface {
 	void (*friendslist_toggle) (struct map_session_data *sd,int account_id, int char_id, int online);
 	void (*friendlist_req) (struct map_session_data* sd, int account_id, int char_id, const char* name);
 	/* gm-related */
-	void (*GM_kickack) (struct map_session_data *sd, int id);
+	void (*GM_kickack) (struct map_session_data *sd, int result);
 	void (*GM_kick) (struct map_session_data *sd,struct map_session_data *tsd);
 	void (*manner_message) (struct map_session_data* sd, uint32 type);
 	void (*GM_silence) (struct map_session_data* sd, struct map_session_data* tsd, uint8 type);
diff --git a/src/map/map.c b/src/map/map.c
index 0d6445021..01d3dbb9f 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3656,6 +3656,8 @@ int inter_config_read(char *cfgName) {
 			strcpy(map->autotrade_merchants_db, w2);
 		else if(strcmpi(w1,"autotrade_data_db")==0)
 			strcpy(map->autotrade_data_db, w2);
+		else if(strcmpi(w1,"npc_market_data_db")==0)
+			strcpy(map->npc_market_data_db, w2);
 		/* sql log db */
 		else if(strcmpi(w1,"log_db_ip")==0)
 			strcpy(logs->db_ip, w2);
diff --git a/src/map/map.h b/src/map/map.h
index 8277c7a62..539b02ed8 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -845,6 +845,7 @@ struct map_interface {
 	char interreg_db[32];
 	char autotrade_merchants_db[32];
 	char autotrade_data_db[32];
+	char npc_market_data_db[32];
 
 	char default_codepage[32];
 	
diff --git a/src/map/npc.c b/src/map/npc.c
index 5596b8e23..8e5854dbf 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1426,8 +1426,7 @@ void npc_market_fromsql(void) {
 	int itemid;
 	int amount;
 	
-	/* TODO inter-server.conf npc_market_data */
-	if ( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `name`, `itemid`, `amount` FROM `npc_market_data`")
+	if ( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `name`, `itemid`, `amount` FROM `%s`", map->npc_market_data_db)
 		|| SQL_ERROR == SQL->StmtExecute(stmt)
 		) {
 		SqlStmt_ShowDebug(stmt);
@@ -1474,20 +1473,20 @@ void npc_market_fromsql(void) {
  * Saves persistent NPC Market Data into SQL
  **/
 void npc_market_tosql(struct npc_data *nd, unsigned short index) {
-	/* TODO inter-server.conf npc_market_data */
-	if( SQL_ERROR == SQL->Query(map->mysql_handle, "REPLACE INTO `npc_market_data` VALUES ('%s','%d','%d')", nd->exname, nd->u.scr.shop->item[index].nameid, nd->u.scr.shop->item[index].qty) )
+	if( SQL_ERROR == SQL->Query(map->mysql_handle, "REPLACE INTO `%s` VALUES ('%s','%d','%d')",
+		map->npc_market_data_db, nd->exname, nd->u.scr.shop->item[index].nameid, nd->u.scr.shop->item[index].qty) )
 		Sql_ShowDebug(map->mysql_handle);
 }
 /**
  * Removes persistent NPC Market Data from SQL
  */
 void npc_market_delfromsql_sub(const char *npcname, unsigned short index) {
-	/* TODO inter-server.conf npc_market_data */
 	if( index == USHRT_MAX ) {
-		if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `npc_market_data` WHERE `name`='%s'", npcname) )
+		if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `name`='%s'", map->npc_market_data_db, npcname) )
 			Sql_ShowDebug(map->mysql_handle);
 	} else {
-		if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `npc_market_data` WHERE `name`='%s' AND `itemid`='%d' LIMIT 1", npcname, index) )
+		if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `name`='%s' AND `itemid`='%d' LIMIT 1",
+			map->npc_market_data_db, npcname, index) )
 			Sql_ShowDebug(map->mysql_handle);
 	}
 }
@@ -1520,7 +1519,7 @@ bool npc_trader_open(struct map_session_data *sd, struct npc_data *nd) {
 			
 				/* nothing to display, no items available */
 				if( i == nd->u.scr.shop->items ) {
-					clif->colormes(sd->fd,COLOR_RED,"Shop is out of stock! Come again later!");/* TODO messages.conf-it */
+					clif->colormes(sd->fd,COLOR_RED, msg_txt(881));
 					return false;
 				}
 
diff --git a/src/map/script.c b/src/map/script.c
index e4cf7f227..068be8524 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2914,6 +2914,8 @@ int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, co
 				return pc_setglobalreg_str(sd, num, str);
 		}
 	} else {// integer variable
+		// FIXME: This isn't safe, in 32bits systems we're converting a 64bit pointer
+		// to a 32bit int, this will lead to overflows! [Panikon]
 		int val = (int)__64BPTRSIZE(value);
 
 		if(script->str_data[script_getvarid(num)].type == C_PARAM) {
-- 
cgit v1.2.3-70-g09d2