summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c47
1 files changed, 25 insertions, 22 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;