diff options
-rw-r--r-- | src/map/atcommand.c | 6 | ||||
-rw-r--r-- | src/map/npc.c | 10 | ||||
-rw-r--r-- | src/map/npc.h | 5 | ||||
-rw-r--r-- | src/map/script.c | 2 | ||||
-rw-r--r-- | src/map/status.c | 2 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 27 |
8 files changed, 47 insertions, 10 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6f97141b2..5e50a06ee 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4591,7 +4591,7 @@ ACMD(disguise) if ((id = atoi(message)) > 0) { //Acquired an ID - if (!mob->db_checkid(id) && !npcdb_checkid(id)) + if (!mob->db_checkid(id) && !npc->db_checkid(id)) id = 0; //Invalid id for either mobs or npcs. } else { //Acquired a Name @@ -4643,7 +4643,7 @@ ACMD(disguiseall) if ((mob_id = mob->db_searchname(message)) == 0) // check name first (to avoid possible name begining by a number) mob_id = atoi(message); - if (!mob->db_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc... + if (!mob->db_checkid(mob_id) && !npc->db_checkid(mob_id)) { //if mob or npc... clif->message(fd, msg_txt(123)); // Monster/NPC name/id not found. return false; } @@ -4676,7 +4676,7 @@ ACMD(disguiseguild) } if( (id = atoi(monster)) > 0 ) { - if( !mob->db_checkid(id) && !npcdb_checkid(id) ) + if( !mob->db_checkid(id) && !npc->db_checkid(id) ) id = 0; } else { if( (id = mob->db_searchname(monster)) == 0 ) { diff --git a/src/map/npc.c b/src/map/npc.c index 04df22f2d..28709d34f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -75,7 +75,7 @@ struct view_data* npc_get_viewdata(int class_) //Returns the viewdata for normal npc classes. if( class_ == INVISIBLE_CLASS ) return &npc_viewdb[0]; - if (npcdb_checkid(class_) || class_ == WARP_CLASS){ + if (npc->db_checkid(class_) || class_ == WARP_CLASS){ if( class_ > MAX_NPC_CLASS2_START ){ return &npc_viewdb2[class_-MAX_NPC_CLASS2_START]; }else{ @@ -85,6 +85,13 @@ struct view_data* npc_get_viewdata(int class_) return NULL; } +//Checks if a given id is a valid npc id. [Skotlex] +//Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001) +bool npc_db_checkid(int id) +{ + return ((id >= 46 && id <= 125) || id == HIDDEN_WARP_CLASS || (id > 400 && id < MAX_NPC_CLASS) || id == INVISIBLE_CLASS || (id > MAX_NPC_CLASS2_START && id < MAX_NPC_CLASS2_END)); +} + /// Returns a new npc id that isn't being used in id_db. /// Fatal error if nothing is available. int npc_get_new_npc_id(void) { @@ -4745,4 +4752,5 @@ void npc_defaults(void) { npc->market_tosql = npc_market_tosql; npc->market_delfromsql = npc_market_delfromsql; npc->market_delfromsql_sub = npc_market_delfromsql_sub; + npc->db_checkid = npc_db_checkid; } diff --git a/src/map/npc.h b/src/map/npc.h index a5a2b4676..b0014e323 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -124,10 +124,6 @@ enum actor_classes { #define MAX_NPC_CLASS2_START 10000 #define MAX_NPC_CLASS2_END 10110 -//Checks if a given id is a valid npc id. [Skotlex] -//Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001) -#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( (id) > MAX_NPC_CLASS2_START && (id) < MAX_NPC_CLASS2_END ) ) - //Script NPC events. enum npce_event { NPCE_LOGIN, @@ -276,6 +272,7 @@ struct npc_interface { 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); + bool (*db_checkid) (const int id); /** * For the Secure NPC Timeout option (check config/Secure.h) [RR] **/ diff --git a/src/map/script.c b/src/map/script.c index 3ed779fba..aca4650c5 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12488,7 +12488,7 @@ BUILDIN(disguise) id = script_getnum(st,2); - if (mob->db_checkid(id) || npcdb_checkid(id)) { + if (mob->db_checkid(id) || npc->db_checkid(id)) { pc->disguise(sd, id); script_pushint(st,id); } else diff --git a/src/map/status.c b/src/map/status.c index c0611f97b..7b4e6f274 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6203,7 +6203,7 @@ void status_set_viewdata(struct block_list *bl, int class_) nullpo_retv(bl); if (mob->db_checkid(class_) || mob->is_clone(class_)) vd = mob->get_viewdata(class_); - else if (npcdb_checkid(class_) || (bl->type == BL_NPC && class_ == WARP_CLASS)) + else if (npc->db_checkid(class_) || (bl->type == BL_NPC && class_ == WARP_CLASS)) vd = npc->get_viewdata(class_); else if (homdb_checkid(class_)) vd = homun->get_viewdata(class_); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 034b14b79..c2c6daf58 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -3399,6 +3399,8 @@ struct { struct HPMHookPoint *HP_npc_market_delfromsql_post; struct HPMHookPoint *HP_npc_market_delfromsql_sub_pre; struct HPMHookPoint *HP_npc_market_delfromsql_sub_post; + struct HPMHookPoint *HP_npc_db_checkid_pre; + struct HPMHookPoint *HP_npc_db_checkid_post; struct HPMHookPoint *HP_npc_secure_timeout_timer_pre; struct HPMHookPoint *HP_npc_secure_timeout_timer_post; struct HPMHookPoint *HP_party_init_pre; @@ -8482,6 +8484,8 @@ struct { int HP_npc_market_delfromsql_post; int HP_npc_market_delfromsql_sub_pre; int HP_npc_market_delfromsql_sub_post; + int HP_npc_db_checkid_pre; + int HP_npc_db_checkid_post; int HP_npc_secure_timeout_timer_pre; int HP_npc_secure_timeout_timer_post; int HP_party_init_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 21f48134c..89ded9041 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -1726,6 +1726,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(npc->market_tosql, HP_npc_market_tosql) }, { HP_POP(npc->market_delfromsql, HP_npc_market_delfromsql) }, { HP_POP(npc->market_delfromsql_sub, HP_npc_market_delfromsql_sub) }, + { HP_POP(npc->db_checkid, HP_npc_db_checkid) }, { HP_POP(npc->secure_timeout_timer, HP_npc_secure_timeout_timer) }, /* party */ { HP_POP(party->init, HP_party_init) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 9078efe2e..ff08b8909 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -45435,6 +45435,33 @@ void HP_npc_market_delfromsql_sub(const char *npcname, unsigned short index) { } return; } +bool HP_npc_db_checkid(const int id) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_npc_db_checkid_pre ) { + bool (*preHookFunc) (const int *id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_db_checkid_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_npc_db_checkid_pre[hIndex].func; + retVal___ = preHookFunc(&id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.npc.db_checkid(id); + } + if( HPMHooks.count.HP_npc_db_checkid_post ) { + bool (*postHookFunc) (bool retVal___, const int *id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_db_checkid_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_npc_db_checkid_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &id); + } + } + return retVal___; +} int HP_npc_secure_timeout_timer(int tid, int64 tick, int id, intptr_t data) { int hIndex = 0; int retVal___ = 0; |