summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2014-01-24 18:18:39 -0200
committershennetsind <ind@henn.et>2014-01-24 18:18:39 -0200
commit2263dc4660c6668c373f6a9e654e21bea8c419e4 (patch)
tree5a02d740a74d75979e6adee90acd4d63fe807036 /src
parent7438e401b4209198691d3c8ca65b6c702338fa41 (diff)
parent8fb2b31e8de73872baddc3d983a4eea5c359329d (diff)
downloadhercules-2263dc4660c6668c373f6a9e654e21bea8c419e4.tar.gz
hercules-2263dc4660c6668c373f6a9e654e21bea8c419e4.tar.bz2
hercules-2263dc4660c6668c373f6a9e654e21bea8c419e4.tar.xz
hercules-2263dc4660c6668c373f6a9e654e21bea8c419e4.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Diffstat (limited to 'src')
-rw-r--r--src/char/int_guild.c50
-rw-r--r--src/char/int_quest.c67
-rw-r--r--src/common/cbasetypes.h5
-rw-r--r--src/common/mmo.h8
-rw-r--r--src/common/strlib.c34
-rw-r--r--src/common/strlib.h2
-rw-r--r--src/map/atcommand.c47
-rw-r--r--src/map/atcommand.h2
-rw-r--r--src/map/clif.c46
-rw-r--r--src/map/map.c2
-rw-r--r--src/map/npc.c4
-rw-r--r--src/map/packets_struct.h4
-rw-r--r--src/map/script.c4
-rw-r--r--src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc16
-rw-r--r--src/plugins/HPMHooking/HPMHooking.HookingPoints.inc4
-rw-r--r--src/plugins/HPMHooking/HPMHooking.Hooks.inc40
16 files changed, 200 insertions, 135 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/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);
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 <sys/param.h>
+#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/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
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
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 0cb552bd0..6177fad23 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));
@@ -9754,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];
@@ -9786,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));
@@ -9858,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
@@ -9905,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) ) {
@@ -10242,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 c0b3f7f7f..9ae88200c 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -9824,7 +9824,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) )
@@ -9958,7 +9958,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);
}
@@ -10328,7 +10328,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))
@@ -10487,7 +10487,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);
}
@@ -11822,7 +11822,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);
}
@@ -11839,7 +11839,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);
}
@@ -12150,7 +12150,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) )
@@ -12969,14 +12969,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;
@@ -13210,7 +13214,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) )
@@ -13425,7 +13429,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;
@@ -13470,7 +13474,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);
}
@@ -13490,7 +13494,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);
}
@@ -13505,7 +13509,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);
}
}
@@ -13526,7 +13530,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);
}
@@ -13541,7 +13545,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);
}
}
@@ -13586,14 +13590,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;
}
@@ -13610,7 +13614,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);
}
}
}
@@ -13625,7 +13629,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);
}
@@ -13679,7 +13683,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);
}
@@ -13693,7 +13697,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);
}
@@ -16200,7 +16204,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/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_ */
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;
}
diff --git a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc
index 654d84b42..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;
@@ -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;
@@ -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;
@@ -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..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) },
@@ -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..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___;
@@ -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___);
}
}