summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaruna <haru@dotalux.com>2015-01-11 16:58:52 +0100
committerHaruna <haru@dotalux.com>2015-01-11 16:58:52 +0100
commit670fca4c54445440c25e1114e64170e3934645f1 (patch)
tree2283314884d273c4525d5b527cd0d6c9496020d1 /src
parent0500a83b68485616d53db34c2ac494faba6be7eb (diff)
parentd5cbfe3188c9c0f91f74772237606863c5ff6114 (diff)
downloadhercules-670fca4c54445440c25e1114e64170e3934645f1.tar.gz
hercules-670fca4c54445440c25e1114e64170e3934645f1.tar.bz2
hercules-670fca4c54445440c25e1114e64170e3934645f1.tar.xz
hercules-670fca4c54445440c25e1114e64170e3934645f1.zip
Merge pull request #438 from 4144/pcdb_checkid
Convert pcdb_checkid into function in pc interface
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/clif.c22
-rw-r--r--src/map/mob.c8
-rw-r--r--src/map/pc.c27
-rw-r--r--src/map/pc.h15
-rw-r--r--src/map/script.c4
-rw-r--r--src/map/status.c8
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc4
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc1
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc27
10 files changed, 77 insertions, 41 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 5e50a06ee..215ecbc70 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -971,7 +971,7 @@ ACMD(jobchange) {
return true;
}
- if (pcdb_checkid(job)) {
+ if (pc->db_checkid(job)) {
if (pc->jobchange(sd, job, upper) == 0)
clif->message(fd, msg_txt(12)); // Your job has been changed.
else {
diff --git a/src/map/clif.c b/src/map/clif.c
index 9309ad7b3..c20d6585e 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -258,13 +258,13 @@ uint32 clif_refresh_ip(void) {
#if PACKETVER >= 20071106
static inline unsigned char clif_bl_type(struct block_list *bl) {
switch (bl->type) {
- case BL_PC: return (disguised(bl) && !pcdb_checkid(status->get_viewdata(bl)->class_))? 0x1:0x0; //PC_TYPE
+ case BL_PC: return (disguised(bl) && !pc->db_checkid(status->get_viewdata(bl)->class_))? 0x1:0x0; //PC_TYPE
case BL_ITEM: return 0x2; //ITEM_TYPE
case BL_SKILL: return 0x3; //SKILL_TYPE
case BL_CHAT: return 0x4; //UNKNOWN_TYPE
- case BL_MOB: return pcdb_checkid(status->get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE
- case BL_NPC: return pcdb_checkid(status->get_viewdata(bl)->class_)?0x0:0x6; //NPC_EVT_TYPE
- case BL_PET: return pcdb_checkid(status->get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE
+ case BL_MOB: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE
+ case BL_NPC: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x6; //NPC_EVT_TYPE
+ case BL_PET: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE
case BL_HOM: return 0x8; //NPC_HOM_TYPE
case BL_MER: return 0x9; //NPC_MERSOL_TYPE
case BL_ELEM: return 0xa; //NPC_ELEMENTAL_TYPE
@@ -955,7 +955,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
nullpo_retv(bl);
#if PACKETVER < 20091103
- if( !pcdb_checkid(vd->class_) ) {
+ if( !pc->db_checkid(vd->class_) ) {
clif->set_unit_idle2(bl,tsd,target);
return;
}
@@ -1022,7 +1022,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
if( disguised(bl) ) {
#if PACKETVER >= 20091103
- p.objecttype = pcdb_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
p.GID = -bl->id;
#else
p.GID = -bl->id;
@@ -1086,7 +1086,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
nullpo_retv(bl);
#if PACKETVER < 20091103
- if( !pcdb_checkid(vd->class_) ) {
+ if( !pc->db_checkid(vd->class_) ) {
clif->spawn_unit2(bl,target);
return;
}
@@ -1152,7 +1152,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
if( sd->status.class_ != sd->disguise )
clif->send(&p,sizeof(p),bl,target);
#if PACKETVER >= 20091103
- p.objecttype = pcdb_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
p.GID = -bl->id;
#else
p.GID = -bl->id;
@@ -1233,7 +1233,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
if( disguised(bl) ) {
#if PACKETVER >= 20091103
- p.objecttype = pcdb_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
+ p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE
p.GID = -bl->id;
#else
p.GID = -bl->id;
@@ -1250,7 +1250,7 @@ void clif_class_change(struct block_list *bl,int class_,int type)
{
nullpo_retv(bl);
- if(!pcdb_checkid(class_))
+ if(!pc->db_checkid(class_))
{// player classes yield missing sprites
unsigned char buf[16];
WBUFW(buf,0)=0x1b0;
@@ -8879,7 +8879,7 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig
*------------------------------------------*/
void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type)
{
- if( pcdb_checkid(class_) ) {
+ if( pc->db_checkid(class_) ) {
clif->starskill(sd, pc->job_name(class_), class_, hate_level, type ? 10 : 11);
} else if( mob->db_checkid(class_) ) {
clif->starskill(sd, mob->db(class_)->jname, class_, hate_level, type ? 10 : 11);
diff --git a/src/map/mob.c b/src/map/mob.c
index ce5854928..30a359bc7 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1610,7 +1610,7 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
memmove(&md->lootitem[0], &md->lootitem[1], (LOOTITEM_SIZE-1)*sizeof(md->lootitem[0]));
memcpy (&md->lootitem[LOOTITEM_SIZE-1], &fitem->item_data, sizeof(md->lootitem[0]));
}
- if (pcdb_checkid(md->vd->class_)) {
+ if (pc->db_checkid(md->vd->class_)) {
//Give them walk act/delay to properly mimic players. [Skotlex]
clif->takeitem(&md->bl,tbl);
md->ud.canact_tick = tick + md->status.amotion;
@@ -2627,7 +2627,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
if( !rebirth ) {
- if( pcdb_checkid(md->vd->class_) ) {//Player mobs are not removed automatically by the client.
+ if( pc->db_checkid(md->vd->class_) ) {//Player mobs are not removed automatically by the client.
/* first we set them dead, then we delay the out sight effect */
clif->clearunit_area(&md->bl,CLR_DEAD);
clif->clearunit_delayed(&md->bl, CLR_OUTSIGHT,tick+3000);
@@ -3670,7 +3670,7 @@ bool mob_parse_dbrow(char** str) {
ShowError("mob_parse_dbrow: Invalid monster ID %d, must be in range %d-%d.\n", class_, 1000, MAX_MOB_DB);
return false;
}
- if (pcdb_checkid(class_)) {
+ if (pc->db_checkid(class_)) {
ShowError("mob_parse_dbrow: Invalid monster ID %d, reserved for player classes.\n", class_);
return false;
}
@@ -4030,7 +4030,7 @@ bool mob_readdb_mobavail(char* str[], int columns, int current)
mob->db_data[class_]->vd.class_=k;
//Player sprites
- if(pcdb_checkid(k) && columns==12) {
+ if(pc->db_checkid(k) && columns==12) {
mob->db_data[class_]->vd.sex=atoi(str[2]);
mob->db_data[class_]->vd.hair_style=atoi(str[3]);
mob->db_data[class_]->vd.hair_color=atoi(str[4]);
diff --git a/src/map/pc.c b/src/map/pc.c
index b8902d753..09c406a7c 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -59,7 +59,7 @@ struct pc_interface pc_s;
//Converts a class to its array index for CLASS_COUNT defined arrays.
//Note that it does not do a validity check for speed purposes, where parsing
-//player input make sure to use a pcdb_checkid first!
+//player input make sure to use a pc->db_checkid first!
int pc_class2idx(int class_) {
if (class_ >= JOB_NOVICE_HIGH)
return class_- JOB_NOVICE_HIGH+JOB_MAX_BASIC;
@@ -1222,7 +1222,7 @@ int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl)
}
class_ = status->get_class(bl);
- if (!pcdb_checkid(class_)) {
+ if (!pc->db_checkid(class_)) {
unsigned int max_hp = status_get_max_hp(bl);
if ((pos == 1 && max_hp < 6000) || (pos == 2 && max_hp < 20000))
return 0;
@@ -10307,7 +10307,7 @@ int pc_readdb(void) {
if (job_count < 1)
continue;
job_id = jobs[0];
- if (!pcdb_checkid(job_id)) {
+ if (!pc->db_checkid(job_id)) {
ShowError("pc_readdb: Invalid job ID %d.\n", job_id);
continue;
}
@@ -10343,7 +10343,7 @@ int pc_readdb(void) {
//ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]);
for (i = 1; i < job_count; i++) {
job_id = jobs[i];
- if (!pcdb_checkid(job_id)) {
+ if (!pc->db_checkid(job_id)) {
ShowError("pc_readdb: Invalid job ID %d.\n", job_id);
continue;
}
@@ -10355,7 +10355,7 @@ int pc_readdb(void) {
}
fclose(fp);
for (i = 0; i < JOB_MAX; i++) {
- if (!pcdb_checkid(i)) continue;
+ if (!pc->db_checkid(i)) continue;
if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER)
continue; //Classes that do not need exp tables.
j = pc->class2idx(i);
@@ -10846,6 +10846,20 @@ void pc_autotrade_populate(struct map_session_data *sd) {
idb_remove(pc->at_db, sd->status.char_id);
}
+
+//Checks if the given class value corresponds to a player class. [Skotlex]
+//JOB_NOVICE isn't checked for class_ is supposed to be unsigned
+bool pc_db_checkid(unsigned int class_)
+{
+ return class_ < JOB_MAX_BASIC
+ || (class_ >= JOB_NOVICE_HIGH && class_ <= JOB_DARK_COLLECTOR )
+ || (class_ >= JOB_RUNE_KNIGHT && class_ <= JOB_MECHANIC_T2 )
+ || (class_ >= JOB_BABY_RUNE && class_ <= JOB_BABY_MECHANIC2 )
+ || (class_ >= JOB_SUPER_NOVICE_E && class_ <= JOB_SUPER_BABY_E )
+ || (class_ >= JOB_KAGEROU && class_ <= JOB_OBORO )
+ || (class_ >= JOB_REBELLION && class_ < JOB_MAX );
+}
+
void do_final_pc(void) {
db_destroy(pc->itemcd_db);
@@ -11201,7 +11215,8 @@ void pc_defaults(void) {
pc->expiration_timer = pc_expiration_timer;
pc->global_expiration_timer = pc_global_expiration_timer;
pc->expire_check = pc_expire_check;
-
+ pc->db_checkid = pc_db_checkid;
+
/**
* Autotrade persistency [Ind/Hercules <3]
**/
diff --git a/src/map/pc.h b/src/map/pc.h
index 8472eb34e..1f5e26270 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -618,19 +618,6 @@ struct map_session_data {
//Weapon check considering dual wielding.
#define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \
1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)|(1<<(sd)->status.weapon)))
-//Checks if the given class value corresponds to a player class. [Skotlex]
-//JOB_NOVICE isn't checked for class_ is supposed to be unsigned
-#define pcdb_checkid_sub(class_) \
-( \
- ( (class_) < JOB_MAX_BASIC ) \
- || ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) \
- || ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) \
- || ( (class_) >= JOB_BABY_RUNE && (class_) <= JOB_BABY_MECHANIC2 ) \
- || ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) \
- || ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) \
- || ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \
-)
-#define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)(class_))
// clientside display macros (values to the left/right of the "+")
#ifdef RENEWAL
@@ -1023,6 +1010,8 @@ struct pc_interface {
int (*global_expiration_timer) (int tid, int64 tick, int id, intptr_t data);
void (*expire_check) (struct map_session_data *sd);
+ bool (*db_checkid) (unsigned int class_);
+
/**
* Autotrade persistency [Ind/Hercules <3]
**/
diff --git a/src/map/script.c b/src/map/script.c
index aca4650c5..612bfa69e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -5548,7 +5548,7 @@ BUILDIN(jobchange)
if( script_hasdata(st,3) )
upper=script_getnum(st,3);
- if (pcdb_checkid(job))
+ if (pc->db_checkid(job))
{
TBL_PC* sd;
@@ -16487,7 +16487,7 @@ BUILDIN(questinfo)
if(script_hasdata(st, 5)) {
job = script_getnum(st, 5);
- if (!pcdb_checkid(job))
+ if (!pc->db_checkid(job))
ShowError("buildin_questinfo: Nonexistant Job Class.\n");
else {
qi.hasJob = true;
diff --git a/src/map/status.c b/src/map/status.c
index 7b4e6f274..9a63e32a5 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -6218,7 +6218,7 @@ void status_set_viewdata(struct block_list *bl, int class_)
case BL_PC:
{
TBL_PC* sd = (TBL_PC*)bl;
- if (pcdb_checkid(class_)) {
+ if (pc->db_checkid(class_)) {
if (pc_isridingpeco(sd)) {
switch (class_) {
//Adapt class to a Mounted one.
@@ -6285,7 +6285,7 @@ void status_set_viewdata(struct block_list *bl, int class_)
TBL_PET* pd = (TBL_PET*)bl;
if (vd) {
memcpy(&pd->vd, vd, sizeof(struct view_data));
- if (!pcdb_checkid(vd->class_)) {
+ if (!pc->db_checkid(vd->class_)) {
pd->vd.hair_style = battle_config.pet_hair_style;
if(pd->pet.equip) {
pd->vd.head_bottom = itemdb_viewid(pd->pet.equip);
@@ -12046,7 +12046,7 @@ bool status_readdb_job1(char* fields[], int columns, int current)
class_ = atoi(fields[0]);
- if(!pcdb_checkid(class_))
+ if(!pc->db_checkid(class_))
{
ShowWarning("status_readdb_job1: Invalid job class %d specified.\n", class_);
return false;
@@ -12074,7 +12074,7 @@ bool status_readdb_job2(char* fields[], int columns, int current)
class_ = atoi(fields[0]);
- if(!pcdb_checkid(class_))
+ if(!pc->db_checkid(class_))
{
ShowWarning("status_readdb_job2: Invalid job class %d specified.\n", class_);
return false;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
index 9090af876..06a046812 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
@@ -3949,6 +3949,8 @@ struct {
struct HPMHookPoint *HP_pc_global_expiration_timer_post;
struct HPMHookPoint *HP_pc_expire_check_pre;
struct HPMHookPoint *HP_pc_expire_check_post;
+ struct HPMHookPoint *HP_pc_db_checkid_pre;
+ struct HPMHookPoint *HP_pc_db_checkid_post;
struct HPMHookPoint *HP_pc_autotrade_load_pre;
struct HPMHookPoint *HP_pc_autotrade_load_post;
struct HPMHookPoint *HP_pc_autotrade_update_pre;
@@ -9106,6 +9108,8 @@ struct {
int HP_pc_global_expiration_timer_post;
int HP_pc_expire_check_pre;
int HP_pc_expire_check_post;
+ int HP_pc_db_checkid_pre;
+ int HP_pc_db_checkid_post;
int HP_pc_autotrade_load_pre;
int HP_pc_autotrade_load_post;
int HP_pc_autotrade_update_pre;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
index d83b398eb..7c09737fa 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
@@ -2005,6 +2005,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pc->expiration_timer, HP_pc_expiration_timer) },
{ HP_POP(pc->global_expiration_timer, HP_pc_global_expiration_timer) },
{ HP_POP(pc->expire_check, HP_pc_expire_check) },
+ { HP_POP(pc->db_checkid, HP_pc_db_checkid) },
{ HP_POP(pc->autotrade_load, HP_pc_autotrade_load) },
{ HP_POP(pc->autotrade_update, HP_pc_autotrade_update) },
{ HP_POP(pc->autotrade_start, HP_pc_autotrade_start) },
diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index 3249949e7..9efaa6718 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -52854,6 +52854,33 @@ void HP_pc_expire_check(struct map_session_data *sd) {
}
return;
}
+bool HP_pc_db_checkid(unsigned int class_) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_pc_db_checkid_pre ) {
+ bool (*preHookFunc) (unsigned int *class_);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_db_checkid_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_pc_db_checkid_pre[hIndex].func;
+ retVal___ = preHookFunc(&class_);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.pc.db_checkid(class_);
+ }
+ if( HPMHooks.count.HP_pc_db_checkid_post ) {
+ bool (*postHookFunc) (bool retVal___, unsigned int *class_);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_db_checkid_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_pc_db_checkid_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &class_);
+ }
+ }
+ return retVal___;
+}
void HP_pc_autotrade_load(void) {
int hIndex = 0;
if( HPMHooks.count.HP_pc_autotrade_load_pre ) {