summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-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
7 files changed, 60 insertions, 49 deletions
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;
}