diff options
Diffstat (limited to 'src')
37 files changed, 870 insertions, 561 deletions
diff --git a/src/echar/char.c b/src/echar/char.c index b46ca62..1a75086 100644 --- a/src/echar/char.c +++ b/src/echar/char.c @@ -23,10 +23,11 @@ #include "echar/char.h" #include "echar/config.h" -void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data* sd) +void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data **sdPtr) { // ignore char creation disable option const int fd = *fdPtr; + struct char_session_data *sd = *sdPtr; uint16 race = 0; uint16 look = 0; uint8 sex = 0; @@ -106,15 +107,17 @@ void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data* sd) static int tmpVersion = 0; void echar_parse_char_connect_pre(int *fdPtr, - struct char_session_data *sd __attribute__ ((unused)), - uint32 *ipl __attribute__ ((unused))) + struct char_session_data **sd, + uint32 *ipl) { tmpVersion = RFIFOW(*fdPtr, 14); } -void echar_parse_char_connect_post(int *fdPtr, struct char_session_data *sd, uint32 *ipl __attribute__ ((unused))) +void echar_parse_char_connect_post(int fd, + struct char_session_data *sd, + uint32 ipl __attribute__ ((unused))) { - sd = (struct char_session_data*)sockt->session[*fdPtr]->session_data; + sd = (struct char_session_data*)sockt->session[fd]->session_data; if (sd) sd->version = tmpVersion; } @@ -180,14 +183,16 @@ void echar_parse_login_password_change_ack(int charFd) } } -void echar_mmo_char_send099d(int *fdPtr, struct char_session_data *sd) +void echar_mmo_char_send099d_post(int fd, struct char_session_data *sd) { - send_additional_slots(*fdPtr, sd); + send_additional_slots(fd, sd); } -int echar_mmo_char_send_characters_post(int retVal, int *fdPtr, struct char_session_data* sd) +int echar_mmo_char_send_characters_post(int retVal, + int fd, + struct char_session_data* sd) { - send_additional_slots(*fdPtr, sd); + send_additional_slots(fd, sd); return retVal; } diff --git a/src/echar/char.h b/src/echar/char.h index a4a29c8..726f2c2 100644 --- a/src/echar/char.h +++ b/src/echar/char.h @@ -4,7 +4,8 @@ #ifndef EVOL_CHAR_CHAR #define EVOL_CHAR_CHAR -void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data* sd); +void echar_parse_char_create_new_char(int *fdPtr, + struct char_session_data **sdPtr); void echar_creation_failed(int *fdPtr, int *result); @@ -12,19 +13,17 @@ void echar_parse_change_paassword(int fd); void echar_parse_login_password_change_ack(int charFd); -void echar_mmo_char_send099d_post(int *fdPtr, struct char_session_data *sd); +void echar_mmo_char_send099d_post(int fd, struct char_session_data *sd); -int echar_mmo_char_send_characters_post(int retVal, int *fdPtr, struct char_session_data *sd); +int echar_mmo_char_send_characters_post(int retVal, int fd, struct char_session_data *sd); int echar_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf); -void echar_mmo_char_send099d(int *fdPtr, struct char_session_data *sd); - void send_additional_slots(int fd, struct char_session_data* sd); -void echar_parse_char_connect_pre(int *fdPtr, struct char_session_data *sd, uint32 *ipl); +void echar_parse_char_connect_pre(int *fdPtr, struct char_session_data **sd, uint32 *ipl); -void echar_parse_char_connect_post(int *fdPtr, struct char_session_data *sd, uint32 *ipl); +void echar_parse_char_connect_post(int fd, struct char_session_data *sd, uint32 ipl); void echar_parse_frommap_request_stats_report_pre(int *fdPtr); diff --git a/src/echar/init.c b/src/echar/init.c index e6f3eaa..e40395c 100644 --- a/src/echar/init.c +++ b/src/echar/init.c @@ -52,14 +52,14 @@ HPExport void plugin_init (void) addPacket(0x0061, 50, echar_parse_change_paassword, hpParse_Char); addPacket(0x5001, 7, echar_parse_login_password_change_ack, hpParse_FromLogin); - addHookPre("chr->parse_char_create_new_char", echar_parse_char_create_new_char); - addHookPre("chr->creation_failed", echar_creation_failed); - addHookPre("chr->parse_char_connect", echar_parse_char_connect_pre); - addHookPre("chr->parse_frommap_request_stats_report", echar_parse_frommap_request_stats_report_pre); + addHookPre(chr, parse_char_create_new_char, echar_parse_char_create_new_char); + addHookPre(chr, creation_failed, echar_creation_failed); + addHookPre(chr, parse_char_connect, echar_parse_char_connect_pre); + addHookPre(chr, parse_frommap_request_stats_report, echar_parse_frommap_request_stats_report_pre); - addHookPost("chr->mmo_char_send099d", echar_mmo_char_send099d); - addHookPost("chr->mmo_char_send_characters", echar_mmo_char_send_characters_post); - addHookPost("chr->parse_char_connect", echar_parse_char_connect_post); + addHookPost(chr, mmo_char_send099d, echar_mmo_char_send099d_post); + addHookPost(chr, mmo_char_send_characters, echar_mmo_char_send_characters_post); + addHookPost(chr, parse_char_connect, echar_parse_char_connect_post); } HPExport void server_preinit (void) diff --git a/src/elogin/init.c b/src/elogin/init.c index 4246ffd..d420cba 100644 --- a/src/elogin/init.c +++ b/src/elogin/init.c @@ -15,6 +15,7 @@ #include "common/timer.h" #include "common/mapindex.h" #include "login/lclif.h" +#include "login/lclif.p.h" #include "login/login.h" #include "ecommon/init.h" @@ -33,6 +34,11 @@ HPExport struct hplugin_info pinfo = HPM_VERSION }; +#define addHookPrePriv(ifname, type, funcname, hook) ( \ + (void)((HPMHOOK_pre_ ## type ## _ ## funcname)0 == (hook)), \ + HPMi->hooking->AddHook(HOOK_TYPE_PRE, #ifname "->" #funcname, (hook), HPMi->pid) \ + ) + HPExport void plugin_init (void) { interfaces_init_common(); @@ -40,10 +46,12 @@ HPExport void plugin_init (void) addPacket(0x7530, 22, login_parse_version, hpParse_Login); addPacket(0x027c, 91, elogin_parse_client_login2, hpParse_Login); addPacket(0x5000, 54, elogin_parse_change_paassword, hpParse_FromChar); - addHookPre("login->client_login", elogin_client_login_pre); - addHookPre("login->check_password", elogin_check_password); - addHookPre("lclif->p->parse_CA_CONNECT_INFO_CHANGED", elogin_parse_ping); - addHookPost("login->client_login", elogin_client_login_post); + + addHookPre(login, client_login, elogin_client_login_pre); + addHookPre(login, check_password, elogin_check_password_pre); + addHookPrePriv(lclif->p, PRIV__lclif, parse_CA_CONNECT_INFO_CHANGED, elogin_parse_ping_pre); + + addHookPost(login, client_login, elogin_client_login_post); } HPExport void server_preinit (void) diff --git a/src/elogin/login.c b/src/elogin/login.c index 0075f4b..854ba97 100644 --- a/src/elogin/login.c +++ b/src/elogin/login.c @@ -18,12 +18,13 @@ #include "elogin/md5calc.h" -bool elogin_check_password(const char* md5key __attribute__ ((unused)), - int *passwdenc __attribute__ ((unused)), - const char* passwd, - const char* refpass) +bool elogin_check_password_pre(const char **md5key __attribute__ ((unused)), + int *passwdenc __attribute__ ((unused)), + const char **passwdPtr, + const char **refpassPtr) { - if (!strcmp(passwd, refpass) || pass_ok(passwd, refpass)) + if (!strcmp(*passwdPtr, *refpassPtr) || + pass_ok(*passwdPtr, *refpassPtr)) { hookStop(); return 1; diff --git a/src/elogin/login.h b/src/elogin/login.h index 2e76e53..4f2f8c1 100644 --- a/src/elogin/login.h +++ b/src/elogin/login.h @@ -4,6 +4,9 @@ #ifndef EVOL_LOGIN_LOGIN #define EVOL_LOGIN_LOGIN -bool elogin_check_password(const char* md5key, int *passwdenc, const char* passwd, const char* refpass); +bool elogin_check_password_pre(const char **md5key, + int *passwdenc, + const char **passwdPtr, + const char **refpassPtr); #endif // EVOL_LOGIN_SEND diff --git a/src/elogin/parse.c b/src/elogin/parse.c index d17e325..3d8a326 100644 --- a/src/elogin/parse.c +++ b/src/elogin/parse.c @@ -44,8 +44,8 @@ void login_parse_version(int fd) send_server_version(fd); } -int elogin_client_login_pre(int *fdPtr, - struct login_session_data* sd __attribute__ ((unused))) +bool elogin_client_login_pre(int *fdPtr, + struct login_session_data **sdPtr __attribute__ ((unused))) { int fd = *fdPtr; uint16 command = RFIFOW(fd,0); @@ -53,7 +53,7 @@ int elogin_client_login_pre(int *fdPtr, { lclif->login_error(fd, 3); hookStop(); - return 1; + return true; } char username[NAME_LENGTH]; safestrncpy(username, RFIFOP(fd, 6), NAME_LENGTH); @@ -62,25 +62,26 @@ int elogin_client_login_pre(int *fdPtr, { lclif->login_error(fd, 5); hookStop(); - return 1; + return true; } else if (len >= 2 && username[len - 2] == '_' && memchr("FfMm", username[len - 1], 4)) { lclif->login_error(fd, 3); hookStop(); - return 1; + return true; } short *ptr = (short*)RFIFOP(fd, 2); if (*ptr == 20) *ptr = clientVersion; - return 0; + return false; } -int elogin_client_login_post(int retVal, int *fdPtr, - struct login_session_data* sd) +bool elogin_client_login_post(bool retVal, + int fd, + struct login_session_data* sd) { - sd = (struct login_session_data*)sockt->session[*fdPtr]->session_data; + sd = (struct login_session_data*)sockt->session[fd]->session_data; if (sd) sd->version = clientVersion; return retVal; @@ -156,19 +157,21 @@ void elogin_parse_client_login2(int fd) return; } -void elogin_parse_ping(int *fd, struct login_session_data* sd) +enum parsefunc_rcode elogin_parse_ping_pre(int *fd, + struct login_session_data **sdPtr) { + struct login_session_data *sd = *sdPtr; RFIFOSKIP(*fd, 26); if (!sd) { hookStop(); - return; + return PACKET_VALID; } struct online_login_data* data = (struct online_login_data*)idb_get(login->online_db, sd->account_id); if (data == NULL) { hookStop(); - return; + return PACKET_VALID; } if (data->waiting_disconnect != INVALID_TIMER) { @@ -176,6 +179,7 @@ void elogin_parse_ping(int *fd, struct login_session_data* sd) data->waiting_disconnect = timer->add(timer->gettick() + 30000, login->waiting_disconnect_timer, sd->account_id, 0); } hookStop(); + return PACKET_VALID; } void elogin_parse_change_paassword(int fd) diff --git a/src/elogin/parse.h b/src/elogin/parse.h index 97f66d4..07d2a3d 100644 --- a/src/elogin/parse.h +++ b/src/elogin/parse.h @@ -5,10 +5,14 @@ #define EVOL_LOGIN_PARSE void login_parse_version(int fd); -int elogin_client_login_pre(int *fd, struct login_session_data* sd); -int elogin_client_login_post(int retVal, int *fd, struct login_session_data* sd); +bool elogin_client_login_pre(int *fd, + struct login_session_data **sdPtr); +bool elogin_client_login_post(bool retVal, + int fd, + struct login_session_data *sd); void elogin_parse_client_login2(int fd); -void elogin_parse_ping(int *fd, struct login_session_data* sd); +enum parsefunc_rcode elogin_parse_ping_pre(int *fd, + struct login_session_data **sdPtr); void elogin_parse_change_paassword(int fd); #endif // EVOL_LOGIN_PARSE diff --git a/src/emap/atcommand.c b/src/emap/atcommand.c index cd3c102..b7acb4a 100644 --- a/src/emap/atcommand.c +++ b/src/emap/atcommand.c @@ -24,9 +24,11 @@ #include "emap/atcommand.h" #include "emap/lang.h" -const char* eatcommand_msgsd(struct map_session_data *sd, int *msgPtr) +const char* eatcommand_msgsd_pre(struct map_session_data **sdPtr, + int *msgPtr) { const int msg_number = *msgPtr; + struct map_session_data *sd = *sdPtr; if (!(msg_number >= 0 && msg_number < MAX_MSG)) { hookStop(); @@ -48,7 +50,8 @@ const char* eatcommand_msgsd(struct map_session_data *sd, int *msgPtr) return lang_pctrans(atcommand->msg_table[0][msg_number], sd); } -const char* eatcommand_msgfd(int *fdPtr, int *msgPtr) +const char* eatcommand_msgfd_pre(int *fdPtr, + int *msgPtr) { const int msg_number = *msgPtr; const int fd = *fdPtr; diff --git a/src/emap/atcommand.h b/src/emap/atcommand.h index b3166ab..fa40548 100644 --- a/src/emap/atcommand.h +++ b/src/emap/atcommand.h @@ -4,8 +4,10 @@ #ifndef EVOL_MAP_ATCOMMAND #define EVOL_MAP_ATCOMMAND -const char* eatcommand_msgsd(struct map_session_data *sd, int *msgPtr); -const char* eatcommand_msgfd(int *fdPtr, int *msgPtr); +const char* eatcommand_msgsd_pre(struct map_session_data **sdPtr, + int *msgPtr); +const char* eatcommand_msgfd_pre(int *fdPtr, + int *msgPtr); #define ACMD2(x) bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command __attribute__ ((unused)), const char* message, struct AtCommandInfo *info) diff --git a/src/emap/battleground.c b/src/emap/battleground.c index 4592624..c22d733 100644 --- a/src/emap/battleground.c +++ b/src/emap/battleground.c @@ -24,7 +24,10 @@ #include "emap/struct/bgdext.h" #include "emap/struct/sessionext.h" -bool ebg_team_warp(int *bg_idPtr, unsigned short *map_index, short *x, short *y) +bool ebg_team_warp_pre(int *bg_idPtr, + unsigned short *map_index, + short *x, + short *y) { int i; int bg_id = *bg_idPtr; diff --git a/src/emap/battleground.h b/src/emap/battleground.h index ece290e..d9a8ccb 100644 --- a/src/emap/battleground.h +++ b/src/emap/battleground.h @@ -4,6 +4,9 @@ #ifndef EVOL_MAP_BATTLEGROUND #define EVOL_MAP_BATTLEGROUND -bool ebg_team_warp(int *bg_idPtr, unsigned short *map_index, short *x, short *y); +bool ebg_team_warp_pre(int *bg_idPtr, + unsigned short *map_index, + short *x, + short *y); #endif // EVOL_MAP_BATTLEGROUND diff --git a/src/emap/clif.c b/src/emap/clif.c index a4d60ae..d2a89e8 100644 --- a/src/emap/clif.c +++ b/src/emap/clif.c @@ -39,8 +39,10 @@ extern bool isInit; -void eclif_quest_send_list(TBL_PC *sd) +void eclif_quest_send_list_pre(TBL_PC **sdPtr) { + TBL_PC *sd = *sdPtr; + if (!sd) { hookStop(); @@ -72,7 +74,14 @@ void eclif_quest_send_list(TBL_PC *sd) hookStop(); } -void eclif_quest_add(TBL_PC *sd, struct quest *qd) +void eclif_quest_add_pre(TBL_PC **sdPtr, + struct quest **qdPtr) +{ + eclif_quest_add(*sdPtr, *qdPtr); +} + +void eclif_quest_add(TBL_PC *sd, + struct quest *qd) { if (!sd || !qd) { @@ -99,8 +108,10 @@ void eclif_quest_add(TBL_PC *sd, struct quest *qd) hookStop(); } -void eclif_charnameack(int *fdPtr, struct block_list *bl) +void eclif_charnameack_pre(int *fdPtr, + struct block_list **blPtr) { + struct block_list *bl = *blPtr; if (!bl) { hookStop(); @@ -313,7 +324,8 @@ static void eclif_send_additional_slots2(struct block_list *bl) #undef equipPos2 #undef equipPos2Id -void eclif_getareachar_unit_post(TBL_PC* sd, struct block_list *bl) +void eclif_getareachar_unit_post(TBL_PC *sd, + struct block_list *bl) { if (!bl || !sd) return; @@ -324,7 +336,8 @@ void eclif_getareachar_unit_post(TBL_PC* sd, struct block_list *bl) } } -bool eclif_spawn_post(bool retVal, struct block_list *bl) +bool eclif_spawn_post(bool retVal, + struct block_list *bl) { if (!bl) return retVal; @@ -349,13 +362,13 @@ void eclif_authok_post(TBL_PC *sd) } void eclif_changemap_post(TBL_PC *sd, - short *m, - int *x __attribute__ ((unused)), - int *y __attribute__ ((unused))) + short m, + int x __attribute__ ((unused)), + int y __attribute__ ((unused))) { if (!sd) return; - struct MapdExt *data = mapd_get(*m); + struct MapdExt *data = mapd_get(m); int mask = data ? data->mask : 1; send_mapmask(sd->fd, mask); } @@ -370,23 +383,26 @@ void eclif_handle_invisible_map(struct block_list *bl, hookStop(); } -void eclif_sendlook(struct block_list *bl, - int *id __attribute__ ((unused)), - int *type __attribute__ ((unused)), - int *val __attribute__ ((unused)), - int *val2 __attribute__ ((unused)), - enum send_target *target) +void eclif_sendlook_pre(struct block_list **blPtr, + int *id __attribute__ ((unused)), + int *type __attribute__ ((unused)), + int *val __attribute__ ((unused)), + int *val2 __attribute__ ((unused)), + enum send_target *target) { + struct block_list *bl = *blPtr; if (*target == SELF) return; eclif_handle_invisible_map(bl, *target); } -bool eclif_send(const void* buf __attribute__ ((unused)), - int *len __attribute__ ((unused)), - struct block_list* bl, - enum send_target *type) +bool eclif_send_pre(const void **bufPtr, + int *len __attribute__ ((unused)), + struct block_list **blPtr, + enum send_target *type) { + struct block_list *bl = *blPtr; + const void *buf = *bufPtr; if (*type == SELF) { if (*len >= 2) @@ -423,16 +439,23 @@ bool eclif_send(const void* buf __attribute__ ((unused)), return true; } -void eclif_set_unit_idle(struct block_list* bl, TBL_PC *tsd, enum send_target *target) +void eclif_set_unit_idle_pre(struct block_list **blPtr, + TBL_PC **tsdPtr, + enum send_target *target) { + struct block_list *bl = *blPtr; + TBL_PC *tsd = *tsdPtr; if (tsd && bl && bl->id == tsd->bl.id && *target == SELF) return; eclif_handle_invisible_map(bl, *target); } -int eclif_send_actual(int *fd, void *buf, int *len) +int eclif_send_actual_pre(int *fd, + void **bufPtr, + int *len) { + void *buf = *bufPtr; if (*len >= 2) { const int packet = RBUFW (buf, 0); @@ -577,29 +600,35 @@ int eclif_send_actual(int *fd, void *buf, int *len) uint16 GetWord(uint32 val, int idx) { - switch( idx ) - { - case 0: return (uint16)( (val & 0x0000FFFF) ); - case 1: return (uint16)( (val & 0xFFFF0000) >> 0x10 ); - default: + switch( idx ) + { + case 0: return (uint16)( (val & 0x0000FFFF) ); + case 1: return (uint16)( (val & 0xFFFF0000) >> 0x10 ); + default: #if defined(DEBUG) - ShowDebug("GetWord: invalid index (idx=%d)\n", idx); + ShowDebug("GetWord: invalid index (idx=%d)\n", idx); #endif - return 0; - } + return 0; + } } //To make the assignation of the level based on limits clearer/easier. [Skotlex] -static int clif_setlevel_sub(int lv) { - if( lv < battle->bc->max_lv ) { - ; - } else if( lv < battle->bc->aura_lv ) { - lv = battle->bc->max_lv - 1; - } else { - lv = battle->bc->max_lv; - } - - return lv; +static int clif_setlevel_sub(int lv) +{ + if (lv < battle->bc->max_lv) + { + ; + } + else if (lv < battle->bc->aura_lv) + { + lv = battle->bc->max_lv - 1; + } + else + { + lv = battle->bc->max_lv; + } + + return lv; } static int clif_setlevel(struct block_list* bl) @@ -971,35 +1000,35 @@ void eclif_damage_old(struct block_list* src, } } -void eclif_set_unit_idle_post(struct block_list* bl, +void eclif_set_unit_idle_post(struct block_list *bl, TBL_PC *tsd, - enum send_target *target) + enum send_target target) { if (!bl || !tsd) return; - eclif_set_unit_idle_old(bl, tsd, *target); + eclif_set_unit_idle_old(bl, tsd, target); if (bl->type == BL_MOB) - send_mob_info(bl, &tsd->bl, *target); + send_mob_info(bl, &tsd->bl, target); else if (bl->type == BL_PC) - send_pc_info(bl, &tsd->bl, *target); + send_pc_info(bl, &tsd->bl, target); else if (bl->type == BL_NPC) - send_npc_info(bl, &tsd->bl, *target); + send_npc_info(bl, &tsd->bl, target); } -void eclif_set_unit_walking_pre(struct block_list* bl, - TBL_PC *tsd, - struct unit_data* ud, +void eclif_set_unit_walking_pre(struct block_list **blPtr, + TBL_PC **tsdPtr, + struct unit_data **udPtr, enum send_target *target) { - eclif_set_unit_walking_old(bl, tsd, ud, *target); + eclif_set_unit_walking_old(*blPtr, *tsdPtr, *udPtr, *target); } -void eclif_set_unit_walking_post(struct block_list* bl, +void eclif_set_unit_walking_post(struct block_list *bl, TBL_PC *tsd, struct unit_data* ud, - enum send_target *target) + enum send_target target) { if (!ud) return; @@ -1007,29 +1036,29 @@ void eclif_set_unit_walking_post(struct block_list* bl, if (!sd || !pc_isinvisible(sd)) { if (ud->walktimer != INVALID_TIMER) - send_advmoving(ud, true, tsd ? &tsd->bl : bl, *target); + send_advmoving(ud, true, tsd ? &tsd->bl : bl, target); else - send_advmoving(ud, false, tsd ? &tsd->bl : bl, *target); + send_advmoving(ud, false, tsd ? &tsd->bl : bl, target); } } int eclif_damage_post(int retVal, struct block_list* src, struct block_list* dst, - int *sdelay, - int *ddelay, - int64 *in_damage, - short *div, - unsigned char *type, - int64 *in_damage2) + int sdelay, + int ddelay, + int64 in_damage, + short div, + unsigned char type, + int64 in_damage2) { eclif_damage_old(src, dst, - *sdelay, *ddelay, *in_damage, - *div, *type, *in_damage2); + sdelay, ddelay, in_damage, + div, type, in_damage2); return retVal; } -void eclif_move(struct unit_data *ud) +void eclif_move_post(struct unit_data *ud) { if (!ud) return; @@ -1038,23 +1067,25 @@ void eclif_move(struct unit_data *ud) send_advmoving(ud, false, ud->bl, AREA_WOS); } -void eclif_spawn_unit_pre(struct block_list* bl, enum send_target *target) +void eclif_spawn_unit_pre(struct block_list **blPtr, + enum send_target *target) { - eclif_spawn_unit_old(bl, *target); + eclif_spawn_unit_old(*blPtr, *target); } bool tempChangeMap; void eclif_parse_LoadEndAck_pre(int *fdPtr __attribute__ ((unused)), - struct map_session_data *sd) + struct map_session_data **sdPtr) { + struct map_session_data *sd = *sdPtr; if (!sd) return; sd->state.warp_clean = 0; tempChangeMap = sd->state.changemap; } -void eclif_parse_LoadEndAck_post(int *fdPtr __attribute__ ((unused)), +void eclif_parse_LoadEndAck_post(int fd __attribute__ ((unused)), struct map_session_data *sd) { if (!tempChangeMap) @@ -1201,10 +1232,12 @@ static inline int itemtype(const int type) } } -void eclif_getareachar_item(struct map_session_data *sd, - struct flooritem_data *fitem) +void eclif_getareachar_item_pre(struct map_session_data **sdPtr, + struct flooritem_data **fitemPtr) { int view; + struct map_session_data *sd = *sdPtr; + struct flooritem_data *fitem = *fitemPtr; if (!sd || !fitem) return; int fd = sd->fd; @@ -1234,10 +1267,11 @@ void eclif_getareachar_item(struct map_session_data *sd, hookStop(); } -void eclif_dropflooritem(struct flooritem_data* fitem) +void eclif_dropflooritem_pre(struct flooritem_data **fitemPtr) { char buf[28]; int view; + struct flooritem_data *fitem = *fitemPtr; if (!fitem) return; @@ -1274,9 +1308,10 @@ void eclif_dropflooritem(struct flooritem_data* fitem) clif->send(&buf, 28, &fitem->bl, AREA); } -void eclif_sendbgemblem_area(struct map_session_data *sd) +void eclif_sendbgemblem_area_pre(struct map_session_data **sdPtr) { unsigned char buf[34]; + struct map_session_data *sd = *sdPtr; struct SessionExt *data = session_get_bysd(sd); if (!sd || !data || data->clientVersion < 12) return; @@ -1289,9 +1324,11 @@ void eclif_sendbgemblem_area(struct map_session_data *sd) clif->send(buf, 34, &sd->bl, AREA); } -void eclif_sendbgemblem_single(int *fdPtr, struct map_session_data *sd) +void eclif_sendbgemblem_single_pre(int *fdPtr, + struct map_session_data **sdPtr) { int fd = *fdPtr; + struct map_session_data *sd = *sdPtr; struct SessionExt *data = session_get_bysd(sd); struct SessionExt *ddata = session_get_bysd(sd); if (!sd || !data || !ddata || ddata->clientVersion < 12) @@ -1308,11 +1345,13 @@ void eclif_sendbgemblem_single(int *fdPtr, struct map_session_data *sd) return; } -void eclif_disp_message(struct block_list* src, - const char* mes, - enum send_target *targetPtr) +void eclif_disp_message_pre(struct block_list **srcPtr, + const char **mesPtr, + enum send_target *targetPtr) { unsigned char buf[256]; + struct block_list *src = *srcPtr; + const char *mes = *mesPtr; nullpo_retv(mes); diff --git a/src/emap/clif.h b/src/emap/clif.h index 2b95249..d396d98 100644 --- a/src/emap/clif.h +++ b/src/emap/clif.h @@ -4,54 +4,82 @@ #ifndef EVOL_MAP_CLIF #define EVOL_MAP_CLIF -void eclif_quest_send_list(TBL_PC *sd); -void eclif_quest_add(TBL_PC *sd, struct quest *qd); -void eclif_charnameack(int *fdPtr, struct block_list *bl); -void eclif_getareachar_unit_post(TBL_PC* sd, struct block_list *bl); -bool eclif_spawn_post(bool retVal, struct block_list *bl); -void eclif_sendlook(struct block_list *bl, int *id, int *type, - int *val, int *val2, enum send_target *target); -bool eclif_send(const void* buf, int *len, struct block_list* bl, enum send_target *type); -void eclif_set_unit_idle(struct block_list* bl, TBL_PC *tsd, - enum send_target *target); -int eclif_send_actual(int *fd, void *buf, int *len); - +void eclif_quest_send_list_pre(TBL_PC **sdPtr); +void eclif_quest_add(TBL_PC *sd, + struct quest *qd); +void eclif_quest_add_pre(TBL_PC **sdPtr, + struct quest **qdPtr); +void eclif_charnameack_pre(int *fdPtr, + struct block_list **blPtr); +void eclif_getareachar_unit_post(TBL_PC *sd, + struct block_list *bl); +bool eclif_spawn_post(bool retVal, + struct block_list *bl); +void eclif_sendlook_pre(struct block_list **blPtr, + int *id, + int *type, + int *val, + int *val2, + enum send_target *target); +bool eclif_send_pre(const void **bufPtr, + int *len, + struct block_list **blPtr, + enum send_target *type); +void eclif_set_unit_idle_pre(struct block_list **blPtr, + TBL_PC **tsdPtr, + enum send_target *target); +int eclif_send_actual_pre(int *fd, + void **bufPtr, + int *len); void eclif_authok_post(TBL_PC *sd); -void eclif_changemap_post(TBL_PC *sd, short *m, int *x, int *y); -void eclif_set_unit_idle_post(struct block_list* bl, TBL_PC *tsd, - enum send_target *target); -void eclif_set_unit_walking_pre(struct block_list* bl, TBL_PC *tsd, - struct unit_data* ud, enum send_target *target); -void eclif_set_unit_walking_post(struct block_list* bl, TBL_PC *tsd, - struct unit_data* ud, enum send_target *target); +void eclif_changemap_post(TBL_PC *sd, + short m, + int x, + int y); +void eclif_set_unit_idle_post(struct block_list *bl, + TBL_PC *tsd, + enum send_target target); +void eclif_set_unit_walking_pre(struct block_list **blPtr, + TBL_PC **tsdPtr, + struct unit_data **udPtr, + enum send_target *target); +void eclif_set_unit_walking_post(struct block_list *bl, + TBL_PC *tsd, + struct unit_data *ud, + enum send_target target); int eclif_damage_post(int retVal, - struct block_list* src, - struct block_list* dst, - int *sdelay, - int *ddelay, - int64 *in_damage, - short *div, - unsigned char *type, - int64 *in_damage2); -void eclif_move(struct unit_data *ud); + struct block_list *src, + struct block_list *dst, + int sdelay, + int ddelay, + int64 in_damage, + short div, + unsigned char type, + int64 in_damage2); +void eclif_move_post(struct unit_data *ud); void eclif_parse_LoadEndAck_pre(int *fdPtr, - struct map_session_data *sd); -void eclif_parse_LoadEndAck_post(int *fdPtr, + struct map_session_data **sdPtr); +void eclif_parse_LoadEndAck_post(int fd, struct map_session_data *sd); -void eclif_changelook2(struct block_list *bl, int type, int val, - struct item_data *id, int n); -void eclif_getareachar_item(struct map_session_data *sd, struct flooritem_data *fitem); -void eclif_dropflooritem(struct flooritem_data* fitem); -void eclif_sendbgemblem_area(struct map_session_data *sd); -void eclif_sendbgemblem_single(int *fdPtr, struct map_session_data *sd); -void eclif_disp_message(struct block_list* src, - const char* mes, - enum send_target *targetPtr); +void eclif_changelook2(struct block_list *bl, + int type, + int val, + struct item_data *id, + int n); +void eclif_getareachar_item_pre(struct map_session_data **sdPtr, + struct flooritem_data **fitemPtr); +void eclif_dropflooritem_pre(struct flooritem_data **fitemPtr); +void eclif_sendbgemblem_area_pre(struct map_session_data **sdPtr); +void eclif_sendbgemblem_single_pre(int *fdPtr, + struct map_session_data **sdPtr); +void eclif_disp_message_pre(struct block_list **srcPtr, + const char **mesPtr, + enum send_target *targetPtr); void eclif_set_unit_idle_old(struct block_list* bl, struct map_session_data *tsd, enum send_target target); -void eclif_spawn_unit_pre(struct block_list* bl, +void eclif_spawn_unit_pre(struct block_list **blPtr, enum send_target *target); #endif // EVOL_MAP_CLIF diff --git a/src/emap/init.c b/src/emap/init.c index cdd3b34..5210524 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -171,101 +171,99 @@ HPExport void plugin_init (void) addPacket(0xb14, 3, map_parse_homun_emote, hpClif_Parse); addPacket(0xb15, 9, map_parse_homun_dir, hpClif_Parse); - addHookPre("atcommand->msgfd", eatcommand_msgfd); - addHookPre("atcommand->msgsd", eatcommand_msgsd); + addHookPre(atcommand, msgfd, eatcommand_msgfd_pre); + addHookPre(atcommand, msgsd, eatcommand_msgsd_pre); + addHookPre(bg, team_warp, ebg_team_warp_pre); + addHookPre(pc, can_Adopt, epc_can_Adopt_pre); + addHookPre(pc, adoption, epc_adoption_pre); + addHookPre(pc, readparam, epc_readparam_pre); + addHookPre(pc, setregistry, epc_setregistry_pre); + addHookPre(pc, equipitem_pos, epc_equipitem_pos_pre); + addHookPre(pc, unequipitem_pos, epc_unequipitem_pos_pre); + addHookPre(pc, can_attack, epc_can_attack_pre); + addHookPre(pc, takeitem, epc_takeitem_pre); + addHookPre(pc, validate_levels, epc_validate_levels_pre); + addHookPre(pc, check_job_name, epc_check_job_name_pre); + addHookPre(pc, delitem, epc_delitem_pre); + addHookPre(pc, dropitem, epc_dropitem_pre); + addHookPre(pc, insert_card, epc_insert_card_pre); + addHookPre(pc, process_chat_message, epc_process_chat_message_pre); + addHookPre(mob, deleteslave_sub, emob_deleteslave_sub_pre); + addHookPre(mob, read_db_additional_fields, emob_read_db_additional_fields_pre); + addHookPre(npc, parse_unknown_mapflag, enpc_parse_unknown_mapflag_pre); + addHookPre(npc, buysellsel, enpc_buysellsel_pre); + addHookPre(npc, db_checkid, enpc_db_checkid_pre); + addHookPre(clif, quest_send_list, eclif_quest_send_list_pre); + addHookPre(clif, quest_add, eclif_quest_add_pre); + addHookPre(clif, charnameack, eclif_charnameack_pre); + addHookPre(clif, getareachar_item, eclif_getareachar_item_pre); + addHookPre(clif, dropflooritem, eclif_dropflooritem_pre); + addHookPre(clif, disp_message, eclif_disp_message_pre); + addHookPre(clif, sendlook, eclif_sendlook_pre); + addHookPre(clif, send, eclif_send_pre); + addHookPre(clif, sendbgemblem_area, eclif_sendbgemblem_area_pre); + addHookPre(clif, sendbgemblem_single, eclif_sendbgemblem_single_pre); + addHookPre(clif, set_unit_idle, eclif_set_unit_idle_pre); + addHookPre(clif, set_unit_walking, eclif_set_unit_walking_pre); + addHookPre(clif, send_actual, eclif_send_actual_pre); + addHookPre(clif, pLoadEndAck, eclif_parse_LoadEndAck_pre); + addHookPre(clif, spawn_unit, eclif_spawn_unit_pre); + addHookPre(itemdb, is_item_usable, eitemdb_is_item_usable_pre); + addHookPre(itemdb, readdb_additional_fields, eitemdb_readdb_additional_fields_pre); + addHookPre(itemdb, destroy_item_data, edestroy_item_data_pre); + addHookPre(unit, can_move, eunit_can_move_pre); + addHookPre(unit, walktoxy, eunit_walktoxy_pre); + addHookPre(mail, invalid_operation, email_invalid_operation_pre); + addHookPre(map, list_final, edo_final_maps_pre); + addHookPre(map, cell2gat, emap_cell2gat_pre); + addHookPre(map, gat2cell, emap_gat2cell_pre); + addHookPre(map, getcellp, emap_getcellp_pre); + addHookPre(map, setgatcell, emap_setgatcell_pre); + addHookPre(map, iwall_set, emap_iwall_set_pre); + addHookPre(map, iwall_get, emap_iwall_get_pre); + addHookPre(map, iwall_remove, emap_iwall_remove_pre); + addHookPre(script, get_val_npc_num, eget_val_npcscope_num_pre); + addHookPre(script, get_val_ref_num, eget_val_npcscope_num_pre); + addHookPre(script, get_val_npc_str, eget_val_npcscope_str_pre); + addHookPre(script, get_val_ref_str, eget_val_npcscope_str_pre); + addHookPre(script, set_reg_npc_num, eset_reg_npcscope_num_pre); + addHookPre(script, set_reg_ref_num, eset_reg_npcscope_num_pre); + addHookPre(script, set_reg_npc_str, eset_reg_npcscope_str_pre); + addHookPre(script, set_reg_ref_str, eset_reg_npcscope_str_pre); + addHookPre(script, reload, escript_reload_pre); + addHookPre(script, load_translations, escript_load_translations_pre); + addHookPre(script, load_parameters, escript_load_parameters_pre); + addHookPre(status, calc_pc_additional, estatus_calc_pc_additional_pre); - addHookPre("bg->team_warp", ebg_team_warp); - addHookPre("pc->can_Adopt", epc_can_Adopt_pre); - addHookPre("pc->adoption", epc_adoption_pre); - addHookPre("pc->readparam", epc_readparam_pre); - addHookPre("pc->setregistry", epc_setregistry); - addHookPre("pc->equipitem_pos", epc_equipitem_pos); - addHookPre("pc->unequipitem_pos", epc_unequipitem_pos); - addHookPre("pc->can_attack", epc_can_attack); - addHookPre("pc->takeitem", epc_takeitem); - addHookPre("pc->validate_levels", epc_validate_levels); - addHookPre("pc->check_job_name", epc_check_job_name); - addHookPre("pc->delitem", epc_delitem_pre); - addHookPre("pc->dropitem", epc_dropitem_pre); - addHookPre("pc->takeitem", epc_takeitem_pre); - addHookPre("pc->insert_card", epc_insert_card_pre); - addHookPre("pc->process_chat_message", epc_process_chat_message_pre); - addHookPre("mob->deleteslave_sub", emob_deleteslave_sub); - addHookPre("mob->read_db_additional_fields", emob_read_db_additional_fields); - addHookPre("npc->parse_unknown_mapflag", enpc_parse_unknown_mapflag); - addHookPre("npc->buysellsel", enpc_buysellsel); - addHookPre("npc->db_checkid", enpc_db_checkid); - addHookPre("clif->quest_send_list", eclif_quest_send_list); - addHookPre("clif->quest_add", eclif_quest_add); - addHookPre("clif->charnameack", eclif_charnameack); - addHookPre("clif->getareachar_item", eclif_getareachar_item); - addHookPre("clif->dropflooritem", eclif_dropflooritem); - addHookPre("clif->disp_message", eclif_disp_message); - addHookPre("clif->sendlook", eclif_sendlook); - addHookPre("clif->send", eclif_send); - addHookPre("clif->sendbgemblem_area", eclif_sendbgemblem_area); - addHookPre("clif->sendbgemblem_single", eclif_sendbgemblem_single); - addHookPre("clif->set_unit_idle", eclif_set_unit_idle); - addHookPre("clif->set_unit_walking", eclif_set_unit_walking_pre); - addHookPre("clif->send_actual", eclif_send_actual); - addHookPre("clif->pLoadEndAck", eclif_parse_LoadEndAck_pre); - addHookPre("clif->spawn_unit", eclif_spawn_unit_pre); - addHookPre("itemdb->is_item_usable", eitemdb_is_item_usable); - addHookPre("itemdb->readdb_additional_fields", eitemdb_readdb_additional_fields); - addHookPre("itemdb->destroy_item_data", edestroy_item_data); - addHookPre("unit->can_move", eunit_can_move); - addHookPre("unit->walktoxy", eunit_walktoxy); - addHookPre("mail->invalid_operation", email_invalid_operation); - addHookPre("map->list_final", edo_final_maps); - addHookPre("map->cell2gat", emap_cell2gat); - addHookPre("map->gat2cell", emap_gat2cell); - addHookPre("map->getcellp", emap_getcellp); - addHookPre("map->setgatcell", emap_setgatcell); - addHookPre("map->iwall_set", emap_iwall_set); - addHookPre("map->iwall_get", emap_iwall_get); - addHookPre("map->iwall_remove", emap_iwall_remove); - addHookPre("script->get_val_npc_num", eget_val_npcscope_num); - addHookPre("script->get_val_ref_num", eget_val_npcscope_num); - addHookPre("script->get_val_npc_str", eget_val_npcscope_str); - addHookPre("script->get_val_ref_str", eget_val_npcscope_str); - addHookPre("script->set_reg_npc_num", eset_reg_npcscope_num); - addHookPre("script->set_reg_ref_num", eset_reg_npcscope_num); - addHookPre("script->set_reg_npc_str", eset_reg_npcscope_str); - addHookPre("script->set_reg_ref_str", eset_reg_npcscope_str); - addHookPre("script->reload", escript_reload); - addHookPre("script->load_translations", escript_load_translations); - addHookPre("script->load_parameters", escript_load_parameters); - addHookPre("status->calc_pc_additional", estatus_calc_pc_additional); - - addHookPost("clif->getareachar_unit", eclif_getareachar_unit_post); - addHookPost("clif->authok", eclif_authok_post); - addHookPost("clif->changemap", eclif_changemap_post); - addHookPost("clif->set_unit_idle", eclif_set_unit_idle_post); - addHookPost("clif->pLoadEndAck", eclif_parse_LoadEndAck_post); - addHookPost("clif->spawn", eclif_spawn_post); - addHookPost("clif->damage", eclif_damage_post); - addHookPost("status->set_viewdata", estatus_set_viewdata_post); - addHookPost("status->read_job_db_sub", estatus_read_job_db_sub); - addHookPost("status->calc_pc_", estatus_calc_pc__post); - addHookPost("status->calc_speed", estatus_calc_speed_post); - addHookPost("clif->set_unit_walking", eclif_set_unit_walking_post); - addHookPost("clif->move", eclif_move); - addHookPost("map->addflooritem", emap_addflooritem_post); - addHookPost("mob->read_db_mode_sub", emob_read_db_mode_sub_post); - addHookPost("skill->check_condition_castend", eskill_check_condition_castend_post); - addHookPost("pc->additem", epc_additem_post); - addHookPost("pc->isequip", epc_isequip_post); - addHookPost("pc->isUseitem", epc_isequip_post); - addHookPost("pc->useitem", epc_useitem_post); - addHookPost("pc->equipitem", epc_equipitem_post); - addHookPost("pc->unequipitem", epc_unequipitem_post); - addHookPost("pc->setnewpc", epc_setnewpc_post); - addHookPost("pc->dead", epc_dead_post); - addHookPost("pc->delitem", epc_delitem_post); - addHookPost("pc->dropitem", epc_dropitem_post); - addHookPost("pc->takeitem", epc_takeitem_post); - addHookPost("pc->can_insert_card_into", epc_can_insert_card_into_post); - addHookPost("pc->insert_card", epc_insert_card_post); + addHookPost(clif, getareachar_unit, eclif_getareachar_unit_post); + addHookPost(clif, authok, eclif_authok_post); + addHookPost(clif, changemap, eclif_changemap_post); + addHookPost(clif, set_unit_idle, eclif_set_unit_idle_post); + addHookPost(clif, pLoadEndAck, eclif_parse_LoadEndAck_post); + addHookPost(clif, spawn, eclif_spawn_post); + addHookPost(clif, damage, eclif_damage_post); + addHookPost(clif, set_unit_walking, eclif_set_unit_walking_post); + addHookPost(clif, move, eclif_move_post); + addHookPost(status, set_viewdata, estatus_set_viewdata_post); + addHookPost(status, read_job_db_sub, estatus_read_job_db_sub_post); + addHookPost(status, calc_pc_, estatus_calc_pc__post); + addHookPost(status, calc_speed, estatus_calc_speed_post); + addHookPost(map, addflooritem, emap_addflooritem_post); + addHookPost(mob, read_db_mode_sub, emob_read_db_mode_sub_post); + addHookPost(skill, check_condition_castend, eskill_check_condition_castend_post); + addHookPost(pc, additem, epc_additem_post); + addHookPost(pc, isequip, epc_isequip_post); + addHookPost(pc, isUseitem, epc_isequip_post); + addHookPost(pc, useitem, epc_useitem_post); + addHookPost(pc, equipitem, epc_equipitem_post); + addHookPost(pc, unequipitem, epc_unequipitem_post); + addHookPost(pc, setnewpc, epc_setnewpc_post); + addHookPost(pc, dead, epc_dead_post); + addHookPost(pc, delitem, epc_delitem_post); + addHookPost(pc, dropitem, epc_dropitem_post); + addHookPost(pc, takeitem, epc_takeitem_post); + addHookPost(pc, can_insert_card_into, epc_can_insert_card_into_post); + addHookPost(pc, insert_card, epc_insert_card_post); langScriptId = script->add_str("Lang"); mountScriptId = script->add_str("mount"); @@ -283,7 +281,8 @@ HPExport void server_preinit (void) addMapInterConf("default_y", config_default_y); addMapInterConf("warn_missing_translation", config_warn_missing_translation); - addHookPre("quest->read_db_sub", equest_read_db_sub); + addHookPre(quest, read_db_sub, equest_read_db_sub_pre); + addGroupPermission("send_gm", permission_send_gm_flag); addGroupPermission("show_client_version", permission_show_client_version_flag); } diff --git a/src/emap/itemdb.c b/src/emap/itemdb.c index 0a36a21..0c2ca9d 100644 --- a/src/emap/itemdb.c +++ b/src/emap/itemdb.c @@ -24,19 +24,22 @@ #include "emap/struct/itemdext.h" #include "emap/npc.h" -bool eitemdb_is_item_usable(struct item_data *item) +bool eitemdb_is_item_usable_pre(struct item_data **itemPtr) { + struct item_data *item = *itemPtr; hookStop(); if (!item) return false; return item->type == IT_HEALING || item->type == IT_USABLE || item->type == IT_CASH || item->type == IT_PETEGG; } -void eitemdb_readdb_additional_fields(int *itemid, - struct config_setting_t *it, - int *n __attribute__ ((unused)), - const char *source) +void eitemdb_readdb_additional_fields_pre(int *itemid, + struct config_setting_t **itPtr, + int *n __attribute__ ((unused)), + const char **sourcePtr) { + struct config_setting_t *it = *itPtr; + const char *source = *sourcePtr; struct item_data *item = itemdb->exists(*itemid); int i32 = 0; const char *str = NULL; @@ -161,9 +164,10 @@ void eitemdb_readdb_additional_fields(int *itemid, hookStop(); } -void edestroy_item_data(struct item_data* self, - int *free_selfPtr __attribute__ ((unused))) +void edestroy_item_data_pre(struct item_data **selfPtr, + int *free_selfPtr __attribute__ ((unused))) { + struct item_data *self = *selfPtr; struct ItemdExt *data = itemd_get(self); if (!data) return; diff --git a/src/emap/itemdb.h b/src/emap/itemdb.h index 3b1c651..02fbb45 100644 --- a/src/emap/itemdb.h +++ b/src/emap/itemdb.h @@ -4,8 +4,12 @@ #ifndef EVOL_MAP_ITEMDB #define EVOL_MAP_ITEMDB -bool eitemdb_is_item_usable(struct item_data *item); -void eitemdb_readdb_additional_fields(int *itemid, struct config_setting_t *it, int *n, const char *source); -void edestroy_item_data(struct item_data* self, int *free_selfPtr); +bool eitemdb_is_item_usable_pre(struct item_data **itemPtr); +void eitemdb_readdb_additional_fields_pre(int *itemid, + struct config_setting_t **itPtr, + int *n, + const char **sourcePtr); +void edestroy_item_data_pre(struct item_data **selfPtr, + int *free_selfPtr); #endif // EVOL_MAP_ITEMDB diff --git a/src/emap/mail.c b/src/emap/mail.c index 4f293d1..5d9e37c 100644 --- a/src/emap/mail.c +++ b/src/emap/mail.c @@ -21,8 +21,9 @@ #include "plugins/HPMHooking.h" -bool email_invalid_operation(struct map_session_data *sd) +bool email_invalid_operation_pre(struct map_session_data **sdPtr) { + struct map_session_data *sd = *sdPtr; if (!sd) { hookStop(); diff --git a/src/emap/mail.h b/src/emap/mail.h index f2c3ce0..02a41d7 100644 --- a/src/emap/mail.h +++ b/src/emap/mail.h @@ -4,6 +4,6 @@ #ifndef EVOL_MAP_MAIL #define EVOL_MAP_MAIL -bool email_invalid_operation(struct map_session_data *sd); +bool email_invalid_operation_pre(struct map_session_data **sdPtr); #endif // EVOL_MAP_MAIL diff --git a/src/emap/map.c b/src/emap/map.c index 6313f20..4fef163 100644 --- a/src/emap/map.c +++ b/src/emap/map.c @@ -66,14 +66,14 @@ struct mapcell2 int emap_addflooritem_post(int retVal, const struct block_list *bl __attribute__ ((unused)), struct item *item, - int *amount __attribute__ ((unused)), - int16 *m __attribute__ ((unused)), - int16 *x __attribute__ ((unused)), - int16 *y __attribute__ ((unused)), - int *first_charid __attribute__ ((unused)), - int *second_charid __attribute__ ((unused)), - int *third_charid __attribute__ ((unused)), - int *flags __attribute__ ((unused))) + int amount __attribute__ ((unused)), + int16 m __attribute__ ((unused)), + int16 x __attribute__ ((unused)), + int16 y __attribute__ ((unused)), + int first_charid __attribute__ ((unused)), + int second_charid __attribute__ ((unused)), + int third_charid __attribute__ ((unused)), + int flags __attribute__ ((unused))) { TBL_ITEM* fitem = (TBL_ITEM*)idb_get(map->id_db, retVal); if (fitem) @@ -241,11 +241,14 @@ static bool isWallCell(const struct block_list *bl, struct mapcell2 cell) #define strangeCast(type, val) *((type*)(&val)) -int emap_getcellp(struct map_data* m, - const struct block_list *bl, - int16 *xPtr, int16 *yPtr, - cell_chk *cellchkPtr) +int emap_getcellp_pre(struct map_data **mPtr, + const struct block_list **blPtr, + int16 *xPtr, + int16 *yPtr, + cell_chk *cellchkPtr) { + struct map_data *m = *mPtr; + const struct block_list *bl = *blPtr; if (bl && m) { const int x = *xPtr; @@ -297,7 +300,7 @@ int emap_getcellp(struct map_data* m, return 0; } -struct mapcell emap_gat2cell(int *gatPtr) +struct mapcell emap_gat2cell_pre(int *gatPtr) { struct mapcell2 cell; const int gat = *gatPtr; @@ -350,7 +353,7 @@ struct mapcell emap_gat2cell(int *gatPtr) return strangeCast(struct mapcell, cell); } -int emap_cell2gat(struct mapcell *cellPtr) +int emap_cell2gat_pre(struct mapcell *cellPtr) { struct mapcell2 cell = *((struct mapcell2*)cellPtr); hookStop(); @@ -367,7 +370,10 @@ int emap_cell2gat(struct mapcell *cellPtr) return 1; } -void emap_setgatcell2(int16 m, int16 x, int16 y, int gat) +void emap_setgatcell2(int16 m, + int16 x, + int16 y, + int gat) { int j; @@ -393,27 +399,32 @@ void emap_setgatcell2(int16 m, int16 x, int16 y, int gat) cell2->wall = cell->wall; } -void emap_setgatcell(int16 *mPtr, int16 *xPtr, int16 *yPtr, int *gatPtr) +void emap_setgatcell_pre(int16 *mPtr, + int16 *xPtr, + int16 *yPtr, + int *gatPtr) { emap_setgatcell2(*mPtr, *xPtr, *yPtr, *gatPtr); hookStop(); } -bool emap_iwall_set(int16 *m __attribute__ ((unused)), - int16 *x __attribute__ ((unused)), - int16 *y __attribute__ ((unused)), - int *size __attribute__ ((unused)), - int8 *dir __attribute__ ((unused)), - bool *shootable __attribute__ ((unused)), - const char* wall_name __attribute__ ((unused))) +bool emap_iwall_set_pre(int16 *m __attribute__ ((unused)), + int16 *x __attribute__ ((unused)), + int16 *y __attribute__ ((unused)), + int *size __attribute__ ((unused)), + int8 *dir __attribute__ ((unused)), + bool *shootable __attribute__ ((unused)), + const char *wall_namePtr __attribute__ ((unused))) { ShowError("Unsupported set wall function\n"); hookStop(); return false; } -void emap_iwall_get(struct map_session_data *sd) +void emap_iwall_get_pre(struct map_session_data **sdPtr) { + struct map_session_data *sd = *sdPtr; + if (!sd || map->list[sd->bl.m].iwall_num < 1) { hookStop(); @@ -432,9 +443,10 @@ void emap_iwall_get(struct map_session_data *sd) hookStop(); } -void emap_iwall_remove(const char *name) +void emap_iwall_remove_pre(const char **namePtr) { struct WallData *wall; + const char *name = *namePtr; if ((wall = (struct WallData *)strdb_get(map->iwall_db, name)) == NULL) { @@ -466,7 +478,14 @@ void emap_iwall_remove(const char *name) hookStop(); } -bool emap_iwall_set2(int m, int layer, int x1, int y1, int x2, int y2, int mask, const char *name) +bool emap_iwall_set2(int m, + int layer, + int x1, + int y1, + int x2, + int y2, + int mask, + const char *name) { struct WallData *wall; @@ -580,7 +599,7 @@ void map_clear_data(void) } } -void edo_final_maps(void) +void edo_final_maps_pre(void) { map_clear_data(); } diff --git a/src/emap/map.h b/src/emap/map.h index 6906af3..fb6d740 100644 --- a/src/emap/map.h +++ b/src/emap/map.h @@ -7,32 +7,35 @@ int emap_addflooritem_post(int retVal, const struct block_list *bl, struct item *item, - int *amount, - int16 *m, - int16 *x, - int16 *y, - int *first_charid, - int *second_charid, - int *third_charid, - int *flags); + int amount, + int16 m, + int16 x, + int16 y, + int first_charid, + int second_charid, + int third_charid, + int flags); void emap_online_list(int fd); -int emap_getcellp(struct map_data* m, - const struct block_list *bl, - int16 *xPtr, int16 *yPtr, - cell_chk *cellchkPtr); -struct mapcell emap_gat2cell(int *gatPtr); -int emap_cell2gat(struct mapcell *cellPtr); -void emap_setgatcell(int16 *mPtr, - int16 *xPtr, int16 *yPtr, - int *gatPtr); -bool emap_iwall_set(int16 *m, - int16 *x, int16 *y, - int *size, - int8 *dir, - bool *shootable, - const char* wall_name); -void emap_iwall_get(struct map_session_data *sd); -void emap_iwall_remove(const char *name); +int emap_getcellp_pre(struct map_data **mPtr, + const struct block_list **blPtr, + int16 *xPtr, + int16 *yPtr, + cell_chk *cellchkPtr); +struct mapcell emap_gat2cell_pre(int *gatPtr); +int emap_cell2gat_pre(struct mapcell *cellPtr); +void emap_setgatcell_pre(int16 *mPtr, + int16 *xPtr, + int16 *yPtr, + int *gatPtr); +bool emap_iwall_set_pre(int16 *m, + int16 *x, + int16 *y, + int *size, + int8 *dir, + bool *shootable, + const char **wall_namePtr); +void emap_iwall_get_pre(struct map_session_data **sdPtr); +void emap_iwall_remove_pre(const char **namePtr); bool emap_iwall_set2(int m, int layer, int x1, int y1, @@ -43,7 +46,7 @@ void map_alwaysVisible_add(const struct block_list *bl); void map_alwaysVisible_delete(const struct block_list *bl); bool map_alwaysVisible_find(const struct block_list *bl); void map_alwaysVisible_send(TBL_PC *sd); -void edo_final_maps(void); +void edo_final_maps_pre(void); void map_clear_data(void); #endif // EVOL_MAP_MAP diff --git a/src/emap/mob.c b/src/emap/mob.c index 217f60a..0bddb02 100644 --- a/src/emap/mob.c +++ b/src/emap/mob.c @@ -25,8 +25,10 @@ #include "emap/data/mobd.h" #include "emap/struct/mobdext.h" -int emob_deleteslave_sub(struct block_list *bl, va_list ap) +int emob_deleteslave_sub_pre(struct block_list **blPtr, + va_list ap) { + struct block_list *bl = *blPtr; if (!bl) { hookStop(); @@ -57,27 +59,27 @@ int emob_deleteslave_sub(struct block_list *bl, va_list ap) return 0; } -void emob_read_db_additional_fields(struct mob_db *entry, - struct config_setting_t *it, - int *nPtr __attribute__ ((unused)), - const char *source __attribute__ ((unused))) +void emob_read_db_additional_fields_pre(struct mob_db **entryPtr, + struct config_setting_t **itPtr, + int *nPtr __attribute__ ((unused)), + const char **sourcePtr __attribute__ ((unused))) { int i32 = 0; - struct MobdExt *data = mobd_get(entry); + struct MobdExt *data = mobd_get(*entryPtr); if (!data) { hookStop(); return; } - if (mob->lookup_const(it, "WalkMask", &i32)) + if (mob->lookup_const(*itPtr, "WalkMask", &i32)) data->walkMask = i32; } -int emob_read_db_mode_sub_post(int retVal, - struct mob_db *entry __attribute__ ((unused)), - struct config_setting_t *t) +uint32 emob_read_db_mode_sub_post(uint32 retVal, + struct mob_db *entry __attribute__ ((unused)), + struct config_setting_t *t) { struct config_setting_t *t2; diff --git a/src/emap/mob.h b/src/emap/mob.h index 8ac76b0..2074730 100644 --- a/src/emap/mob.h +++ b/src/emap/mob.h @@ -6,12 +6,14 @@ #define MD_SURVIVE_WITHOUT_MASTER 0x0040000 -int emob_deleteslave_sub(struct block_list *bl, va_list ap); -void emob_read_db_additional_fields(struct mob_db *entry, - struct config_setting_t *it, - int *nPtr, const char *source); -int emob_read_db_mode_sub_post(int retVal, - struct mob_db *entry, - struct config_setting_t *t); +int emob_deleteslave_sub_pre(struct block_list **blPtr, + va_list ap); +void emob_read_db_additional_fields_pre(struct mob_db **entryPtr, + struct config_setting_t **itPtr, + int *nPtr, + const char **sourcePtr); +uint32 emob_read_db_mode_sub_post(uint32 retVal, + struct mob_db *entry, + struct config_setting_t *t); #endif // EVOL_MAP_MOB diff --git a/src/emap/npc.c b/src/emap/npc.c index b7d7b37..3a6f395 100644 --- a/src/emap/npc.c +++ b/src/emap/npc.c @@ -24,14 +24,19 @@ #include "emap/struct/npcdext.h" #include "emap/npc.h" -void enpc_parse_unknown_mapflag(const char *name, - const char *w3, - const char *w4, - const char* start, - const char* buffer, - const char* filepath, - int *retval) +void enpc_parse_unknown_mapflag_pre(const char **namePtr, + const char **w3Ptr, + const char **w4Ptr, + const char **startPtr, + const char **bufferPtr, + const char **filepathPtr, + int **retvalPtr) { + const char *name = *namePtr; + const char *w3 = *w3Ptr; + const char *w4 = *w4Ptr; + int *retval = *retvalPtr; + if (!strcmpi(w3, "invisible")) { int16 m = map->mapname2mapid(name); @@ -55,16 +60,22 @@ void enpc_parse_unknown_mapflag(const char *name, } else { - ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer)); + ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.\n", + w3, + *filepathPtr, + strline(*bufferPtr, *startPtr - *bufferPtr)); if (retval) *retval = EXIT_FAILURE; } hookStop(); } -int enpc_buysellsel(TBL_PC* sd, int *id, int *type) +int enpc_buysellsel_pre(TBL_PC **sdPtr, + int *id, + int *type) { TBL_NPC *nd; + TBL_PC *sd = *sdPtr; if (!sd) return 1; @@ -121,7 +132,7 @@ int enpc_buysellsel(TBL_PC* sd, int *id, int *type) return 0; } -bool enpc_db_checkid(int *idPtr) +bool enpc_db_checkid_pre(const int *idPtr) { const int id = *idPtr; hookStop(); diff --git a/src/emap/npc.h b/src/emap/npc.h index 2be72e0..1d6c254 100644 --- a/src/emap/npc.h +++ b/src/emap/npc.h @@ -4,11 +4,18 @@ #ifndef EVOL_MAP_NPC #define EVOL_MAP_NPC -void enpc_parse_unknown_mapflag(const char *name, const char *w3, const char *w4, const char* start, - const char* buffer, const char* filepath, int *retval); +void enpc_parse_unknown_mapflag_pre(const char **namePtr, + const char **w3Ptr, + const char **w4Ptr, + const char **startPtr, + const char **bufferPtr, + const char **filepathPtr, + int **retval); -int enpc_buysellsel(TBL_PC* sd, int *id, int *type); +int enpc_buysellsel_pre(TBL_PC **sdPtr, + int *id, + int *type); -bool enpc_db_checkid(int *idPtr); +bool enpc_db_checkid_pre(const int *idPtr); #endif // EVOL_MAP_NPC diff --git a/src/emap/pc.c b/src/emap/pc.c index 0697430..8164ad1 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -33,11 +33,12 @@ int langScriptId; int mountScriptId; -int epc_readparam_pre(TBL_PC* sd, int *type) +int epc_readparam_pre(TBL_PC **sdPtr, + int *type) { if (*type == Const_ClientVersion) { - struct SessionExt *data = session_get_bysd(sd); + struct SessionExt *data = session_get_bysd(*sdPtr); hookStop(); if (!data) return 0; @@ -46,8 +47,12 @@ int epc_readparam_pre(TBL_PC* sd, int *type) return 0; } -int epc_setregistry(TBL_PC *sd, int64 *reg, int *val) +int epc_setregistry_pre(TBL_PC **sdPtr, + int64 *reg, + int *val) { + TBL_PC *sd = *sdPtr; + if (*reg == langScriptId) { struct SessionExt *data = session_get_bysd(sd); @@ -89,10 +94,15 @@ int epc_setregistry(TBL_PC *sd, int64 *reg, int *val) eclif_changelook2(&sd->bl, lookf, 0, id, n); \ } -void epc_equipitem_pos(TBL_PC *sd, struct item_data *id, int *nPtr, int *posPtr) +void epc_equipitem_pos_pre(TBL_PC **sdPtr, + struct item_data **idPtr, + int *nPtr, + int *posPtr) { const int n = *nPtr; int pos = *posPtr; + TBL_PC *sd = *sdPtr; + struct item_data *id = *idPtr; hookStop(); @@ -165,10 +175,11 @@ void epc_equipitem_pos(TBL_PC *sd, struct item_data *id, int *nPtr, int *posPtr) if (pos & (mask)) \ eclif_changelook2(&sd->bl, lookf, 0, 0, n); -void epc_unequipitem_pos(TBL_PC *sd, - int *nPtr, - int *posPtr) +void epc_unequipitem_pos_pre(TBL_PC **sdPtr, + int *nPtr, + int *posPtr) { + TBL_PC *sd = *sdPtr; if (!sd) return; @@ -211,8 +222,10 @@ void epc_unequipitem_pos(TBL_PC *sd, #undef unequipPos #undef unequipPos2 -bool epc_can_attack (TBL_PC *sd, int *target_id) +bool epc_can_attack_pre(TBL_PC **sdPtr, + int *target_id) { + TBL_PC *sd = *sdPtr; if (!sd) return false; @@ -230,25 +243,8 @@ bool epc_can_attack (TBL_PC *sd, int *target_id) return true; } -int epc_takeitem(TBL_PC *sd __attribute__ ((unused)), - TBL_ITEM *fitem) -{ - if (!fitem) - return 0; - - struct ItemdExt *data = itemd_get_by_item(&fitem->item_data); - if (!data) - return 1; - - if (!data->allowPickup) - { - hookStop(); - return 0; - } - return 1; -} -void epc_validate_levels(void) +void epc_validate_levels_pre(void) { int i; for (i = 0; i < 7; i++) { @@ -264,9 +260,10 @@ void epc_validate_levels(void) hookStop(); } -int epc_isequip_post(int retVal, struct map_session_data *sd, int *nPtr) +int epc_isequip_post(int retVal, + struct map_session_data *sd, + int n) { - const int n = *nPtr; if (retVal) { if (!sd) @@ -301,9 +298,10 @@ int epc_isequip_post(int retVal, struct map_session_data *sd, int *nPtr) return retVal; } -int epc_useitem_post(int retVal, struct map_session_data *sd, int *nPtr) +int epc_useitem_post(int retVal, + struct map_session_data *sd, + int n) { - const int n = *nPtr; if (!sd) return retVal; @@ -320,7 +318,10 @@ int epc_useitem_post(int retVal, struct map_session_data *sd, int *nPtr) return retVal; } -static void equippost_effect(struct map_session_data *const sd, const int n, const bool retVal, const bool equip) +static void equippost_effect(struct map_session_data *const sd, + const int n, + const bool retVal, + const bool equip) { if (!sd) return; @@ -343,23 +344,28 @@ static void equippost_effect(struct map_session_data *const sd, const int n, con return; } -int epc_equipitem_post(int retVal, struct map_session_data *sd, - int *nPtr, int *data __attribute__ ((unused))) +int epc_equipitem_post(int retVal, + struct map_session_data *sd, + int n, + int data __attribute__ ((unused))) { - equippost_effect(sd, *nPtr, retVal, true); + equippost_effect(sd, n, retVal, true); return retVal; } -int epc_unequipitem_post(int retVal, struct map_session_data *sd, - int *nPtr, int *data __attribute__ ((unused))) +int epc_unequipitem_post(int retVal, + struct map_session_data *sd, + int n, + int data __attribute__ ((unused))) { - equippost_effect(sd, *nPtr, retVal, false); + equippost_effect(sd, n, retVal, false); return retVal; } -int epc_check_job_name(const char *name) +int epc_check_job_name_pre(const char **namePtr) { int val = -1; + const char *name = *namePtr; if (script->get_constant(name, &val)) { hookStop(); @@ -369,13 +375,14 @@ int epc_check_job_name(const char *name) return -1; } -int epc_setnewpc_post(int retVal, struct map_session_data *sd, - int *account_id __attribute__ ((unused)), - int *char_id __attribute__ ((unused)), - int *login_id1 __attribute__ ((unused)), - unsigned int *client_tick __attribute__ ((unused)), - int *sex __attribute__ ((unused)), - int *fd __attribute__ ((unused))) +int epc_setnewpc_post(int retVal, + struct map_session_data *sd, + int account_id __attribute__ ((unused)), + int char_id __attribute__ ((unused)), + int login_id1 __attribute__ ((unused)), + unsigned int client_tick __attribute__ ((unused)), + int sex __attribute__ ((unused)), + int fd __attribute__ ((unused))) { if (sd) { @@ -385,10 +392,11 @@ int epc_setnewpc_post(int retVal, struct map_session_data *sd, return retVal; } -int epc_additem_post(int retVal, struct map_session_data *sd, +int epc_additem_post(int retVal, + struct map_session_data *sd, struct item *item_data, - int *amountPtr __attribute__ ((unused)), - e_log_pick_type *log_type __attribute__ ((unused))) + int amount __attribute__ ((unused)), + e_log_pick_type log_type __attribute__ ((unused))) { if (!retVal) { @@ -401,12 +409,14 @@ int epc_additem_post(int retVal, struct map_session_data *sd, static bool calcPc = false; -int epc_delitem_pre(struct map_session_data *sd, - int *nPtr, int *amountPtr, +int epc_delitem_pre(struct map_session_data **sdPtr, + int *nPtr, + int *amountPtr, int *typePtr __attribute__ ((unused)), short *reasonPtr __attribute__ ((unused)), e_log_pick_type *log_type __attribute__ ((unused))) { + struct map_session_data *sd = *sdPtr; if (!sd) return 1; const int n = *nPtr; @@ -429,11 +439,11 @@ int epc_delitem_pre(struct map_session_data *sd, int epc_delitem_post(int retVal, struct map_session_data *sd, - int *nPtr __attribute__ ((unused)), - int *amountPtr __attribute__ ((unused)), - int *typePtr __attribute__ ((unused)), - short *reasonPtr __attribute__ ((unused)), - e_log_pick_type *log_type __attribute__ ((unused))) + int n __attribute__ ((unused)), + int amount __attribute__ ((unused)), + int type __attribute__ ((unused)), + short reason __attribute__ ((unused)), + e_log_pick_type log_type __attribute__ ((unused))) { if (!retVal && calcPc && sd) status_calc_pc(sd, SCO_NONE); @@ -441,19 +451,21 @@ int epc_delitem_post(int retVal, return retVal; } -bool epc_can_insert_card_into_post(bool retVal, struct map_session_data* sd, - int *idx_card, int *idx_equip) +bool epc_can_insert_card_into_post(bool retVal, + struct map_session_data* sd, + int idx_card, + int idx_equip) { int f; if (retVal) { if (!sd) return retVal; - struct ItemdExt *data = itemd_get(sd->inventory_data[*idx_equip]); + struct ItemdExt *data = itemd_get(sd->inventory_data[idx_equip]); if (!data || !data->allowedCards[0].id) // allow cards if AllowedCards list is empty return retVal; - const int newCardId = sd->status.inventory[*idx_card].nameid; + const int newCardId = sd->status.inventory[idx_card].nameid; int cardAmountLimit = 0; for (f = 0; f < 100 && data->allowedCards[f].id; f ++) @@ -468,10 +480,10 @@ bool epc_can_insert_card_into_post(bool retVal, struct map_session_data* sd, return false; int cardsAmount = 0; - const int slots = sd->inventory_data[*idx_equip]->slot; + const int slots = sd->inventory_data[idx_equip]->slot; for (f = 0; f < slots; f ++) { - const int cardId = sd->status.inventory[*idx_equip].card[f]; + const int cardId = sd->status.inventory[idx_equip].card[f]; if (cardId == newCardId) cardsAmount ++; } @@ -485,10 +497,11 @@ static int tempN = 0; static int tempId = 0; static int tempAmount = 0; -int epc_dropitem_pre(struct map_session_data *sd, +int epc_dropitem_pre(struct map_session_data **sdPtr, int *nPtr, int *amountPtr __attribute__ ((unused))) { + struct map_session_data *sd = *sdPtr; const int n = *nPtr; if (!sd || n < 0 || n >= MAX_INVENTORY) { @@ -502,9 +515,12 @@ int epc_dropitem_pre(struct map_session_data *sd, return 1; } -int epc_dropitem_post(int retVal, struct map_session_data *sd, int *nPtr, int *amountPtr) +int epc_dropitem_post(int retVal, + struct map_session_data *sd, + int n, + int amount) { - if (retVal && *nPtr == tempN && tempId) + if (retVal && n == tempN && tempId) { struct item_data *item = itemdb->search(tempId); if (!item) @@ -512,20 +528,37 @@ int epc_dropitem_post(int retVal, struct map_session_data *sd, int *nPtr, int *a struct ItemdExt *data = itemd_get(item); if (!data) return retVal; - script_run_item_amount_script(sd, data->dropScript, tempId, *amountPtr); + script_run_item_amount_script(sd, data->dropScript, tempId, amount); } return retVal; } -int epc_takeitem_pre(struct map_session_data *sd __attribute__ ((unused)), - struct flooritem_data *fitem) +int epc_takeitem_pre(struct map_session_data **sdPtr __attribute__ ((unused)), + struct flooritem_data **fitemPtr) { + struct flooritem_data *fitem = *fitemPtr; if (!fitem) { tempN = 0; tempId = 0; return 0; } + + struct ItemdExt *data = itemd_get_by_item(&fitem->item_data); + if (!data) + { + tempN = -1; + tempId = fitem->item_data.nameid; + tempAmount = fitem->item_data.amount; + return 1; + } + + if (!data->allowPickup) + { + hookStop(); + return 0; + } + tempN = -1; tempId = fitem->item_data.nameid; tempAmount = fitem->item_data.amount; @@ -549,8 +582,11 @@ int epc_takeitem_post(int retVal, return retVal; } -int epc_insert_card_pre(struct map_session_data* sd, int *idx_card, int *idx_equip) +int epc_insert_card_pre(struct map_session_data **sdPtr, + int *idx_card, + int *idx_equip) { + struct map_session_data *sd = *sdPtr; if (!sd || *idx_equip < 0 || *idx_equip >= MAX_INVENTORY || @@ -570,10 +606,10 @@ int epc_insert_card_pre(struct map_session_data* sd, int *idx_card, int *idx_equ int epc_insert_card_post(int retVal, struct map_session_data* sd, - int *idx_card __attribute__ ((unused)), - int *idx_equip) + int idx_card __attribute__ ((unused)), + int idx_equip) { - if (retVal && *idx_equip == tempN && tempId) + if (retVal && idx_equip == tempN && tempId) { struct item_data *item = itemdb->search(tempId); if (!item) @@ -586,10 +622,14 @@ int epc_insert_card_post(int retVal, return retVal; } -bool epc_can_Adopt_pre(struct map_session_data *p1_sd, - struct map_session_data *p2_sd, - struct map_session_data *b_sd) +bool epc_can_Adopt_pre(struct map_session_data **p1_sdPtr, + struct map_session_data **p2_sdPtr, + struct map_session_data **b_sdPtr) { + struct map_session_data *p1_sd = *p1_sdPtr; + struct map_session_data *p2_sd = *p2_sdPtr; + struct map_session_data *b_sd = *b_sdPtr; + hookStop(); if (!p1_sd || !p2_sd || !b_sd) @@ -644,10 +684,14 @@ bool epc_can_Adopt_pre(struct map_session_data *p1_sd, return true; } -bool epc_adoption_pre(struct map_session_data *p1_sd, - struct map_session_data *p2_sd, - struct map_session_data *b_sd) +bool epc_adoption_pre(struct map_session_data **p1_sdPtr, + struct map_session_data **p2_sdPtr, + struct map_session_data **b_sdPtr) { + struct map_session_data *p1_sd = *p1_sdPtr; + struct map_session_data *p2_sd = *p2_sdPtr; + struct map_session_data *b_sd = *b_sdPtr; + if (!pc->can_Adopt(p1_sd, p2_sd, b_sd)) { hookStop(); @@ -673,8 +717,11 @@ bool epc_adoption_pre(struct map_session_data *p1_sd, // copy from pc_process_chat_message // exception only prevent call gm command if string start with ## -bool epc_process_chat_message_pre(struct map_session_data *sd, const char *message) +bool epc_process_chat_message_pre(struct map_session_data **sdPtr, + const char **messagePtr) { + struct map_session_data *sd = *sdPtr; + const char *message = *messagePtr; if (message && strlen(message) > 2 && message[0] == '#' && message[1] == '#') { // do nothing diff --git a/src/emap/pc.h b/src/emap/pc.h index a56eb4d..88a544d 100644 --- a/src/emap/pc.h +++ b/src/emap/pc.h @@ -9,73 +9,117 @@ enum VarConst Const_ClientVersion = 10000 }; -int epc_readparam_pre(TBL_PC* sd, int *type); - -int epc_setregistry(TBL_PC *sd, int64 *reg, int *val); - -void epc_equipitem_pos(TBL_PC *sd, struct item_data *id, int *nPtr, int *posPtr); - -void epc_unequipitem_pos(TBL_PC *sd, int *nPtr, int *posPtr); - -bool epc_can_attack (TBL_PC *sd, int *target_id); - -int epc_takeitem(TBL_PC *sd, TBL_ITEM *fitem); - -void epc_validate_levels(void); - -int epc_isequip_post(int retVal, struct map_session_data *sd, int *nPtr); - -int epc_useitem_post(int retVal, struct map_session_data *sd, int *nPtr); - -int epc_equipitem_post(int retVal, struct map_session_data *sd, - int *nPtr, int *data); - -int epc_unequipitem_post(int retVal, struct map_session_data *sd, - int *nPtr, int *data); - -int epc_check_job_name(const char *name); - -int epc_setnewpc_post(int retVal, struct map_session_data *sd, - int *account_id, int *char_id, int *login_id1, - unsigned int *client_tick, int *sex, int *fd); - -int epc_additem_post(int retVal, struct map_session_data *sd, - struct item *item_data, int *amountPtr, - e_log_pick_type *log_type); - -int epc_delitem_pre(struct map_session_data *sd, int *nPtr, int *amountPtr, - int *typePtr, short *reasonPtr, +int epc_readparam_pre(TBL_PC **sdPtr, + int *type); + +int epc_setregistry_pre(TBL_PC **sdPtr, + int64 *reg, + int *val); + +void epc_equipitem_pos_pre(TBL_PC **sdPtr, + struct item_data **idPtr, + int *nPtr, + int *posPtr); + +void epc_unequipitem_pos_pre(TBL_PC **sdPtr, + int *nPtr, + int *posPtr); + +bool epc_can_attack_pre(TBL_PC **sdPtr, + int *target_id); + +void epc_validate_levels_pre(void); + +int epc_isequip_post(int retVal, + struct map_session_data *sd, + int n); + +int epc_useitem_post(int retVal, + struct map_session_data *sd, + int n); + +int epc_equipitem_post(int retVal, + struct map_session_data *sd, + int n, + int data); + +int epc_unequipitem_post(int retVal, + struct map_session_data *sd, + int n, + int data); + +int epc_check_job_name_pre(const char **namePtr); + +int epc_setnewpc_post(int retVal, + struct map_session_data *sd, + int account_id, + int char_id, + int login_id1, + unsigned int client_tick, + int sex, + int fd); + +int epc_additem_post(int retVal, + struct map_session_data *sd, + struct item *item_data, + int amount, + e_log_pick_type log_type); + +int epc_delitem_pre(struct map_session_data **sdPtr, + int *nPtr, + int *amountPtr, + int *typePtr, + short *reasonPtr, e_log_pick_type *log_type); -int epc_delitem_post(int retVal, struct map_session_data *sd, int *nPtr, int *amountPtr, - int *typePtr, short *reasonPtr, - e_log_pick_type *log_type); - -bool epc_can_insert_card_into_post(bool retVal, struct map_session_data* sd, - int *idx_card, int *idx_equip); - -int epc_dropitem_pre(struct map_session_data *sd, int *nPtr, int *amountPtr); - -int epc_dropitem_post(int retVal, struct map_session_data *sd, int *nPtr, int *amountPtr); - -int epc_takeitem_pre(struct map_session_data *sd, struct flooritem_data *fitem); - -int epc_takeitem_post(int retVal, struct map_session_data *sd, struct flooritem_data *fitem); - -int epc_insert_card_pre(struct map_session_data* sd, int *idx_card, int *idx_equip); - -int epc_insert_card_post(int retVal, struct map_session_data* sd, int *idx_card, int *idx_equip); - -bool epc_can_Adopt_pre(struct map_session_data *p1_sd, - struct map_session_data *p2_sd, - struct map_session_data *b_sd); - -bool epc_adoption_pre(struct map_session_data *p1_sd, - struct map_session_data *p2_sd, - struct map_session_data *b_sd); - -bool epc_process_chat_message_pre(struct map_session_data *sd, - const char *message); +int epc_delitem_post(int retVal, + struct map_session_data *sd, + int n, + int amount, + int type, + short reason, + e_log_pick_type log_type); + +bool epc_can_insert_card_into_post(bool retVal, + struct map_session_data* sd, + int idx_card, + int idx_equip); + +int epc_dropitem_pre(struct map_session_data **sdPtr, + int *nPtr, + int *amountPtr); + +int epc_dropitem_post(int retVal, + struct map_session_data *sd, + int n, + int amount); + +int epc_takeitem_pre(struct map_session_data **sdPtr, + struct flooritem_data **fitemPtr); + +int epc_takeitem_post(int retVal, + struct map_session_data *sd, + struct flooritem_data *fitem); + +int epc_insert_card_pre(struct map_session_data **sdPtr, + int *idx_card, + int *idx_equip); + +int epc_insert_card_post(int retVal, + struct map_session_data* sd, + int idx_card, + int idx_equip); + +bool epc_can_Adopt_pre(struct map_session_data **p1_sdPtr, + struct map_session_data **p2_sdPtr, + struct map_session_data **b_sdPtr); + +bool epc_adoption_pre(struct map_session_data **p1_sdPtr, + struct map_session_data **p2_sdPtr, + struct map_session_data **b_sdPtr); + +bool epc_process_chat_message_pre(struct map_session_data **sdPtr, + const char **messagePtr); int epc_dead_post(int retVal, struct map_session_data *sd, diff --git a/src/emap/quest.c b/src/emap/quest.c index 1368a4e..ff9d5de 100644 --- a/src/emap/quest.c +++ b/src/emap/quest.c @@ -30,13 +30,17 @@ * @return The parsed quest entry. * @retval NULL in case of errors. */ -struct quest_db *equest_read_db_sub(struct config_setting_t *cs, int *nPtr, const char *source) +struct quest_db *equest_read_db_sub_pre(struct config_setting_t **csPtr, + int *nPtr, + const char **sourcePtr) { struct quest_db *entry = NULL; struct config_setting_t *t = NULL; int i32 = 0, quest_id; const char *str = NULL; const int n = *nPtr; + struct config_setting_t *cs = *csPtr; + const char *source = *sourcePtr; /* * Id: Quest ID [int] diff --git a/src/emap/quest.h b/src/emap/quest.h index 3c303ab..b6f78f0 100644 --- a/src/emap/quest.h +++ b/src/emap/quest.h @@ -4,6 +4,8 @@ #ifndef EVOL_MAP_QUEST #define EVOL_MAP_QUEST -struct quest_db *equest_read_db_sub(struct config_setting_t *cs, int *nPtr, const char *source); +struct quest_db *equest_read_db_sub_pre(struct config_setting_t **csPtr, + int *nPtr, + const char **sourcePtr); #endif // EVOL_MAP_QUEST diff --git a/src/emap/script.c b/src/emap/script.c index 37e71f0..f34206a 100644 --- a/src/emap/script.c +++ b/src/emap/script.c @@ -66,13 +66,13 @@ if (!nd) \ return r; -int escript_reload(void) +int escript_reload_pre(void) { map_clear_data(); return 0; } -void escript_load_parameters(void) +void escript_load_parameters_pre(void) { script->constdb_comment("Evol parameters"); script->set_constant("ClientVersion", 10000, true, false); @@ -80,7 +80,7 @@ void escript_load_parameters(void) } // stripped copy from script_load_translations without actual translation loading. -void escript_load_translations(void) +void escript_load_translations_pre(void) { if (map->minimal) { @@ -113,12 +113,16 @@ void escript_load_translations(void) hookStop(); } -void eset_reg_npcscope_num(struct script_state* st, - struct reg_db *n, - int64 *num __attribute__ ((unused)), - const char* name, - int *val) +void eset_reg_npcscope_num_pre(struct script_state **stPtr, + struct reg_db **nPtr, + int64 *num __attribute__ ((unused)), + const char **namePtr, + int *val) { + struct script_state *st = *stPtr; + struct reg_db *n = *nPtr; + const char *name = *namePtr; + if (!strcmp(name, ".lang")) { getExt2(); @@ -218,8 +222,13 @@ void eset_reg_npcscope_num(struct script_state* st, } } -int eget_val_npcscope_num(struct script_state* st, struct reg_db *n, struct script_data* data) +int eget_val_npcscope_num_pre(struct script_state **stPtr, + struct reg_db **nPtr, + struct script_data **dataPtr) { + struct script_state *st = *stPtr; + struct reg_db *n = *nPtr; + struct script_data *data = *dataPtr; const char *name = reference_getname(data); if (!strcmp(name, ".lang")) { @@ -303,12 +312,17 @@ int eget_val_npcscope_num(struct script_state* st, struct reg_db *n, struct scri return 0; } -void eset_reg_npcscope_str(struct script_state* st, - struct reg_db *n, - int64 *num __attribute__ ((unused)), - const char* name, - const char *str) +void eset_reg_npcscope_str_pre(struct script_state **stPtr, + struct reg_db **nPtr, + int64 *num __attribute__ ((unused)), + const char **namePtr, + const char **strPtr) { + struct script_state *st = *stPtr; + struct reg_db *n = *nPtr; + const char *name = *namePtr; + const char *str = *strPtr; + if (!strcmp(name, ".map$")) { ShowWarning("you cant assign '.map$'.\n"); @@ -333,8 +347,13 @@ void eset_reg_npcscope_str(struct script_state* st, } } -char *eget_val_npcscope_str(struct script_state* st, struct reg_db *n, struct script_data* data) +char *eget_val_npcscope_str_pre(struct script_state **stPtr, + struct reg_db **nPtr, + struct script_data **dataPtr) { + struct script_state *st = *stPtr; + struct reg_db *n = *nPtr; + struct script_data *data = *dataPtr; const char *name = reference_getname(data); if (!strcmp(name, ".map$")) { @@ -357,7 +376,10 @@ char *eget_val_npcscope_str(struct script_state* st, struct reg_db *n, struct sc return NULL; } -void script_run_item_amount_script(TBL_PC *sd, struct script_code *itemScript, int itemId, int amount) +void script_run_item_amount_script(TBL_PC *sd, + struct script_code *itemScript, + int itemId, + int amount) { if (!itemScript) return; @@ -371,7 +393,10 @@ void script_run_item_amount_script(TBL_PC *sd, struct script_code *itemScript, i script->current_item_id = 0; } -void script_run_card_script(TBL_PC *sd, struct script_code *itemScript, int itemId, int cardId) +void script_run_card_script(TBL_PC *sd, + struct script_code *itemScript, + int itemId, + int cardId) { if (!itemScript) return; diff --git a/src/emap/script.h b/src/emap/script.h index 852c997..3985dcf 100644 --- a/src/emap/script.h +++ b/src/emap/script.h @@ -4,14 +4,32 @@ #ifndef EVOL_MAP_SCRIPT #define EVOL_MAP_SCRIPT -int escript_reload(void); -void escript_load_translations(void); -void escript_load_parameters(void); -void eset_reg_npcscope_num(struct script_state* st, struct reg_db *n, int64 *num, const char* name, int *val); -int eget_val_npcscope_num(struct script_state* st, struct reg_db *n, struct script_data* data); -void eset_reg_npcscope_str(struct script_state* st, struct reg_db *n, int64 *num, const char* name, const char *str); -char *eget_val_npcscope_str(struct script_state* st, struct reg_db *n, struct script_data* data); -void script_run_item_amount_script(TBL_PC *sd, struct script_code *itemScript, int itemId, int amount); -void script_run_card_script(TBL_PC *sd, struct script_code *itemScript, int itemId, int cardId); +int escript_reload_pre(void); +void escript_load_translations_pre(void); +void escript_load_parameters_pre(void); +void eset_reg_npcscope_num_pre(struct script_state **stPtr, + struct reg_db **nPtr, + int64 *numPtr, + const char **namePtr, + int *val); +int eget_val_npcscope_num_pre(struct script_state **stPtr, + struct reg_db **nPtr, + struct script_data **dataPtr); +void eset_reg_npcscope_str_pre(struct script_state **stPtr, + struct reg_db **nPtr, + int64 *num, + const char **namePtr, + const char **strPtr); +char *eget_val_npcscope_str_pre(struct script_state **stPtr, + struct reg_db **nPtr, + struct script_data **dataPtr); +void script_run_item_amount_script(TBL_PC *sd, + struct script_code *itemScript, + int itemId, + int amount); +void script_run_card_script(TBL_PC *sd, + struct script_code *itemScript, + int itemId, + int cardId); #endif // EVOL_MAP_SCRIPT diff --git a/src/emap/skill.c b/src/emap/skill.c index 87cefdf..435c3a7 100644 --- a/src/emap/skill.c +++ b/src/emap/skill.c @@ -20,8 +20,8 @@ int eskill_check_condition_castend_post(int retVal, TBL_PC* sd, - uint16 *skill_id, - uint16 *skill_lv) + uint16 skill_id, + uint16 skill_lv) { if (retVal && sd) { @@ -35,8 +35,8 @@ int eskill_check_condition_castend_post(int retVal, struct event_data* ev = node->data; if (ev) { - pc->setreg(sd, script->add_str("@skillId"), *skill_id); - pc->setreg(sd, script->add_str("@skillLv"), *skill_lv); + pc->setreg(sd, script->add_str("@skillId"), skill_id); + pc->setreg(sd, script->add_str("@skillLv"), skill_lv); script->run(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id); } node = node->next; diff --git a/src/emap/skill.h b/src/emap/skill.h index 87a3566..7b4e15b 100644 --- a/src/emap/skill.h +++ b/src/emap/skill.h @@ -6,7 +6,7 @@ int eskill_check_condition_castend_post(int retVal, TBL_PC* sd, - uint16 *skill_id, - uint16 *skill_lv); + uint16 skill_id, + uint16 skill_lv); #endif // EVOL_MAP_SKILL diff --git a/src/emap/status.c b/src/emap/status.c index 7b58329..90c25d4 100644 --- a/src/emap/status.c +++ b/src/emap/status.c @@ -37,7 +37,7 @@ void status_init(void) } void estatus_set_viewdata_post(struct block_list *bl, - int *class_ __attribute__ ((unused))) + int class_ __attribute__ ((unused))) { if (!bl) return; @@ -63,19 +63,18 @@ void estatus_set_viewdata_post(struct block_list *bl, } } -void estatus_read_job_db_sub(int *idxPtr, - const char *name __attribute__ ((unused)), - struct config_setting_t *jdb) +void estatus_read_job_db_sub_post(int idx, + const char *name __attribute__ ((unused)), + struct config_setting_t *jdb) { int i32 = 0; - const int idx = *idxPtr; if (itemdb->lookup_const(jdb, "MoveSpeed", &i32)) class_move_speed[idx] = i32; } int estatus_calc_pc__post(int retVal, struct map_session_data *sd, - enum e_status_calc_opt *opt __attribute__ ((unused))) + enum e_status_calc_opt opt __attribute__ ((unused))) { if (!sd) return retVal; @@ -88,16 +87,18 @@ int estatus_calc_pc__post(int retVal, return retVal; } -int estatus_calc_pc_additional(struct map_session_data* sd, - enum e_status_calc_opt *opt __attribute__ ((unused))) +void estatus_calc_pc_additional_pre(struct map_session_data **sdPtr, + enum e_status_calc_opt *optPtr __attribute__ ((unused))) { int f; int k; - - hookStop(); + struct map_session_data *sd = *sdPtr; if (!sd) - return 0; + { + hookStop(); + return; + } for (f = 0; f < MAX_INVENTORY; f ++) { @@ -132,13 +133,13 @@ int estatus_calc_pc_additional(struct map_session_data* sd, horse_add_bonus(sd); - return 0; + hookStop(); } unsigned short estatus_calc_speed_post(unsigned short retVal, struct block_list *bl, struct status_change *sc __attribute__ ((unused)), - int *speed __attribute__ ((unused))) + int speed __attribute__ ((unused))) { return horse_add_speed_bonus(BL_CAST(BL_PC, bl), retVal); } diff --git a/src/emap/status.h b/src/emap/status.h index d81e12d..fce6c83 100644 --- a/src/emap/status.h +++ b/src/emap/status.h @@ -5,10 +5,19 @@ #define EVOL_MAP_STATUS void status_init(void); -void estatus_set_viewdata_post(struct block_list *bl, int *class_); -void estatus_read_job_db_sub(int *idxPtr, const char *name, struct config_setting_t *jdb); -int estatus_calc_pc__post(int retVal, struct map_session_data* sd, enum e_status_calc_opt *opt); -int estatus_calc_pc_additional(struct map_session_data* sd, enum e_status_calc_opt *opt); -unsigned short estatus_calc_speed_post(unsigned short retVal, struct block_list *bl, struct status_change *sc, int *speed); +void estatus_set_viewdata_post(struct block_list *bl, + int class_); +void estatus_read_job_db_sub_post(int idx, + const char *name, + struct config_setting_t *jdb); +int estatus_calc_pc__post(int retVal, + struct map_session_data *sd, + enum e_status_calc_opt opt); +void estatus_calc_pc_additional_pre(struct map_session_data **sdPtr, + enum e_status_calc_opt *optPtr); +unsigned short estatus_calc_speed_post(unsigned short retVal, + struct block_list *bl, + struct status_change *sc, + int speed); #endif // EVOL_MAP_STATUS diff --git a/src/emap/unit.c b/src/emap/unit.c index b53e691..c0db6b2 100644 --- a/src/emap/unit.c +++ b/src/emap/unit.c @@ -24,11 +24,12 @@ #include "emap/unit.h" -int eunit_can_move(struct block_list *bl) +int eunit_can_move_pre(struct block_list **blPtr) { TBL_PC *sd; struct unit_data *ud; struct status_change *sc; + struct block_list *bl = *blPtr; if (!bl) { @@ -149,11 +150,12 @@ int eunit_can_move(struct block_list *bl) return 1; } -int eunit_walktoxy(struct block_list *bl __attribute__ ((unused)), - short *x __attribute__ ((unused)), - short *y __attribute__ ((unused)), - int *flagPtr) +int eunit_walktoxy_pre(struct block_list **blPtr __attribute__ ((unused)), + short *x __attribute__ ((unused)), + short *y __attribute__ ((unused)), + int *flagPtr) { + struct block_list *bl = *blPtr; // reset flag "Search for an unoccupied cell and cancel if none available" // this reduce CPU usage and allow mobs to walk on each other. if ((*flagPtr)&8) diff --git a/src/emap/unit.h b/src/emap/unit.h index 771f6a3..dbb3cb6 100644 --- a/src/emap/unit.h +++ b/src/emap/unit.h @@ -4,7 +4,10 @@ #ifndef EVOL_MAP_UNIT #define EVOL_MAP_UNIT -int eunit_can_move(struct block_list *bl); -int eunit_walktoxy(struct block_list *bl, short *x, short *y, int *flagPtr); +int eunit_can_move_pre(struct block_list **blPtr); +int eunit_walktoxy_pre(struct block_list **blPtr, + short *x, + short *y, + int *flagPtr); #endif // EVOL_MAP_UNIT |