From 284a1631b40f442e058dabd9fd31301b9e50e71b Mon Sep 17 00:00:00 2001 From: "Hercules.ws" Date: Sun, 19 Jan 2014 05:59:58 +0100 Subject: HPM Hooks Update Signed-off-by: HerculesWSAPI --- src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc | 8 ++++---- src/plugins/HPMHooking/HPMHooking.HookingPoints.inc | 2 +- src/plugins/HPMHooking/HPMHooking.Hooks.inc | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc index 654d84b42..0f9748153 100644 --- a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc @@ -329,8 +329,8 @@ struct { struct HPMHookPoint *HP_chrif_removefriend_post; struct HPMHookPoint *HP_chrif_send_report_pre; struct HPMHookPoint *HP_chrif_send_report_post; - struct HPMHookPoint *HP_chrif_flush_fifo_pre; - struct HPMHookPoint *HP_chrif_flush_fifo_post; + struct HPMHookPoint *HP_chrif_flush_pre; + struct HPMHookPoint *HP_chrif_flush_post; struct HPMHookPoint *HP_chrif_skillid2idx_pre; struct HPMHookPoint *HP_chrif_skillid2idx_post; struct HPMHookPoint *HP_chrif_sd_to_auth_pre; @@ -5348,8 +5348,8 @@ struct { int HP_chrif_removefriend_post; int HP_chrif_send_report_pre; int HP_chrif_send_report_post; - int HP_chrif_flush_fifo_pre; - int HP_chrif_flush_fifo_post; + int HP_chrif_flush_pre; + int HP_chrif_flush_post; int HP_chrif_skillid2idx_pre; int HP_chrif_skillid2idx_post; int HP_chrif_sd_to_auth_pre; diff --git a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc index 144eff850..226497c3f 100644 --- a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc @@ -173,7 +173,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(chrif->divorce, HP_chrif_divorce) }, { HP_POP(chrif->removefriend, HP_chrif_removefriend) }, { HP_POP(chrif->send_report, HP_chrif_send_report) }, - { HP_POP(chrif->flush_fifo, HP_chrif_flush_fifo) }, + { HP_POP(chrif->flush, HP_chrif_flush) }, { HP_POP(chrif->skillid2idx, HP_chrif_skillid2idx) }, { HP_POP(chrif->sd_to_auth, HP_chrif_sd_to_auth) }, { HP_POP(chrif->check_connect_char_server, HP_chrif_check_connect_char_server) }, diff --git a/src/plugins/HPMHooking/HPMHooking.Hooks.inc b/src/plugins/HPMHooking/HPMHooking.Hooks.inc index 73936f460..7b69fd902 100644 --- a/src/plugins/HPMHooking/HPMHooking.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking.Hooks.inc @@ -4254,13 +4254,13 @@ void HP_chrif_send_report(char *buf, int len) { } return; } -bool HP_chrif_flush_fifo(void) { +bool HP_chrif_flush(void) { int hIndex = 0; bool retVal___ = false; - if( HPMHooks.count.HP_chrif_flush_fifo_pre ) { + if( HPMHooks.count.HP_chrif_flush_pre ) { bool (*preHookFunc) (void); - for(hIndex = 0; hIndex < HPMHooks.count.HP_chrif_flush_fifo_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_chrif_flush_fifo_pre[hIndex].func; + for(hIndex = 0; hIndex < HPMHooks.count.HP_chrif_flush_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_chrif_flush_pre[hIndex].func; retVal___ = preHookFunc(); } if( *HPMforce_return ) { @@ -4269,12 +4269,12 @@ bool HP_chrif_flush_fifo(void) { } } { - retVal___ = HPMHooks.source.chrif.flush_fifo(); + retVal___ = HPMHooks.source.chrif.flush(); } - if( HPMHooks.count.HP_chrif_flush_fifo_post ) { + if( HPMHooks.count.HP_chrif_flush_post ) { bool (*postHookFunc) (bool retVal___); - for(hIndex = 0; hIndex < HPMHooks.count.HP_chrif_flush_fifo_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_chrif_flush_fifo_post[hIndex].func; + for(hIndex = 0; hIndex < HPMHooks.count.HP_chrif_flush_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_chrif_flush_post[hIndex].func; retVal___ = postHookFunc(retVal___); } } -- cgit v1.2.3-70-g09d2 From 9701fe324412112c6288afbc956b299f2b9cc779 Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 21 Jan 2014 12:34:46 +0100 Subject: Fixed --disable-packetver-re / --enable-packetver-re in ./configure - Follow-up to c50e094dff1898badd4136d9cdeb7318c803cb61 Signed-off-by: Haru --- configure | 12 ++++++------ configure.in | 10 +++++----- src/common/mmo.h | 8 +++++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 7142ed479..a0cf9ecad 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in d0f16b7. +# From configure.in 284a163. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # @@ -1328,8 +1328,8 @@ Optional Features: --enable-manager=ARG memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin) --enable-packetver=ARG Sets the PACKETVER define. (see src/common/mmo.h) - --disable-packetver-re Sets or unsets the PACKETVER_RE define - see - src/common/mmo.h (currently enabled by default) + --enable-packetver-re Sets or unsets the PACKETVER_RE define - see + src/common/mmo.h (currently disabled by default) --enable-debug[=ARG] Compiles extra debug code. (disabled by default) (available options: yes, no, gdb) --enable-buildbot[=ARG] (available options: yes, no) @@ -3485,7 +3485,7 @@ if test "${enable_packetver_re+set}" = set; then : esac else - enable_packetver_re="yes" + enable_packetver_re="no" fi @@ -6232,10 +6232,10 @@ fi # case $enable_packetver_re in "yes") - # default value - CFLAGS="$CFLAGS -DDISABLE_PACKETVER_RE" + CFLAGS="$CFLAGS -DENABLE_PACKETVER_RE" ;; "no") + # default value ;; esac diff --git a/configure.in b/configure.in index 94bad9ca4..1fc2d0e29 100644 --- a/configure.in +++ b/configure.in @@ -59,8 +59,8 @@ AC_ARG_ENABLE( AC_ARG_ENABLE( [packetver-re], AC_HELP_STRING( - [--disable-packetver-re], - [Sets or unsets the PACKETVER_RE define - see src/common/mmo.h (currently enabled by default)] + [--enable-packetver-re], + [Sets or unsets the PACKETVER_RE define - see src/common/mmo.h (currently disabled by default)] ), [ enable_packetver_re="$enableval" @@ -70,7 +70,7 @@ AC_ARG_ENABLE( *) AC_MSG_ERROR([[invalid argument --enable-packetver-re=$enableval... stopping]]);; esac ], - [enable_packetver_re="yes"] + [enable_packetver_re="no"] ) @@ -929,10 +929,10 @@ fi # case $enable_packetver_re in "yes") - # default value - CFLAGS="$CFLAGS -DDISABLE_PACKETVER_RE" + CFLAGS="$CFLAGS -DENABLE_PACKETVER_RE" ;; "no") + # default value ;; esac diff --git a/src/common/mmo.h b/src/common/mmo.h index 670c2f7f7..573962601 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -51,9 +51,11 @@ #define PACKETVER 20131223 #endif // PACKETVER -#ifndef DISABLE_PACKETVER_RE - //Uncomment the following line if your client is ragexeRE instead of ragexe (required because of conflicting packets in ragexe vs ragexeRE). - //#define PACKETVER_RE +//Uncomment the following line if your client is ragexeRE instead of ragexe (required because of conflicting packets in ragexe vs ragexeRE). +//#define ENABLE_PACKETVER_RE +#ifdef ENABLE_PACKETVER_RE + #define PACKETVER_RE + #undef ENABLE_PACKETVER_RE #endif // DISABLE_PACKETVER_RE // Client support for experimental RagexeRE UI present in 2012-04-10 and 2012-04-18 -- cgit v1.2.3-70-g09d2 From ce15f827e4e3b945e0aae6881b2d02bffe0d6164 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 20 Jan 2014 15:16:51 +0100 Subject: Improvements to exp_guild.txt loading - Modified exp_guild.txt processing to honor the value of MAX_GUILDLEVEL and correctly handle overflows. Signed-off-by: Haru --- src/char/int_guild.c | 50 ++++++++++++++++++++++---------------------------- src/map/atcommand.c | 25 +++++++++++++------------ 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 427c57531..ec01dab5b 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -35,7 +35,7 @@ static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9 static DBMap* guild_db_; // int guild_id -> struct guild* static DBMap *castle_db; -static unsigned int guild_exp[100]; +static unsigned int guild_exp[MAX_GUILDLEVEL]; int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int flag,const char *mes); int mapif_guild_broken(int guild_id,int flag); @@ -598,16 +598,15 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id) // Read exp_guild.txt -static bool exp_guild_parse_row(char* split[], int column, int current) -{ - unsigned int exp = (unsigned int)atol(split[0]); +static bool exp_guild_parse_row(char* split[], int column, int current) { + int64 exp = strtoll(split[0], NULL, 10); - if (exp >= UINT_MAX) { - ShowError("exp_guild: Invalid exp %d at line %d\n", exp, current); + if (exp < 0 || exp >= UINT_MAX) { + ShowError("exp_guild: Invalid exp %"PRId64" (valid range: 0 - %u) at line %d\n", exp, UINT_MAX, current); return false; } - guild_exp[current] = exp; + guild_exp[current] = (unsigned int)exp; return true; } @@ -725,7 +724,7 @@ int inter_guild_sql_init(void) castle_db = idb_alloc(DB_OPT_RELEASE_DATA); //Read exp file - sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, 100, exp_guild_parse_row); + sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, MAX_GUILDLEVEL, exp_guild_parse_row); timer->add_func_list(guild_save_timer, "guild_save_timer"); timer->add(timer->gettick() + 10000, guild_save_timer, 0, 0); @@ -794,14 +793,13 @@ static bool guild_check_empty(struct guild *g) return true; } -unsigned int guild_nextexp(int level) -{ +unsigned int guild_nextexp(int level) { if (level == 0) return 1; - if (level < 100 && level > 0) // Change by hack - return guild_exp[level-1]; + if (level <= 0 || level >= MAX_GUILDLEVEL) + return 0; - return 0; + return guild_exp[level-1]; } int guild_checkskill(struct guild *g,int id) @@ -825,7 +823,7 @@ int guild_calcinfo(struct guild *g) nextexp = guild_nextexp(g->guild_lv); // Consume guild exp and increase guild level - while(g->exp >= nextexp && nextexp > 0){ //fixed guild exp overflow [Kevin] + while(g->exp >= nextexp && nextexp > 0) { // nextexp would be 0 if g->guild_lv was >= MAX_GUILDLEVEL g->exp-=nextexp; g->guild_lv++; g->skill_point++; @@ -1424,24 +1422,20 @@ int mapif_parse_GuildMessage(int fd,int guild_id,int account_id,char *mes,int le } // Modification of the guild -int mapif_parse_GuildBasicInfoChange(int fd,int guild_id,int type,const char *data,int len) -{ - struct guild * g; - short dw=*((short *)data); +int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void *data, int len) { + struct guild *g; + short value = *((const int16 *)data); g = inter_guild_fromsql(guild_id); if(g==NULL) return 0; - switch(type) - { + switch(type) { case GBI_GUILDLV: - if(dw>0 && g->guild_lv+dw<=50) - { - g->guild_lv+=dw; - g->skill_point+=dw; - } - else if(dw<0 && g->guild_lv+dw>=1) - g->guild_lv+=dw; + if (value > 0 && g->guild_lv + value <= MAX_GUILDLEVEL) { + g->guild_lv += value; + g->skill_point += value; + } else if (value < 0 && g->guild_lv + value >= 1) + g->guild_lv += value; mapif_guild_info(-1,g); g->save_flag |= GS_LEVEL; return 0; @@ -1837,7 +1831,7 @@ int inter_guild_parse_frommap(int fd) case 0x3035: mapif_parse_GuildChangeMemberInfoShort(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); break; case 0x3036: mapif_parse_BreakGuild(fd,RFIFOL(fd,2)); break; case 0x3037: mapif_parse_GuildMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),(char*)RFIFOP(fd,12),RFIFOW(fd,2)-12); break; - case 0x3039: mapif_parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),(const char*)RFIFOP(fd,10),RFIFOW(fd,2)-10); break; + case 0x3039: mapif_parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),(const int16 *)RFIFOP(fd,10),RFIFOW(fd,2)-10); break; case 0x303A: mapif_parse_GuildMemberInfoChange(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOL(fd,12),RFIFOW(fd,16),(const char*)RFIFOP(fd,18),RFIFOW(fd,2)-18); break; case 0x303B: mapif_parse_GuildPosition(fd,RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); break; case 0x303C: mapif_parse_GuildSkillUp(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14)); break; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0cb552bd0..31357c074 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2472,10 +2472,9 @@ ACMD(stat_all) { /*========================================== * *------------------------------------------*/ -ACMD(guildlevelup) -{ +ACMD(guildlevelup) { int level = 0; - short added_level; + int16 added_level; struct guild *guild_info; if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) { @@ -2487,16 +2486,18 @@ ACMD(guildlevelup) clif->message(fd, msg_txt(43)); // You're not in a guild. return false; } - //if (strcmp(sd->status.name, guild_info->master) != 0) { - // clif->message(fd, msg_txt(44)); // You're not the master of your guild. - // return false; - //} +#if 0 // By enabling this, only the guild leader can use this command + if (strcmp(sd->status.name, guild_info->master) != 0) { + clif->message(fd, msg_txt(44)); // You're not the master of your guild. + return false; + } +#endif // 0 - added_level = (short)level; - if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow - added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv; - else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow - added_level = 1 - guild_info->guild_lv; + if (level > INT16_MAX || (level > 0 && level > MAX_GUILDLEVEL - guild_info->guild_lv)) // fix positive overflow + level = MAX_GUILDLEVEL - guild_info->guild_lv; + else if (level < INT16_MIN || (level < 0 && level < 1 - guild_info->guild_lv)) // fix negative overflow + level = 1 - guild_info->guild_lv; + added_level = (int16)level; if (added_level != 0) { intif->guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level)); -- cgit v1.2.3-70-g09d2 From 1da48873bb0c9e29e53528eca04593560bcea57f Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 20 Jan 2014 15:31:49 +0100 Subject: Improved questlog handling to honor the value of MAX_QUEST_OBJECTIVES Signed-off-by: Haru --- src/char/int_quest.c | 67 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/src/char/int_quest.c b/src/char/int_quest.c index f8a05bc8f..061dd89d9 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -31,6 +31,9 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) { struct quest *questlog = NULL; struct quest tmp_quest; SqlStmt *stmt; + StringBuf buf; + int i; + int sqlerror = SQL_SUCCESS; if (!count) return NULL; @@ -42,18 +45,31 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) { return NULL; } + StrBuf->Init(&buf); + StrBuf->AppendStr(&buf, "SELECT `quest_id`, `state`, `time`"); + for (i = 0; i < MAX_QUEST_OBJECTIVES; i++) { + StrBuf->Printf(&buf, ", `count%d`", i+1); + } + StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=?", quest_db); + memset(&tmp_quest, 0, sizeof(struct quest)); - if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=?", quest_db) + if (SQL_ERROR == SQL->StmtPrepare(stmt, StrBuf->Value(&buf)) || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) || SQL_ERROR == SQL->StmtExecute(stmt) || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_quest.state, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_INT, &tmp_quest.count[0], 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_INT, &tmp_quest.count[1], 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_INT, &tmp_quest.count[2], 0, NULL, NULL) - ) { + ) + sqlerror = SQL_ERROR; + + StrBuf->Destroy(&buf); + + for (i = 0; sqlerror != SQL_ERROR && i < MAX_QUEST_OBJECTIVES; i++) { // Stop on the first error + sqlerror = SQL->StmtBindColumn(stmt, 3+i, SQLDT_INT, &tmp_quest.count[i], 0, NULL, NULL); + } + + if (sqlerror == SQL_ERROR) { SqlStmt_ShowDebug(stmt); SQL->StmtFree(stmt); *count = 0; @@ -62,7 +78,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) { *count = (int)SQL->StmtNumRows(stmt); if (*count > 0) { - int i = 0; + i = 0; questlog = (struct quest *)aCalloc(*count, sizeof(struct quest)); while (SQL_SUCCESS == SQL->StmtNextRow(stmt)) { @@ -105,13 +121,25 @@ bool mapif_quest_delete(int char_id, int quest_id) { * @return false in case of errors, true otherwise */ bool mapif_quest_add(int char_id, struct quest qd) { - if (SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`, `count1`, `count2`, `count3`) " - "VALUES ('%d', '%d', '%d','%d', '%d', '%d', '%d')", - quest_db, qd.quest_id, char_id, qd.state, qd.time, qd.count[0], qd.count[1], qd.count[2]) - ) { + StringBuf buf; + int i; + + StrBuf->Init(&buf); + StrBuf->Printf(&buf, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`", quest_db); + for (i = 0; i < MAX_QUEST_OBJECTIVES; i++) { + StrBuf->Printf(&buf, ", `count%d`", i+1); + } + StrBuf->Printf(&buf, ") VALUES ('%d', '%d', '%d', '%d'", qd.quest_id, char_id, qd.state, qd.time); + for (i = 0; i < MAX_QUEST_OBJECTIVES; i++) { + StrBuf->Printf(&buf, ", '%d'", qd.count[i]); + } + StrBuf->AppendStr(&buf, ")"); + if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))) { Sql_ShowDebug(sql_handle); + StrBuf->Destroy(&buf); return false; } + StrBuf->Destroy(&buf); return true; } @@ -124,13 +152,22 @@ bool mapif_quest_add(int char_id, struct quest qd) { * @return false in case of errors, true otherwise */ bool mapif_quest_update(int char_id, struct quest qd) { - if (SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `state`='%d', `count1`='%d', `count2`='%d', `count3`='%d' " - "WHERE `quest_id` = '%d' AND `char_id` = '%d'", - quest_db, qd.state, qd.count[0], qd.count[1], qd.count[2], qd.quest_id, char_id) - ) { + StringBuf buf; + int i; + + StrBuf->Init(&buf); + StrBuf->Printf(&buf, "UPDATE `%s` SET `state`='%d'", quest_db, qd.state); + for (i = 0; i < MAX_QUEST_OBJECTIVES; i++) { + StrBuf->Printf(&buf, ", `count%d`='%d'", i+1, qd.count[i]); + } + StrBuf->Printf(&buf, " WHERE `quest_id` = '%d' AND `char_id` = '%d'", qd.quest_id, char_id); + + if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))) { Sql_ShowDebug(sql_handle); + StrBuf->Destroy(&buf); return false; } + StrBuf->Destroy(&buf); return true; } @@ -148,7 +185,7 @@ int mapif_parse_quest_save(int fd) { struct quest *old_qd = NULL, *new_qd = NULL; bool success = true; - if (new_n) + if (new_n > 0) new_qd = (struct quest*)RFIFOP(fd,8); old_qd = mapif_quests_fromsql(char_id, &old_n); -- cgit v1.2.3-70-g09d2 From 0b96dc2756d97048fc8d4bf2c0eca8ae2555a82e Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 20 Jan 2014 15:50:07 +0100 Subject: Renamed atcommand->parse to atcommand->exec - Renamed function to a more appropriate name. - Changed its last argument 'int type' to 'bool player_invoked' to make its purpose more obvious. Signed-off-by: Haru --- src/map/atcommand.c | 22 ++++++++++++---------- src/map/atcommand.h | 2 +- src/map/clif.c | 42 +++++++++++++++++++++--------------------- src/map/map.c | 2 +- src/map/script.c | 4 ++-- 5 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 31357c074..6177fad23 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9755,9 +9755,14 @@ void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bo dbi_destroy(alias_iter); } -/// Executes an at-command. -bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type) -{ +/** + * Executes an at-command + * @param fd fd associated to the invoking character + * @param sd sd associated to the invoking character + * @param message atcommand arguments + * @param player_invoked true if the command was invoked by a player, false if invoked by the server (bypassing any restrictions) + */ +bool atcommand_exec(const int fd, struct map_session_data *sd, const char *message, bool player_invoked) { char charname[NAME_LENGTH], params[100]; char charname2[NAME_LENGTH], params2[100]; char command[100]; @@ -9787,9 +9792,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message if ( *message != atcommand->at_symbol && *message != atcommand->char_symbol ) return false; - // type value 0 = server invoked: bypass restrictions - // 1 = player invoked - if ( type == 1) { + if (player_invoked) { //Commands are disabled on maps flagged as 'nocommand' if ( map->list[sd->bl.m].nocommand && pc_get_group_level(sd) < map->list[sd->bl.m].nocommand ) { clif->message(fd, msg_txt(143)); @@ -9859,7 +9862,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message params[0] = '\0'; // @commands (script based) - if(type == 1 && atcommand->binding_count > 0) { + if(player_invoked && atcommand->binding_count > 0) { struct atcmd_binding_data * binding; // Get atcommand binding @@ -9906,8 +9909,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message return false; } - // type == 1 : player invoked - if (type == 1) { + if (player_invoked) { int i; if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] == 0) || (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] == 0) ) { @@ -10243,7 +10245,7 @@ void atcommand_defaults(void) { atcommand->init = do_init_atcommand; atcommand->final = do_final_atcommand; - atcommand->parse = is_atcommand; + atcommand->exec = atcommand_exec; atcommand->create = atcommand_hp_add; atcommand->can_use = atcommand_can_use; atcommand->can_use2 = atcommand_can_use2; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 710499a43..f95940924 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -80,7 +80,7 @@ struct atcommand_interface { void (*init) (bool minimal); void (*final) (void); /* */ - bool (*parse) (const int fd, struct map_session_data* sd, const char* message, int type); + bool (*exec) (const int fd, struct map_session_data *sd, const char *message, bool player_invoked); bool (*create) (char *name, AtCommandFunc func); bool (*can_use) (struct map_session_data *sd, const char *command); bool (*can_use2) (struct map_session_data *sd, const char *command, AtCommandType type); diff --git a/src/map/clif.c b/src/map/clif.c index 975a5aa01..5f835a8ab 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9814,7 +9814,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) ) return; - if( atcommand->parse(fd, sd, message, 1) ) + if( atcommand->exec(fd, sd, message, true) ) return; if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) @@ -9948,7 +9948,7 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd) map_name = (char*)RFIFOP(fd,2); map_name[MAP_NAME_LENGTH_EXT-1]='\0'; sprintf(command, "%cmapmove %s %d %d", atcommand->at_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20)); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } @@ -10318,7 +10318,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) if( !clif->process_message(sd, 1, &target, &namelen, &message, &messagelen) ) return; - if ( atcommand->parse(fd, sd, message, 1) ) + if ( atcommand->exec(fd, sd, message, true) ) return; if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)) @@ -10477,7 +10477,7 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd) { mes_len_check(msg, len, CHAT_SIZE_MAX); sprintf(command, "%ckami %s", atcommand->at_symbol, msg); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } @@ -11812,7 +11812,7 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) { else sprintf(cmd,"%cstreset",atcommand->at_symbol); - atcommand->parse(fd, sd, cmd, 1); + atcommand->exec(fd, sd, cmd, true); } @@ -11829,7 +11829,7 @@ void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd) mes_len_check(msg, len, CHAT_SIZE_MAX); sprintf(command, "%clkami %s", atcommand->at_symbol, msg); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } @@ -12140,7 +12140,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) ) return; - if( atcommand->parse(fd, sd, message, 1) ) + if( atcommand->exec(fd, sd, message, true) ) return; if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) @@ -13200,7 +13200,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) ) return; - if( atcommand->parse(fd, sd, message, 1) ) + if( atcommand->exec(fd, sd, message, true) ) return; if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) @@ -13415,7 +13415,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) { { char command[NAME_LENGTH+6]; sprintf(command, "%ckick %s", atcommand->at_symbol, status->get_name(target)); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } break; @@ -13460,7 +13460,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) { void clif_parse_GMKickAll(int fd, struct map_session_data* sd) { char cmd[15]; sprintf(cmd,"%ckickall",atcommand->at_symbol); - atcommand->parse(fd, sd, cmd, 1); + atcommand->exec(fd, sd, cmd, true); } @@ -13480,7 +13480,7 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd) player_name[NAME_LENGTH-1] = '\0'; sprintf(command, "%cjumpto %s", atcommand->at_symbol, player_name); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } @@ -13495,7 +13495,7 @@ void clif_parse_GMRemove2(int fd, struct map_session_data* sd) { if( (pl_sd = map->id2sd(account_id)) != NULL ) { char command[NAME_LENGTH+8]; sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } } @@ -13516,7 +13516,7 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd) player_name[NAME_LENGTH-1] = '\0'; sprintf(command, "%crecall %s", atcommand->at_symbol, player_name); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } @@ -13531,7 +13531,7 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd) { if( (pl_sd = map->id2sd(account_id)) != NULL ) { char command[NAME_LENGTH+8]; sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } } @@ -13576,14 +13576,14 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) { snprintf(command, sizeof(command)-1, "%citem2 %d 1 0 0 0 0 0 0 0", atcommand->at_symbol, item_array[i]->nameid); else snprintf(command, sizeof(command)-1, "%citem %d 20", atcommand->at_symbol, item_array[i]->nameid); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); return; } } if( strcmp("money", item_monster_name) == 0 ){ snprintf(command, sizeof(command)-1, "%czeny %d", atcommand->at_symbol, INT_MAX); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); return; } @@ -13600,7 +13600,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) { if( i < count ){ snprintf(command, sizeof(command)-1, "%cmonster %s", atcommand->at_symbol, mob_array[i]->sprite); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } } } @@ -13615,7 +13615,7 @@ void clif_parse_GMHide(int fd, struct map_session_data *sd) { sprintf(cmd,"%chide",atcommand->at_symbol); - atcommand->parse(fd, sd, cmd, 1); + atcommand->exec(fd, sd, cmd, true); } @@ -13669,7 +13669,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) { } sprintf(command, "%cmute %d %s", atcommand->at_symbol, value, dstsd->status.name); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } @@ -13683,7 +13683,7 @@ void clif_parse_GMRc(int fd, struct map_session_data* sd) name[NAME_LENGTH-1] = '\0'; sprintf(command, "%cmute %d %s", atcommand->at_symbol, 60, name); - atcommand->parse(fd, sd, command, 1); + atcommand->exec(fd, sd, command, true); } @@ -16190,7 +16190,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) ) return; - if( atcommand->parse(fd, sd, message, 1) ) + if( atcommand->exec(fd, sd, message, true) ) return; if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) diff --git a/src/map/map.c b/src/map/map.c index 07881ea56..33721b028 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5316,7 +5316,7 @@ CPCMD(gm_use) { return; } map->cpsd->fd = -2; - if( !atcommand->parse(map->cpsd->fd, map->cpsd, line, 0) ) + if( !atcommand->exec(map->cpsd->fd, map->cpsd, line, false) ) ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' failed\n",line); else ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' was used\n",line); diff --git a/src/map/script.c b/src/map/script.c index 8e8f89727..adea269c7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12659,7 +12659,7 @@ BUILDIN(atcommand) { } } - if (!atcommand->parse(fd, sd, cmd, 0)) { + if (!atcommand->exec(fd, sd, cmd, false)) { ShowWarning("script: buildin_atcommand: failed to execute command '%s'\n", cmd); script->reportsrc(st); ret = false; @@ -17320,7 +17320,7 @@ BUILDIN(useatcmd) { cmd++; } - atcommand->parse(fd, sd, cmd, 1); + atcommand->exec(fd, sd, cmd, true); if (dummy_sd) aFree(dummy_sd); return true; } -- cgit v1.2.3-70-g09d2 From 22b7f90297184775ad94d8cb4806e8664c78d934 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 20 Jan 2014 15:56:09 +0100 Subject: Minor fixes to the strlib interface - Fixed a typo in the strnlen() macro (was strnln) - Initialized strlib->strnlen and strlib->strtoull to NULL on platforms that don't require them. Please note that those two functions are supposed to never be called directly but only through the strnlen() and strtoull() macros, which take care of the platform abstraction. - Removed localized versions of yes/no from config_switch (if you really want to be able to use "oui", "ja", "si", "non", "nein", feel free to add them back yourself following the example in strlib.c) Signed-off-by: Haru --- src/common/strlib.c | 34 +++++++++++++++++++++++++--------- src/common/strlib.h | 2 +- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/common/strlib.c b/src/common/strlib.c index 0f68eb206..361595b07 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -240,16 +240,19 @@ char* _strtok_r(char *s1, const char *s2, char **lasts) { } #endif +// TODO: The _MSC_VER check can probably be removed (we no longer support VS +// versions <= 2003, do we?), but this implementation might be still necessary +// for NetBSD 5.x and possibly some Solaris versions. #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ -size_t strnlen (const char* string, size_t maxlen) -{ - const char* end = (const char*)memchr(string, '\0', maxlen); - return end ? (size_t) (end - string) : maxlen; +size_t strnlen(const char* string, size_t maxlen) { + const char* end = (const char*)memchr(string, '\0', maxlen); + return end ? (size_t) (end - string) : maxlen; } #endif +// TODO: This should probably be removed, I don't think we support MSVC++ 6.0 anymore. #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 uint64 strtoull(const char* str, char** endptr, int base) { @@ -331,13 +334,22 @@ int e_mail_check(char* email) //-------------------------------------------------- // Return numerical value of a switch configuration -// on/off, english, français, deutsch, español +// on/off, yes/no, true/false, number //-------------------------------------------------- -int config_switch(const char* str) -{ - if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0) +int config_switch(const char* str) { + size_t len = strlen(str); + if ((len == 2 && strcmpi(str, "on") == 0) + || (len == 3 && strcmpi(str, "yes") == 0) + || (len == 4 && strcmpi(str, "true") == 0) + // || (len == 3 && strcmpi(str, "oui") == 0) // Uncomment and edit to add your own localized versions + ) return 1; - if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0) + + if ((len == 3 && strcmpi(str, "off") == 0) + || (len == 2 && strcmpi(str, "no") == 0) + || (len == 5 && strcmpi(str, "false") == 0) + // || (len == 3 && strcmpi(str, "non") == 0) // Uncomment and edit to add your own localized versions + ) return 0; return (int)strtol(str, NULL, 0); @@ -1119,10 +1131,14 @@ void strlib_defaults(void) { #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) strlib->strnlen = strnlen; +#else + strlib->strnlen = NULL; #endif #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 strlib->strtoull = strtoull; +#else + strlib->strtoull = NULL; #endif strlib->e_mail_check = e_mail_check; strlib->config_switch = config_switch; diff --git a/src/common/strlib.h b/src/common/strlib.h index 5336260f6..7a1066401 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -175,7 +175,7 @@ void strlib_defaults(void); #define stristr(haystack,needle) (strlib->stristr((haystack),(needle))) #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) - #define strnln(string,maxlen) (strlib->strnlen((string),(maxlen))) + #define strnlen(string,maxlen) (strlib->strnlen((string),(maxlen))) #endif #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 -- cgit v1.2.3-70-g09d2 From e68d860dbaa6b1bcf8104463cd3001ae946b7d4e Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 23 Jan 2014 16:51:56 +0100 Subject: Compatibility fixes for NetBSD and Solaris - Fixed some warnings in NetBSD (5.x and 6.x) and Solaris (11) Signed-off-by: Haru --- src/common/cbasetypes.h | 5 +++++ src/map/clif.c | 4 ++++ src/map/npc.c | 4 ++-- src/map/packets_struct.h | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 120f4f861..977897506 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -42,6 +42,11 @@ #define __DARWIN__ #endif +// Necessary for __NetBSD_Version__ (defined as VVRR00PP00) on NetBSD +#ifdef __NETBSD__ +#include +#endif // __NETBSD__ + // 64bit OS #if defined(_M_IA64) || defined(_M_X64) || defined(_WIN64) || defined(_LP64) || defined(_ILP64) || defined(__LP64__) || defined(__ppc64__) #define __64BIT__ diff --git a/src/map/clif.c b/src/map/clif.c index 5f835a8ab..fe3e7cfe9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12959,14 +12959,18 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) { BITMAP_WIDTH = 24, BITMAP_HEIGHT = 24, }; +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(push, 1) +#endif // not NetBSD < 6 / Solaris struct s_bitmaptripple { //uint8 b; //uint8 g; //uint8 r; unsigned int rgb:24; } __attribute__((packed)); +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) +#endif // not NetBSD < 6 / Solaris uint8 buf[1800]; // no well-formed emblem bitmap is larger than 1782 (24 bit) / 1654 (8 bit) bytes unsigned long buf_len = sizeof(buf); int header = 0, bitmap = 0, offbits = 0, palettesize = 0, i = 0; diff --git a/src/map/npc.c b/src/map/npc.c index 722e5199c..458fc52ed 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2432,7 +2432,7 @@ int npc_parseview(const char* w4, const char* start, const char* buffer, const c // Extract view ID / constant while (w4[i] != '\0') { - if (isspace(w4[i]) || w4[i] == '/' || w4[i] == ',') + if (ISSPACE(w4[i]) || w4[i] == '/' || w4[i] == ',') break; i++; @@ -2464,7 +2464,7 @@ bool npc_viewisid(const char * viewid) { // Loop through view, looking for non-numeric character. while (*viewid) { - if (isdigit(*viewid++) == 0) return false; + if (ISDIGIT(*viewid++) == 0) return false; } } diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 8f0989f3d..1156f4465 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -205,7 +205,9 @@ enum packet_headers { npcmarketopenType = 0x9d5, }; +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(push, 1) +#endif // not NetBSD < 6 / Solaris /** * structs for data @@ -939,6 +941,8 @@ struct packet_npc_market_open { } list[1000];/* TODO: whats the actual max of this? */ } __attribute__((packed)); +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) +#endif // not NetBSD < 6 / Solaris #endif /* _PACKETS_STRUCT_H_ */ -- cgit v1.2.3-70-g09d2 From 8fb2b31e8de73872baddc3d983a4eea5c359329d Mon Sep 17 00:00:00 2001 From: "Hercules.ws" Date: Thu, 23 Jan 2014 17:21:30 +0100 Subject: HPM Hooks Update Signed-off-by: HerculesWSAPI --- src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc | 8 ++++---- .../HPMHooking/HPMHooking.HookingPoints.inc | 2 +- src/plugins/HPMHooking/HPMHooking.Hooks.inc | 24 +++++++++++----------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc index 0f9748153..3dfa69d4c 100644 --- a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc @@ -9,8 +9,8 @@ struct { struct HPMHookPoint *HP_atcommand_init_post; struct HPMHookPoint *HP_atcommand_final_pre; struct HPMHookPoint *HP_atcommand_final_post; - struct HPMHookPoint *HP_atcommand_parse_pre; - struct HPMHookPoint *HP_atcommand_parse_post; + struct HPMHookPoint *HP_atcommand_exec_pre; + struct HPMHookPoint *HP_atcommand_exec_post; struct HPMHookPoint *HP_atcommand_create_pre; struct HPMHookPoint *HP_atcommand_create_post; struct HPMHookPoint *HP_atcommand_can_use_pre; @@ -5028,8 +5028,8 @@ struct { int HP_atcommand_init_post; int HP_atcommand_final_pre; int HP_atcommand_final_post; - int HP_atcommand_parse_pre; - int HP_atcommand_parse_post; + int HP_atcommand_exec_pre; + int HP_atcommand_exec_post; int HP_atcommand_create_pre; int HP_atcommand_create_post; int HP_atcommand_can_use_pre; diff --git a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc index 226497c3f..0b7201cdc 100644 --- a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc @@ -8,7 +8,7 @@ struct HookingPointData HookingPoints[] = { /* atcommand */ { HP_POP(atcommand->init, HP_atcommand_init) }, { HP_POP(atcommand->final, HP_atcommand_final) }, - { HP_POP(atcommand->parse, HP_atcommand_parse) }, + { HP_POP(atcommand->exec, HP_atcommand_exec) }, { HP_POP(atcommand->create, HP_atcommand_create) }, { HP_POP(atcommand->can_use, HP_atcommand_can_use) }, { HP_POP(atcommand->can_use2, HP_atcommand_can_use2) }, diff --git a/src/plugins/HPMHooking/HPMHooking.Hooks.inc b/src/plugins/HPMHooking/HPMHooking.Hooks.inc index 7b69fd902..4db53868d 100644 --- a/src/plugins/HPMHooking/HPMHooking.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking.Hooks.inc @@ -55,14 +55,14 @@ void HP_atcommand_final(void) { } return; } -bool HP_atcommand_parse(const int fd, struct map_session_data *sd, const char *message, int type) { +bool HP_atcommand_exec(const int fd, struct map_session_data *sd, const char *message, bool player_invoked) { int hIndex = 0; bool retVal___ = false; - if( HPMHooks.count.HP_atcommand_parse_pre ) { - bool (*preHookFunc) (const int *fd, struct map_session_data *sd, const char *message, int *type); - for(hIndex = 0; hIndex < HPMHooks.count.HP_atcommand_parse_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_atcommand_parse_pre[hIndex].func; - retVal___ = preHookFunc(&fd, sd, message, &type); + if( HPMHooks.count.HP_atcommand_exec_pre ) { + bool (*preHookFunc) (const int *fd, struct map_session_data *sd, const char *message, bool *player_invoked); + for(hIndex = 0; hIndex < HPMHooks.count.HP_atcommand_exec_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_atcommand_exec_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd, message, &player_invoked); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -70,13 +70,13 @@ bool HP_atcommand_parse(const int fd, struct map_session_data *sd, const char *m } } { - retVal___ = HPMHooks.source.atcommand.parse(fd, sd, message, type); + retVal___ = HPMHooks.source.atcommand.exec(fd, sd, message, player_invoked); } - if( HPMHooks.count.HP_atcommand_parse_post ) { - bool (*postHookFunc) (bool retVal___, const int *fd, struct map_session_data *sd, const char *message, int *type); - for(hIndex = 0; hIndex < HPMHooks.count.HP_atcommand_parse_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_atcommand_parse_post[hIndex].func; - retVal___ = postHookFunc(retVal___, &fd, sd, message, &type); + if( HPMHooks.count.HP_atcommand_exec_post ) { + bool (*postHookFunc) (bool retVal___, const int *fd, struct map_session_data *sd, const char *message, bool *player_invoked); + for(hIndex = 0; hIndex < HPMHooks.count.HP_atcommand_exec_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_atcommand_exec_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd, message, &player_invoked); } } return retVal___; -- cgit v1.2.3-70-g09d2