From 41a63f4b3d4e5287af652a1b9d30c87980923d35 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Fri, 18 Oct 2013 07:54:50 -0700 Subject: Rewrite @command dispatch and help --- src/common/version.cpp | 7 + src/common/version.hpp | 2 + src/map/atcommand.cpp | 3325 ++++++++++++++++++++---------------------------- src/map/atcommand.hpp | 2 + src/map/map.cpp | 6 + 5 files changed, 1428 insertions(+), 1914 deletions(-) diff --git a/src/common/version.cpp b/src/common/version.cpp index 7f4a0f2..1ee4071 100644 --- a/src/common/version.cpp +++ b/src/common/version.cpp @@ -26,3 +26,10 @@ Version CURRENT_MAP_SERVER_VERSION = 0, TMWA_SERVER_MAP, VENDOR_VERSION, }; + +#define S2(a) #a +#define S(a) S2(a) + +const char CURRENT_VERSION_STRING[] = "TMWA " + S(VERSION_MAJOR) "." S(VERSION_MINOR) "." S(VERSION_PATCH) + " dev" S(VERSION_DEVEL) " (" VENDOR " " S(VENDOR_VERSION) ")"; diff --git a/src/common/version.hpp b/src/common/version.hpp index e34ec50..677806b 100644 --- a/src/common/version.hpp +++ b/src/common/version.hpp @@ -29,4 +29,6 @@ extern Version CURRENT_LOGIN_SERVER_VERSION; extern Version CURRENT_CHAR_SERVER_VERSION; extern Version CURRENT_MAP_SERVER_VERSION; +extern const char CURRENT_VERSION_STRING[]; + #endif // TMWA_COMMON_VERSION_HPP diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 76355f5..abfe0d4 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -23,6 +23,7 @@ #include "../common/socket.hpp" #include "../common/timer.hpp" #include "../common/utils2.hpp" +#include "../common/version.hpp" #include "battle.hpp" #include "chrif.hpp" @@ -42,315 +43,84 @@ #include "../poison.hpp" -#define ATCOMMAND_FUNC(x) static \ -int atcommand_##x(const int fd, dumb_ptr sd, ZString message) -ATCOMMAND_FUNC(setup); -ATCOMMAND_FUNC(broadcast); -ATCOMMAND_FUNC(localbroadcast); -ATCOMMAND_FUNC(charwarp); -ATCOMMAND_FUNC(warp); -ATCOMMAND_FUNC(where); -ATCOMMAND_FUNC(goto); -ATCOMMAND_FUNC(jump); -ATCOMMAND_FUNC(who); -ATCOMMAND_FUNC(whogroup); -ATCOMMAND_FUNC(whomap); -ATCOMMAND_FUNC(whomapgroup); -ATCOMMAND_FUNC(whogm); // by Yor -ATCOMMAND_FUNC(save); -ATCOMMAND_FUNC(load); -ATCOMMAND_FUNC(speed); -ATCOMMAND_FUNC(storage); -ATCOMMAND_FUNC(option); -ATCOMMAND_FUNC(hide); -ATCOMMAND_FUNC(die); -ATCOMMAND_FUNC(kill); -ATCOMMAND_FUNC(alive); -ATCOMMAND_FUNC(kami); -ATCOMMAND_FUNC(heal); -ATCOMMAND_FUNC(item); -ATCOMMAND_FUNC(itemreset); -ATCOMMAND_FUNC(itemcheck); -ATCOMMAND_FUNC(baselevelup); -ATCOMMAND_FUNC(joblevelup); -ATCOMMAND_FUNC(help); -ATCOMMAND_FUNC(gm); -ATCOMMAND_FUNC(pvpoff); -ATCOMMAND_FUNC(pvpon); -ATCOMMAND_FUNC(model); -ATCOMMAND_FUNC(spawn); -ATCOMMAND_FUNC(killmonster); -ATCOMMAND_FUNC(killmonster2); -ATCOMMAND_FUNC(gat); -ATCOMMAND_FUNC(packet); -ATCOMMAND_FUNC(statuspoint); -ATCOMMAND_FUNC(skillpoint); -ATCOMMAND_FUNC(zeny); -template -ATCOMMAND_FUNC(param); -ATCOMMAND_FUNC(recall); -ATCOMMAND_FUNC(recallall); -ATCOMMAND_FUNC(revive); -ATCOMMAND_FUNC(character_stats); -ATCOMMAND_FUNC(character_stats_all); -ATCOMMAND_FUNC(character_option); -ATCOMMAND_FUNC(character_save); -ATCOMMAND_FUNC(doom); -ATCOMMAND_FUNC(doommap); -ATCOMMAND_FUNC(raise); -ATCOMMAND_FUNC(raisemap); -ATCOMMAND_FUNC(character_baselevel); -ATCOMMAND_FUNC(character_joblevel); -ATCOMMAND_FUNC(kick); -ATCOMMAND_FUNC(kickall); -ATCOMMAND_FUNC(questskill); -ATCOMMAND_FUNC(charquestskill); -ATCOMMAND_FUNC(lostskill); -ATCOMMAND_FUNC(charlostskill); -ATCOMMAND_FUNC(party); -ATCOMMAND_FUNC(charskreset); -ATCOMMAND_FUNC(charstreset); -ATCOMMAND_FUNC(charreset); -ATCOMMAND_FUNC(charstpoint); -ATCOMMAND_FUNC(charmodel); -ATCOMMAND_FUNC(charskpoint); -ATCOMMAND_FUNC(charzeny); -ATCOMMAND_FUNC(reloaditemdb); -ATCOMMAND_FUNC(reloadmobdb); -ATCOMMAND_FUNC(reloadskilldb); -ATCOMMAND_FUNC(reloadscript); -ATCOMMAND_FUNC(reloadgmdb); // by Yor -ATCOMMAND_FUNC(mapexit); -ATCOMMAND_FUNC(idsearch); -ATCOMMAND_FUNC(mapinfo); -ATCOMMAND_FUNC(dye); //** by fritz -ATCOMMAND_FUNC(hair_style); //** by fritz -ATCOMMAND_FUNC(hair_color); //** by fritz -ATCOMMAND_FUNC(all_stats); //** by fritz -ATCOMMAND_FUNC(char_change_sex); // by Yor -ATCOMMAND_FUNC(char_block); // by Yor -ATCOMMAND_FUNC(char_ban); // by Yor -ATCOMMAND_FUNC(char_unblock); // by Yor -ATCOMMAND_FUNC(char_unban); // by Yor -ATCOMMAND_FUNC(partyspy); // [Syrus22] -ATCOMMAND_FUNC(partyrecall); // by Yor -ATCOMMAND_FUNC(enablenpc); -ATCOMMAND_FUNC(disablenpc); -ATCOMMAND_FUNC(servertime); // by Yor -ATCOMMAND_FUNC(chardelitem); // by Yor -ATCOMMAND_FUNC(email); // by Yor -ATCOMMAND_FUNC(effect); //by Apple -ATCOMMAND_FUNC(character_item_list); // by Yor -ATCOMMAND_FUNC(character_storage_list); // by Yor -ATCOMMAND_FUNC(character_cart_list); // by Yor -ATCOMMAND_FUNC(addwarp); // by MouseJstr -ATCOMMAND_FUNC(killer); // by MouseJstr -ATCOMMAND_FUNC(charkiller); // by o11c -ATCOMMAND_FUNC(npcmove); // by MouseJstr -ATCOMMAND_FUNC(killable); // by MouseJstr -ATCOMMAND_FUNC(charkillable); // by MouseJstr -ATCOMMAND_FUNC(chareffect); // by MouseJstr -ATCOMMAND_FUNC(dropall); // by MouseJstr -ATCOMMAND_FUNC(chardropall); // by MouseJstr -ATCOMMAND_FUNC(storeall); // by MouseJstr -ATCOMMAND_FUNC(charstoreall); // by MouseJstr -ATCOMMAND_FUNC(summon); -ATCOMMAND_FUNC(rain); -ATCOMMAND_FUNC(snow); -ATCOMMAND_FUNC(sakura); -ATCOMMAND_FUNC(fog); -ATCOMMAND_FUNC(leaves); -ATCOMMAND_FUNC(adjgmlvl); // by MouseJstr -ATCOMMAND_FUNC(adjcmdlvl); // by MouseJstr -ATCOMMAND_FUNC(trade); // by MouseJstr -ATCOMMAND_FUNC(char_wipe); // [Fate] -ATCOMMAND_FUNC(set_magic); // [Fate] -ATCOMMAND_FUNC(magic_info); // [Fate] -ATCOMMAND_FUNC(log); // [Fate] -ATCOMMAND_FUNC(tee); // [Fate] -ATCOMMAND_FUNC(invisible); // [Fate] -ATCOMMAND_FUNC(visible); // [Fate] -ATCOMMAND_FUNC(list_nearby); // [Fate] -ATCOMMAND_FUNC(iterate_forward_over_players); // [Fate] -ATCOMMAND_FUNC(iterate_backwards_over_players); // [Fate] -ATCOMMAND_FUNC(skillpool_info); // [Fate] -ATCOMMAND_FUNC(skillpool_focus); // [Fate] -ATCOMMAND_FUNC(skillpool_unfocus); // [Fate] -ATCOMMAND_FUNC(skill_learn); // [Fate] -ATCOMMAND_FUNC(wgm); -ATCOMMAND_FUNC(ipcheck); -ATCOMMAND_FUNC(doomspot); - -/*========================================== - *AtCommandInfo atcommand_info[]構造体の定義 - *------------------------------------------ - */ + +enum class ATCE +{ + OKAY, + USAGE, + EXIST, + RANGE, + PERM, +}; + struct AtCommandInfo { - ZString command; + ZString args; int level; - int (*proc)(const int fd, dumb_ptr sd, ZString message); - + ATCE (*proc)(const int fd, dumb_ptr sd, ZString message); + ZString help; - AtCommandInfo(ZString c, int l, int (*p)(const int, dumb_ptr, ZString)) - : command(c), level(l), proc(p) + AtCommandInfo(ZString a, int l, ATCE (*p)(const int, dumb_ptr, ZString), ZString h) + : args(a), level(l), proc(p), help(h) {} }; -// First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value. -// to set default level, read atcommand_athena.conf first please. -static -AtCommandInfo atcommand_info[] = -{ - {"@setup", 40, atcommand_setup}, - {"@charwarp", 60, atcommand_charwarp}, - {"@warp", 40, atcommand_warp}, - {"@where", 1, atcommand_where}, - {"@goto", 20, atcommand_goto}, - {"@jump", 40, atcommand_jump}, - {"@who", 20, atcommand_who}, - {"@whogroup", 20, atcommand_whogroup}, - {"@whomap", 20, atcommand_whomap}, - {"@whomapgroup", 20, atcommand_whomapgroup}, - {"@whogm", 20, atcommand_whogm}, // by Yor - {"@save", 40, atcommand_save}, - {"@return", 40, atcommand_load}, - {"@load", 40, atcommand_load}, - {"@speed", 40, atcommand_speed}, - {"@storage", 1, atcommand_storage}, - {"@option", 40, atcommand_option}, - {"@hide", 40, atcommand_hide}, // + /hide - {"@die", 1, atcommand_die}, - {"@kill", 60, atcommand_kill}, - {"@alive", 60, atcommand_alive}, - {"@kami", 40, atcommand_kami}, - {"@heal", 40, atcommand_heal}, - {"@item", 60, atcommand_item}, - {"@itemreset", 40, atcommand_itemreset}, - {"@itemcheck", 60, atcommand_itemcheck}, - {"@blvl", 60, atcommand_baselevelup}, - {"@jlvl", 60, atcommand_joblevelup}, - {"@help", 20, atcommand_help}, - {"@gm", 100, atcommand_gm}, - {"@pvpoff", 40, atcommand_pvpoff}, - {"@pvpon", 40, atcommand_pvpon}, - {"@model", 20, atcommand_model}, - {"@spawn", 50, atcommand_spawn}, - {"@killmonster", 60, atcommand_killmonster}, - {"@killmonster2", 40, atcommand_killmonster2}, - {"@gat", 99, atcommand_gat}, // debug function - {"@packet", 99, atcommand_packet}, // debug function - {"@stpoint", 60, atcommand_statuspoint}, - {"@skpoint", 60, atcommand_skillpoint}, - {"@zeny", 60, atcommand_zeny}, - {"@str", 60, atcommand_param}, - {"@agi", 60, atcommand_param}, - {"@vit", 60, atcommand_param}, - {"@int", 60, atcommand_param}, - {"@dex", 60, atcommand_param}, - {"@luk", 60, atcommand_param}, - {"@recall", 60, atcommand_recall}, // + /recall - {"@revive", 60, atcommand_revive}, - {"@charstats", 40, atcommand_character_stats}, - {"@charstatsall", 40, atcommand_character_stats_all}, - {"@charoption", 60, atcommand_character_option}, - {"@charsave", 60, atcommand_character_save}, - {"@doom", 80, atcommand_doom}, - {"@doommap", 80, atcommand_doommap}, - {"@raise", 80, atcommand_raise}, - {"@raisemap", 80, atcommand_raisemap}, - {"@charbaselvl", 60, atcommand_character_baselevel}, - {"@charjlvl", 60, atcommand_character_joblevel}, - {"@kick", 20, atcommand_kick}, // + right click menu for GM "(name) force to quit" - {"@kickall", 99, atcommand_kickall}, - {"@questskill", 40, atcommand_questskill}, - {"@charquestskill", 60, atcommand_charquestskill}, - {"@lostskill", 40, atcommand_lostskill}, - {"@charlostskill", 60, atcommand_charlostskill}, - {"@party", 1, atcommand_party}, - {"@mapexit", 99, atcommand_mapexit}, - {"@idsearch", 60, atcommand_idsearch}, - {"@mapmove", 40, atcommand_warp}, // /mm command - {"@broadcast", 40, atcommand_broadcast}, // /b and /nb command - {"@localbroadcast", 40, atcommand_localbroadcast}, // /lb and /nlb command - {"@recallall", 80, atcommand_recallall}, - {"@charskreset", 60, atcommand_charskreset}, - {"@charstreset", 60, atcommand_charstreset}, - {"@reloaditemdb", 99, atcommand_reloaditemdb}, // admin command - {"@reloadmobdb", 99, atcommand_reloadmobdb}, // admin command - {"@reloadskilldb", 99, atcommand_reloadskilldb}, // admin command - {"@reloadscript", 99, atcommand_reloadscript}, // admin command - {"@reloadgmdb", 99, atcommand_reloadgmdb}, // admin command - {"@charreset", 60, atcommand_charreset}, - {"@charmodel", 50, atcommand_charmodel}, - {"@charskpoint", 60, atcommand_charskpoint}, - {"@charstpoint", 60, atcommand_charstpoint}, - {"@charzeny", 60, atcommand_charzeny}, - {"@mapinfo", 99, atcommand_mapinfo}, - {"@dye", 40, atcommand_dye}, // by fritz - {"@ccolor", 40, atcommand_dye}, // by fritz - {"@hairstyle", 40, atcommand_hair_style}, // by fritz - {"@haircolor", 40, atcommand_hair_color}, // by fritz - {"@allstats", 60, atcommand_all_stats}, // by fritz - {"@charchangesex", 60, atcommand_char_change_sex}, // by Yor - {"@block", 60, atcommand_char_block}, // by Yor - {"@unblock", 60, atcommand_char_unblock}, // by Yor - {"@ban", 60, atcommand_char_ban}, // by Yor - {"@unban", 60, atcommand_char_unban}, // by Yor - {"@partyspy", 60, atcommand_partyspy}, // [Syrus22] - {"@partyrecall", 60, atcommand_partyrecall}, // by Yor - {"@enablenpc", 80, atcommand_enablenpc}, // [] - {"@disablenpc", 80, atcommand_disablenpc}, // [] - {"@servertime", 0, atcommand_servertime}, // by Yor - {"@chardelitem", 60, atcommand_chardelitem}, // by Yor - {"@listnearby", 40, atcommand_list_nearby}, // by Yor - {"@email", 0, atcommand_email}, // by Yor - {"@effect", 40, atcommand_effect}, // by Apple - {"@charitemlist", 40, atcommand_character_item_list}, // by Yor - {"@charstoragelist", 40, atcommand_character_storage_list}, // by Yor - {"@charcartlist", 40, atcommand_character_cart_list}, // by Yor - {"@addwarp", 20, atcommand_addwarp}, // by MouseJstr - {"@killer", 60, atcommand_killer}, // by MouseJstr - {"@charkiller", 60, atcommand_charkiller}, // by o11c - {"@npcmove", 20, atcommand_npcmove}, // by MouseJstr - {"@killable", 40, atcommand_killable}, // by MouseJstr - {"@charkillable", 40, atcommand_charkillable}, // by MouseJstr - {"@chareffect", 40, atcommand_chareffect}, // MouseJstr - {"@dropall", 40, atcommand_dropall}, // MouseJstr - {"@chardropall", 40, atcommand_chardropall}, // MouseJstr - {"@storeall", 40, atcommand_storeall}, // MouseJstr - {"@charstoreall", 40, atcommand_charstoreall}, // MouseJstr - {"@rain", 99, atcommand_rain}, - {"@snow", 99, atcommand_snow}, - {"@sakura", 99, atcommand_sakura}, - {"@fog", 99, atcommand_fog}, - {"@leaves", 99, atcommand_leaves}, - {"@summon", 60, atcommand_summon}, - {"@adjgmlvl", 99, atcommand_adjgmlvl}, - {"@adjcmdlvl", 99, atcommand_adjcmdlvl}, - {"@trade", 60, atcommand_trade}, - {"@charwipe", 60, atcommand_char_wipe}, // [Fate] - {"@setmagic", 99, atcommand_set_magic}, // [Fate] - {"@magicinfo", 60, atcommand_magic_info}, // [Fate] - {"@log", 60, atcommand_log}, // [Fate] - {"@l", 60, atcommand_log}, // [Fate] - {"@tee", 60, atcommand_tee}, // [Fate] - {"@t", 60, atcommand_tee}, // [Fate] - {"@invisible", 60, atcommand_invisible}, // [Fate] - {"@visible", 60, atcommand_visible}, // [Fate] - {"@hugo", 60, atcommand_iterate_forward_over_players}, // [Fate] - {"@linus", 60, atcommand_iterate_backwards_over_players}, // [Fate] - {"@sp-info", 40, atcommand_skillpool_info}, // [Fate] - {"@sp-focus", 80, atcommand_skillpool_focus}, // [Fate] - {"@sp-unfocus", 80, atcommand_skillpool_unfocus}, // [Fate] - {"@skill-learn", 80, atcommand_skill_learn}, // [Fate] - {"@wgm", 0, atcommand_wgm}, - {"@ipcheck", 60, atcommand_ipcheck}, - {"@doomspot", 60, atcommand_doomspot}, - -// add new commands before this line - {ZString(), 1, nullptr} -}; + +// TODO What we really want is an ArrayMap ... +// This is defined at the end of the file. +extern +Map atcommand_info; + + +static +AtCommandInfo *atcommand(const int level, XString cmd); + +// These @commands are used within other @commands. +static +ATCE atcommand_character_baselevel(const int fd, dumb_ptr sd, + ZString message); +static +ATCE atcommand_skill_learn(const int fd, dumb_ptr, + ZString message); +static +ATCE atcommand_charwarp(const int fd, dumb_ptr sd, + ZString message); +static +ATCE atcommand_charstreset(const int fd, dumb_ptr sd, + ZString message); + + +void atcommand_config_write(ZString cfgName) +{ + FILE *out = fopen(cfgName.c_str(), "w"); + + if (!out) + { + FPRINTF(stderr, "Failed to write atcommand config: %s\n", cfgName); + return; + } + + FPRINTF(out, "// Generated by %s\n", CURRENT_VERSION_STRING); + for (const auto& pair : atcommand_info) + { + // This XString is really a ZString, but not declared as one + // in order to allow non-heterogenous lookup by XString. + const char *cmd = &*pair.first.begin(); + const AtCommandInfo& info = pair.second; + + FPRINTF(out, + "\n" + "// %s\n" + "// Usage: @%s %s\n" + "%s: %d\n", + info.help, + cmd, info.args, + cmd, info.level); + } + + fclose(out); +} + // If your last arg is not a ZString, you probably wanted extract() // but not always ... @@ -393,25 +163,9 @@ bool asplit(ZString raw, F *first_arg, R *... rest_args) return extract(frist, first_arg) && asplit(rest, rest_args...); } -/*========================================== - * get_atcommand_level @コマンドの必要レベルを取得 - *------------------------------------------ - */ -static -int get_atcommand_level(const AtCommandInfo *type) -{ - if (type) - return type->level; - - return 100; // 100: command can not be used -} - static FILE *get_gm_log(); -/*======================================== - * At-command logging - */ void log_atcommand(dumb_ptr sd, ZString cmd) { FILE *fp = get_gm_log(); @@ -428,10 +182,7 @@ void log_atcommand(dumb_ptr sd, ZString cmd) } FString gm_log; -/*========================================== - * Log a timestamped line to GM log file - *------------------------------------------ - */ + FILE *get_gm_log() { if (!gm_log) @@ -465,12 +216,6 @@ FILE *get_gm_log() return gm_logfile; } -static -AtCommandInfo *atcommand(const int level, ZString message); -/*========================================== - *is_atcommand @コマンドに存在するかどうか確認する - *------------------------------------------ - */ bool is_atcommand(const int fd, dumb_ptr sd, ZString message, int gmlvl) { @@ -479,32 +224,46 @@ bool is_atcommand(const int fd, dumb_ptr sd, if (!message.startswith('@')) return false; - AtCommandInfo *info = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), message); + XString command; + ZString arg; + asplit(message, &command, &arg); + + AtCommandInfo *info = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), command); if (!info) { FString output = STRPRINTF("GM command not found: %s", - message); + FString(command)); clif_displaymessage(fd, output); - return true; // don't show in chat + return true; + // don't show in chat } { - XString command; - ZString arg; - asplit(message, &command, &arg); - { - if (info->proc(fd, sd, arg) != 0) + ATCE err = info->proc(fd, sd, arg); + switch (err) { - // Command can not be executed - FString output = STRPRINTF("%s failed.", FString(command)); - clif_displaymessage(fd, output); - } - else - { - if (get_atcommand_level(info) != 0) // Don't log level 0 commands + case ATCE::OKAY: + // Don't log level 0 commands + if (info->level) log_atcommand(sd, message); + break; + case ATCE::USAGE: + clif_displaymessage(fd, "Command failed: usage error"); + clif_displaymessage(fd, STRPRINTF("Usage: %s %s", FString(command), info->args)); + break; + case ATCE::EXIST: + clif_displaymessage(fd, "Command failed: something does not exist (or already exists)"); + break; + case ATCE::RANGE: + clif_displaymessage(fd, "Command failed: value out of range"); + break; + case ATCE::PERM: + clif_displaymessage(fd, "Command failed: permission denied"); + break; + default: + abort(); } } @@ -512,45 +271,22 @@ bool is_atcommand(const int fd, dumb_ptr sd, } } -/*========================================== - * - *------------------------------------------ - */ -AtCommandInfo *atcommand(const int level, ZString message) +AtCommandInfo *atcommand(const int level, XString cmd) { - ZString p = message; - - if (battle_config.atcommand_gm_only != 0 && !level) // level = pc_isGM(sd) + if (battle_config.atcommand_gm_only != 0 && !level) + // level = pc_isGM(sd) return nullptr; - if (!p) - { - FPRINTF(stderr, "at command message is empty\n"); - return nullptr; - } - if (p.startswith('@')) + if (cmd.startswith('@')) { - ZString::iterator space = std::find(p.begin(), p.end(), ' '); - XString command = p.xislice_h(space); - int i = 0; - - while (atcommand_info[i].command) - { - if (command == atcommand_info[i].command - && level >= atcommand_info[i].level) - { - return &atcommand_info[i]; - } - i++; - } + XString command = cmd.xslice_t(1); + AtCommandInfo *it = atcommand_info.search(command); + if (it && level >= it->level) + return it; } return nullptr; } -/*========================================== - * - *------------------------------------------ - */ static void atkillmonster_sub(dumb_ptr bl, int flag) { @@ -563,24 +299,12 @@ void atkillmonster_sub(dumb_ptr bl, int flag) mob_delete(md); } -/*========================================== - * - *------------------------------------------ - */ static AtCommandInfo *get_atcommandinfo_byname(XString name) { - for (int i = 0; atcommand_info[i].command; i++) - if (atcommand_info[i].command.xslice_t(1) == name) - return &atcommand_info[i]; - - return NULL; + return atcommand_info.search(name); } -/*========================================== - * - *------------------------------------------ - */ int atcommand_config_read(ZString cfgName) { std::ifstream in(cfgName.c_str()); @@ -615,27 +339,71 @@ int atcommand_config_read(ZString cfgName) return 0; } -/*========================================== -// @ command processing functions - *------------------------------------------ - */ +/// @ command processing functions + +static +ATCE atcommand_help(const int fd, dumb_ptr, + ZString message) +{ + if (!message) + { + clif_displaymessage(fd, "There is too much help to display it all at once"); + clif_displaymessage(fd, "Try @help <@command> or @help or @help "); + clif_displaymessage(fd, "Right now the only category is 'all'"); + return ATCE::OKAY; + } + + if (message.startswith('@')) + { + ZString cmd = message.xslice_t(1); + const AtCommandInfo *info = atcommand_info.search(cmd); + if (!info) + return ATCE::EXIST; + clif_displaymessage(fd, STRPRINTF("Usage: @%s %s", cmd, info->args)); + clif_displaymessage(fd, info->help); + return ATCE::OKAY; + } + + if (message == "all") + { + clif_displaymessage(fd, "Synopses of GM commands in category 'all':"); + for (const auto& pair : atcommand_info) + { + const char *cmd = &*pair.first.begin(); + const AtCommandInfo& info = pair.second; + clif_displaymessage(fd, STRPRINTF("@%s %s", cmd, info.args)); + } + return ATCE::OKAY; + } + + int low = 0, high; + if (extract(message, &high)) + ++high; + else if (!extract(message, record<'-'>(&low, &high))) + return ATCE::USAGE; + + if (low < 0 || high > 100 || low >= high) + return ATCE::RANGE; + clif_displaymessage(fd, STRPRINTF("Synopses of GM commands in level [%d, %d):", low, high)); + for (const auto& pair : atcommand_info) + { + const char *cmd = &*pair.first.begin(); + const AtCommandInfo& info = pair.second; + if (low <= info.level && info.level < high) + clif_displaymessage(fd, STRPRINTF("@%s %s", cmd, info.args)); + } + return ATCE::OKAY; +} -/*========================================== - * @setup - Safely set a chars levels and warp them to a special place - * TAW Specific - *------------------------------------------ - */ -int atcommand_setup(const int fd, dumb_ptr sd, +static +ATCE atcommand_setup(const int fd, dumb_ptr sd, ZString message) { int level = 1; CharName character; if (!asplit(message, &level, &character)) - { - clif_displaymessage(fd, "Usage: @setup "); - return -1; - } + return ATCE::USAGE; level--; FString buf; @@ -660,15 +428,11 @@ int atcommand_setup(const int fd, dumb_ptr sd, STRPRINTF("018-1.gat 24 98 %s", character); atcommand_charwarp(fd, sd, buf); - return 0; - + return ATCE::OKAY; } -/*========================================== - * @rura+ - *------------------------------------------ - */ -int atcommand_charwarp(const int fd, dumb_ptr sd, +//static +ATCE atcommand_charwarp(const int fd, dumb_ptr sd, ZString message) { MapName map_name; @@ -676,11 +440,7 @@ int atcommand_charwarp(const int fd, dumb_ptr sd, int x = 0, y = 0; if (!asplit(message, &map_name, &x, &y, &character)) - { - clif_displaymessage(fd, - "Usage: @charwarp/@rura+ "); - return -1; - } + return ATCE::USAGE; if (x <= 0) x = random_::in(1, 399); @@ -701,14 +461,14 @@ int atcommand_charwarp(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "You are not authorised to warp someone to this map."); - return -1; + return ATCE::PERM; } if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp this player from its actual map."); - return -1; + return ATCE::PERM; } if (pc_setpos(pl_sd, map_name, x, y, BeingRemoveWhy::WARPED) == 0) { @@ -718,35 +478,32 @@ int atcommand_charwarp(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Map not found."); - return -1; + return ATCE::EXIST; } } else { clif_displaymessage(fd, "Coordinates out of range."); - return -1; + return ATCE::RANGE; } } else { clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player."); - return -1; + return ATCE::PERM; } } else { clif_displaymessage(fd, "Character not found."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_warp(const int fd, dumb_ptr sd, +static +ATCE atcommand_warp(const int fd, dumb_ptr sd, ZString message) { MapName map_name; @@ -757,7 +514,7 @@ int atcommand_warp(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "Please, enter a map (usage: @warp )."); - return -1; + return ATCE::USAGE; } if (x <= 0) @@ -773,37 +530,34 @@ int atcommand_warp(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "You are not authorised to warp you to this map."); - return -1; + return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you from your actual map."); - return -1; + return ATCE::PERM; } if (pc_setpos(sd, map_name, x, y, BeingRemoveWhy::WARPED) == 0) clif_displaymessage(fd, "Warped."); else { clif_displaymessage(fd, "Map not found."); - return -1; + return ATCE::EXIST; } } else { clif_displaymessage(fd, "Coordinates out of range."); - return -1; + return ATCE::RANGE; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_where(const int fd, dumb_ptr sd, +static +ATCE atcommand_where(const int fd, dumb_ptr sd, ZString message) { CharName character; @@ -814,7 +568,8 @@ int atcommand_where(const int fd, dumb_ptr sd, !((battle_config.hide_GM_session || bool(pl_sd->status.option & Option::HIDE)) && (pc_isGM(pl_sd) > pc_isGM(sd)))) - { // you can look only lower or same level + { + // you can look only lower or same level FString output = STRPRINTF("%s: %s (%d,%d)", pl_sd->status.name, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); @@ -823,17 +578,14 @@ int atcommand_where(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Character not found."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_goto(const int fd, dumb_ptr sd, +static +ATCE atcommand_goto(const int fd, dumb_ptr sd, ZString message) { CharName character; @@ -842,7 +594,7 @@ int atcommand_goto(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto )."); - return -1; + return ATCE::USAGE; } dumb_ptr pl_sd = map_nick2sd(character); @@ -853,14 +605,14 @@ int atcommand_goto(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "You are not authorised to warp you to the map of this player."); - return -1; + return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you from your actual map."); - return -1; + return ATCE::PERM; } pc_setpos(sd, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y, BeingRemoveWhy::WARPED); FString output = STRPRINTF("Jump to %s", character); @@ -869,17 +621,14 @@ int atcommand_goto(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Character not found."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_jump(const int fd, dumb_ptr sd, +static +ATCE atcommand_jump(const int fd, dumb_ptr sd, ZString message) { int x = 0, y = 0; @@ -897,14 +646,14 @@ int atcommand_jump(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "You are not authorised to warp you to your actual map."); - return -1; + return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you from your actual map."); - return -1; + return ATCE::PERM; } pc_setpos(sd, sd->mapname_, x, y, BeingRemoveWhy::WARPED); FString output = STRPRINTF("Jump to %d %d", x, y); @@ -913,17 +662,14 @@ int atcommand_jump(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Coordinates out of range."); - return -1; + return ATCE::RANGE; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_who(const int fd, dumb_ptr sd, +static +ATCE atcommand_who(const int fd, dumb_ptr sd, ZString message) { int count; @@ -979,14 +725,11 @@ int atcommand_who(const int fd, dumb_ptr sd, clif_displaymessage(fd, output); } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_whogroup(const int fd, dumb_ptr sd, +static +ATCE atcommand_whogroup(const int fd, dumb_ptr sd, ZString message) { int count; @@ -1040,14 +783,11 @@ int atcommand_whogroup(const int fd, dumb_ptr sd, clif_displaymessage(fd, output); } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_whomap(const int fd, dumb_ptr sd, +static +ATCE atcommand_whomap(const int fd, dumb_ptr sd, ZString message) { int count; @@ -1076,7 +816,8 @@ int atcommand_whomap(const int fd, dumb_ptr sd, ((battle_config.hide_GM_session || bool(pl_sd->status.option & Option::HIDE)) && (pl_GM_level > GM_level))) - { // you can look only lower or same level + { + // you can look only lower or same level if (pl_sd->bl_m == map_id) { FString output; @@ -1101,14 +842,11 @@ int atcommand_whomap(const int fd, dumb_ptr sd, count, map_id->name_); clif_displaymessage(fd, output); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_whomapgroup(const int fd, dumb_ptr sd, +static +ATCE atcommand_whomapgroup(const int fd, dumb_ptr sd, ZString message) { int count; @@ -1169,14 +907,11 @@ int atcommand_whomapgroup(const int fd, dumb_ptr sd, } clif_displaymessage(fd, output); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_whogm(const int fd, dumb_ptr sd, +static +ATCE atcommand_whogm(const int fd, dumb_ptr sd, ZString message) { int count; @@ -1243,31 +978,23 @@ int atcommand_whogm(const int fd, dumb_ptr sd, clif_displaymessage(fd, output); } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_save(const int fd, dumb_ptr sd, +static +ATCE atcommand_save(const int fd, dumb_ptr sd, ZString) { - nullpo_retr(-1, sd); - pc_setsavepoint(sd, sd->mapname_, sd->bl_x, sd->bl_y); pc_makesavestatus(sd); chrif_save(sd); clif_displaymessage(fd, "Character data respawn point saved."); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_load(const int fd, dumb_ptr sd, +static +ATCE atcommand_load(const int fd, dumb_ptr sd, ZString) { map_local *m = map_mapname2mapid(sd->status.save_point.map_); @@ -1276,28 +1003,25 @@ int atcommand_load(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "You are not authorised to warp you to your save map."); - return -1; + return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you from your actual map."); - return -1; + return ATCE::PERM; } pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x, sd->status.save_point.y, BeingRemoveWhy::GONE); clif_displaymessage(fd, "Warping to respawn point."); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_speed(const int fd, dumb_ptr sd, +static +ATCE atcommand_speed(const int fd, dumb_ptr sd, ZString message) { if (!message) @@ -1307,7 +1031,7 @@ int atcommand_speed(const int fd, dumb_ptr sd, static_cast(MIN_WALK_SPEED.count()), static_cast(MAX_WALK_SPEED.count())); clif_displaymessage(fd, output); - return -1; + return ATCE::USAGE; } interval_t speed = static_cast(atoi(message.c_str())); @@ -1326,59 +1050,46 @@ int atcommand_speed(const int fd, dumb_ptr sd, static_cast(MIN_WALK_SPEED.count()), static_cast(MAX_WALK_SPEED.count())); clif_displaymessage(fd, output); - return -1; + return ATCE::RANGE; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_storage(const int fd, dumb_ptr sd, +static +ATCE atcommand_storage(const int fd, dumb_ptr sd, ZString) { - struct storage *stor; //changes from Freya/Yor - nullpo_retr(-1, sd); + struct storage *stor; if (sd->state.storage_open) { clif_displaymessage(fd, "msg_table[250]"); - return -1; + return ATCE::EXIST; } if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) { clif_displaymessage(fd, "msg_table[250]"); - return -1; + return ATCE::EXIST; } storage_storageopen(sd); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_option(const int fd, dumb_ptr sd, +static +ATCE atcommand_option(const int fd, dumb_ptr sd, ZString message) { - nullpo_retr(-1, sd); - Opt1 param1 = Opt1::ZERO; Opt2 param2 = Opt2::ZERO; Option param3 = Option::ZERO; if (!extract(message, record<',', 1>(¶m1, ¶m2, ¶m3))) - { - clif_displaymessage(fd, - "Please, enter at least a option (usage: @option )."); - return -1; - } + return ATCE::USAGE; sd->opt1 = param1; sd->opt2 = param2; @@ -1388,88 +1099,73 @@ int atcommand_option(const int fd, dumb_ptr sd, pc_calcstatus(sd, 0); clif_displaymessage(fd, "Options changed."); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_hide(const int fd, dumb_ptr sd, +static +ATCE atcommand_hide(const int fd, dumb_ptr sd, ZString) { if (bool(sd->status.option & Option::HIDE)) { sd->status.option &= ~Option::HIDE; - clif_displaymessage(fd, "Invisible: Off."); // Invisible: Off + clif_displaymessage(fd, "Invisible: Off."); } else { sd->status.option |= Option::HIDE; - clif_displaymessage(fd, "Invisible: On."); // Invisible: On + clif_displaymessage(fd, "Invisible: On."); } clif_changeoption(sd); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_die(const int fd, dumb_ptr sd, +static +ATCE atcommand_die(const int fd, dumb_ptr sd, ZString) { pc_damage(NULL, sd, sd->status.hp + 1); clif_displaymessage(fd, "A pity! You've died."); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_kill(const int fd, dumb_ptr sd, +static +ATCE atcommand_kill(const int fd, dumb_ptr sd, ZString message) { CharName character; if (!asplit(message, &character)) - { - clif_displaymessage(fd, - "Please, enter a player name (usage: @kill )."); - return -1; - } + return ATCE::USAGE; dumb_ptr pl_sd = map_nick2sd(character); if (pl_sd != NULL) { if (pc_isGM(sd) >= pc_isGM(pl_sd)) - { // you can kill only lower or same level + { + // you can kill only lower or same level pc_damage(NULL, pl_sd, pl_sd->status.hp + 1); clif_displaymessage(fd, "Character killed."); } else { clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player."); - return -1; + return ATCE::PERM; } } else { clif_displaymessage(fd, "Character not found."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_alive(const int fd, dumb_ptr sd, +static +ATCE atcommand_alive(const int fd, dumb_ptr sd, ZString) { sd->status.hp = sd->status.max_hp; @@ -1482,36 +1178,26 @@ int atcommand_alive(const int fd, dumb_ptr sd, clif_resurrection(sd, 1); clif_displaymessage(fd, "You've been revived! It's a miracle!"); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_kami(const int fd, dumb_ptr, +static +ATCE atcommand_kami(const int, dumb_ptr, ZString message) { if (!message) - { - clif_displaymessage(fd, - "Please, enter a message (usage: @kami )."); - return -1; - } + return ATCE::USAGE; intif_GMmessage(message); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_heal(const int fd, dumb_ptr sd, +static +ATCE atcommand_heal(const int fd, dumb_ptr sd, ZString message) { - int hp = 0, sp = 0; // [Valaris] thanks to fov + int hp = 0, sp = 0; extract(message, record<' '>(&hp, &sp)); @@ -1522,17 +1208,22 @@ int atcommand_heal(const int fd, dumb_ptr sd, } else { - if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow + if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) + // fix positiv overflow hp = sd->status.max_hp - sd->status.hp; - else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow + else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) + // fix negativ overflow hp = 1 - sd->status.hp; - if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow + if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) + // fix positiv overflow sp = sd->status.max_sp - sd->status.sp; - else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow + else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) + // fix negativ overflow sp = 1 - sd->status.sp; } - if (hp < 0) // display like damage + if (hp < 0) + // display like damage clif_damage(sd, sd, gettick(), interval_t::zero(), interval_t::zero(), -hp, 0, DamageType::RETURNED, 0); if (hp != 0 || sp != 0) @@ -1546,17 +1237,14 @@ int atcommand_heal(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "HP and SP are already with the good value."); - return -1; + return ATCE::RANGE; } - return 0; + return ATCE::OKAY; } -/*========================================== - * @item command (usage: @item ) - *------------------------------------------ - */ -int atcommand_item(const int fd, dumb_ptr sd, +static +ATCE atcommand_item(const int fd, dumb_ptr sd, ZString message) { ItemName item_name; @@ -1568,7 +1256,7 @@ int atcommand_item(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "Please, enter an item name/id (usage: @item [quantity])."); - return -1; + return ATCE::USAGE; } if (number <= 0) @@ -1604,17 +1292,14 @@ int atcommand_item(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Invalid item ID or name."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_itemreset(const int fd, dumb_ptr sd, +static +ATCE atcommand_itemreset(const int fd, dumb_ptr sd, ZString) { int i; @@ -1627,26 +1312,20 @@ int atcommand_itemreset(const int fd, dumb_ptr sd, } clif_displaymessage(fd, "All of your items have been removed."); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_itemcheck(const int, dumb_ptr sd, +static +ATCE atcommand_itemcheck(const int, dumb_ptr sd, ZString) { pc_checkitem(sd); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_baselevelup(const int fd, dumb_ptr sd, +static +ATCE atcommand_baselevelup(const int fd, dumb_ptr sd, ZString message) { int level, i; @@ -1655,17 +1334,18 @@ int atcommand_baselevelup(const int fd, dumb_ptr sd, { clif_displaymessage(fd, "Please, enter a level adjustement (usage: @blvl )."); - return -1; + return ATCE::USAGE; } if (level > 0) { if (sd->status.base_level == battle_config.maximum_level) - { // check for max level by Valaris + { clif_displaymessage(fd, "Base level can't go any higher."); - return -1; - } // End Addition - if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow + return ATCE::RANGE; + } + if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) + // fix positiv overflow level = battle_config.maximum_level - sd->status.base_level; for (i = 1; i <= level; i++) sd->status.status_point += (sd->status.base_level + i + 14) / 4; @@ -1683,9 +1363,10 @@ int atcommand_baselevelup(const int fd, dumb_ptr sd, if (sd->status.base_level == 1) { clif_displaymessage(fd, "Base level can't go any lower."); - return -1; + return ATCE::USAGE; } - if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow + if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) + // fix negativ overflow level = 1 - sd->status.base_level; if (sd->status.status_point > 0) { @@ -1695,7 +1376,8 @@ int atcommand_baselevelup(const int fd, dumb_ptr sd, if (sd->status.status_point < 0) sd->status.status_point = 0; clif_updatestatus(sd, SP::STATUSPOINT); - } // to add: remove status points from stats + } + // to add: remove status points from stats sd->status.base_level += level; clif_updatestatus(sd, SP::BASELEVEL); clif_updatestatus(sd, SP::NEXTBASEEXP); @@ -1703,26 +1385,19 @@ int atcommand_baselevelup(const int fd, dumb_ptr sd, clif_displaymessage(fd, "Base level lowered."); } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ // TODO: merge this with pc_setparam(SP::JOBLEVEL) // then fix the funny 50 and/or 10 limitation. -int atcommand_joblevelup(const int fd, dumb_ptr sd, +static +ATCE atcommand_joblevelup(const int fd, dumb_ptr sd, ZString message) { int up_level = 50, level; if (!extract(message, &level) || !level) - { - clif_displaymessage(fd, - "Please, enter a level adjustement (usage: @jlvl )."); - return -1; - } + return ATCE::USAGE; up_level -= 40; @@ -1731,9 +1406,10 @@ int atcommand_joblevelup(const int fd, dumb_ptr sd, if (sd->status.job_level == up_level) { clif_displaymessage(fd, "Job level can't go any higher."); - return -1; + return ATCE::RANGE; } - if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow + if (level > up_level || level > (up_level - sd->status.job_level)) + // fix positiv overflow level = up_level - sd->status.job_level; sd->status.job_level += level; clif_updatestatus(sd, SP::JOBLEVEL); @@ -1749,9 +1425,10 @@ int atcommand_joblevelup(const int fd, dumb_ptr sd, if (sd->status.job_level == 1) { clif_displaymessage(fd, "Job level can't go any lower."); - return -1; + return ATCE::RANGE; } - if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow + if (level < -up_level || level < (1 - sd->status.job_level)) + // fix negativ overflow level = 1 - sd->status.job_level; sd->status.job_level += level; clif_updatestatus(sd, SP::JOBLEVEL); @@ -1762,84 +1439,43 @@ int atcommand_joblevelup(const int fd, dumb_ptr sd, if (sd->status.skill_point < 0) sd->status.skill_point = 0; clif_updatestatus(sd, SP::SKILLPOINT); - } // to add: remove status points from skills + } + // to add: remove status points from skills pc_calcstatus(sd, 0); clif_displaymessage(fd, "Job level lowered."); } - return 0; -} - -/*========================================== - * - *------------------------------------------ - */ -int atcommand_help(const int fd, dumb_ptr sd, - ZString) -{ - std::ifstream in(help_txt.c_str()); - if (in.is_open()) - { - clif_displaymessage(fd, "Help commands:"); - int gm_level = pc_isGM(sd); - FString line; - while (io::getline(in, line)) - { - XString w1; - ZString w2; - if (!split_key_value(line, &w1, &w2)) - continue; - int level; - extract(w1.strip(), &level); - if (gm_level >= level) - clif_displaymessage(fd, w2); - } - } - else - { - clif_displaymessage(fd, "File help.txt not found."); - return -1; - } - - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_gm(const int fd, dumb_ptr sd, +static +ATCE atcommand_gm(const int fd, dumb_ptr sd, ZString message) { if (!message) - { - clif_displaymessage(fd, - "Please, enter a password (usage: @gm )."); - return -1; - } + return ATCE::USAGE; if (pc_isGM(sd)) - { // a GM can not use this function. only a normal player (become gm is not for gm!) + { + // a GM can not use this function. only a normal player (become gm is not for gm!) clif_displaymessage(fd, "You already have some GM powers."); - return -1; + return ATCE::PERM; } else chrif_changegm(sd->status.account_id, message); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_pvpoff(const int fd, dumb_ptr sd, +static +ATCE atcommand_pvpoff(const int fd, dumb_ptr sd, ZString) { if (battle_config.pk_mode) - { //disable command if server is in PK mode [Valaris] + { + //disable command if server is in PK mode [Valaris] clif_displaymessage(fd, "This option cannot be used in PK Mode."); - return -1; + return ATCE::EXIST; } if (sd->bl_m->flag.pvp) @@ -1863,23 +1499,21 @@ int atcommand_pvpoff(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "PvP is already Off."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_pvpon(const int fd, dumb_ptr sd, +static +ATCE atcommand_pvpon(const int fd, dumb_ptr sd, ZString) { if (battle_config.pk_mode) - { //disable command if server is in PK mode [Valaris] + { + //disable command if server is in PK mode [Valaris] clif_displaymessage(fd, "This option cannot be used in PK Mode."); - return -1; + return ATCE::EXIST; } if (!sd->bl_m->flag.pvp && !sd->bl_m->flag.nopvp) @@ -1907,31 +1541,20 @@ int atcommand_pvpon(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "PvP is already On."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_model(const int fd, dumb_ptr sd, +static +ATCE atcommand_model(const int fd, dumb_ptr sd, ZString message) { int hair_style = 0, hair_color = 0, cloth_color = 0; if (!extract(message, record<' ', 1>(&hair_style, &hair_color, &cloth_color))) - { - FString output = STRPRINTF( - "Please, enter at least a value (usage: @model ).", - MIN_HAIR_STYLE, MAX_HAIR_STYLE, - MIN_HAIR_COLOR, MAX_HAIR_COLOR, - MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); - clif_displaymessage(fd, output); - return -1; - } + return ATCE::USAGE; if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE && hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR && @@ -1945,31 +1568,19 @@ int atcommand_model(const int fd, dumb_ptr sd, } } else - { - clif_displaymessage(fd, "An invalid number was specified."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * @dye && @ccolor - *------------------------------------------ - */ -int atcommand_dye(const int fd, dumb_ptr sd, +static +ATCE atcommand_dye(const int fd, dumb_ptr sd, ZString message) { int cloth_color = 0; if (!extract(message, &cloth_color)) - { - FString output = STRPRINTF( - "Please, enter a clothes color (usage: @dye/@ccolor ).", - MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); - clif_displaymessage(fd, output); - return -1; - } + return ATCE::USAGE; if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) { @@ -1979,31 +1590,19 @@ int atcommand_dye(const int fd, dumb_ptr sd, } } else - { - clif_displaymessage(fd, "An invalid number was specified."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * @hairstyle && @hstyle - *------------------------------------------ - */ -int atcommand_hair_style(const int fd, dumb_ptr sd, +static +ATCE atcommand_hair_style(const int fd, dumb_ptr sd, ZString message) { int hair_style = 0; if (!extract(message, &hair_style)) - { - FString output = STRPRINTF( - "Please, enter a hair style (usage: @hairstyle/@hstyle ).", - MIN_HAIR_STYLE, MAX_HAIR_STYLE); - clif_displaymessage(fd, output); - return -1; - } + return ATCE::USAGE; if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) { @@ -2013,31 +1612,19 @@ int atcommand_hair_style(const int fd, dumb_ptr sd, } } else - { - clif_displaymessage(fd, "An invalid number was specified."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * @haircolor && @hcolor - *------------------------------------------ - */ -int atcommand_hair_color(const int fd, dumb_ptr sd, +static +ATCE atcommand_hair_color(const int fd, dumb_ptr sd, ZString message) { int hair_color = 0; if (!extract(message, &hair_color)) - { - FString output = STRPRINTF( - "Please, enter a hair color (usage: @haircolor/@hcolor ).", - MIN_HAIR_COLOR, MAX_HAIR_COLOR); - clif_displaymessage(fd, output); - return -1; - } + return ATCE::USAGE; if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) { @@ -2047,19 +1634,13 @@ int atcommand_hair_color(const int fd, dumb_ptr sd, } } else - { - clif_displaymessage(fd, "An invalid number was specified."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_spawn(const int fd, dumb_ptr sd, +static +ATCE atcommand_spawn(const int fd, dumb_ptr sd, ZString message) { MobName monster; @@ -2071,20 +1652,15 @@ int atcommand_spawn(const int fd, dumb_ptr sd, int mx, my, range; if (!extract(message, record<' ', 1>(&monster, &number, &x, &y))) - { - clif_displaymessage(fd, "Give a monster name/id please."); - return -1; - } + return ATCE::USAGE; // If monster identifier/name argument is a name - if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number) + if ((mob_id = mobdb_searchname(monster)) == 0) + // check name first (to avoid possible name begining by a number) mob_id = mobdb_checkid(atoi(monster.c_str())); if (mob_id == 0) - { - clif_displaymessage(fd, "Invalid monster ID or name."); - return -1; - } + return ATCE::EXIST; if (number <= 0) number = 1; @@ -2100,7 +1676,8 @@ int atcommand_spawn(const int fd, dumb_ptr sd, count = 0; range = sqrt(number) / 2; - range = range * 2 + 5; // calculation of an odd number (+ 4 area around) + range = range * 2 + 5; + // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { j = 0; @@ -2133,16 +1710,12 @@ int atcommand_spawn(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Invalid monster ID or name."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ static void atcommand_killmonster_sub(const int fd, dumb_ptr sd, ZString message, const int drop) @@ -2165,22 +1738,15 @@ void atcommand_killmonster_sub(const int fd, dumb_ptr sd, clif_displaymessage(fd, "All monsters killed!"); } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_killmonster(const int fd, dumb_ptr sd, +static +ATCE atcommand_killmonster(const int fd, dumb_ptr sd, ZString message) { atcommand_killmonster_sub(fd, sd, message, 1); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ static void atlist_nearby_sub(dumb_ptr bl, int fd) { @@ -2191,11 +1757,8 @@ void atlist_nearby_sub(dumb_ptr bl, int fd) clif_displaymessage(fd, buf); } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_list_nearby(const int fd, dumb_ptr sd, +static +ATCE atcommand_list_nearby(const int fd, dumb_ptr sd, ZString) { clif_displaymessage(fd, "Nearby players:"); @@ -2205,26 +1768,20 @@ int atcommand_list_nearby(const int fd, dumb_ptr sd, sd->bl_x + 1, sd->bl_x + 1, BL::PC); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_killmonster2(const int fd, dumb_ptr sd, +static +ATCE atcommand_killmonster2(const int fd, dumb_ptr sd, ZString message) { atcommand_killmonster_sub(fd, sd, message, 0); - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_gat(const int fd, dumb_ptr sd, +static +ATCE atcommand_gat(const int fd, dumb_ptr sd, ZString) { int y; @@ -2242,51 +1799,39 @@ int atcommand_gat(const int fd, dumb_ptr sd, clif_displaymessage(fd, output); } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_packet(const int fd, dumb_ptr sd, +static +ATCE atcommand_packet(const int, dumb_ptr sd, ZString message) { StatusChange type {}; int flag = 0; if (!extract(message, record<' '>(&type, &flag))) - { - clif_displaymessage(fd, - "Please, enter a status type/flag (usage: @packet )."); - return -1; - } + return ATCE::USAGE; clif_status_change(sd, type, flag); - return 0; + return ATCE::OKAY; } -/*========================================== - * @stpoint (Rewritten by [Yor]) - *------------------------------------------ - */ -int atcommand_statuspoint(const int fd, dumb_ptr sd, +static +ATCE atcommand_statuspoint(const int fd, dumb_ptr sd, ZString message) { int point, new_status_point; if (!extract(message, &point) || point == 0) - { - clif_displaymessage(fd, - "Please, enter a number (usage: @stpoint )."); - return -1; - } + return ATCE::USAGE; new_status_point = sd->status.status_point + point; - if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow + if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) + // fix positiv overflow new_status_point = 0x7FFF; - else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow + else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) + // fix negativ overflow new_status_point = 0; if (new_status_point != sd->status.status_point) @@ -2296,37 +1841,26 @@ int atcommand_statuspoint(const int fd, dumb_ptr sd, clif_displaymessage(fd, "Number of status points changed!"); } else - { - if (point < 0) - clif_displaymessage(fd, "Impossible to decrease the number/value."); - else - clif_displaymessage(fd, "Impossible to increase the number/value."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * @skpoint (Rewritten by [Yor]) - *------------------------------------------ - */ -int atcommand_skillpoint(const int fd, dumb_ptr sd, +static +ATCE atcommand_skillpoint(const int fd, dumb_ptr sd, ZString message) { int point, new_skill_point; if (!extract(message, &point) || point == 0) - { - clif_displaymessage(fd, - "Please, enter a number (usage: @skpoint )."); - return -1; - } + return ATCE::USAGE; new_skill_point = sd->status.skill_point + point; - if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow + if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) + // fix positiv overflow new_skill_point = 0x7FFF; - else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow + else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) + // fix negativ overflow new_skill_point = 0; if (new_skill_point != sd->status.skill_point) @@ -2336,37 +1870,26 @@ int atcommand_skillpoint(const int fd, dumb_ptr sd, clif_displaymessage(fd, "Number of skill points changed!"); } else - { - if (point < 0) - clif_displaymessage(fd, "Impossible to decrease the number/value."); - else - clif_displaymessage(fd, "Impossible to increase the number/value."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * @zeny (Rewritten by [Yor]) - *------------------------------------------ - */ -int atcommand_zeny(const int fd, dumb_ptr sd, +static +ATCE atcommand_zeny(const int fd, dumb_ptr sd, ZString message) { int zeny, new_zeny; if (!extract(message, &zeny) || zeny == 0) - { - clif_displaymessage(fd, - "Please, enter an amount (usage: @zeny )."); - return -1; - } + return ATCE::USAGE; new_zeny = sd->status.zeny + zeny; - if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow + if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) + // fix positiv overflow new_zeny = MAX_ZENY; - else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow + else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) + // fix negativ overflow new_zeny = 0; if (new_zeny != sd->status.zeny) @@ -2376,41 +1899,27 @@ int atcommand_zeny(const int fd, dumb_ptr sd, clif_displaymessage(fd, "Number of zenys changed!"); } else - { - if (zeny < 0) - clif_displaymessage(fd, "Impossible to decrease the number/value."); - else - clif_displaymessage(fd, "Impossible to increase the number/value."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ template -int atcommand_param(const int fd, dumb_ptr sd, +ATCE atcommand_param(const int fd, dumb_ptr sd, ZString message) { int value = 0, new_value; if (!extract(message, &value) || value == 0) - { - // there was a clang bug here - // fortunately, STRPRINTF was not actually needed - clif_displaymessage(fd, - "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>)."); - return -1; - } + return ATCE::USAGE; new_value = sd->status.attrs[attr] + value; - if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow + if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) + // fix positiv overflow new_value = battle_config.max_parameter; - else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow + else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) + // fix negativ overflow new_value = 1; if (new_value != sd->status.attrs[attr]) @@ -2422,23 +1931,13 @@ int atcommand_param(const int fd, dumb_ptr sd, clif_displaymessage(fd, "Stat changed."); } else - { - if (value < 0) - clif_displaymessage(fd, "Impossible to decrease the number/value."); - else - clif_displaymessage(fd, "Impossible to increase the number/value."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -//** Stat all by fritz (rewritten by [Yor]) -int atcommand_all_stats(const int fd, dumb_ptr sd, +static +ATCE atcommand_all_stats(const int fd, dumb_ptr sd, ZString message) { int count, value = 0, new_value; @@ -2451,9 +1950,11 @@ int atcommand_all_stats(const int fd, dumb_ptr sd, for (ATTR attr : ATTRs) { new_value = sd->status.attrs[attr] + value; - if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow + if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) + // fix positiv overflow new_value = battle_config.max_parameter; - else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow + else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) + // fix negativ overflow new_value = 1; if (new_value != sd->status.attrs[attr]) @@ -2466,54 +1967,43 @@ int atcommand_all_stats(const int fd, dumb_ptr sd, } } - if (count > 0) // if at least 1 stat modified + if (count > 0) + // if at least 1 stat modified clif_displaymessage(fd, "All stats changed!"); else - { - if (value < 0) - clif_displaymessage(fd, "Impossible to decrease a stat."); - else - clif_displaymessage(fd, "Impossible to increase a stat."); - return -1; - } + return ATCE::RANGE; - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_recall(const int fd, dumb_ptr sd, +static +ATCE atcommand_recall(const int fd, dumb_ptr sd, ZString message) { CharName character; if (!asplit(message, &character)) - { - clif_displaymessage(fd, - "Please, enter a player name (usage: @recall )."); - return -1; - } + return ATCE::USAGE; dumb_ptr pl_sd = map_nick2sd(character); if (pl_sd != NULL) { if (pc_isGM(sd) >= pc_isGM(pl_sd)) - { // you can recall only lower or same level + { + // you can recall only lower or same level if (sd->bl_m && sd->bl_m->flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map."); - return -1; + return ATCE::PERM; } if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp this player from its actual map."); - return -1; + return ATCE::PERM; } pc_setpos(pl_sd, sd->mapname_, sd->bl_x, sd->bl_y, BeingRemoveWhy::QUIT); FString output = STRPRINTF("%s recalled!", character); @@ -2522,33 +2012,26 @@ int atcommand_recall(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player."); - return -1; + return ATCE::PERM; } } else { clif_displaymessage(fd, "Character not found."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_revive(const int fd, dumb_ptr sd, +static +ATCE atcommand_revive(const int fd, dumb_ptr sd, ZString message) { CharName character; if (!asplit(message, &character)) - { - clif_displaymessage(fd, - "Please, enter a player name (usage: @revive )."); - return -1; - } + return ATCE::USAGE; dumb_ptr pl_sd = map_nick2sd(character); if (pl_sd != NULL) @@ -2565,27 +2048,20 @@ int atcommand_revive(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Character not found."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_character_stats(const int fd, dumb_ptr, +static +ATCE atcommand_character_stats(const int fd, dumb_ptr, ZString message) { CharName character; if (!asplit(message, &character)) - { - clif_displaymessage(fd, - "Please, enter a player name (usage: @charstats )."); - return -1; - } + return ATCE::USAGE; dumb_ptr pl_sd = map_nick2sd(character); if (pl_sd != NULL) @@ -2623,18 +2099,14 @@ int atcommand_character_stats(const int fd, dumb_ptr, else { clif_displaymessage(fd, "Character not found."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::USAGE; } -/*========================================== - * - *------------------------------------------ - */ -//** Character Stats All by fritz -int atcommand_character_stats_all(const int fd, dumb_ptr, +static +ATCE atcommand_character_stats_all(const int fd, dumb_ptr, ZString) { int count; @@ -2686,14 +2158,11 @@ int atcommand_character_stats_all(const int fd, dumb_ptr, clif_displaymessage(fd, output); } - return 0; + return ATCE::OKAY; } -/*========================================== - * - *------------------------------------------ - */ -int atcommand_character_option(const int fd, dumb_ptr sd, +static +ATCE atcommand_character_option(const int fd, dumb_ptr sd, ZString message) { Opt1 opt1; @@ -2701,11 +2170,7 @@ int atcommand_character_option(const int fd, dumb_ptr sd, Option opt3; CharName character; if (!asplit(message, &opt1, &opt2, &opt3, &character)) - { - clif_displaymessage(fd, - "Please, enter valid options and a player name (usage: @charoption )."); - return -1; - } + return ATCE::USAGE; dumb_ptr pl_sd = map_nick2sd(character); if (pl_sd != NULL) @@ -2724,84 +2189,56 @@ int atcommand_character_option(const int fd, dumb_ptr sd, else { clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player."); - return -1; + return ATCE::PERM; } } else { clif_displaymessage(fd, "Character not found."); - return -1; + return ATCE::EXIST; } - return 0; + return ATCE::OKAY; } -/*========================================== - * charchangesex command (usage: charchangesex ) - *------------------------------------------ - */ -int atcommand_char_change_sex(const int fd, dumb_ptr sd, +static +ATCE atcommand_char_change_sex(const int fd, dumb_ptr sd, ZString message) { CharName character; if (!asplit(message, &character)) - { - clif_displaymessage(fd, - "Please, enter a player name (usage: @charchangesex )."); - return -1; - } + return ATCE::USAGE; { - chrif_char_ask_name(sd->status.account_id, character, 5, HumanTimeDiff()); // type: 5 - changesex + chrif_char_ask_name(sd->status.account_id, character, 5, HumanTimeDiff()); + // type: 5 - changesex clif_displaymessage(fd, "Character name sends to char-server to ask it."); } - return 0; + return ATCE::OKAY; } -/*========================================== - * charblock command (usage: charblock ) - * This command do a definitiv ban on a player - *------------------------------------------ - */ -int atcommand_char_block(const int fd, dumb_ptr sd, +static +ATCE atcommand_char_block(const int fd, dumb_ptr sd, ZString message) { CharName character; if (!asplit(message, &character)) - { - clif_displaymessage(fd, - "Please, enter a player name (usage: @block )."); - return -1; - } + return ATCE::USAGE; { - chrif_char_ask_name(sd->status.account_id, character, 1, HumanTimeDiff()); // type: 1 - block + chrif_char_ask_name(sd->status.account_id, character, 1, HumanTimeDiff()); + // type: 1 - block clif_displaymessage(fd, "Character name sends to char-server to ask it."); } - return 0; + return ATCE::OKAY; } -/*========================================== - * charban command (usage: charban