From fb97f35adeef33ad17061bffaed57842d9ceda47 Mon Sep 17 00:00:00 2001 From: ☈king Date: Sat, 2 Mar 2013 18:25:35 -0600 Subject: Remove atcommand_info's first (redundant) entry This was an experimental in pair programming. :) --- src/map/atcommand.cpp | 392 +++++++++++++++++++++++--------------------------- src/map/atcommand.hpp | 189 ------------------------ src/map/pc.cpp | 6 +- 3 files changed, 183 insertions(+), 404 deletions(-) (limited to 'src') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 27245b2..6abdfda 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -178,182 +178,180 @@ ATCOMMAND_FUNC(doomspot); *------------------------------------------ */ +struct AtCommandInfo +{ + const char *command; + int level; + int(*proc)(const int, struct map_session_data *, + const char *command, const char *message); +}; + // 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[] = { - {AtCommand_Setup, "@setup", 40, atcommand_setup}, - {AtCommand_CharWarp, "@charwarp", 60, atcommand_charwarp}, - {AtCommand_Warp, "@warp", 40, atcommand_warp}, - {AtCommand_Where, "@where", 1, atcommand_where}, - {AtCommand_Goto, "@goto", 20, atcommand_goto}, - {AtCommand_Jump, "@jump", 40, atcommand_jump}, - {AtCommand_Who, "@who", 20, atcommand_who}, - {AtCommand_WhoGroup, "@whogroup", 20, atcommand_whogroup}, - {AtCommand_WhoMap, "@whomap", 20, atcommand_whomap}, - {AtCommand_WhoMapGroup, "@whomapgroup", 20, atcommand_whomapgroup}, - {AtCommand_WhoGM, "@whogm", 20, atcommand_whogm}, // by Yor - {AtCommand_Save, "@save", 40, atcommand_save}, - {AtCommand_Load, "@return", 40, atcommand_load}, - {AtCommand_Load, "@load", 40, atcommand_load}, - {AtCommand_Speed, "@speed", 40, atcommand_speed}, - {AtCommand_Storage, "@storage", 1, atcommand_storage}, - {AtCommand_Option, "@option", 40, atcommand_option}, - {AtCommand_Hide, "@hide", 40, atcommand_hide}, // + /hide - {AtCommand_Die, "@die", 1, atcommand_die}, - {AtCommand_Kill, "@kill", 60, atcommand_kill}, - {AtCommand_Alive, "@alive", 60, atcommand_alive}, - {AtCommand_Kami, "@kami", 40, atcommand_kami}, - {AtCommand_Heal, "@heal", 40, atcommand_heal}, - {AtCommand_Item, "@item", 60, atcommand_item}, - {AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset}, - {AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck}, - {AtCommand_BaseLevelUp, "@blvl", 60, atcommand_baselevelup}, - {AtCommand_JobLevelUp, "@jlvl", 60, atcommand_joblevelup}, - {AtCommand_Help, "@help", 20, atcommand_help}, - {AtCommand_GM, "@gm", 100, atcommand_gm}, - {AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff}, - {AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon}, - {AtCommand_Model, "@model", 20, atcommand_model}, - {AtCommand_Spawn, "@spawn", 50, atcommand_spawn}, - {AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster}, - {AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2}, - {AtCommand_GAT, "@gat", 99, atcommand_gat}, // debug function - {AtCommand_Packet, "@packet", 99, atcommand_packet}, // debug function - {AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint}, - {AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint}, - {AtCommand_Zeny, "@zeny", 60, atcommand_zeny}, - {AtCommand_Strength, "@str", 60, atcommand_param}, - {AtCommand_Agility, "@agi", 60, atcommand_param}, - {AtCommand_Vitality, "@vit", 60, atcommand_param}, - {AtCommand_Intelligence, "@int", 60, atcommand_param}, - {AtCommand_Dexterity, "@dex", 60, atcommand_param}, - {AtCommand_Luck, "@luk", 60, atcommand_param}, - {AtCommand_Recall, "@recall", 60, atcommand_recall}, // + /recall - {AtCommand_Revive, "@revive", 60, atcommand_revive}, - {AtCommand_CharacterStats, "@charstats", 40, atcommand_character_stats}, - {AtCommand_CharacterStatsAll, "@charstatsall", 40, - atcommand_character_stats_all}, - {AtCommand_CharacterOption, "@charoption", 60, - atcommand_character_option}, - {AtCommand_CharacterSave, "@charsave", 60, atcommand_character_save}, - {AtCommand_Doom, "@doom", 80, atcommand_doom}, - {AtCommand_DoomMap, "@doommap", 80, atcommand_doommap}, - {AtCommand_Raise, "@raise", 80, atcommand_raise}, - {AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap}, - {AtCommand_CharacterBaseLevel, "@charbaselvl", 60, - atcommand_character_baselevel}, - {AtCommand_CharacterJobLevel, "@charjlvl", 60, - atcommand_character_joblevel}, - {AtCommand_Kick, "@kick", 20, atcommand_kick}, // + right click menu for GM "(name) force to quit" - {AtCommand_KickAll, "@kickall", 99, atcommand_kickall}, - {AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill}, - {AtCommand_CharQuestSkill, "@charquestskill", 60, - atcommand_charquestskill}, - {AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill}, - {AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill}, - {AtCommand_Party, "@party", 1, atcommand_party}, - {AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit}, - {AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch}, - {AtCommand_MapMove, "@mapmove", 40, atcommand_warp}, // /mm command - {AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast}, // /b and /nb command - {AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast}, // /lb and /nlb command - {AtCommand_RecallAll, "@recallall", 80, atcommand_recallall}, - {AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset}, - {AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset}, - {AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb}, // admin command - {AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb}, // admin command - {AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb}, // admin command - {AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript}, // admin command - {AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb}, // admin command - {AtCommand_CharReset, "@charreset", 60, atcommand_charreset}, - {AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel}, - {AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint}, - {AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint}, - {AtCommand_CharZeny, "@charzeny", 60, atcommand_charzeny}, - {AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo}, - {AtCommand_Dye, "@dye", 40, atcommand_dye}, // by fritz - {AtCommand_Dye, "@ccolor", 40, atcommand_dye}, // by fritz - {AtCommand_HairStyle, "@hairstyle", 40, atcommand_hair_style}, // by fritz - {AtCommand_HairColor, "@haircolor", 40, atcommand_hair_color}, // by fritz - {AtCommand_AllStats, "@allstats", 60, atcommand_all_stats}, // by fritz - {AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex}, // by Yor - {AtCommand_CharBlock, "@block", 60, atcommand_char_block}, // by Yor - {AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock}, // by Yor - {AtCommand_CharBan, "@ban", 60, atcommand_char_ban}, // by Yor - {AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban}, // by Yor - {AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy}, // [Syrus22] - {AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall}, // by Yor - {AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc}, // [] - {AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc}, // [] - {AtCommand_ServerTime, "@servertime", 0, atcommand_servertime}, // by Yor - {AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem}, // by Yor - {AtCommand_ListNearby, "@listnearby", 40, atcommand_list_nearby}, // by Yor - {AtCommand_IgnoreList, "@ignorelist", 0, atcommand_ignorelist}, // by Yor - {AtCommand_CharIgnoreList, "@charignorelist", 20, atcommand_charignorelist}, // by Yor - {AtCommand_IgnoreList, "@inall", 20, atcommand_inall}, // by Yor - {AtCommand_ExAll, "@exall", 20, atcommand_exall}, // by Yor - {AtCommand_EMail, "@email", 0, atcommand_email}, // by Yor - {AtCommand_Effect, "@effect", 40, atcommand_effect}, // by Apple - {AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list}, // by Yor - {AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list}, // by Yor - {AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list}, // by Yor - {AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp}, // by MouseJstr - {AtCommand_Killer, "@killer", 60, atcommand_killer}, // by MouseJstr - {AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove}, // by MouseJstr - {AtCommand_Killable, "@killable", 40, atcommand_killable}, // by MouseJstr - {AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable}, // by MouseJstr - {AtCommand_Chareffect, "@chareffect", 40, atcommand_chareffect}, // MouseJstr - {AtCommand_Dropall, "@dropall", 40, atcommand_dropall}, // MouseJstr - {AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall}, // MouseJstr - {AtCommand_Storeall, "@storeall", 40, atcommand_storeall}, // MouseJstr - {AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall}, // MouseJstr - {AtCommand_Rain, "@rain", 99, atcommand_rain}, - {AtCommand_Snow, "@snow", 99, atcommand_snow}, - {AtCommand_Sakura, "@sakura", 99, atcommand_sakura}, - {AtCommand_Fog, "@fog", 99, atcommand_fog}, - {AtCommand_Leaves, "@leaves", 99, atcommand_leaves}, - //{ AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle }, - //{ AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance }, - //{ AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect }, - {AtCommand_Summon, "@summon", 60, atcommand_summon}, - {AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl}, - {AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl}, - {AtCommand_Trade, "@trade", 60, atcommand_trade}, - {AtCommand_UnMute, "@charwipe", 60, atcommand_char_wipe}, // [Fate] - {AtCommand_SetMagic, "@setmagic", 99, atcommand_set_magic}, // [Fate] - {AtCommand_MagicInfo, "@magicinfo", 60, atcommand_magic_info}, // [Fate] - {AtCommand_Log, "@log", 60, atcommand_log}, // [Fate] - {AtCommand_Log, "@l", 60, atcommand_log}, // [Fate] - {AtCommand_Tee, "@tee", 60, atcommand_tee}, // [Fate] - {AtCommand_Tee, "@t", 60, atcommand_tee}, // [Fate] - {AtCommand_Invisible, "@invisible", 60, atcommand_invisible}, // [Fate] - {AtCommand_Visible, "@visible", 60, atcommand_visible}, // [Fate] - {AtCommand_IterateForward, "@hugo", 60, atcommand_iterate_forward_over_players}, // [Fate] - {AtCommand_IterateBackward, "@linus", 60, atcommand_iterate_backwards_over_players}, // [Fate] - {AtCommand_IterateBackward, "@sp-info", 40, atcommand_skillpool_info}, // [Fate] - {AtCommand_IterateBackward, "@sp-focus", 80, atcommand_skillpool_focus}, // [Fate] - {AtCommand_IterateBackward, "@sp-unfocus", 80, atcommand_skillpool_unfocus}, // [Fate] - {AtCommand_IterateBackward, "@skill-learn", 80, atcommand_skill_learn}, // [Fate] - {AtCommand_Wgm, "@wgm", 0, atcommand_wgm}, - {AtCommand_IpCheck, "@ipcheck", 60, atcommand_ipcheck}, - {AtCommand_DoomSpot, "@doomspot", 60, atcommand_doomspot}, + {"@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 + {"@ignorelist", 0, atcommand_ignorelist}, // by Yor + {"@charignorelist", 20, atcommand_charignorelist}, // by Yor + {"@inall", 20, atcommand_inall}, // by Yor + {"@exall", 20, atcommand_exall}, // 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 + {"@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 - {AtCommand_Unknown, NULL, 1, NULL} + {NULL, 1, NULL} }; /*========================================== * get_atcommand_level @コマンドの必要レベルを取得 *------------------------------------------ */ -int get_atcommand_level(const AtCommandType type) +static +int get_atcommand_level(const AtCommandInfo *type) { - int i; - - for (i = 0; atcommand_info[i].type != AtCommand_None; i++) - if (atcommand_info[i].type == type) - return atcommand_info[i].level; + if (type) + return type->level; return 100; // 100: command can not be used } @@ -418,8 +416,7 @@ FILE *get_gm_log() } static -AtCommandType atcommand(const int level, const char *message, - struct AtCommandInfo * info); +AtCommandInfo *atcommand(const int level, const char *message); /*========================================== *is_atcommand @コマンドに存在するかどうか確認する *------------------------------------------ @@ -427,18 +424,21 @@ AtCommandType atcommand(const int level, const char *message, bool is_atcommand(const int fd, struct map_session_data *sd, const char *message, int gmlvl) { - AtCommandInfo info; - AtCommandType type; - nullpo_retr(false, sd); - if (!message || !*message) + if (!message || message[0] != '@') return false; - memset(&info, 0, sizeof(info)); + AtCommandInfo *info = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), message); + + if (!info) + { + std::string output = STRPRINTF("GM command not found: %s", + info->command); + clif_displaymessage(fd, output); + return true; // don't show in chat + } - type = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), message, &info); - if (type != AtCommand_None) { char command[100]; const char *str = message; @@ -452,15 +452,8 @@ bool is_atcommand(const int fd, struct map_session_data *sd, while (isspace(*p)) p++; - if (type == AtCommand_Unknown || info.proc == NULL) - { - std::string output = STRPRINTF("%s is Unknown Command.", - command); - clif_displaymessage(fd, output); - } - else { - if (info.proc(fd, sd, command, p) != 0) + if (info->proc(fd, sd, command, p) != 0) { // Command can not be executed std::string output = STRPRINTF("%s failed.", command); @@ -468,70 +461,49 @@ bool is_atcommand(const int fd, struct map_session_data *sd, } else { - if (get_atcommand_level(type) != 0) // Don't log level 0 commands + if (get_atcommand_level(info) != 0) // Don't log level 0 commands log_atcommand(sd, message); } } return true; } - - return false; } /*========================================== * *------------------------------------------ */ -AtCommandType atcommand(const int level, const char *message, - struct AtCommandInfo * info) +AtCommandInfo *atcommand(const int level, const char *message) { const char *p = message; - if (!info) - return AtCommand_None; if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd) - return AtCommand_None; + return nullptr; if (!p || !*p) { FPRINTF(stderr, "at command message is empty\n"); - return AtCommand_None; + return nullptr; } if (*p == '@') { // check first char. char command[101]; int i = 0; - memset(info, 0, sizeof(AtCommandInfo)); sscanf(p, "%100s", command); command[sizeof(command) - 1] = '\0'; - while (atcommand_info[i].type != AtCommand_Unknown) + while (atcommand_info[i].command) { if (strcasecmp(command, atcommand_info[i].command) == 0 && level >= atcommand_info[i].level) { - break; + return &atcommand_info[i]; } i++; } - - if (atcommand_info[i].type == AtCommand_Unknown) - { - // doesn't return Unknown if player is normal player (display the text, not display: unknown command) - if (level == 0) - return AtCommand_None; - else - return AtCommand_Unknown; - } - memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]); } - else - { - return AtCommand_None; - } - - return info->type; + return nullptr; } /*========================================== @@ -559,7 +531,7 @@ AtCommandInfo *get_atcommandinfo_byname(const char *name) { int i; - for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++) + for (i = 0; atcommand_info[i].command; i++) if (strcasecmp(atcommand_info[i].command + 1, name) == 0) return &atcommand_info[i]; @@ -6108,7 +6080,7 @@ int atcommand_adjcmdlvl(const int fd, struct map_session_data *, return -1; } - for (i = 0; atcommand_info[i].type != AtCommand_None; i++) + for (i = 0; atcommand_info[i].command; i++) if (strcasecmp(cmd, atcommand_info[i].command + 1) == 0) { atcommand_info[i].level = newlev; diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp index 5db9287..a226b76 100644 --- a/src/map/atcommand.hpp +++ b/src/map/atcommand.hpp @@ -3,198 +3,9 @@ #include "../common/const_array.hpp" -enum AtCommandType -{ - AtCommand_None = -1, - AtCommand_Broadcast = 0, - AtCommand_Setup, - AtCommand_LocalBroadcast, - AtCommand_MapMove, - AtCommand_ResetState, - AtCommand_CharWarp, - AtCommand_Warp, - AtCommand_Where, - AtCommand_Goto, - AtCommand_Jump, - AtCommand_Who, - AtCommand_WhoGroup, - AtCommand_WhoMap, - AtCommand_WhoMapGroup, - AtCommand_WhoGM, - AtCommand_Save, - AtCommand_Load, - AtCommand_Speed, - AtCommand_Storage, - AtCommand_Option, - AtCommand_Hide, - AtCommand_Die, - AtCommand_Kill, - AtCommand_Alive, - AtCommand_Kami, - AtCommand_KamiB, - AtCommand_Heal, - AtCommand_Item, - AtCommand_ItemReset, - AtCommand_ItemCheck, - AtCommand_BaseLevelUp, - AtCommand_JobLevelUp, - AtCommand_Help, - AtCommand_GM, - AtCommand_PvPOff, - AtCommand_PvPOn, - AtCommand_GvGOff, - AtCommand_GvGOn, - AtCommand_Model, - AtCommand_Go, - AtCommand_Spawn, - AtCommand_Monster, - AtCommand_KillMonster, - AtCommand_KillMonster2, - AtCommand_Produce, - AtCommand_Memo, - AtCommand_GAT, - AtCommand_Packet, - AtCommand_StatusPoint, - AtCommand_SkillPoint, - AtCommand_Zeny, - AtCommand_Param, - AtCommand_Strength, - AtCommand_Agility, - AtCommand_Vitality, - AtCommand_Intelligence, - AtCommand_Dexterity, - AtCommand_Luck, - AtCommand_Recall, - AtCommand_Revive, - AtCommand_CharacterStats, - AtCommand_CharacterStatsAll, - AtCommand_CharacterOption, - AtCommand_CharacterSave, - AtCommand_CharacterLoad, - AtCommand_Night, - AtCommand_Day, - AtCommand_Doom, - AtCommand_DoomMap, - AtCommand_Raise, - AtCommand_RaiseMap, - AtCommand_CharacterBaseLevel, - AtCommand_CharacterJobLevel, - AtCommand_Kick, - AtCommand_KickAll, - AtCommand_AllSkills, - AtCommand_QuestSkill, - AtCommand_CharQuestSkill, - AtCommand_LostSkill, - AtCommand_CharLostSkill, - AtCommand_Party, - AtCommand_MapExit, - AtCommand_IDSearch, - AtCommand_CharSkReset, - AtCommand_CharStReset, - AtCommand_CharReset, - //by chbrules - AtCommand_CharModel, - AtCommand_CharSKPoint, - AtCommand_CharSTPoint, - AtCommand_CharZeny, - AtCommand_RecallAll, - AtCommand_ReloadItemDB, - AtCommand_ReloadMobDB, - AtCommand_ReloadSkillDB, - AtCommand_ReloadScript, - AtCommand_ReloadGMDB, - AtCommand_MapInfo, - AtCommand_Dye, - AtCommand_HairStyle, - AtCommand_HairColor, - AtCommand_AllStats, - AtCommand_CharChangeSex, // by Yor - AtCommand_CharBlock, // by Yor - AtCommand_CharBan, // by Yor - AtCommand_CharUnBlock, // by Yor - AtCommand_CharUnBan, // by Yor - AtCommand_MountPeco, // by Valaris - AtCommand_CharMountPeco, // by Yor - AtCommand_PartySpy, // [Syrus22] - AtCommand_PartyRecall, // by Yor - AtCommand_Enablenpc, - AtCommand_Disablenpc, - AtCommand_ServerTime, // by Yor - AtCommand_CharDelItem, // by Yor - AtCommand_Jail, // by Yor - AtCommand_UnJail, // by Yor - AtCommand_Disguise, // [Valaris] - AtCommand_UnDisguise, // by Yor - AtCommand_IgnoreList, // by Yor - AtCommand_CharIgnoreList, // by Yor - AtCommand_InAll, // by Yor - AtCommand_ExAll, // by Yor - AtCommand_CharDisguise, // Kalaspuff - AtCommand_CharUnDisguise, // Kalaspuff - AtCommand_EMail, // by Yor - AtCommand_Hatch, - AtCommand_Effect, // by Apple - AtCommand_Char_Item_List, // by Yor - AtCommand_Char_Storage_List, // by Yor - AtCommand_Char_Cart_List, // by Yor - AtCommand_AddWarp, // by MouseJstr - AtCommand_SkillOn, // by MouseJstr - AtCommand_SkillOff, // by MouseJstr - AtCommand_Killer, // by MouseJstr - AtCommand_NpcMove, // by MouseJstr - AtCommand_Killable, // by MouseJstr - AtCommand_CharKillable, // by MouseJstr - AtCommand_Chareffect, // by MouseJstr - AtCommand_Dropall, // by MouseJstr - AtCommand_Chardropall, // by MouseJstr - AtCommand_Storeall, // by MouseJstr - AtCommand_Charstoreall, // by MouseJstr - AtCommand_Skillid, // by MouseJstr - AtCommand_Useskill, // by MouseJstr - AtCommand_Summon, - AtCommand_Rain, - AtCommand_Snow, - AtCommand_Sakura, - AtCommand_Fog, - AtCommand_Leaves, - AtCommand_AdjGmLvl, - AtCommand_AdjCmdLvl, - AtCommand_Trade, - AtCommand_UnMute, - AtCommand_CharWipe, - AtCommand_SetMagic, - AtCommand_MagicInfo, - AtCommand_Log, - AtCommand_Tee, - AtCommand_Invisible, - AtCommand_Visible, - AtCommand_IterateForward, - AtCommand_IterateBackward, - AtCommand_Wgm, - AtCommand_IpCheck, - AtCommand_ListNearby, // [fate] - AtCommand_DoomSpot, - // end - AtCommand_Unknown, - AtCommand_MAX, -}; - -typedef enum AtCommandType AtCommandType; - -typedef struct AtCommandInfo -{ - AtCommandType type; - const char *command; - int level; - int(*proc)(const int, struct map_session_data *, - const char *command, const char *message); -} AtCommandInfo; - bool is_atcommand(const int fd, struct map_session_data *sd, const char *message, int gmlvl); -int get_atcommand_level(const AtCommandType type); - int atcommand_config_read(const char *cfgName); void log_atcommand(struct map_session_data *sd, const_string cmd); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 883d9bb..e355063 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -704,11 +704,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, sd->sc_data[i].val1 = 0; } sd->sc_count = 0; - if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && - (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) - sd->status.option &= Option::HIDE; - else - sd->status.option = Option::ZERO; + sd->status.option = Option::ZERO; // init ignore list memset(sd->ignore, 0, sizeof(sd->ignore)); -- cgit v1.2.3-60-g2f50