diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/npc.c | 21 | ||||
-rw-r--r-- | src/map/npc.h | 1 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index dc29f04aa..9ed6d2a7e 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1426,9 +1426,11 @@ void npc_market_fromsql(void) { if( !(nd = npc->name2id(name)) ) { ShowError("npc_market_fromsql: NPC '%s' not found! skipping...\n",name); + npc->market_delfromsql_sub(name, USHRT_MAX); continue; } else if ( nd->subtype != SCRIPT || !nd->u.scr.shop || !nd->u.scr.shop->items || nd->u.scr.shop->type != NST_MARKET ) { ShowError("npc_market_fromsql: NPC '%s' is not proper for market, skipping...\n",name); + npc->market_delfromsql_sub(name, USHRT_MAX); continue; } @@ -1441,9 +1443,7 @@ void npc_market_fromsql(void) { if( i == nd->u.scr.shop->items ) { ShowError("npc_market_fromsql: NPC '%s' does not sell item %d (qty %d), deleting...\n",name,itemid,amount); - /* TODO inter-server.conf npc_market_data */ - if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `npc_market_data` WHERE `name`='%s' AND `itemid`='%d' LIMIT 1", name,itemid) ) - Sql_ShowDebug(map->mysql_handle); + npc->market_delfromsql_sub(name, itemid); continue; } @@ -1461,18 +1461,24 @@ void npc_market_tosql(struct npc_data *nd, unsigned short index) { } /** * Removes persistent NPC Market Data from SQL - **/ -void npc_market_delfromsql(struct npc_data *nd, unsigned short index) { + */ +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'", nd->exname) ) + if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `npc_market_data` WHERE `name`='%s'", 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", nd->exname, nd->u.scr.shop->item[index].nameid) ) + if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `npc_market_data` WHERE `name`='%s' AND `itemid`='%d' LIMIT 1", npcname, index) ) Sql_ShowDebug(map->mysql_handle); } } /** + * Removes persistent NPC Market Data from SQL + **/ +void npc_market_delfromsql(struct npc_data *nd, unsigned short index) { + npc->market_delfromsql_sub(nd->exname, index == USHRT_MAX ? index : nd->u.scr.shop->item[index].nameid); +} +/** * Judges whether to allow and spawn a trader's window. **/ bool npc_trader_open(struct map_session_data *sd, struct npc_data *nd) { @@ -4579,4 +4585,5 @@ void npc_defaults(void) { npc->market_fromsql = npc_market_fromsql; npc->market_tosql = npc_market_tosql; npc->market_delfromsql = npc_market_delfromsql; + npc->market_delfromsql_sub = npc_market_delfromsql_sub; } diff --git a/src/map/npc.h b/src/map/npc.h index 792d85d59..a3f07e79c 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -268,6 +268,7 @@ struct npc_interface { void (*market_fromsql) (void); void (*market_tosql) (struct npc_data *nd, unsigned short index); void (*market_delfromsql) (struct npc_data *nd, unsigned short index); + void (*market_delfromsql_sub) (const char *npcname, unsigned short index); /** * For the Secure NPC Timeout option (check config/Secure.h) [RR] **/ |