diff options
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 1148 |
1 files changed, 808 insertions, 340 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2beb6c634..0a1fd6da3 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2016 Hercules Dev Team + * Copyright (C) 2012-2018 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -28,6 +28,7 @@ #include "map/channel.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/duel.h" #include "map/elemental.h" @@ -54,12 +55,14 @@ #include "map/storage.h" #include "map/trade.h" #include "map/unit.h" +#include "map/achievement.h" #include "common/cbasetypes.h" #include "common/conf.h" #include "common/core.h" #include "common/memmgr.h" #include "common/mmo.h" // MAX_CARTS #include "common/nullpo.h" +#include "common/packets.h" #include "common/random.h" #include "common/showmsg.h" #include "common/socket.h" @@ -73,14 +76,15 @@ #include <stdlib.h> #include <string.h> -struct atcommand_interface atcommand_s; +static struct atcommand_interface atcommand_s; struct atcommand_interface *atcommand; static char atcmd_output[CHAT_SIZE_MAX]; static char atcmd_player_name[NAME_LENGTH]; // @commands (script-based) -struct atcmd_binding_data* get_atcommandbind_byname(const char* name) { +static struct atcmd_binding_data *get_atcommandbind_byname(const char *name) +{ int i = 0; nullpo_retr(NULL, name); @@ -92,14 +96,16 @@ struct atcmd_binding_data* get_atcommandbind_byname(const char* name) { return ( i < atcommand->binding_count ) ? atcommand->binding[i] : NULL; } -const char* atcommand_msgsd(struct map_session_data *sd, int msg_number) { +static const char *atcommand_msgsd(struct map_session_data *sd, int msg_number) +{ Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG && atcommand->msg_table[0][msg_number] != NULL); if (!sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number]) return atcommand->msg_table[0][msg_number]; return atcommand->msg_table[sd->lang_id][msg_number]; } -const char* atcommand_msgfd(int fd, int msg_number) { +static const char *atcommand_msgfd(int fd, int msg_number) +{ struct map_session_data *sd = sockt->session_is_valid(fd) ? sockt->session[fd]->session_data : NULL; Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG && atcommand->msg_table[0][msg_number] != NULL); if (!sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number]) @@ -110,7 +116,8 @@ const char* atcommand_msgfd(int fd, int msg_number) { //----------------------------------------------------------- // Return the message string of the specified number by [Yor] //----------------------------------------------------------- -const char* atcommand_msg(int msg_number) { +static const char *atcommand_msg(int msg_number) +{ Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG); if (atcommand->msg_table[map->default_lang_id][msg_number] != NULL && atcommand->msg_table[map->default_lang_id][msg_number][0] != '\0') return atcommand->msg_table[map->default_lang_id][msg_number]; @@ -128,7 +135,8 @@ const char* atcommand_msg(int msg_number) { * @param[in] allow_override whether to allow duplicate message IDs to override the original value. * @return success state. */ -bool msg_config_read(const char *cfg_name, bool allow_override) { +static bool msg_config_read(const char *cfg_name, bool allow_override) +{ int msg_number; char line[1024], w1[1024], w2[1024]; FILE *fp; @@ -175,7 +183,8 @@ bool msg_config_read(const char *cfg_name, bool allow_override) { /*========================================== * Cleanup Message Data *------------------------------------------*/ -void do_final_msg(void) { +static void do_final_msg(void) +{ int i, j; for(i = 0; i < atcommand->max_message_table; i++) { @@ -193,7 +202,8 @@ void do_final_msg(void) { /** * retrieves the help string associated with a given command. */ -static inline const char* atcommand_help_string(AtCommandInfo *info) { +static inline const char *atcommand_help_string(AtCommandInfo *info) +{ return info->help; } @@ -253,12 +263,15 @@ ACMD(send) if (len) { // show packet length - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, clif->packet(type)->len); // Packet 0x%x length: %d + Assert_retr(false, type <= MAX_PACKET_DB && type >= MIN_PACKET_DB); + len = packets->db[type]; + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, len); // Packet 0x%x length: %d clif->message(fd, atcmd_output); return true; } - len = clif->packet(type)->len; + Assert_retr(false, type <= MAX_PACKET_DB && type >= MIN_PACKET_DB); + len = packets->db[type]; if (len == -1) { // dynamic packet @@ -406,7 +419,7 @@ ACMD(send) SKIP_VALUE(message); } - if (clif->packet(type)->len == -1) { // send dynamic packet + if (packets->db[type] == -1) { // send dynamic packet WFIFOW(sd->fd,2)=TOW(off); WFIFOSET(sd->fd,off); } else {// send static packet @@ -430,7 +443,8 @@ ACMD(send) /*========================================== * @rura, @warp, @mapmove *------------------------------------------*/ -ACMD(mapmove) { +ACMD(mapmove) +{ char map_name[MAP_NAME_LENGTH_EXT]; unsigned short map_index; short x = 0, y = 0; @@ -485,7 +499,8 @@ ACMD(mapmove) { /*========================================== * Displays where a character is. Corrected version by Silent. [Skotlex] *------------------------------------------*/ -ACMD(where) { +ACMD(where) +{ struct map_session_data* pl_sd; memset(atcmd_player_name, '\0', sizeof atcmd_player_name); @@ -513,7 +528,8 @@ ACMD(where) { /*========================================== * *------------------------------------------*/ -ACMD(jumpto) { +ACMD(jumpto) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -596,7 +612,8 @@ ACMD(jump) * Display list of online characters with * various info. *------------------------------------------*/ -ACMD(who) { +ACMD(who) +{ const struct map_session_data *pl_sd = NULL; struct s_mapiterator *iter = NULL; char player_name[NAME_LENGTH] = ""; @@ -793,7 +810,8 @@ ACMD(save) /*========================================== * *------------------------------------------*/ -ACMD(load) { +ACMD(load) +{ int16 m; m = map->mapindex2mapid(sd->status.save_point.map); @@ -931,7 +949,8 @@ ACMD(option) /*========================================== * *------------------------------------------*/ -ACMD(hide) { +ACMD(hide) +{ if (pc_isinvisible(sd)) { sd->sc.option &= ~OPTION_INVISIBLE; if (sd->disguise != -1 ) @@ -950,6 +969,7 @@ ACMD(hide) { //bugreport:2266 map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); } else { + clif->clearunit_area(&sd->bl, CLR_OUTSIGHT); sd->sc.option |= OPTION_INVISIBLE; sd->vd.class = INVISIBLE_CLASS; clif->message(fd, msg_fd(fd,11)); // Invisible: On @@ -1115,7 +1135,7 @@ ACMD(heal) } if ( hp > 0 && sp >= 0 ) { - if(!status->heal(&sd->bl, hp, sp, 0)) + if (status->heal(&sd->bl, hp, sp, STATUS_HEAL_DEFAULT) == 0) clif->message(fd, msg_fd(fd,157)); // HP and SP are already with the good value. else clif->message(fd, msg_fd(fd,17)); // HP, SP recovered. @@ -1132,7 +1152,7 @@ ACMD(heal) //Opposing signs. if ( hp ) { if (hp > 0) - status->heal(&sd->bl, hp, 0, 0); + status->heal(&sd->bl, hp, 0, STATUS_HEAL_DEFAULT); else { status->damage(NULL, &sd->bl, -hp, 0, 0, 0); clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, BDT_ENDURE, 0); @@ -1141,7 +1161,7 @@ ACMD(heal) if ( sp ) { if (sp > 0) - status->heal(&sd->bl, 0, sp, 0); + status->heal(&sd->bl, 0, sp, STATUS_HEAL_DEFAULT); else status->damage(NULL, &sd->bl, 0, -sp, 0, 0); } @@ -1339,9 +1359,7 @@ ACMD(item2) *------------------------------------------*/ ACMD(itemreset) { - int i; - - for (i = 0; i < MAX_INVENTORY; i++) { + for (int i = 0; i < sd->status.inventorySize; i++) { if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) { pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_COMMAND); } @@ -1406,9 +1424,13 @@ ACMD(baselevelup) clif->updatestatus(sd, SP_BASEEXP); clif->updatestatus(sd, SP_NEXTBASEEXP); pc->baselevelchanged(sd); + + // achievements + achievement->validate_stats(sd, SP_BASELEVEL, sd->status.base_level); + if(sd->status.party_id) party->send_levelup(sd); - + if (level > 0 && battle_config.atcommand_levelup_events) npc->script_event(sd, NPCE_BASELVUP); // Trigger OnPCBaseLvUpEvent @@ -1471,7 +1493,8 @@ ACMD(joblevelup) /*========================================== * @help *------------------------------------------*/ -ACMD(help) { +ACMD(help) +{ const char *command_name = NULL; char *default_command = "help"; AtCommandInfo *tinfo = NULL; @@ -1539,7 +1562,7 @@ ACMD(help) { * Arglist parameters: * - (int) id: If 0, stop any attacks. Otherwise, the target block list id to stop attacking. */ -int atcommand_stopattack(struct block_list *bl,va_list ap) +static int atcommand_stopattack(struct block_list *bl, va_list ap) { struct unit_data *ud = NULL; int id = 0; @@ -1558,7 +1581,7 @@ int atcommand_stopattack(struct block_list *bl,va_list ap) /*========================================== * *------------------------------------------*/ -int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) +static int atcommand_pvpoff_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd = NULL; nullpo_ret(bl); @@ -1596,7 +1619,7 @@ ACMD(pvpoff) /*========================================== * *------------------------------------------*/ -int atcommand_pvpon_sub(struct block_list *bl,va_list ap) +static int atcommand_pvpon_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd = NULL; nullpo_ret(bl); @@ -1604,7 +1627,8 @@ int atcommand_pvpon_sub(struct block_list *bl,va_list ap) sd = BL_UCAST(BL_PC, bl); if (sd->pvp_timer == INVALID_TIMER) { - sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); + if (!map->list[sd->bl.m].flag.pvp_nocalcrank) + sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -1638,7 +1662,8 @@ ACMD(pvpon) /*========================================== * *------------------------------------------*/ -ACMD(gvgoff) { +ACMD(gvgoff) +{ if (!map->list[sd->bl.m].flag.gvg) { clif->message(fd, msg_fd(fd,162)); // GvG is already Off. @@ -1677,6 +1702,45 @@ ACMD(gvgon) /*========================================== * *------------------------------------------*/ +ACMD(cvcoff) +{ + if (!map->list[sd->bl.m].flag.cvc) { + clif->message(fd, msg_fd(fd, 141)); // CvC is already Off. + return false; + } + + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); + map->list[sd->bl.m].flag.cvc = 0; + clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); + clif->maptypeproperty2(&sd->bl, ALL_SAMEMAP); + map->foreachinmap(atcommand->stopattack, sd->bl.m, BL_CHAR, 0); + clif->message(fd, msg_fd(fd, 137)); // CvC: Off. + + return true; +} + +/*========================================== + * + *------------------------------------------*/ +ACMD(cvcon) +{ + if (map->list[sd->bl.m].flag.cvc) { + clif->message(fd, msg_fd(fd, 142)); // CvC is already On. + return false; + } + + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_CVC_NAME)); + map->list[sd->bl.m].flag.cvc = 1; + clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); + clif->maptypeproperty2(&sd->bl, ALL_SAMEMAP); + clif->message(fd, msg_fd(fd, 138)); // CvC: On. + + return true; +} + +/*========================================== + * + *------------------------------------------*/ ACMD(model) { int hair_style = 0, hair_color = 0, cloth_color = 0; @@ -1714,7 +1778,12 @@ ACMD(bodystyle) memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (!*message || sscanf(message, "%d", &body_style) < 1) { + if (!pc->has_second_costume(sd)) { + clif->message(fd, msg_fd(fd, 35)); // This job has no alternate body styles. + return false; + } + + if (*message == '\0' || sscanf(message, "%d", &body_style) < 1) { sprintf(atcmd_output, "Please, enter a body style (usage: @bodystyle <body ID: %d-%d>).", MIN_BODY_STYLE, MAX_BODY_STYLE); clif->message(fd, atcmd_output); return false; @@ -1722,9 +1791,9 @@ ACMD(bodystyle) if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) { pc->changelook(sd, LOOK_BODY2, body_style); - clif->message(fd, msg_txt(36)); // Appearence changed. + clif->message(fd, msg_fd(fd, 36)); // Appearence changed. } else { - clif->message(fd, msg_txt(37)); // An invalid number was specified. + clif->message(fd, msg_fd(fd, 37)); // An invalid number was specified. return false; } @@ -1809,10 +1878,68 @@ ACMD(hair_color) return true; } +ACMD(setzone) +{ + char zone_name[MAP_ZONE_MAPFLAG_LENGTH]; + memset(zone_name, '\0', sizeof(zone_name)); + + char fmt_str[8] = ""; + safesnprintf(fmt_str, 8, "%%%ds", MAP_ZONE_MAPFLAG_LENGTH - 1); + + if (*message == '\0' || sscanf(message, fmt_str, zone_name) < 1) { + clif->message(fd, msg_fd(fd, 924)); // usage info + return false; + } + + struct map_zone_data *zone = strdb_get(map->zone_db, zone_name); + const char *prev_zone_name = map->list[sd->bl.m].zone->name; + + // handle special zones: + if (zone == NULL && strcmp(zone_name, MAP_ZONE_NORMAL_NAME) == 0) { + zone = &map->zone_all; + } else if (zone == NULL && strcmp(zone_name, MAP_ZONE_PK_NAME) == 0) { + zone = &map->zone_pk; + } + + if (zone != NULL) { + if (map->list[sd->bl.m].zone != zone) { + if (strcmp(prev_zone_name, MAP_ZONE_PVP_NAME) == 0) { + atcommand_pvpoff(fd, sd, command, message, info); + } else if (strcmp(prev_zone_name, MAP_ZONE_GVG_NAME) == 0) { + atcommand_gvgoff(fd, sd, command, message, info); + } else if (strcmp(prev_zone_name, MAP_ZONE_CVC_NAME) == 0) { + atcommand_cvcoff(fd, sd, command, message, info); + } + } else { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 925), zone_name); + clif->message(fd, atcmd_output); // nothing to do + return false; + } + + if (strcmp(zone_name, MAP_ZONE_PVP_NAME) == 0) { + atcommand_pvpon(fd, sd, command, message, info); + } else if (strcmp(zone_name, MAP_ZONE_GVG_NAME) == 0) { + atcommand_gvgon(fd, sd, command, message, info); + } else if (strcmp(zone_name, MAP_ZONE_CVC_NAME) == 0) { + atcommand_cvcon(fd, sd, command, message, info); + } else { + map->zone_change2(sd->bl.m, zone); + } + } else { + clif->message(fd, msg_fd(fd, 926)); // zone not found + return false; + } + + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 927), prev_zone_name, zone_name); + clif->message(fd, atcmd_output); // changed successfully + return true; +} + /*========================================== * @go [city_number or city_name] - Updated by Harbin *------------------------------------------*/ -ACMD(go) { +ACMD(go) +{ int town = INT_MAX; // Initialized to INT_MAX instead of -1 to avoid conflicts with those who map [-3:-1] to @memo locations. char map_name[MAP_NAME_LENGTH]; @@ -1999,7 +2126,7 @@ ACMD(monster) number = 1; if (!name[0]) - strcpy(name, "--ja--"); + strcpy(name, DEFAULT_MOB_JNAME); // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit) @@ -2042,7 +2169,7 @@ ACMD(monster) /*========================================== * *------------------------------------------*/ -int atkillmonster_sub(struct block_list *bl, va_list ap) +static int atkillmonster_sub(struct block_list *bl, va_list ap) { struct mob_data *md = NULL; int flag = va_arg(ap, int); @@ -2060,7 +2187,8 @@ int atkillmonster_sub(struct block_list *bl, va_list ap) return 1; } -ACMD(killmonster) { +ACMD(killmonster) +{ int map_id, drop_flag; char map_name[MAP_NAME_LENGTH_EXT]; @@ -2257,7 +2385,8 @@ ACMD(memo) /*========================================== * *------------------------------------------*/ -ACMD(gat) { +ACMD(gat) +{ int y; memset(atcmd_output, '\0', sizeof(atcmd_output)); @@ -2403,7 +2532,8 @@ ACMD(zeny) /*========================================== * *------------------------------------------*/ -ACMD(param) { +ACMD(param) +{ int i, value = 0, new_value, max; const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" }; short* stats[6]; @@ -2449,6 +2579,7 @@ ACMD(param) { clif->updatestatus(sd, SP_USTR + i); status_calc_pc(sd, SCO_FORCE); clif->message(fd, msg_fd(fd,42)); // Stat changed. + achievement->validate_stats(sd, SP_STR + i, new_value); // Achievements [Smokexyz/Hercules] } else { if (value < 0) clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value. @@ -2463,7 +2594,8 @@ ACMD(param) { /*========================================== * Stat all by fritz (rewritten by [Yor]) *------------------------------------------*/ -ACMD(stat_all) { +ACMD(stat_all) +{ int index, count, value, max, new_value; short* stats[6]; //we don't use direct initialization because it isn't part of the c standard. @@ -2519,7 +2651,8 @@ ACMD(stat_all) { /*========================================== * *------------------------------------------*/ -ACMD(guildlevelup) { +ACMD(guildlevelup) +{ int level = 0; int16 added_level; struct guild *guild_info; @@ -2586,7 +2719,7 @@ ACMD(makeegg) intif->create_pet( sd->status.account_id, sd->status.char_id, (short)pet->db[pet_id].class_, (short)mob->db(pet->db[pet_id].class_)->lv, - (short)pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate, + pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate, 100, 0, 1, pet->db[pet_id].jname); } else { clif->message(fd, msg_fd(fd,180)); // The monster/egg name/id doesn't exist. @@ -2708,7 +2841,8 @@ ACMD(petrename) /*========================================== * *------------------------------------------*/ -ACMD(recall) { +ACMD(recall) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -2980,7 +3114,7 @@ ACMD(doommap) /*========================================== * *------------------------------------------*/ -void atcommand_raise_sub(struct map_session_data* sd) +static void atcommand_raise_sub(struct map_session_data *sd) { nullpo_retv(sd); status->revive(&sd->bl, 100, 100); @@ -3278,7 +3412,8 @@ ACMD(breakguild) /*========================================== * *------------------------------------------*/ -ACMD(agitstart) { +ACMD(agitstart) +{ if (map->agit_flag == 1) { clif->message(fd, msg_fd(fd,73)); // War of Emperium is currently in progress. return false; @@ -3294,7 +3429,8 @@ ACMD(agitstart) { /*========================================== * *------------------------------------------*/ -ACMD(agitstart2) { +ACMD(agitstart2) +{ if (map->agit2_flag == 1) { clif->message(fd, msg_fd(fd,404)); // "War of Emperium SE is currently in progress." return false; @@ -3310,7 +3446,8 @@ ACMD(agitstart2) { /*========================================== * *------------------------------------------*/ -ACMD(agitend) { +ACMD(agitend) +{ if (map->agit_flag == 0) { clif->message(fd, msg_fd(fd,75)); // War of Emperium is currently not in progress. return false; @@ -3326,7 +3463,8 @@ ACMD(agitend) { /*========================================== * *------------------------------------------*/ -ACMD(agitend2) { +ACMD(agitend2) +{ if (map->agit2_flag == 0) { clif->message(fd, msg_fd(fd,406)); // "War of Emperium SE is currently not in progress." return false; @@ -3342,7 +3480,8 @@ ACMD(agitend2) { /*========================================== * @mapexit - shuts down the map server *------------------------------------------*/ -ACMD(mapexit) { +ACMD(mapexit) +{ map->do_shutdown(); return true; } @@ -3552,7 +3691,8 @@ ACMD(reloaditemdb) /*========================================== * *------------------------------------------*/ -ACMD(reloadmobdb) { +ACMD(reloadmobdb) +{ mob->reload(); pet->read_db(); homun->reload(); @@ -3581,7 +3721,8 @@ ACMD(reloadskilldb) /*========================================== * @reloadatcommand - reloads conf/atcommand.conf conf/groups.conf *------------------------------------------*/ -ACMD(reloadatcommand) { +ACMD(reloadatcommand) +{ struct config_t run_test; if (!libconfig->load_file(&run_test, "conf/groups.conf")) { @@ -3655,13 +3796,14 @@ ACMD(reloadbattleconf) /*========================================== * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt *------------------------------------------*/ -ACMD(reloadstatusdb) { +ACMD(reloadstatusdb) +{ status->readdb(); clif->message(fd, msg_fd(fd,256)); return true; } /*========================================== - * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt + * @reloadpcdb - reloads exp_group_db.conf skill_tree.txt attr_fix.txt statpoint.txt *------------------------------------------*/ ACMD(reloadpcdb) { @@ -3673,7 +3815,8 @@ ACMD(reloadpcdb) /*========================================== * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...) *------------------------------------------*/ -ACMD(reloadscript) { +ACMD(reloadscript) +{ struct s_mapiterator* iter; struct map_session_data* pl_sd; @@ -3782,6 +3925,9 @@ ACMD(mapinfo) if (map->list[m_id].flag.battleground) clif->message(fd, msg_fd(fd,1045)); // Battlegrounds ON + if (map->list[m_id].flag.cvc) + clif->message(fd, msg_fd(fd, 139)); // CvC ON + strcpy(atcmd_output,msg_fd(fd,1046)); // PvP Flags: if (map->list[m_id].flag.pvp) strcat(atcmd_output, msg_fd(fd,1047)); // Pvp ON | @@ -3892,8 +4038,14 @@ ACMD(mapinfo) strcat(atcmd_output, msg_fd(fd,1096)); // PartyLock | if (map->list[m_id].flag.guildlock) strcat(atcmd_output, msg_fd(fd,1097)); // GuildLock | + if (map->list[m_id].flag.noautoloot) + strcat(atcmd_output, msg_fd(fd, 1063)); // NoAutoloot | if (map->list[m_id].flag.noviewid != EQP_NONE) strcat(atcmd_output, msg_fd(fd,1079)); // NoViewID | + if (map->list[m_id].flag.pairship_startable) + strcat(atcmd_output, msg_fd(fd, 1292)); // PrivateAirshipStartable | + if (map->list[m_id].flag.pairship_endable) + strcat(atcmd_output, msg_fd(fd, 1293)); // PrivateAirshipEndable | clif->message(fd, atcmd_output); switch (list) { @@ -4037,7 +4189,8 @@ ACMD(mount_peco) /*========================================== *Spy Commands by Syrus22 *------------------------------------------*/ -ACMD(guildspy) { +ACMD(guildspy) +{ char guild_name[NAME_LENGTH]; struct guild *g; @@ -4076,7 +4229,8 @@ ACMD(guildspy) { /*========================================== * *------------------------------------------*/ -ACMD(partyspy) { +ACMD(partyspy) +{ char party_name[NAME_LENGTH]; struct party_data *p; @@ -4118,10 +4272,10 @@ ACMD(partyspy) { *------------------------------------------*/ ACMD(repairall) { - int count, i; - - count = 0; - for (i = 0; i < MAX_INVENTORY; i++) { + int count = 0; + for (int i = 0; i < sd->status.inventorySize; i++) { + if (sd->status.inventory[i].card[0] == CARD0_PET) + continue; if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { sd->status.inventory[i].attribute |= ATTR_BROKEN; sd->status.inventory[i].attribute ^= ATTR_BROKEN; @@ -4132,7 +4286,7 @@ ACMD(repairall) if (count > 0) { clif->misceffect(&sd->bl, 3); - clif->equiplist(sd); + clif->equipList(sd); clif->message(fd, msg_fd(fd,107)); // All items have been repaired. } else { clif->message(fd, msg_fd(fd,108)); // No item need to be repaired. @@ -4145,7 +4299,8 @@ ACMD(repairall) /*========================================== * @nuke [Valaris] *------------------------------------------*/ -ACMD(nuke) { +ACMD(nuke) +{ struct map_session_data *pl_sd; memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); @@ -4174,7 +4329,8 @@ ACMD(nuke) { /*========================================== * @tonpc *------------------------------------------*/ -ACMD(tonpc) { +ACMD(tonpc) +{ char npcname[NAME_LENGTH+1]; struct npc_data *nd; @@ -4300,7 +4456,8 @@ ACMD(unloadnpc) /*========================================== * time in txt for time command (by [Yor]) *------------------------------------------*/ -char* txt_time(int fd, unsigned int duration) { +static char *txt_time(int fd, unsigned int duration) +{ int days, hours, minutes, seconds; static char temp1[CHAT_SIZE_MAX]; int tlen = 0; @@ -4338,7 +4495,8 @@ char* txt_time(int fd, unsigned int duration) { * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor] * Calculation management of GM modification (@day/@night GM commands) is done *------------------------------------------*/ -ACMD(servertime) { +ACMD(servertime) +{ time_t time_server; // variable for number of seconds (used with time() function) struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ... char temp[CHAT_SIZE_MAX]; @@ -4393,7 +4551,7 @@ ACMD(servertime) { //Added by Coltaro //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status->change_timer...). //Well, using time_t could still work but for some reason that looks like more coding x_x -void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) +static void get_jail_time(int jailtime, int *year, int *month, int *day, int *hour, int *minute) { const int factor_year = 518400; //12*30*24*60 = 518400 const int factor_month = 43200; //30*24*60 = 43200 @@ -4427,7 +4585,8 @@ void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int * @jail <char_name> by [Yor] * Special warp! No check with nowarp and nowarpto flag *------------------------------------------*/ -ACMD(jail) { +ACMD(jail) +{ struct map_session_data *pl_sd; int x, y; unsigned short m_index; @@ -4480,7 +4639,8 @@ ACMD(jail) { * @unjail/@discharge <char_name> by [Yor] * Special warp! No check with nowarp and nowarpto flag *------------------------------------------*/ -ACMD(unjail) { +ACMD(unjail) +{ struct map_session_data *pl_sd; memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); @@ -4514,7 +4674,8 @@ ACMD(unjail) { return true; } -ACMD(jailfor) { +ACMD(jailfor) +{ struct map_session_data *pl_sd = NULL; int year, month, day, hour, minute; char * modif_p; @@ -4798,7 +4959,8 @@ ACMD(undisguise) /*========================================== * UndisguiseAll *------------------------------------------*/ -ACMD(undisguiseall) { +ACMD(undisguiseall) +{ struct map_session_data *pl_sd; struct s_mapiterator* iter; @@ -4850,21 +5012,19 @@ ACMD(undisguiseguild) *------------------------------------------*/ ACMD(exp) { - char output[CHAT_SIZE_MAX]; - double nextb, nextj; - - memset(output, '\0', sizeof(output)); + double percentb = 0.0, percentj = 0.0; + uint64 nextb, nextj; nextb = pc->nextbaseexp(sd); - if (nextb) - nextb = sd->status.base_exp*100.0/nextb; + if (nextb != 0) + percentb = sd->status.base_exp * 100.0 / nextb; nextj = pc->nextjobexp(sd); - if (nextj) - nextj = sd->status.job_exp*100.0/nextj; + if (nextj != 0) + percentj = sd->status.job_exp * 100.0 / nextj; - sprintf(output, msg_fd(fd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%) - clif->message(fd, output); + sprintf(atcmd_output, msg_fd(fd,1148), sd->status.base_level, percentb, sd->status.job_level, percentj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%) + clif->message(fd, atcmd_output); return true; } @@ -4978,7 +5138,8 @@ ACMD(killer) * @killable by MouseJstr * enable other people killing you *------------------------------------------*/ -ACMD(killable) { +ACMD(killable) +{ sd->state.killable = !sd->state.killable; if (sd->state.killable) { @@ -4994,7 +5155,8 @@ ACMD(killable) { * @skillon by MouseJstr * turn skills on for the map *------------------------------------------*/ -ACMD(skillon) { +ACMD(skillon) +{ map->list[sd->bl.m].flag.noskill = 0; clif->message(fd, msg_fd(fd,244)); return true; @@ -5004,7 +5166,8 @@ ACMD(skillon) { * @skilloff by MouseJstr * Turn skills off on the map *------------------------------------------*/ -ACMD(skilloff) { +ACMD(skilloff) +{ map->list[sd->bl.m].flag.noskill = 1; clif->message(fd, msg_fd(fd,243)); return true; @@ -5014,7 +5177,8 @@ ACMD(skilloff) { * @npcmove by MouseJstr * move a npc *------------------------------------------*/ -ACMD(npcmove) { +ACMD(npcmove) +{ int x = 0, y = 0, m; struct npc_data *nd = 0; @@ -5084,7 +5248,8 @@ ACMD(addwarp) * @follow by [MouseJstr] * Follow a player .. staying no more then 5 spaces away *------------------------------------------*/ -ACMD(follow) { +ACMD(follow) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -5117,9 +5282,7 @@ ACMD(follow) { *------------------------------------------*/ ACMD(dropall) { - int i; - - for (i = 0; i < MAX_INVENTORY; i++) { + for (int i = 0; i < sd->status.inventorySize; i++) { if (sd->status.inventory[i].amount) { if(sd->status.inventory[i].equip != 0) pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); @@ -5135,8 +5298,6 @@ ACMD(dropall) *------------------------------------------*/ ACMD(storeall) { - int i; - if (sd->state.storage_flag != STORAGE_FLAG_NORMAL) { //Open storage. if (storage->open(sd) == 1) { @@ -5145,7 +5306,12 @@ ACMD(storeall) } } - for (i = 0; i < MAX_INVENTORY; i++) { + if (sd->storage.received == false) { + clif->message(fd, msg_fd(fd, 27)); // "Storage has not been loaded yet" + return false; + } + + for (int i = 0; i < sd->status.inventorySize; i++) { if (sd->status.inventory[i].amount) { if(sd->status.inventory[i].equip != 0) pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); @@ -5160,17 +5326,25 @@ ACMD(storeall) ACMD(clearstorage) { - int i, j; + int i; if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) { clif->message(fd, msg_fd(fd,250)); return false; } - j = sd->status.storage.storage_amount; - for (i = 0; i < j; ++i) { - storage->delitem(sd, i, sd->status.storage.items[i].amount); + if (sd->storage.received == false) { + clif->message(fd, msg_fd(fd, 27)); // "Storage has not been loaded yet" + return false; + } + + for (i = 0; i < VECTOR_LENGTH(sd->storage.item); ++i) { + if (VECTOR_INDEX(sd->storage.item, i).nameid == 0) + continue; // we skip the already deleted items. + + storage->delitem(sd, i, VECTOR_INDEX(sd->storage.item, i).amount); } + storage->close(sd); clif->message(fd, msg_fd(fd,1394)); // Your storage was cleaned. @@ -5267,12 +5441,13 @@ ACMD(skillid) iter = db_iterator(skill->name2id_db); for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) { - int idx = skill->get_index(DB->data2i(data)); - if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->dbs->db[idx].desc, message, skillen) == 0) { - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); // skill %d: %s (%s) + int skill_id = DB->data2i(data); + const char *skill_desc = skill->get_desc(skill_id); + if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_desc, message, skillen) == 0) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1164), skill_id, skill_desc, key.str); // skill %d: %s (%s) clif->message(fd, atcmd_output); - } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->dbs->db[idx].desc,message) ) ) { - snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); + } else if (found < MAX_SKILLID_PARTIAL_RESULTS && (stristr(key.str, message) != NULL || stristr(skill_desc, message) != NULL)) { + snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd, 1164), skill_id, skill_desc, key.str); found++; } } @@ -5295,7 +5470,8 @@ ACMD(skillid) * @useskill by [MouseJstr] * A way of using skills without having to find them in the skills menu *------------------------------------------*/ -ACMD(useskill) { +ACMD(useskill) +{ struct map_session_data *pl_sd = NULL; struct block_list *bl; uint16 skill_id; @@ -5341,7 +5517,8 @@ ACMD(useskill) { * Debug command to locate new skill IDs. It sends the * three possible skill-effect packets to the area. *------------------------------------------*/ -ACMD(displayskill) { +ACMD(displayskill) +{ struct status_data *st; int64 tick; uint16 skill_id; @@ -5399,7 +5576,7 @@ ACMD(skilltree) for (j = 0; j < VECTOR_LENGTH(entry->need); j++) { struct skill_tree_requirement *req = &VECTOR_INDEX(entry->need, j); if (pc->checkskill(sd, req->id) < req->lv) { - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1170), req->lv, skill->dbs->db[req->id].desc); // Player requires level %d of skill %s. + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1170), req->lv, skill->get_desc(req->id)); // Player requires level %d of skill %s. clif->message(fd, atcmd_output); meets = 0; } @@ -5412,7 +5589,8 @@ ACMD(skilltree) } // Hand a ring with partners name on it to this char -void atcommand_getring(struct map_session_data* sd) { +static void atcommand_getring(struct map_session_data *sd) +{ int flag, item_id; struct item item_tmp; nullpo_retv(sd); @@ -5427,7 +5605,7 @@ void atcommand_getring(struct map_session_data* sd) { if((flag = pc->additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) { clif->additem(sd,0,0,flag); - map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } } @@ -5435,7 +5613,8 @@ void atcommand_getring(struct map_session_data* sd) { * @marry by [MouseJstr], fixed by Lupus * Marry two players *------------------------------------------*/ -ACMD(marry) { +ACMD(marry) +{ struct map_session_data *pl_sd = NULL; char player_name[NAME_LENGTH] = ""; @@ -5554,7 +5733,8 @@ ACMD(autotrade) * @changegm by durf (changed by Lupus) * Changes Master of your Guild to a specified guild member *------------------------------------------*/ -ACMD(changegm) { +ACMD(changegm) +{ struct guild *g; struct map_session_data *pl_sd; @@ -5578,7 +5758,7 @@ ACMD(changegm) { return false; } - guild->gm_change(sd->status.guild_id, pl_sd); + guild->gm_change(sd->status.guild_id, pl_sd->status.char_id); return true; } @@ -5586,7 +5766,8 @@ ACMD(changegm) { * @changeleader by Skotlex * Changes the leader of a party. *------------------------------------------*/ -ACMD(changeleader) { +ACMD(changeleader) +{ if (!message[0]) { clif->message(fd, msg_fd(fd,1185)); // Usage: @changeleader <party_member_name> @@ -5775,7 +5956,8 @@ ACMD(autolootitem) * Credits: * chriser,Aleos *------------------------------------------*/ -ACMD(autoloottype) { +ACMD(autoloottype) +{ uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset enum item_types type = -1; int ITEM_NONE = 0; @@ -5888,8 +6070,8 @@ ACMD(snow) /*========================================== * Cherry tree snowstorm is made to fall. (Sakura) *------------------------------------------*/ -ACMD(sakura) { - +ACMD(sakura) +{ if (map->list[sd->bl.m].flag.sakura) { map->list[sd->bl.m].flag.sakura=0; clif->weather(sd->bl.m); @@ -5905,8 +6087,8 @@ ACMD(sakura) { /*========================================== * Clouds appear. *------------------------------------------*/ -ACMD(clouds) { - +ACMD(clouds) +{ if (map->list[sd->bl.m].flag.clouds) { map->list[sd->bl.m].flag.clouds=0; clif->weather(sd->bl.m); @@ -5923,8 +6105,8 @@ ACMD(clouds) { /*========================================== * Different type of clouds using effect 516 *------------------------------------------*/ -ACMD(clouds2) { - +ACMD(clouds2) +{ if (map->list[sd->bl.m].flag.clouds2) { map->list[sd->bl.m].flag.clouds2=0; clif->weather(sd->bl.m); @@ -5941,8 +6123,8 @@ ACMD(clouds2) { /*========================================== * Fog hangs over. *------------------------------------------*/ -ACMD(fog) { - +ACMD(fog) +{ if (map->list[sd->bl.m].flag.fog) { map->list[sd->bl.m].flag.fog=0; clif->weather(sd->bl.m); @@ -5958,8 +6140,8 @@ ACMD(fog) { /*========================================== * Fallen leaves fall. *------------------------------------------*/ -ACMD(leaves) { - +ACMD(leaves) +{ if (map->list[sd->bl.m].flag.leaves) { map->list[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); @@ -5976,8 +6158,8 @@ ACMD(leaves) { /*========================================== * Fireworks appear. *------------------------------------------*/ -ACMD(fireworks) { - +ACMD(fireworks) +{ if (map->list[sd->bl.m].flag.fireworks) { map->list[sd->bl.m].flag.fireworks=0; clif->weather(sd->bl.m); @@ -6054,9 +6236,10 @@ ACMD(mobsearch) clif->message(fd, atcmd_output); return false; } - if (mob_id == atoi(mob_name)) - strcpy(mob_name,mob->db(mob_id)->jname); // --ja-- - //strcpy(mob_name,mob_db(mob_id)->name); // --en-- + if (mob_id == atoi(mob_name)) { + strcpy(mob_name,mob->db(mob_id)->jname); // DEFAULT_MOB_JNAME + //strcpy(mob_name,mob_db(mob_id)->name); // DEFAULT_MOB_NAME + } snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s clif->message(fd, atcmd_output); @@ -6084,20 +6267,23 @@ ACMD(mobsearch) * @cleanmap - cleans items on the ground * @cleanarea - cleans items on the ground within an specified area *------------------------------------------*/ -int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) { +static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) +{ nullpo_ret(bl); map->clearflooritem(bl); return 0; } -ACMD(cleanmap) { +ACMD(cleanmap) +{ map->foreachinmap(atcommand->cleanfloor_sub, sd->bl.m, BL_ITEM); clif->message(fd, msg_fd(fd,1221)); // All dropped items have been cleaned up. return true; } -ACMD(cleanarea) { +ACMD(cleanarea) +{ int x0 = 0, y0 = 0, x1 = 0, y1 = 0, n = 0; if (!*message || (n=sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1)) < 1) { @@ -6118,7 +6304,7 @@ ACMD(cleanarea) { *------------------------------------------*/ ACMD(npctalk) { - char name[NAME_LENGTH],mes[100],temp[100]; + char name[NAME_LENGTH], mes[100], temp[200]; struct npc_data *nd; bool ifcolor=(*(info->command + 7) != 'c' && *(info->command + 7) != 'C')?0:1; unsigned int color = 0; @@ -6148,14 +6334,14 @@ ACMD(npctalk) snprintf(temp, sizeof(temp), "%s : %s", name, mes); if(ifcolor) clif->messagecolor(&nd->bl,color,temp); - else clif->disp_overhead(&nd->bl, temp); + else clif->disp_overhead(&nd->bl, temp, AREA_CHAT_WOC, NULL); return true; } ACMD(pettalk) { - char mes[100],temp[100]; + char mes[100], temp[200]; struct pet_data *pd; if (battle_config.min_chat_delay) { @@ -6208,7 +6394,7 @@ ACMD(pettalk) } snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes); - clif->disp_overhead(&pd->bl, temp); + clif->disp_overhead(&pd->bl, temp, AREA_CHAT_WOC, NULL); return true; } @@ -6261,7 +6447,8 @@ ACMD(users) /*========================================== * *------------------------------------------*/ -ACMD(reset) { +ACMD(reset) +{ pc->resetstate(sd); pc->resetskill(sd, PCRESETSKILL_RESYNC); safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,208), sd->status.name); // '%s' skill and stats points reseted! @@ -6299,7 +6486,7 @@ ACMD(summon) return false; } - md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, DEFAULT_MOB_JNAME, mob_id, "", SZ_SMALL, AI_NONE); if(!md) return false; @@ -6344,7 +6531,8 @@ ACMD(adjgroup) * @trade by [MouseJstr] * Open a trade window with a remote player *------------------------------------------*/ -ACMD(trade) { +ACMD(trade) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -6387,7 +6575,8 @@ ACMD(setbattleflag) /*========================================== * @unmute [Valaris] *------------------------------------------*/ -ACMD(unmute) { +ACMD(unmute) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -6438,7 +6627,8 @@ ACMD(uptime) * @changesex <sex> * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female. *------------------------------------------*/ -ACMD(changesex) { +ACMD(changesex) +{ int i; pc->resetskill(sd, PCRESETSKILL_CHSEX); @@ -6452,7 +6642,8 @@ ACMD(changesex) { /*================================================ * @mute - Mutes a player for a set amount of time *------------------------------------------------*/ -ACMD(mute) { +ACMD(mute) +{ struct map_session_data *pl_sd = NULL; int manner; @@ -6515,9 +6706,9 @@ ACMD(refreshall) *------------------------------------------*/ ACMD(identify) { - int i,num; + int num = 0; - for (i=num=0;i<MAX_INVENTORY;i++) { + for (int i = 0; i < sd->status.inventorySize; i++) { if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){ num++; } @@ -6530,7 +6721,8 @@ ACMD(identify) return true; } -ACMD(misceffect) { +ACMD(misceffect) +{ int effect = 0; if (!*message) @@ -6740,9 +6932,10 @@ ACMD(showmobs) return false; } - if(mob_id == atoi(mob_name)) - strcpy(mob_name,mob->db(mob_id)->jname); // --ja-- - //strcpy(mob_name,mob_db(mob_id)->name); // --en-- + if (mob_id == atoi(mob_name)) { + strcpy(mob_name,mob->db(mob_id)->jname); // DEFAULT_MOB_JNAME + //strcpy(mob_name,mob_db(mob_id)->name); // DEFAULT_MOB_NAME + } snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1252), // Mob Search... %s %s mob_name, mapindex_id2name(sd->mapindex)); @@ -6770,7 +6963,8 @@ ACMD(showmobs) /*========================================== * homunculus level up [orn] *------------------------------------------*/ -ACMD(homlevel) { +ACMD(homlevel) +{ struct homun_data *hd; int level = 0; enum homun_type htype; @@ -6841,7 +7035,8 @@ ACMD(homevolution) return true; } -ACMD(hommutate) { +ACMD(hommutate) +{ int homun_id; enum homun_type m_class, m_id; @@ -6870,7 +7065,8 @@ ACMD(hommutate) { /*========================================== * call choosen homunculus [orn] *------------------------------------------*/ -ACMD(makehomun) { +ACMD(makehomun) +{ int homunid; if (!*message) { @@ -6960,7 +7156,7 @@ ACMD(homhungry) *------------------------------------------*/ ACMD(homtalk) { - char mes[100],temp[100]; + char mes[100], temp[200]; if (battle_config.min_chat_delay) { if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) @@ -6982,7 +7178,7 @@ ACMD(homtalk) } snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes); - clif->disp_overhead(&sd->hd->bl, temp); + clif->disp_overhead(&sd->hd->bl, temp, AREA_CHAT_WOC, NULL); return true; } @@ -6990,7 +7186,8 @@ ACMD(homtalk) /*========================================== * Show homunculus stats *------------------------------------------*/ -ACMD(hominfo) { +ACMD(hominfo) +{ struct homun_data *hd; struct status_data *st; @@ -7250,7 +7447,8 @@ ACMD(whereis) return true; } -ACMD(version) { +ACMD(version) +{ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1296), sysinfo->is64bit() ? 64 : 32, sysinfo->platform()); // Hercules %d-bit for %s clif->message(fd, atcmd_output); safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1295), sysinfo->vcstype(), sysinfo->vcsrevision_src(), sysinfo->vcsrevision_scripts()); // %s revision '%s' (src) / '%s' (scripts) @@ -7262,8 +7460,9 @@ ACMD(version) { /*========================================== * @mutearea by MouseJstr *------------------------------------------*/ -int atcommand_mutearea_sub(struct block_list *bl, va_list ap) -{ // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way +static int atcommand_mutearea_sub(struct block_list *bl, va_list ap) +{ + // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way int time, id; struct map_session_data *pl_sd = BL_CAST(BL_PC, bl); @@ -7283,7 +7482,8 @@ int atcommand_mutearea_sub(struct block_list *bl, va_list ap) return 1; } -ACMD(mutearea) { +ACMD(mutearea) +{ int time; if (!*message) { @@ -7342,7 +7542,7 @@ ACMD(me) } safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,270), sd->status.name, tempmes); // *%s %s* - clif->disp_overhead(&sd->bl, atcmd_output); + clif->disp_overhead(&sd->bl, atcmd_output, AREA_CHAT_WOC, NULL); return true; } @@ -7448,11 +7648,11 @@ ACMD(sizeguild) *------------------------------------------*/ ACMD(monsterignore) { - if (!sd->state.monster_ignore) { - sd->state.monster_ignore = 1; + if (!sd->block_action.immune) { + sd->block_action.immune = 1; clif->message(sd->fd, msg_fd(fd,1305)); // You are now immune to attacks. } else { - sd->state.monster_ignore = 0; + sd->block_action.immune = 0; clif->message(sd->fd, msg_fd(fd,1306)); // Returned to normal state. } @@ -7498,7 +7698,8 @@ ACMD(fakename) /*========================================== * Ragnarok Resources *------------------------------------------*/ -ACMD(mapflag) { +ACMD(mapflag) +{ #define CHECKFLAG( cmd ) do { if (map->list[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd);} while(0) #define SETFLAG( cmd ) do { \ if (strcmp( flag_name , #cmd ) == 0) { \ @@ -7521,15 +7722,15 @@ ACMD(mapflag) { CHECKFLAG(noreturn); CHECKFLAG(monster_noteleport); CHECKFLAG(nosave); CHECKFLAG(nobranch); CHECKFLAG(noexppenalty); CHECKFLAG(pvp); CHECKFLAG(pvp_noparty); CHECKFLAG(pvp_noguild); CHECKFLAG(pvp_nightmaredrop); CHECKFLAG(pvp_nocalcrank); CHECKFLAG(gvg_castle); CHECKFLAG(gvg); - CHECKFLAG(gvg_dungeon); CHECKFLAG(gvg_noparty); CHECKFLAG(battleground); CHECKFLAG(nozenypenalty); - CHECKFLAG(notrade); CHECKFLAG(noskill); CHECKFLAG(nowarp); CHECKFLAG(nowarpto); - CHECKFLAG(noicewall); CHECKFLAG(snow); CHECKFLAG(clouds); CHECKFLAG(clouds2); - CHECKFLAG(fog); CHECKFLAG(fireworks); CHECKFLAG(sakura); CHECKFLAG(leaves); - CHECKFLAG(nobaseexp); + CHECKFLAG(gvg_dungeon); CHECKFLAG(gvg_noparty); CHECKFLAG(battleground); CHECKFLAG(cvc); + CHECKFLAG(nozenypenalty); CHECKFLAG(notrade); CHECKFLAG(noskill); CHECKFLAG(nowarp); + CHECKFLAG(nowarpto); CHECKFLAG(noicewall); CHECKFLAG(snow); CHECKFLAG(clouds); + CHECKFLAG(clouds2); CHECKFLAG(fog); CHECKFLAG(fireworks); CHECKFLAG(sakura); + CHECKFLAG(leaves); CHECKFLAG(nobaseexp); CHECKFLAG(nojobexp); CHECKFLAG(nomobloot); CHECKFLAG(nomvploot); CHECKFLAG(nightenabled); CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent); CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance); - CHECKFLAG(notomb); CHECKFLAG(nocashshop); CHECKFLAG(noviewid); + CHECKFLAG(notomb); CHECKFLAG(nocashshop); CHECKFLAG(noviewid); CHECKFLAG(town); clif->message(sd->fd," "); clif->message(sd->fd,msg_fd(fd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) clif->message(sd->fd,msg_fd(fd,1313)); // Type "@mapflag available" to list the available mapflags. @@ -7537,48 +7738,54 @@ ACMD(mapflag) { } for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase - if (strcmp( flag_name , "gvg" ) == 0) { - if( flag && !map->list[sd->bl.m].flag.gvg ) - map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); - else if ( !flag && map->list[sd->bl.m].flag.gvg ) - map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); - } else if ( strcmp( flag_name , "pvp" ) == 0 ) { - if ( flag && !map->list[sd->bl.m].flag.pvp ) - map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); - else if ( !flag && map->list[sd->bl.m].flag.pvp ) - map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); - } else if ( strcmp( flag_name , "battleground" ) == 0 ) { - if ( flag && !map->list[sd->bl.m].flag.battleground ) - map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_BG_NAME)); - else if ( !flag && map->list[sd->bl.m].flag.battleground ) - map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); + if (strcmp(flag_name, "gvg") == 0) { + if (flag && !map->list[sd->bl.m].flag.gvg) + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); + else if (!flag && map->list[sd->bl.m].flag.gvg) + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); + } else if (strcmp(flag_name, "pvp") == 0) { + if (flag && !map->list[sd->bl.m].flag.pvp) + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); + else if (!flag && map->list[sd->bl.m].flag.pvp) + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); + } else if (strcmp(flag_name, "battleground") == 0) { + if (flag && !map->list[sd->bl.m].flag.battleground) + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_BG_NAME)); + else if (!flag && map->list[sd->bl.m].flag.battleground) + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); + } else if (strcmp(flag_name, "cvc") == 0) { + if (flag && !map->list[sd->bl.m].flag.cvc) + map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_CVC_NAME)); + else if (!flag && map->list[sd->bl.m].flag.cvc) + map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone); } SETFLAG(autotrade); SETFLAG(allowks); SETFLAG(nomemo); SETFLAG(noteleport); SETFLAG(noreturn); SETFLAG(monster_noteleport); SETFLAG(nosave); SETFLAG(nobranch); SETFLAG(noexppenalty); SETFLAG(pvp); SETFLAG(pvp_noparty); SETFLAG(pvp_noguild); SETFLAG(pvp_nightmaredrop); SETFLAG(pvp_nocalcrank); SETFLAG(gvg_castle); SETFLAG(gvg); - SETFLAG(gvg_dungeon); SETFLAG(gvg_noparty); SETFLAG(battleground); SETFLAG(nozenypenalty); - SETFLAG(notrade); SETFLAG(noskill); SETFLAG(nowarp); SETFLAG(nowarpto); - SETFLAG(noicewall); SETFLAG(snow); SETFLAG(clouds); SETFLAG(clouds2); - SETFLAG(fog); SETFLAG(fireworks); SETFLAG(sakura); SETFLAG(leaves); - SETFLAG(nobaseexp); - SETFLAG(nojobexp); SETFLAG(nomobloot); SETFLAG(nomvploot); SETFLAG(nightenabled); - SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent); - SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance); - SETFLAG(notomb); SETFLAG(nocashshop); SETFLAG(noviewid); - - clif->message(sd->fd,msg_fd(fd,1314)); // Invalid flag name or flag. - clif->message(sd->fd,msg_fd(fd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) - clif->message(sd->fd,msg_fd(fd,1315)); // Available Flags: - clif->message(sd->fd,"----------------------------------"); - clif->message(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,"); - clif->message(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,"); - clif->message(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,"); - clif->message(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,"); - clif->message(sd->fd,"fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,"); - clif->message(sd->fd,"nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,"); - clif->message(sd->fd,"guildlock, src4instance, notomb, nocashshop, noviewid"); + SETFLAG(gvg_dungeon); SETFLAG(gvg_noparty); SETFLAG(battleground); SETFLAG(cvc); + SETFLAG(nozenypenalty); SETFLAG(notrade); SETFLAG(noskill); SETFLAG(nowarp); + SETFLAG(nowarpto); SETFLAG(noicewall); SETFLAG(snow); SETFLAG(clouds); + SETFLAG(clouds2); SETFLAG(fog); SETFLAG(fireworks); SETFLAG(sakura); + SETFLAG(leaves); SETFLAG(nobaseexp); SETFLAG(nojobexp); SETFLAG(nomobloot); + SETFLAG(nomvploot); SETFLAG(nightenabled); SETFLAG(nodrop); SETFLAG(novending); + SETFLAG(loadevent); SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); + SETFLAG(src4instance); SETFLAG(notomb); SETFLAG(nocashshop); SETFLAG(noviewid); + SETFLAG(town); + + + clif->message(sd->fd, msg_fd(fd, 1314)); // Invalid flag name or flag. + clif->message(sd->fd, msg_fd(fd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) + clif->message(sd->fd, msg_fd(fd, 1315)); // Available Flags: + clif->message(sd->fd, "----------------------------------"); + clif->message(sd->fd, "town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,"); + clif->message(sd->fd, "nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,"); + clif->message(sd->fd, "pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground, cvc,"); + clif->message(sd->fd, "nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,"); + clif->message(sd->fd, "fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,"); + clif->message(sd->fd, "nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,"); + clif->message(sd->fd, "guildlock, src4instance, notomb, nocashshop, noviewid"); #undef CHECKFLAG #undef SETFLAG @@ -7681,7 +7888,8 @@ ACMD(invite) return true; } -ACMD(duel) { +ACMD(duel) +{ unsigned int maxpl = 0; if (sd->duel_group > 0) { @@ -7734,7 +7942,8 @@ ACMD(duel) { return true; } -ACMD(leave) { +ACMD(leave) +{ if (sd->duel_group <= 0) { // "Duel: @leave without @duel." clif->message(fd, msg_fd(fd,358)); @@ -7745,7 +7954,8 @@ ACMD(leave) { return true; } -ACMD(accept) { +ACMD(accept) +{ if (!duel->checktime(sd)) { char output[CHAT_SIZE_MAX]; // "Duel: You can take part in duel only one time per %d minutes." @@ -7773,7 +7983,8 @@ ACMD(accept) { return true; } -ACMD(reject) { +ACMD(reject) +{ if (sd->duel_invite <= 0) { // "Duel: @reject without invitation." clif->message(fd, msg_fd(fd,362)); @@ -7793,7 +8004,6 @@ ACMD(cash) { char output[128]; int value; - int ret=0; if (!*message || (value = atoi(message)) == 0) { clif->message(fd, msg_fd(fd,1322)); // Please enter an amount. @@ -7801,38 +8011,38 @@ ACMD(cash) } if (!strcmpi(info->command,"cash")) { - if( value > 0 ) { - if( (ret=pc->getcash(sd, value, 0)) >= 0){ + if (value > 0) { + if ((pc->getcash(sd, value, 0)) >= 0) { // If this option is set, the message is already sent by pc function - if( !battle_config.cashshop_show_points ){ - sprintf(output, msg_fd(fd,505), ret, sd->cashPoints); + if (!battle_config.cashshop_show_points) { + sprintf(output, msg_fd(fd,505), value, sd->cashPoints); clif_disp_onlyself(sd, output); clif->message(fd, output); } } else clif->message(fd, msg_fd(fd,149)); // Unable to decrease the number/value. } else { - if( (ret=pc->paycash(sd, -value, 0)) >= 0){ - sprintf(output, msg_fd(fd,410), ret, sd->cashPoints); + if ((pc->paycash(sd, -value, 0)) >= 0) { + sprintf(output, msg_fd(fd,410), -value, sd->cashPoints); clif_disp_onlyself(sd, output); clif->message(fd, output); } else clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value. } } else { // @points - if( value > 0 ) { - if( (ret=pc->getcash(sd, 0, value)) >= 0) { + if (value > 0) { + if ((pc->getcash(sd, 0, value)) >= 0) { // If this option is set, the message is already sent by pc function - if( !battle_config.cashshop_show_points ){ - sprintf(output, msg_fd(fd,506), ret, sd->kafraPoints); + if (!battle_config.cashshop_show_points) { + sprintf(output, msg_fd(fd,506), value, sd->kafraPoints); clif_disp_onlyself(sd, output); clif->message(fd, output); } } else clif->message(fd, msg_fd(fd,149)); // Unable to decrease the number/value. } else { - if( (ret=pc->paycash(sd, -value, -value)) >= 0){ - sprintf(output, msg_fd(fd,411), ret, sd->kafraPoints); + if ((pc->paycash(sd, -value, -value)) >= 0) { + sprintf(output, msg_fd(fd,411), -value, sd->kafraPoints); clif_disp_onlyself(sd, output); clif->message(fd, output); } else @@ -7844,7 +8054,8 @@ ACMD(cash) } // @clone/@slaveclone/@evilclone <playername> [Valaris] -ACMD(clone) { +ACMD(clone) +{ int x=0,y=0,flag=0,master=0,i=0; struct map_session_data *pl_sd=NULL; @@ -7962,7 +8173,8 @@ ACMD(auction) /*========================================== * Kill Steal Protection *------------------------------------------*/ -ACMD(ksprotection) { +ACMD(ksprotection) +{ if( sd->state.noks ) { sd->state.noks = KSPROTECT_NONE; clif->message(fd, msg_fd(fd,1325)); // [ K.S Protection Inactive ] @@ -8027,8 +8239,8 @@ ACMD(itemlist) if( strcmpi(info->command, "storagelist") == 0 ) { location = "storage"; - items = sd->status.storage.items; - size = MAX_STORAGE; + items = VECTOR_DATA(sd->storage.item); + size = VECTOR_LENGTH(sd->storage.item); } else if( strcmpi(info->command, "cartlist") == 0 ) { location = "cart"; items = sd->status.cart; @@ -8036,7 +8248,7 @@ ACMD(itemlist) } else if( strcmpi(info->command, "itemlist") == 0 ) { location = "inventory"; items = sd->status.inventory; - size = MAX_INVENTORY; + size = sd->status.inventorySize; } else return false; @@ -8049,7 +8261,7 @@ ACMD(itemlist) const struct item* it = &items[i]; struct item_data* itd; - if( it->nameid == 0 || (itd = itemdb->exists(it->nameid)) == NULL ) + if (it->nameid == 0 || (itd = itemdb->exists(it->nameid)) == NULL) continue; counter += it->amount; @@ -8222,7 +8434,8 @@ ACMD(stats) return true; } -ACMD(delitem) { +ACMD(delitem) +{ char item_name[100]; int nameid, amount = 0, total, idx; struct item_data* id; @@ -8283,7 +8496,8 @@ ACMD(delitem) { /*========================================== * Custom Fonts *------------------------------------------*/ -ACMD(font) { +ACMD(font) +{ int font_id; font_id = atoi(message); @@ -8318,7 +8532,7 @@ ACMD(font) { /*========================================== * type: 1 = commands (@), 2 = charcommands (#) *------------------------------------------*/ -void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type) +static void atcommand_commands_sub(struct map_session_data *sd, const int fd, AtCommandType type) { char line_buff[CHATBOX_SIZE]; char* cur = line_buff; @@ -8366,6 +8580,38 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand dbi_destroy(iter); clif->message(fd,line_buff); + if (atcommand->binding_count > 0) { + int i, count_bind = 0; + int gm_lvl = pc_get_group_level(sd); + + for (i = 0; i < atcommand->binding_count; i++) { + if (gm_lvl >= ((type == COMMAND_ATCOMMAND) ? atcommand->binding[i]->group_lv : atcommand->binding[i]->group_lv_char) + || (type == COMMAND_ATCOMMAND && atcommand->binding[i]->at_groups[pcg->get_idx(sd->group)] > 0) + || (type == COMMAND_CHARCOMMAND && atcommand->binding[i]->char_groups[pcg->get_idx(sd->group)] > 0)) { + size_t slen = strlen(atcommand->binding[i]->command); + if (count_bind == 0) { + cur = line_buff; + memset(line_buff, ' ', CHATBOX_SIZE); + line_buff[CHATBOX_SIZE - 1] = 0; + clif->message(fd, "------------------"); + clif->message(fd, "Custom commands:"); + } + if (slen + cur - line_buff >= CHATBOX_SIZE) { + clif->message(fd, line_buff); + cur = line_buff; + memset(line_buff, ' ', CHATBOX_SIZE); + line_buff[CHATBOX_SIZE - 1] = 0; + } + memcpy(cur, atcommand->binding[i]->command, slen); + cur += slen + (10 - slen % 10); + count_bind++; + } + } + if (count_bind > 0) + clif->message(fd, line_buff); // Last Line + count += count_bind; + } + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,274), count); // "%d commands found." clif->message(fd, atcmd_output); @@ -8390,26 +8636,29 @@ ACMD(charcommands) return true; } -/* for new mounts */ +/* For new mounts */ ACMD(cashmount) { if (pc_hasmount(sd)) { - clif->message(fd, msg_fd(fd,1476)); // You are already mounting something else + clif->message(fd, msg_fd(fd, 1476)); // You are already mounting something else return false; } - clif->message(sd->fd,msg_fd(fd,1362)); // NOTICE: If you crash with mount your LUA is outdated. + clif->message(sd->fd, msg_fd(fd, 1362)); // NOTICE: If you crash with mount your LUA is outdated. + if (!sd->sc.data[SC_ALL_RIDING]) { - clif->message(sd->fd,msg_fd(fd,1363)); // You have mounted. - sc_start(NULL, &sd->bl, SC_ALL_RIDING, 100, 25, INFINITE_DURATION); + clif->message(sd->fd, msg_fd(fd, 1363)); // You have mounted. + sc_start(NULL, &sd->bl, SC_ALL_RIDING, 100, battle_config.boarding_halter_speed, INFINITE_DURATION); } else { - clif->message(sd->fd,msg_fd(fd,1364)); // You have released your mount. + clif->message(sd->fd, msg_fd(fd, 1364)); // You have released your mount. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER); } + return true; } -ACMD(accinfo) { +ACMD(accinfo) +{ char query[NAME_LENGTH]; if (!*message || strlen(message) > NAME_LENGTH ) { @@ -8474,19 +8723,19 @@ ACMD(set) const char *str = NULL; switch (reg[0]) { case '@': - str = pc->readregstr(sd, script->add_str(reg)); + str = pc->readregstr(sd, script->add_variable(reg)); break; case '$': - str = mapreg->readregstr(script->add_str(reg)); + str = mapreg->readregstr(script->add_variable(reg)); break; case '#': if (reg[1] == '#') - str = pc_readaccountreg2str(sd, script->add_str(reg));// global + str = pc_readaccountreg2str(sd, script->add_variable(reg));// global else - str = pc_readaccountregstr(sd, script->add_str(reg));// local + str = pc_readaccountregstr(sd, script->add_variable(reg));// local break; default: - str = pc_readglobalreg_str(sd, script->add_str(reg)); + str = pc_readglobalreg_str(sd, script->add_variable(reg)); break; } if (str == NULL || str[0] == '\0') { @@ -8502,19 +8751,19 @@ ACMD(set) data->type = C_INT; switch( reg[0] ) { case '@': - data->u.num = pc->readreg(sd, script->add_str(reg)); + data->u.num = pc->readreg(sd, script->add_variable(reg)); break; case '$': - data->u.num = mapreg->readreg(script->add_str(reg)); + data->u.num = mapreg->readreg(script->add_variable(reg)); break; case '#': if( reg[1] == '#' ) - data->u.num = pc_readaccountreg2(sd, script->add_str(reg));// global + data->u.num = pc_readaccountreg2(sd, script->add_variable(reg));// global else - data->u.num = pc_readaccountreg(sd, script->add_str(reg));// local + data->u.num = pc_readaccountreg(sd, script->add_variable(reg));// local break; default: - data->u.num = pc_readglobalreg(sd, script->add_str(reg)); + data->u.num = pc_readglobalreg(sd, script->add_variable(reg)); break; } } @@ -8538,12 +8787,16 @@ ACMD(set) aFree(data); return true; } -ACMD(reloadquestdb) { + +ACMD(reloadquestdb) +{ quest->reload(); clif->message(fd, msg_fd(fd,1377)); // Quest database has been reloaded. return true; } -ACMD(addperm) { + +ACMD(addperm) +{ int perm_size = pcg->permission_count; bool add = (strcmpi(info->command, "addperm") == 0) ? true : false; int i; @@ -8599,6 +8852,7 @@ ACMD(addperm) { return true; } + ACMD(unloadnpcfile) { if (!*message) { @@ -8614,7 +8868,9 @@ ACMD(unloadnpcfile) } return true; } -ACMD(cart) { + +ACMD(cart) +{ #define MC_CART_MDFY(x,idx) do { \ sd->status.skill[idx].id = (x)?MC_PUSHCART:0; \ sd->status.skill[idx].lv = (x)?1:0; \ @@ -8623,7 +8879,7 @@ ACMD(cart) { int val = atoi(message); bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true; - unsigned int index = skill->get_index(MC_PUSHCART); + int index = skill->get_index(MC_PUSHCART); if (!*message || val < 0 || val > MAX_CARTS) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>). @@ -8656,6 +8912,7 @@ ACMD(cart) { return true; #undef MC_CART_MDFY } + /* [Ind/Hercules] */ ACMD(join) { @@ -8699,8 +8956,10 @@ ACMD(join) return true; } + /* [Ind/Hercules] */ -void atcommand_channel_help(int fd, const char *command, bool can_create) { +static void atcommand_channel_help(int fd, const char *command, bool can_create) +{ nullpo_retv(command); safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1404),command); // %s failed. clif->message(fd, atcmd_output); @@ -8729,9 +8988,7 @@ void atcommand_channel_help(int fd, const char *command, bool can_create) { clif->message(fd, msg_fd(fd,1428));// - binds global chat to <channel name>, making anything you type in global be sent to the channel safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1429),command);// -- %s unbind clif->message(fd, atcmd_output); - clif->message(fd, msg_fd(fd,1430));// - unbinds your global chat from its attached channel (if binded) - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1429),command);// -- %s unbind - clif->message(fd, atcmd_output); + clif->message(fd, msg_fd(fd,1430));// - unbinds your global chat from its attached channel (if bound) if( can_create ) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1456),command);// -- %s ban <channel name> <character name> clif->message(fd, atcmd_output); @@ -8750,11 +9007,12 @@ void atcommand_channel_help(int fd, const char *command, bool can_create) { clif->message(fd, msg_fd(fd,1463));// - adds or removes <option name> with <option value> to <channel name> channel } } + /* [Ind/Hercules] */ -ACMD(channel) { +ACMD(channel) +{ struct channel_data *chan; char subcmd[HCS_NAME_LENGTH], sub1[HCS_NAME_LENGTH], sub2[HCS_NAME_LENGTH], sub3[HCS_NAME_LENGTH]; - unsigned char k = 0; sub1[0] = sub2[0] = sub3[0] = '\0'; if (!*message || sscanf(message, "%19s %19s %19s %19s", subcmd, sub1, sub2, sub3) < 1) { @@ -8791,7 +9049,7 @@ ACMD(channel) { } else if (strcmpi(subcmd,"list") == 0) { // sub1 = list type; sub2 = unused; sub3 = unused if (sub1[0] != '\0' && strcmpi(sub1,"colors") == 0) { - for (k = 0; k < channel->config->colors_count; k++) { + for (int k = 0; k < channel->config->colors_count; k++) { safesnprintf(atcmd_output, sizeof(atcmd_output), "[ %s list colors ] : %s", command, channel->config->colors_name[k]); clif->messagecolor_self(fd, channel->config->colors[k], atcmd_output); @@ -8820,6 +9078,7 @@ ACMD(channel) { } } else if (strcmpi(subcmd,"setcolor") == 0) { // sub1 = channel name; sub2 = color; sub3 = unused + int k; if (sub1[0] != '#') { clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#' return false; @@ -8837,10 +9096,7 @@ ACMD(channel) { return false; } - for (k = 0; k < channel->config->colors_count; k++) { - if (strcmpi(sub2, channel->config->colors_name[k]) == 0) - break; - } + ARR_FIND(0, channel->config->colors_count, k, strcmpi(sub2, channel->config->colors_name[k]) == 0); if (k == channel->config->colors_count) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1411), sub2);// Unknown color '%s' clif->message(fd, atcmd_output); @@ -8851,51 +9107,45 @@ ACMD(channel) { clif->message(fd, atcmd_output); } else if (strcmpi(subcmd,"leave") == 0) { // sub1 = channel name; sub2 = unused; sub3 = unused + int k; if (sub1[0] != '#') { clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#' return false; } - for (k = 0; k < sd->channel_count; k++) { - if (strcmpi(sub1+1,sd->channels[k]->name) == 0) - break; - } - if (k == sd->channel_count) { + ARR_FIND(0, VECTOR_LENGTH(sd->channels), k, strcmpi(sub1 + 1, VECTOR_INDEX(sd->channels, k)->name) == 0); + if (k == VECTOR_LENGTH(sd->channels)) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1425),sub1);// You're not part of the '%s' channel clif->message(fd, atcmd_output); return false; } - if (sd->channels[k]->type == HCS_TYPE_ALLY) { - do { - for (k = 0; k < sd->channel_count; k++) { - if (sd->channels[k]->type == HCS_TYPE_ALLY) { - channel->leave(sd->channels[k],sd); - break; - } + if (VECTOR_INDEX(sd->channels, k)->type == HCS_TYPE_ALLY) { + for (k = VECTOR_LENGTH(sd->channels) - 1; k >= 0; k--) { + // Loop downward to avoid issues when channel->leave() compacts the array + if (VECTOR_INDEX(sd->channels, k)->type == HCS_TYPE_ALLY) { + channel->leave(VECTOR_INDEX(sd->channels, k), sd); } - } while (k != sd->channel_count); + } } else { - channel->leave(sd->channels[k],sd); + channel->leave(VECTOR_INDEX(sd->channels, k), sd); } safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1426),sub1); // You've left the '%s' channel clif->message(fd, atcmd_output); } else if (strcmpi(subcmd,"bindto") == 0) { // sub1 = channel name; sub2 = unused; sub3 = unused + int k; if (sub1[0] != '#') { clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#' return false; } - for (k = 0; k < sd->channel_count; k++) { - if (strcmpi(sub1+1,sd->channels[k]->name) == 0) - break; - } - if (k == sd->channel_count) { + ARR_FIND(0, VECTOR_LENGTH(sd->channels), k, strcmpi(sub1 + 1, VECTOR_INDEX(sd->channels, k)->name) == 0); + if (k == VECTOR_LENGTH(sd->channels)) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1425),sub1);// You're not part of the '%s' channel clif->message(fd, atcmd_output); return false; } - sd->gcbind = sd->channels[k]; + sd->gcbind = VECTOR_INDEX(sd->channels, k); safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1431),sub1); // Your global chat is now bound to the '%s' channel clif->message(fd, atcmd_output); } else if (strcmpi(subcmd,"unbind") == 0) { @@ -9067,6 +9317,7 @@ ACMD(channel) { dbi_destroy(iter); } else if (strcmpi(subcmd,"setopt") == 0) { // sub1 = channel name; sub2 = option name; sub3 = value + int k; const char* opt_str[3] = { "None", "JoinAnnounce", @@ -9122,8 +9373,8 @@ ACMD(channel) { } else { int v = atoi(sub3); if (k == HCS_OPT_MSG_DELAY) { - if (v < 0 || v > 10) { - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10) + if (v < 0 || v > channel->config->channel_opt_msg_delay) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1451), v, opt_str[k], channel->config->channel_opt_msg_delay);// value '%d' for option '%s' is out of range (limit is 0-%d) clif->message(fd, atcmd_output); return false; } @@ -9170,8 +9421,10 @@ ACMD(channel) { } return true; } + /* debug only, delete after */ -ACMD(fontcolor) { +ACMD(fontcolor) +{ unsigned char k; if (!*message) { @@ -9203,7 +9456,9 @@ ACMD(fontcolor) { return true; } -ACMD(searchstore){ + +ACMD(searchstore) +{ int val = atoi(message); switch (val) { @@ -9218,7 +9473,12 @@ ACMD(searchstore){ searchstore->open(sd, 99, val); return true; } -ACMD(costume){ + +/*========================================== +* @costume +*------------------------------------------*/ +ACMD(costume) +{ const char* names[] = { "Wedding", "Xmas", @@ -9227,6 +9487,9 @@ ACMD(costume){ #if PACKETVER >= 20131218 "Oktoberfest", #endif +#if PACKETVER >= 20141022 + "Summer2", +#endif }; const int name2id[] = { SC_WEDDING, @@ -9236,41 +9499,54 @@ ACMD(costume){ #if PACKETVER >= 20131218 SC_OKTOBERFEST, #endif +#if PACKETVER >= 20141022 + SC_DRESS_UP, +#endif }; unsigned short k = 0, len = ARRAYLENGTH(names); + bool isChangeDress = (strcmpi(info->command, "changedress") == 0 || strcmpi(info->command, "nocosplay") == 0); + if (!*message) { - for( k = 0; k < len; k++ ) { - if( sd->sc.data[name2id[k]] ) { - safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1473),names[k]);//Costume '%s' removed. - clif->message(sd->fd,atcmd_output); - status_change_end(&sd->bl,name2id[k],INVALID_TIMER); + for (k = 0; k < len; k++) { + if (sd->sc.data[name2id[k]]) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1473), names[k]); // Costume '%s' removed. + clif->message(sd->fd, atcmd_output); + status_change_end(&sd->bl, name2id[k], INVALID_TIMER); return true; } } - clif->message(sd->fd,msg_fd(fd,1472)); - for( k = 0; k < len; k++ ) { - safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1471),names[k]);//-- %s - clif->message(sd->fd,atcmd_output); + + if (isChangeDress) + return true; + clif->message(sd->fd, msg_fd(fd, 1472)); // - Available Costumes + + for (k = 0; k < len; k++) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1471), names[k]); //-- %s + clif->message(sd->fd, atcmd_output); } return false; } - for( k = 0; k < len; k++ ) { - if( sd->sc.data[name2id[k]] ) { - safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1470),names[k]);// You're already with a '%s' costume, type '@costume' to remove it. - clif->message(sd->fd,atcmd_output); + if (isChangeDress) + return true; + + for (k = 0; k < len; k++) { + if (sd->sc.data[name2id[k]]) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1470), names[k]); // You're already with a '%s' costume, type '@costume' to remove it. + clif->message(sd->fd, atcmd_output); return false; } } - for( k = 0; k < len; k++ ) { - if( strcmpi(message,names[k]) == 0 ) + for (k = 0; k < len; k++) { + if (strcmpi(message,names[k]) == 0) break; } - if( k == len ) { - safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1469),message);// '%s' is not a known costume - clif->message(sd->fd,atcmd_output); + + if (k == len) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1469), message); // '%s' is not a known costume + clif->message(sd->fd, atcmd_output); return false; } @@ -9278,6 +9554,7 @@ ACMD(costume){ return true; } + /* for debugging purposes (so users can easily provide us with debug info) */ /* should be trashed as soon as its no longer necessary */ ACMD(skdebug) @@ -9292,10 +9569,12 @@ ACMD(skdebug) clif->message(fd,atcmd_output); return true; } + /** * cooldown-debug **/ -ACMD(cddebug) { +ACMD(cddebug) +{ int i; struct skill_cd* cd = NULL; @@ -9316,7 +9595,7 @@ ACMD(cddebug) { } if (!cd || (*message && !strcmpi(message,"reset"))) { - for(i = 0; i < MAX_SKILL; i++) { + for (i = 0; i < MAX_SKILL_DB; i++) { if( sd->blockskill[i] ) { clif->messages(fd,"Found skill '%s', unblocking...",skill->dbs->db[i].name); sd->blockskill[i] = false; @@ -9340,7 +9619,8 @@ ACMD(cddebug) { /** * **/ -ACMD(lang) { +ACMD(lang) +{ uint8 i; if (!*message) { @@ -9372,12 +9652,164 @@ ACMD(lang) { return true; } + +ACMD(claninfo) +{ + struct DBIterator *iter = db_iterator(clan->db); + struct clan *c; + int i, count; + + for (c = dbi_first(iter); dbi_exists(iter); c = dbi_next(iter)) { + safesnprintf(atcmd_output, sizeof(atcmd_output), "Clan #%d:", c->clan_id); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Name: %s", c->name); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Constant: %s", c->constant); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Master: %s", c->master); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Map: %s", c->map); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Max Member: %d", c->max_member); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Kick Time: %dh", c->kick_time / 3600); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Check Time: %dh", c->check_time / 3600000); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Connected Members: %d", c->connect_member); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Total Members: %d", c->member_count); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Allies: %d", VECTOR_LENGTH(c->allies)); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + count = 0; + for (i = 0; i < VECTOR_LENGTH(c->allies); i++) { + struct clan_relationship *ally = &VECTOR_INDEX(c->allies, i); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- - Ally #%d (Id: %d): %s", i + 1, ally->clan_id, ally->constant); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + count++; + } + + if (count == 0) { + clif->messagecolor_self(fd, COLOR_DEFAULT, "- - No Allies Found!"); + } + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- Antagonists: %d", VECTOR_LENGTH(c->antagonists)); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + + count = 0; + for (i = 0; i < VECTOR_LENGTH(c->antagonists); i++) { + struct clan_relationship *antagonist = &VECTOR_INDEX(c->antagonists, i); + + safesnprintf(atcmd_output, sizeof(atcmd_output), "- - Antagonist #%d (Id: %d): %s", i + 1, antagonist->clan_id, antagonist->constant); + clif->messagecolor_self(fd, COLOR_DEFAULT, atcmd_output); + count++; + } + + if (count == 0) { + clif->messagecolor_self(fd, COLOR_DEFAULT, "- - No Antagonists Found!"); + } + + clif->messagecolor_self(fd, COLOR_DEFAULT, "============================"); + } + dbi_destroy(iter); + return true; +} + +/** + * Clan System: Joins in the given clan + */ +ACMD(joinclan) +{ + int clan_id; + + if (*message == '\0') { + clif->message(fd, "Please enter a Clan ID (usage: @joinclan <clan ID>)."); + return false; + } + if (sd->status.clan_id != 0) { + clif->messagecolor_self(fd, COLOR_RED, "You are already in a clan."); + return false; + } else if (sd->status.guild_id != 0) { + clif->messagecolor_self(fd, COLOR_RED, "You must leave your guild before enter in a clan."); + return false; + } + + clan_id = atoi(message); + if (clan_id <= 0) { + clif->messagecolor_self(fd, COLOR_RED, "Invalid Clan ID."); + return false; + } + if (!clan->join(sd, clan_id)) { + clif->messagecolor_self(fd, COLOR_RED, "The clan couldn't be joined."); + return false; + } + return true; +} + +/** + * Clan System: Leaves current clan + */ +ACMD(leaveclan) +{ + if (sd->status.clan_id == 0) { + clif->messagecolor_self(fd, COLOR_RED, "You aren't in a clan."); + return false; + } + if (!clan->leave(sd, false)) { + clif->messagecolor_self(fd, COLOR_RED, "Failed on leaving clan."); + return false; + } + return true; +} + +/** + * Clan System: Reloads clan db + */ +ACMD(reloadclans) +{ + clan->reload(); + clif->messagecolor_self(fd, COLOR_DEFAULT, "Clan configuration and database have been reloaded."); + return true; +} + +// show camera window or change camera parameters +ACMD(camerainfo) +{ + if (*message == '\0') { + clif->camera_showWindow(sd); + return true; + } + float range = 0; + float rotation = 0; + float latitude = 0; + if (sscanf(message, "%15f %15f %15f", &range, &rotation, &latitude) < 3) { + clif->message(fd, msg_fd(fd, 452)); // usage @camerainfo range rotation latitude + return false; + } + clif->camera_change(sd, range, rotation, latitude, SELF); + return true; +} + /** * Fills the reference of available commands in atcommand DBMap **/ #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, NULL, true } #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, NULL, true } -void atcommand_basecommands(void) { +static void atcommand_basecommands(void) +{ /** * Command reference list, place the base of your commands here **/ @@ -9640,10 +10072,20 @@ void atcommand_basecommands(void) { ACMD_DEF(fontcolor), ACMD_DEF(searchstore), ACMD_DEF(costume), + ACMD_DEF2("changedress", costume), + ACMD_DEF2("nocosplay", costume), ACMD_DEF(skdebug), ACMD_DEF(cddebug), ACMD_DEF(lang), ACMD_DEF(bodystyle), + ACMD_DEF(cvcoff), + ACMD_DEF(cvcon), + ACMD_DEF(claninfo), + ACMD_DEF(joinclan), + ACMD_DEF(leaveclan), + ACMD_DEF(reloadclans), + ACMD_DEF(setzone), + ACMD_DEF(camerainfo), }; int i; @@ -9662,7 +10104,8 @@ void atcommand_basecommands(void) { #undef ACMD_DEF #undef ACMD_DEF2 -bool atcommand_add(char *name, AtCommandFunc func, bool replace) { +static bool atcommand_add(char *name, AtCommandFunc func, bool replace) +{ AtCommandInfo* cmd; nullpo_retr(false, name); @@ -9685,18 +10128,21 @@ bool atcommand_add(char *name, AtCommandFunc func, bool replace) { /*========================================== * Command lookup functions *------------------------------------------*/ -AtCommandInfo* atcommand_exists(const char* name) { +static AtCommandInfo *atcommand_exists(const char *name) +{ return strdb_get(atcommand->db, name); } -AtCommandInfo* get_atcommandinfo_byname(const char *name) { +static AtCommandInfo *get_atcommandinfo_byname(const char *name) +{ AtCommandInfo *cmd; if ((cmd = strdb_get(atcommand->db, name))) return cmd; return NULL; } -const char* atcommand_checkalias(const char *aliasname) { +static const char *atcommand_checkalias(const char *aliasname) +{ AliasInfo *alias_info = NULL; if ((alias_info = (AliasInfo*)strdb_get(atcommand->alias_db, aliasname)) != NULL) return alias_info->command->command; @@ -9704,7 +10150,8 @@ const char* atcommand_checkalias(const char *aliasname) { } /// AtCommand suggestion -void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool is_atcmd_cmd) { +static void atcommand_get_suggestions(struct map_session_data *sd, const char *name, bool is_atcmd_cmd) +{ struct DBIterator *atcommand_iter, *alias_iter; AtCommandInfo* command_info = NULL; AliasInfo* alias_info = NULL; @@ -9785,10 +10232,11 @@ void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bo * @retval true if the message was recognized as atcommand. * @retval false if the message should be considered a non-command message. */ -bool atcommand_exec(const int fd, struct map_session_data *sd, const char *message, bool player_invoked) +static bool atcommand_exec(const int fd, struct map_session_data *sd, const char *message, bool player_invoked) { char params[100], command[100]; char output[CHAT_SIZE_MAX]; + bool logCommand; // Reconstructed message char atcmd_msg[CHAT_SIZE_MAX]; @@ -9823,6 +10271,8 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa return false; } } + if (sd->block_action.commands) // *pcblock script command + return false; if (*message == atcommand->char_symbol) is_atcommand = false; @@ -9887,6 +10337,8 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa && ( (is_atcommand && pc_get_group_level(sd) >= binding->group_lv) || (!is_atcommand && pc_get_group_level(sd) >= binding->group_lv_char) + || (is_atcommand && binding->at_groups[pcg->get_idx(sd->group)] > 0) + || (!is_atcommand && binding->char_groups[pcg->get_idx(sd->group)] > 0) ) ) { if (binding->log) /* log only if this command should be logged [Ind/Hercules] */ @@ -9930,6 +10382,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa } } + logCommand = info->log; //Attempt to use the command if ((info->func(fd, ssd, command, params,info) != true)) { #ifdef AUTOTRADE_PERSISTENCY @@ -9941,7 +10394,8 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa return true; } - if (info->log) /* log only if this command should be logged [Ind/Hercules] */ + // info->log cant be used here, because info can be freed [4144] + if (logCommand) /* log only if this command should be logged [Ind/Hercules] */ logs->atcommand(sd, is_atcommand ? atcmd_msg : message); return true; @@ -9950,7 +10404,8 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa /*========================================== * *------------------------------------------*/ -void atcommand_config_read(const char* config_filename) { +static void atcommand_config_read(const char *config_filename) +{ struct config_t atcommand_config; struct config_setting_t *aliases = NULL, *help = NULL, *nolog = NULL; const char *symbol = NULL; @@ -10089,7 +10544,7 @@ static inline int atcommand_command_type2idx(AtCommandType type) * Loads permissions for groups to use commands. * */ -void atcommand_db_load_groups(GroupSettings **groups, struct config_setting_t **commands_, size_t sz) +static void atcommand_db_load_groups(GroupSettings **groups, struct config_setting_t **commands_, size_t sz) { struct DBIterator *iter = db_iterator(atcommand->db); AtCommandInfo *atcmd; @@ -10149,37 +10604,44 @@ void atcommand_db_load_groups(GroupSettings **groups, struct config_setting_t ** return; } -bool atcommand_can_use(struct map_session_data *sd, const char *command) { - AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); +static bool atcommand_can_use(struct map_session_data *sd, const char *command) +{ + AtCommandInfo *acmd_d; + struct atcmd_binding_data *bcmd_d; nullpo_retr(false, sd); - nullpo_retr(false, command); - if (info == NULL) - return false; - if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] != 0) || - (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] != 0) ) { - return true; + if ((acmd_d = atcommand->get_info_byname(atcommand->check_alias(command + 1))) != NULL) { + return ((*command == atcommand->at_symbol && acmd_d->at_groups[pcg->get_idx(sd->group)] > 0) || + (*command == atcommand->char_symbol && acmd_d->char_groups[pcg->get_idx(sd->group)] > 0)); + } else if ((bcmd_d = atcommand->get_bind_byname(atcommand->check_alias(command + 1))) != NULL) { + return ((*command == atcommand->at_symbol && bcmd_d->at_groups[pcg->get_idx(sd->group)] > 0) || + (*command == atcommand->char_symbol && bcmd_d->char_groups[pcg->get_idx(sd->group)] > 0)); } return false; } -bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) { - AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command)); + +static bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) +{ + AtCommandInfo *acmd_d; + struct atcmd_binding_data *bcmd_d; nullpo_retr(false, sd); - nullpo_retr(false, command); - if (info == NULL) - return false; - if ((type == COMMAND_ATCOMMAND && info->at_groups[pcg->get_idx(sd->group)] != 0) || - (type == COMMAND_CHARCOMMAND && info->char_groups[pcg->get_idx(sd->group)] != 0) ) { - return true; + if ((acmd_d = atcommand->get_info_byname(atcommand->check_alias(command))) != NULL) { + return ((type == COMMAND_ATCOMMAND && acmd_d->at_groups[pcg->get_idx(sd->group)] > 0) || + (type == COMMAND_CHARCOMMAND && acmd_d->char_groups[pcg->get_idx(sd->group)] > 0)); + } else if ((bcmd_d = atcommand->get_bind_byname(atcommand->check_alias(command))) != NULL) { + return ((type == COMMAND_ATCOMMAND && bcmd_d->at_groups[pcg->get_idx(sd->group)] > 0) || + (type == COMMAND_CHARCOMMAND && bcmd_d->char_groups[pcg->get_idx(sd->group)] > 0)); } return false; } -bool atcommand_hp_add(char *name, AtCommandFunc func) { + +static bool atcommand_hp_add(char *name, AtCommandFunc func) +{ /* if commands are added after group permissions are thrown in, they end up with no permissions */ /* so we restrict commands to be linked in during boot */ if( core->runflag == MAPSERVER_ST_RUNNING ) { @@ -10193,7 +10655,7 @@ bool atcommand_hp_add(char *name, AtCommandFunc func) { /** * @see DBApply */ -int atcommand_db_clear_sub(union DBKey key, struct DBData *data, va_list args) +static int atcommand_db_clear_sub(union DBKey key, struct DBData *data, va_list args) { AtCommandInfo *cmd = DB->data2ptr(data); aFree(cmd->at_groups); @@ -10203,7 +10665,8 @@ int atcommand_db_clear_sub(union DBKey key, struct DBData *data, va_list args) return 0; } -void atcommand_db_clear(void) { +static void atcommand_db_clear(void) +{ if( atcommand->db != NULL ) { atcommand->db->destroy(atcommand->db, atcommand->cmd_db_clear_sub); atcommand->db = NULL; @@ -10214,7 +10677,8 @@ void atcommand_db_clear(void) { } } -void atcommand_doload(void) { +static void atcommand_doload(void) +{ if( core->runflag >= MAPSERVER_ST_RUNNING ) atcommand->cmd_db_clear(); if( atcommand->db == NULL ) @@ -10225,12 +10689,14 @@ void atcommand_doload(void) { atcommand->config_read(map->ATCOMMAND_CONF_FILENAME); } -void atcommand_expand_message_table(void) { +static void atcommand_expand_message_table(void) +{ RECREATE(atcommand->msg_table, char **, ++atcommand->max_message_table); CREATE(atcommand->msg_table[atcommand->max_message_table - 1], char *, MAX_MSG); } -void do_init_atcommand(bool minimal) { +static void do_init_atcommand(bool minimal) +{ if (minimal) return; @@ -10241,11 +10707,13 @@ void do_init_atcommand(bool minimal) { atcommand->doload(); } -void do_final_atcommand(void) { +static void do_final_atcommand(void) +{ atcommand->cmd_db_clear(); } -void atcommand_defaults(void) { +void atcommand_defaults(void) +{ atcommand = &atcommand_s; atcommand->db = NULL; |