From 730e5dde39333cb2f63c72a7d7152bee5c4dbb05 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 8 Feb 2014 15:09:25 -0800 Subject: Implement AString --- src/map/atcommand.cpp | 148 +++++++++++++++++------------------ src/map/atcommand.hpp | 2 +- src/map/battle.cpp | 6 +- src/map/chrif.cpp | 4 +- src/map/clif.cpp | 28 +++---- src/map/grfio.cpp | 17 ++-- src/map/intif.cpp | 10 +-- src/map/itemdb.cpp | 4 +- src/map/magic-expr.cpp | 10 +-- src/map/magic-expr.hpp | 2 +- src/map/magic-interpreter-base.cpp | 10 +-- src/map/magic-interpreter-parser.ypp | 29 +++---- src/map/magic-interpreter.hpp | 18 ++--- src/map/magic.hpp | 4 +- src/map/map.cpp | 16 ++-- src/map/map.hpp | 17 ++-- src/map/mob.cpp | 6 +- src/map/npc.cpp | 24 +++--- src/map/npc.hpp | 6 +- src/map/pc.cpp | 13 +-- src/map/pc.hpp | 2 +- src/map/script.cpp | 37 ++++----- src/map/script.hpp | 7 +- src/map/skill.cpp | 8 +- src/map/skill.hpp | 11 +-- src/map/tmw.cpp | 8 +- 26 files changed, 229 insertions(+), 218 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index f5deab8..dca9b4e 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -5,7 +5,7 @@ #include #include "../strings/mstring.hpp" -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" #include "../strings/vstring.hpp" @@ -182,7 +182,7 @@ void log_atcommand(dumb_ptr sd, ZString cmd) cmd); } -FString gm_log; +AString gm_log; io::AppendFile *get_gm_log() { @@ -201,7 +201,7 @@ io::AppendFile *get_gm_log() return gm_logfile.get(); last_logfile_nr = logfile_nr; - FString fullname = STRPRINTF("%s.%04d-%02d", + AString fullname = STRPRINTF("%s.%04d-%02d", gm_log, year, month); if (gm_logfile) @@ -212,7 +212,7 @@ io::AppendFile *get_gm_log() if (!gm_logfile) { perror("GM log file"); - gm_log = FString(); + gm_log = AString(); } return gm_logfile.get(); } @@ -235,24 +235,24 @@ bool is_atcommand(Session *s, dumb_ptr sd, gmlvl = pc_isGM(sd); if (battle_config.atcommand_gm_only != 0 && !gmlvl) { - FString output = STRPRINTF("GM command is level 0, but this server disables level 0 commands: %s", - FString(command)); + AString output = STRPRINTF("GM command is level 0, but this server disables level 0 commands: %s", + AString(command)); clif_displaymessage(s, output); return true; } if (!info) { - FString output = STRPRINTF("GM command not found: %s", - FString(command)); + AString output = STRPRINTF("GM command not found: %s", + AString(command)); clif_displaymessage(s, output); return true; // don't show in chat } if (info->level > gmlvl) { - FString output = STRPRINTF("GM command is level %d, but you are level %d: %s", + AString output = STRPRINTF("GM command is level %d, but you are level %d: %s", info->level, gmlvl, - FString(command)); + AString(command)); clif_displaymessage(s, output); return true; } @@ -269,7 +269,7 @@ bool is_atcommand(Session *s, dumb_ptr sd, break; case ATCE::USAGE: clif_displaymessage(s, "Command failed: usage error"); - clif_displaymessage(s, STRPRINTF("Usage: %s %s", FString(command), info->args)); + clif_displaymessage(s, STRPRINTF("Usage: %s %s", AString(command), info->args)); break; case ATCE::EXIST: clif_displaymessage(s, "Command failed: something does not exist (or already exists)"); @@ -328,7 +328,7 @@ bool atcommand_config_read(ZString cfgName) } bool rv = true; - FString line; + AString line; while (in.getline(line)) { if (is_comment(line)) @@ -442,7 +442,7 @@ ATCE atcommand_setup(Session *s, dumb_ptr sd, return ATCE::USAGE; level--; - FString buf; + AString buf; buf = STRPRINTF("-255 %s", character); atcommand_character_baselevel(s, sd, buf); @@ -606,7 +606,7 @@ ATCE atcommand_where(Session *s, dumb_ptr sd, && (pc_isGM(pl_sd) > pc_isGM(sd)))) { // you can look only lower or same level - FString output = STRPRINTF("%s: %s (%d,%d)", + AString output = STRPRINTF("%s: %s (%d,%d)", pl_sd->status.name, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); clif_displaymessage(s, output); @@ -651,7 +651,7 @@ ATCE atcommand_goto(Session *s, dumb_ptr sd, return ATCE::PERM; } pc_setpos(sd, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y, BeingRemoveWhy::WARPED); - FString output = STRPRINTF("Jump to %s", character); + AString output = STRPRINTF("Jump to %s", character); clif_displaymessage(s, output); } else @@ -692,7 +692,7 @@ ATCE atcommand_jump(Session *s, dumb_ptr sd, return ATCE::PERM; } pc_setpos(sd, sd->mapname_, x, y, BeingRemoveWhy::WARPED); - FString output = STRPRINTF("Jump to %d %d", x, y); + AString output = STRPRINTF("Jump to %d %d", x, y); clif_displaymessage(s, output); } else @@ -734,7 +734,7 @@ ATCE atcommand_who(Session *s, dumb_ptr sd, if (player_name.contains_seq(match_text)) { // search with no case sensitive - FString output; + AString output; if (pl_GM_level > 0) output = STRPRINTF( "Name: %s (GM:%d) | Location: %s %d %d", @@ -758,7 +758,7 @@ ATCE atcommand_who(Session *s, dumb_ptr sd, clif_displaymessage(s, "1 player found."); else { - FString output = STRPRINTF("%d players found.", count); + AString output = STRPRINTF("%d players found.", count); clif_displaymessage(s, output); } @@ -799,7 +799,7 @@ ATCE atcommand_whogroup(Session *s, dumb_ptr sd, // search with no case sensitive p = party_search(pl_sd->status.party_id); PartyName temp0 = p ? p->name : stringish("None"); - FString output; + AString output; if (pl_GM_level > 0) output = STRPRINTF( "Name: %s (GM:%d) | Party: '%s'", @@ -817,7 +817,7 @@ ATCE atcommand_whogroup(Session *s, dumb_ptr sd, clif_displaymessage(s, "1 player found."); else { - FString output = STRPRINTF("%d players found.", count); + AString output = STRPRINTF("%d players found.", count); clif_displaymessage(s, output); } @@ -859,7 +859,7 @@ ATCE atcommand_whomap(Session *s, dumb_ptr sd, // you can look only lower or same level if (pl_sd->bl_m == map_id) { - FString output; + AString output; if (pl_GM_level > 0) output = STRPRINTF( "Name: %s (GM:%d) | Location: %s %d %d", @@ -877,7 +877,7 @@ ATCE atcommand_whomap(Session *s, dumb_ptr sd, } } - FString output = STRPRINTF("%d players found in map '%s'.", + AString output = STRPRINTF("%d players found in map '%s'.", count, map_id->name_); clif_displaymessage(s, output); @@ -922,7 +922,7 @@ ATCE atcommand_whomapgroup(Session *s, dumb_ptr sd, { p = party_search(pl_sd->status.party_id); PartyName temp0 = p ? p->name : stringish("None"); - FString output; + AString output; if (pl_GM_level > 0) output = STRPRINTF("Name: %s (GM:%d) | Party: '%s'", pl_sd->status.name, pl_GM_level, temp0); @@ -936,7 +936,7 @@ ATCE atcommand_whomapgroup(Session *s, dumb_ptr sd, } } - FString output; + AString output; if (count == 0) output = STRPRINTF("No player found in map '%s'.", map_id->name_); else if (count == 1) @@ -984,7 +984,7 @@ ATCE atcommand_whogm(Session *s, dumb_ptr sd, if (player_name.contains_seq(match_text)) { // search with no case sensitive - FString output; + AString output; output = STRPRINTF( "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, @@ -1015,7 +1015,7 @@ ATCE atcommand_whogm(Session *s, dumb_ptr sd, clif_displaymessage(s, "1 GM found."); else { - FString output = STRPRINTF("%d GMs found.", count); + AString output = STRPRINTF("%d GMs found.", count); clif_displaymessage(s, output); } @@ -1067,7 +1067,7 @@ ATCE atcommand_speed(Session *s, dumb_ptr sd, { if (!message) { - FString output = STRPRINTF( + AString output = STRPRINTF( "Please, enter a speed value (usage: @speed <%d-%d>).", static_cast(MIN_WALK_SPEED.count()), static_cast(MAX_WALK_SPEED.count())); @@ -1086,7 +1086,7 @@ ATCE atcommand_speed(Session *s, dumb_ptr sd, } else { - FString output = STRPRINTF( + AString output = STRPRINTF( "Please, enter a valid speed value (usage: @speed <%d-%d>).", static_cast(MIN_WALK_SPEED.count()), static_cast(MAX_WALK_SPEED.count())); @@ -1746,7 +1746,7 @@ ATCE atcommand_spawn(Session *s, dumb_ptr sd, clif_displaymessage(s, "All monster summoned!"); else { - FString output = STRPRINTF("%d monster(s) summoned!", + AString output = STRPRINTF("%d monster(s) summoned!", count); clif_displaymessage(s, output); } @@ -1795,7 +1795,7 @@ void atlist_nearby_sub(dumb_ptr bl, Session *s) { nullpo_retv(bl); - FString buf = STRPRINTF(" - \"%s\"", + AString buf = STRPRINTF(" - \"%s\"", bl->is_player()->status.name); clif_displaymessage(s, buf); } @@ -1831,7 +1831,7 @@ ATCE atcommand_gat(Session *s, dumb_ptr sd, for (y = 2; y >= -2; y--) { - FString output = STRPRINTF( + AString output = STRPRINTF( "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", sd->bl_m->name_, sd->bl_x - 2, sd->bl_y + y, map_getcell(sd->bl_m, sd->bl_x - 2, sd->bl_y + y), @@ -2049,7 +2049,7 @@ ATCE atcommand_recall(Session *s, dumb_ptr sd, return ATCE::PERM; } pc_setpos(pl_sd, sd->mapname_, sd->bl_x, sd->bl_y, BeingRemoveWhy::QUIT); - FString output = STRPRINTF("%s recalled!", character); + AString output = STRPRINTF("%s recalled!", character); clif_displaymessage(s, output); } else @@ -2109,7 +2109,7 @@ ATCE atcommand_character_stats(Session *s, dumb_ptr, dumb_ptr pl_sd = map_nick2sd(character); if (pl_sd != NULL) { - FString output; + AString output; output = STRPRINTF("'%s' stats:", pl_sd->status.name); clif_displaymessage(s, output); output = STRPRINTF("Base Level - %d", pl_sd->status.base_level), @@ -2163,13 +2163,13 @@ ATCE atcommand_character_stats_all(Session *s, dumb_ptr, dumb_ptr pl_sd = dumb_ptr(static_cast(s2->session_data.get())); if (pl_sd && pl_sd->state.auth) { - FString gmlevel; + AString gmlevel; if (pc_isGM(pl_sd) > 0) gmlevel = STRPRINTF("| GM Lvl: %d", pc_isGM(pl_sd)); else gmlevel = " "; - FString output; + AString output; output = STRPRINTF( "Name: %s | BLvl: %d | Job: Novice/Human (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, @@ -2198,7 +2198,7 @@ ATCE atcommand_character_stats_all(Session *s, dumb_ptr, clif_displaymessage(s, "1 player found."); else { - FString output = STRPRINTF("%d players found.", count); + AString output = STRPRINTF("%d players found.", count); clif_displaymessage(s, output); } @@ -2935,7 +2935,7 @@ ATCE atcommand_idsearch(Session *s, dumb_ptr, if (!extract(message, &item_name) || !item_name) return ATCE::USAGE; - FString output = STRPRINTF("The reference result of '%s' (name: id):", item_name); + AString output = STRPRINTF("The reference result of '%s' (name: id):", item_name); clif_displaymessage(s, output); match = 0; for (i = 0; i < 20000; i++) @@ -2970,7 +2970,7 @@ ATCE atcommand_charskreset(Session *s, dumb_ptr sd, { // you can reset skill points only lower or same gm level pc_resetskill(pl_sd); - FString output = STRPRINTF( + AString output = STRPRINTF( "'%s' skill points reseted!", character); clif_displaymessage(s, output); } @@ -3005,7 +3005,7 @@ ATCE atcommand_charstreset(Session *s, dumb_ptr sd, { // you can reset stats points only lower or same gm level pc_resetstate(pl_sd); - FString output = STRPRINTF( + AString output = STRPRINTF( "'%s' stats points reseted!", character); clif_displaymessage(s, output); @@ -3046,7 +3046,7 @@ ATCE atcommand_charreset(Session *s, dumb_ptr sd, // [Fate] Reset magic quest variables pc_setglobalreg(pl_sd, stringish("MAGIC_EXP"), 0); // [Fate] Reset magic experience - FString output = STRPRINTF( + AString output = STRPRINTF( "'%s' skill and stats points reseted!", character); clif_displaymessage(s, output); } @@ -3131,7 +3131,7 @@ ATCE atcommand_char_wipe(Session *s, dumb_ptr sd, pc_setglobalreg(pl_sd, stringish("MAGIC_EXP"), 0); // [Fate] Reset magic experience - FString output = STRPRINTF("%s: wiped.", character); + AString output = STRPRINTF("%s: wiped.", character); clif_displaymessage(s, output); } else @@ -3341,7 +3341,7 @@ ATCE atcommand_recallall(Session *s, dumb_ptr sd, clif_displaymessage(s, "All characters recalled!"); if (count) { - FString output = STRPRINTF( + AString output = STRPRINTF( "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count); clif_displaymessage(s, output); @@ -3391,7 +3391,7 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr sd, pc_setpos(pl_sd, sd->mapname_, sd->bl_x, sd->bl_y, BeingRemoveWhy::QUIT); } } - FString output = STRPRINTF("All online characters of the %s party are near you.", p->name); + AString output = STRPRINTF("All online characters of the %s party are near you.", p->name); clif_displaymessage(s, output); if (count) { @@ -3432,7 +3432,7 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr sd, return ATCE::EXIST; clif_displaymessage(s, "------ Map Info ------"); - FString output = STRPRINTF("Map Name: %s", map_name); + AString output = STRPRINTF("Map Name: %s", map_name); clif_displaymessage(s, output); output = STRPRINTF("Players In Map: %d", m_id->users); clif_displaymessage(s, output); @@ -3565,13 +3565,13 @@ ATCE atcommand_partyspy(Session *s, dumb_ptr sd, if (sd->partyspy == p->party_id) { sd->partyspy = 0; - FString output = STRPRINTF("No longer spying on the %s party.", p->name); + AString output = STRPRINTF("No longer spying on the %s party.", p->name); clif_displaymessage(s, output); } else { sd->partyspy = p->party_id; - FString output = STRPRINTF("Spying on the %s party.", p->name); + AString output = STRPRINTF("Spying on the %s party.", p->name); clif_displaymessage(s, output); } } @@ -3636,7 +3636,7 @@ ATCE atcommand_servertime(Session *s, dumb_ptr, { timestamp_seconds_buffer tsbuf; stamp_time(tsbuf); - FString temp = STRPRINTF("Server time: %s", tsbuf); + AString temp = STRPRINTF("Server time: %s", tsbuf); clif_displaymessage(s, temp); return ATCE::OKAY; @@ -3678,7 +3678,7 @@ ATCE atcommand_chardelitem(Session *s, dumb_ptr sd, item_position = pc_search_inventory(pl_sd, item_id); // for next loop } - FString output = STRPRINTF( + AString output = STRPRINTF( "%d item(s) removed by a GM.", count); clif_displaymessage(pl_sd->sess, output); @@ -3723,7 +3723,7 @@ ATCE atcommand_broadcast(Session *, dumb_ptr sd, if (!message) return ATCE::USAGE; - FString output = STRPRINTF("%s : %s", sd->status.name, message); + AString output = STRPRINTF("%s : %s", sd->status.name, message); intif_GMmessage(output); return ATCE::OKAY; @@ -3736,7 +3736,7 @@ ATCE atcommand_localbroadcast(Session *, dumb_ptr sd, if (!message) return ATCE::USAGE; - FString output = STRPRINTF("%s : %s", sd->status.name, message); + AString output = STRPRINTF("%s : %s", sd->status.name, message); clif_GMmessage(sd, output, 1); @@ -3844,7 +3844,7 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, count++; if (count == 1) { - FString output = STRPRINTF( + AString output = STRPRINTF( "------ Items list of '%s' ------", pl_sd->status.name); clif_displaymessage(s, output); @@ -3888,7 +3888,7 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, else equipstr = MString(); - FString output; + AString output; if (sd->status.inventory[i].refine) output = STRPRINTF("%d %s %+d (%s %+d, id: %d) %s", pl_sd->status.inventory[i].amount, @@ -3897,13 +3897,13 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, item_data->jname, pl_sd->status.inventory[i].refine, pl_sd->status.inventory[i].nameid, - FString(equipstr)); + AString(equipstr)); else output = STRPRINTF("%d %s (%s, id: %d) %s", pl_sd->status.inventory[i].amount, item_data->name, item_data->jname, pl_sd->status.inventory[i].nameid, - FString(equipstr)); + AString(equipstr)); clif_displaymessage(s, output); MString voutput; @@ -3938,7 +3938,7 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, // replace trailing ", " voutput.pop_back(); voutput.back() = ')'; - clif_displaymessage(s, FString(voutput)); + clif_displaymessage(s, AString(voutput)); } } } @@ -3946,7 +3946,7 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, clif_displaymessage(s, "No item found on this player."); else { - FString output = STRPRINTF( + AString output = STRPRINTF( "%d item(s) found in %d kind(s) of items.", counter, count); clif_displaymessage(s, output); @@ -3999,12 +3999,12 @@ ATCE atcommand_character_storage_list(Session *s, dumb_ptr sd, count++; if (count == 1) { - FString output = STRPRINTF( + AString output = STRPRINTF( "------ Storage items list of '%s' ------", pl_sd->status.name); clif_displaymessage(s, output); } - FString output; + AString output; if (stor->storage_[i].refine) output = STRPRINTF("%d %s %+d (%s %+d, id: %d)", stor->storage_[i].amount, @@ -4052,7 +4052,7 @@ ATCE atcommand_character_storage_list(Session *s, dumb_ptr sd, // replace last ", " voutput.pop_back(); voutput.back() = ')'; - clif_displaymessage(s, FString(voutput)); + clif_displaymessage(s, AString(voutput)); } } } @@ -4061,7 +4061,7 @@ ATCE atcommand_character_storage_list(Session *s, dumb_ptr sd, "No item found in the storage of this player."); else { - FString output = STRPRINTF( + AString output = STRPRINTF( "%d item(s) found in %d kind(s) of items.", counter, count); clif_displaymessage(s, output); @@ -4117,13 +4117,13 @@ ATCE atcommand_character_cart_list(Session *s, dumb_ptr sd, count++; if (count == 1) { - FString output = STRPRINTF( + AString output = STRPRINTF( "------ Cart items list of '%s' ------", pl_sd->status.name); clif_displaymessage(s, output); } - FString output; + AString output; if (pl_sd->status.cart[i].refine) output = STRPRINTF("%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, @@ -4170,7 +4170,7 @@ ATCE atcommand_character_cart_list(Session *s, dumb_ptr sd, { voutput.pop_back(); voutput.back() = '0'; - clif_displaymessage(s, FString(voutput)); + clif_displaymessage(s, AString(voutput)); } } } @@ -4179,7 +4179,7 @@ ATCE atcommand_character_cart_list(Session *s, dumb_ptr sd, "No item found in the cart of this player."); else { - FString output = STRPRINTF("%d item(s) found in %d kind(s) of items.", + AString output = STRPRINTF("%d item(s) found in %d kind(s) of items.", counter, count); clif_displaymessage(s, output); } @@ -4312,9 +4312,9 @@ ATCE atcommand_addwarp(Session *s, dumb_ptr sd, if (!extract(message, record<' '>(&mapname, &x, &y))) return ATCE::USAGE; - FString w1 = STRPRINTF("%s,%d,%d", sd->mapname_, sd->bl_x, sd->bl_y); - FString w3 = STRPRINTF("%s%d%d%d%d", mapname, sd->bl_x, sd->bl_y, x, y); - FString w4 = STRPRINTF("1,1,%s.gat,%d,%d", mapname, x, y); + AString w1 = STRPRINTF("%s,%d,%d", sd->mapname_, sd->bl_x, sd->bl_y); + AString w3 = STRPRINTF("%s%d%d%d%d", mapname, sd->bl_x, sd->bl_y, x, y); + AString w4 = STRPRINTF("1,1,%s.gat,%d,%d", mapname, x, y); NpcName w3name = stringish(w3); int ret = npc_parse_warp(w1, ZString("warp"), w3name, w4); @@ -4322,7 +4322,7 @@ ATCE atcommand_addwarp(Session *s, dumb_ptr sd, // warp failed return ATCE::RANGE; - FString output = STRPRINTF("New warp NPC => %s", w3); + AString output = STRPRINTF("New warp NPC => %s", w3); clif_displaymessage(s, output); return ATCE::OKAY; @@ -4689,7 +4689,7 @@ ATCE atcommand_magic_info(Session *s, dumb_ptr, dumb_ptr pl_sd = map_nick2sd(character); if (pl_sd) { - FString buf = STRPRINTF( + AString buf = STRPRINTF( "`%s' has the following magic skills:", character); clif_displaymessage(s, buf); @@ -4788,7 +4788,7 @@ ATCE atcommand_tee(Session *, dumb_ptr sd, data += sd->status.name.to__actual(); data += " : "; data += message; - clif_message(sd, FString(data)); + clif_message(sd, AString(data)); return ATCE::OKAY; } @@ -4845,7 +4845,7 @@ ATCE atcommand_jump_iterate(Session *s, dumb_ptr sd, return ATCE::PERM; } pc_setpos(sd, pl_sd->bl_m->name_, pl_sd->bl_x, pl_sd->bl_y, BeingRemoveWhy::WARPED); - FString output = STRPRINTF("Jump to %s", pl_sd->status.name); + AString output = STRPRINTF("Jump to %s", pl_sd->status.name); clif_displaymessage(s, output); sd->followtarget = pl_sd->bl_id; @@ -4896,7 +4896,7 @@ ATCE atcommand_skillpool_info(Session *s, dumb_ptr, int pool_skills_nr = skill_pool(pl_sd, pool_skills); int i; - FString buf = STRPRINTF( + AString buf = STRPRINTF( "Active skills %d out of %d for %s:", pool_skills_nr, skill_pool_max(pl_sd), character); clif_displaymessage(s, buf); @@ -4915,7 +4915,7 @@ ATCE atcommand_skillpool_info(Session *s, dumb_ptr, for (i = 0; i < skill_pool_skills_size; ++i) { - const FString& name = skill_name(skill_pool_skills[i]); + const RString& name = skill_name(skill_pool_skills[i]); int lvl = pl_sd->status.skill[skill_pool_skills[i]].lv; if (lvl) @@ -5042,7 +5042,7 @@ ATCE atcommand_ipcheck(Session *s, dumb_ptr, // Is checking GM levels really needed here? if (ip == pl_sd->get_ip()) { - FString output = STRPRINTF( + AString output = STRPRINTF( "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp index a18b035..c825976 100644 --- a/src/map/atcommand.hpp +++ b/src/map/atcommand.hpp @@ -15,7 +15,7 @@ bool atcommand_config_read(ZString cfgName); void log_atcommand(dumb_ptr sd, ZString cmd); // only used by map.cpp -extern FString gm_log; +extern AString gm_log; void atcommand_config_write(ZString cfgName); diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 35cef79..d1e79ef 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -2,7 +2,7 @@ #include -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../io/cxxstdio.hpp" @@ -2420,7 +2420,7 @@ bool battle_config_read(ZString cfgName) return false; } - FString line; + AString line; while (in.getline(line)) { #define BATTLE_CONFIG_VAR(name) {{#name}, &battle_config.name} @@ -2555,7 +2555,7 @@ bool battle_config_read(ZString cfgName) goto continue_outer; } - PRINTF("WARNING: unknown battle conf key: %s\n", FString(w1)); + PRINTF("WARNING: unknown battle conf key: %s\n", AString(w1)); rv = false; continue_outer: diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index ab67b5c..c49a101 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -4,7 +4,7 @@ #include -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../io/cxxstdio.hpp" @@ -462,7 +462,7 @@ int chrif_char_ask_name_answer(Session *s) dumb_ptr sd = map_id2sd(acc); if (acc >= 0 && sd != NULL) { - FString output; + AString output; if (RFIFOW(s, 32) == 1) // player not found output = STRPRINTF("The player '%s' doesn't exist.", player_name); diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 61c47d9..3fc716d 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -6,7 +6,7 @@ #include #include -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -217,7 +217,7 @@ enum class ChatType }; static -FString clif_validate_chat(dumb_ptr sd, ChatType type); +AString clif_validate_chat(dumb_ptr sd, ChatType type); /*========================================== * clif_sendでSendWho::AREA*指定時用 @@ -3761,7 +3761,7 @@ void clif_parse_GlobalMessage(Session *s, dumb_ptr sd) { nullpo_retv(sd); - FString mbuf = clif_validate_chat(sd, ChatType::Global); + AString mbuf = clif_validate_chat(sd, ChatType::Global); if (!mbuf) { clif_displaymessage(s, "Your message could not be sent."); @@ -4017,7 +4017,7 @@ void clif_parse_Wis(Session *s, dumb_ptr sd) nullpo_retv(sd); - FString mbuf = clif_validate_chat(sd, ChatType::Whisper); + AString mbuf = clif_validate_chat(sd, ChatType::Whisper); if (!mbuf) { clif_displaymessage(s, "Your message could not be sent."); @@ -4628,7 +4628,7 @@ void clif_parse_PartyMessage(Session *s, dumb_ptr sd) { nullpo_retv(sd); - FString mbuf = clif_validate_chat(sd, ChatType::Party); + AString mbuf = clif_validate_chat(sd, ChatType::Party); if (!mbuf) { clif_displaymessage(s, "Your message could not be sent."); @@ -5294,15 +5294,15 @@ void WARN_MALFORMED_MSG(dumb_ptr sd, const char *msg) * @return a dynamically allocated copy of the message, or empty string upon failure */ static -FString clif_validate_chat(dumb_ptr sd, ChatType type) +AString clif_validate_chat(dumb_ptr sd, ChatType type) { - nullpo_retr(FString(), sd); + nullpo_retr(AString(), sd); /* * Don't send chat in the period between the ban and the connection's * closure. */ if (sd->auto_ban_info.in_progress) - return FString(); + return AString(); Session *s = sd->sess; size_t msg_len = RFIFOW(s, 2) - 4; @@ -5326,14 +5326,14 @@ FString clif_validate_chat(dumb_ptr sd, ChatType type) if (!msg_len) { WARN_MALFORMED_MSG(sd, "no message sent"); - return FString(); + return AString(); } /* The client sent (or claims to have sent) an empty message. */ if (msg_len == min_len) { WARN_MALFORMED_MSG(sd, "empty message"); - return FString(); + return AString(); } /* The protocol specifies that the target must be 24 bytes long. */ @@ -5342,7 +5342,7 @@ FString clif_validate_chat(dumb_ptr sd, ChatType type) /* Disallow malformed messages. */ clif_setwaitclose(s); WARN_MALFORMED_MSG(sd, "illegal target name"); - return FString(); + return AString(); } size_t pstart = 4; @@ -5352,7 +5352,7 @@ FString clif_validate_chat(dumb_ptr sd, ChatType type) pstart += 24; buf_len -= 24; } - FString pbuf = RFIFO_STRING(s, pstart, buf_len); + AString pbuf = RFIFO_STRING(s, pstart, buf_len); /* * The client attempted to exceed the maximum message length. @@ -5364,7 +5364,7 @@ FString clif_validate_chat(dumb_ptr sd, ChatType type) if (buf_len >= battle_config.chat_maxline) { WARN_MALFORMED_MSG(sd, "exceeded maximum message length"); - return FString(); + return AString(); } if (type == ChatType::Global) @@ -5375,7 +5375,7 @@ FString clif_validate_chat(dumb_ptr sd, ChatType type) /* Disallow malformed/spoofed messages. */ clif_setwaitclose(s); WARN_MALFORMED_MSG(sd, "spoofed name/invalid format"); - return FString(); + return AString(); } /* Step beyond the separator. */ XString xs = p.xslice_t(name_len + 3); diff --git a/src/map/grfio.cpp b/src/map/grfio.cpp index ff73c90..d89fe21 100644 --- a/src/map/grfio.cpp +++ b/src/map/grfio.cpp @@ -13,7 +13,8 @@ #include #include "../strings/mstring.hpp" -#include "../strings/fstring.hpp" +#include "../strings/rstring.hpp" +#include "../strings/astring.hpp" #include "../io/cxxstdio.hpp" #include "../io/read.hpp" @@ -23,7 +24,7 @@ #include "../poison.hpp" static -std::map resnametable; +std::map resnametable; bool load_resnametable(ZString filename) { @@ -35,11 +36,11 @@ bool load_resnametable(ZString filename) } bool rv = true; - FString line; + AString line; while (in.getline(line)) { MapName key; - FString value; + AString value; if (!extract(line, record<'#'>(&key, &value))) { @@ -47,6 +48,7 @@ bool load_resnametable(ZString filename) rv = false; continue; } + // TODO add "data/" here ... resnametable[key] = value; } return rv; @@ -54,18 +56,21 @@ bool load_resnametable(ZString filename) /// Change *.gat to *.wlk static -FString grfio_resnametable(MapName rname) +RString grfio_resnametable(MapName rname) { + // TODO return an error instead of throwing an exception return resnametable.at(rname); } std::vector grfio_reads(MapName rname) { MString lfname_; + // TODO ... instead of here lfname_ += "data/"; lfname_ += grfio_resnametable(rname); - FString lfname = FString(lfname_); + AString lfname = AString(lfname_); + // TODO wrap this immediately int fd = open(lfname.c_str(), O_RDONLY); if (fd == -1) { diff --git a/src/map/intif.cpp b/src/map/intif.cpp index 7d699dd..e994bdb 100644 --- a/src/map/intif.cpp +++ b/src/map/intif.cpp @@ -3,7 +3,7 @@ #include #include -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -254,7 +254,7 @@ int intif_parse_WisMessage(Session *s) CharName to = stringish(RFIFO_STRING<24>(s, 32)); size_t len = RFIFOW(s, 2) - 56; - FString buf = RFIFO_STRING(s, 56, len); + AString buf = RFIFO_STRING(s, 56, len); if (battle_config.etc_log) { @@ -313,7 +313,7 @@ void mapif_parse_WisToGM(Session *s) min_gm_level = RFIFOW(s, 28); CharName Wisp_name = stringish(RFIFO_STRING<24>(s, 4)); - FString message = RFIFO_STRING(s, 30, len); + AString message = RFIFO_STRING(s, 30, len); // information is sended to all online GM for (io::FD i : iter_fds()) { @@ -503,7 +503,7 @@ static void intif_parse_PartyMessage(Session *s) { size_t len = RFIFOW(s, 2) - 12; - FString buf = RFIFO_STRING(s, 12, len); + AString buf = RFIFO_STRING(s, 12, len); party_recv_message(RFIFOL(s, 4), RFIFOL(s, 8), buf); } @@ -542,7 +542,7 @@ int intif_parse(Session *s) { case 0x3800: { - FString mes = RFIFO_STRING(s, 4, packet_len - 4); + AString mes = RFIFO_STRING(s, 4, packet_len - 4); clif_GMmessage(NULL, mes, 0); } break; diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index bcef583..ba225bd 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -3,7 +3,7 @@ #include #include -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -161,7 +161,7 @@ bool itemdb_readdb(ZString filename) lines = 0; - FString line; + AString line; while (in.getline(line)) { lines++; diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index 655da1b..7343e50 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -6,7 +6,7 @@ #include #include "../strings/mstring.hpp" -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/vstring.hpp" @@ -93,7 +93,7 @@ void magic_clear_var(val_t *v) } static -FString show_entity(dumb_ptr entity) +AString show_entity(dumb_ptr entity) { switch (entity->bl_type) { @@ -126,7 +126,7 @@ void stringify(val_t *v, int within_op) {"north"}, {"north-east"}, {"east"}, {"south-east"}, }}; - FString buf; + AString buf; switch (v->ty) { @@ -287,7 +287,7 @@ int fun_add(dumb_ptr, val_t *result, const_array args) MString m; m += ARGSTR(0); m += ARGSTR(1); - RESULTSTR = dumb_string::copys(FString(m)); + RESULTSTR = dumb_string::copys(AString(m)); result->ty = TYPE::STRING; } return 0; @@ -1677,7 +1677,7 @@ int magic_eval_int(dumb_ptr env, dumb_ptr expr) return result.v.v_int; } -FString magic_eval_str(dumb_ptr env, dumb_ptr expr) +AString magic_eval_str(dumb_ptr env, dumb_ptr expr) { val_t result; magic_eval(env, &result, expr); diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp index 7601bef..0fdc435 100644 --- a/src/map/magic-expr.hpp +++ b/src/map/magic-expr.hpp @@ -61,7 +61,7 @@ int magic_eval_int(dumb_ptr env, dumb_ptr expr); /** * Evaluates an expression and coerces the result into a string */ -FString magic_eval_str(dumb_ptr env, dumb_ptr expr); +AString magic_eval_str(dumb_ptr env, dumb_ptr expr); dumb_ptr magic_new_expr(EXPR ty); diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp index 0ba145a..f1878a0 100644 --- a/src/map/magic-interpreter-base.cpp +++ b/src/map/magic-interpreter-base.cpp @@ -3,7 +3,7 @@ #include "magic-interpreter-aux.hpp" #include "magic-interpreter.hpp" -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/xstring.hpp" #include "../io/cxxstdio.hpp" @@ -68,13 +68,13 @@ void set_spell SETTER(dumb_ptr, TYPE::SPELL, v_spell) magic_conf_t magic_conf; /* Global magic conf */ env_t magic_default_env = { &magic_conf, NULL }; -FString magic_find_invocation(XString spellname) +AString magic_find_invocation(XString spellname) { auto it = magic_conf.spells_by_name.find(spellname); if (it != magic_conf.spells_by_name.end()) return it->second->invocation; - return FString(); + return AString(); } dumb_ptr magic_find_spell(XString invocation) @@ -90,14 +90,14 @@ dumb_ptr magic_find_spell(XString invocation) /* Spell anchors */ /* -------------------------------------------------------------------------------- */ -FString magic_find_anchor_invocation(XString anchor_name) +AString magic_find_anchor_invocation(XString anchor_name) { auto it = magic_conf.anchors_by_name.find(anchor_name); if (it != magic_conf.anchors_by_name.end()) return it->second->invocation; - return FString(); + return AString(); } dumb_ptr magic_find_anchor(XString name) diff --git a/src/map/magic-interpreter-parser.ypp b/src/map/magic-interpreter-parser.ypp index a86f1c8..3ec1bdd 100644 --- a/src/map/magic-interpreter-parser.ypp +++ b/src/map/magic-interpreter-parser.ypp @@ -3,7 +3,7 @@ #include "magic-interpreter.hpp" extern -FString current_magic_filename; +AString current_magic_filename; } // %code requires %code @@ -13,7 +13,8 @@ FString current_magic_filename; #include #include // exception to "no va_list" rule, even after cxxstdio -#include "../strings/fstring.hpp" +#include "../strings/rstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../io/cxxstdio.hpp" @@ -23,7 +24,7 @@ FString current_magic_filename; #include "itemdb.hpp" #include "magic-expr.hpp" -FString current_magic_filename; +AString current_magic_filename; // can't use src/warnings.hpp in generated code #pragma GCC diagnostic warning "-Wall" @@ -37,13 +38,13 @@ static size_t intern_id(ZString id_name); static -dumb_ptr fun_expr(FString name, const_array> argv, int line, int column); +dumb_ptr fun_expr(AString name, const_array> argv, int line, int column); static dumb_ptr dot_expr(dumb_ptr lhs, int id); static -void BIN_EXPR(dumb_ptr& x, FString name, dumb_ptr arg1, dumb_ptr arg2, int line, int column) +void BIN_EXPR(dumb_ptr& x, AString name, dumb_ptr arg1, dumb_ptr arg2, int line, int column) { dumb_ptr e[2]; e[0] = arg1; @@ -82,7 +83,7 @@ static void add_teleport_anchor(dumb_ptr anchor, int line_nr); static -dumb_ptr op_effect(FString name, const_array> argv, int line, int column); +dumb_ptr op_effect(AString name, const_array> argv, int line, int column); // in magic-interpreter-lexer.cpp int magic_frontend_lex(void); @@ -94,10 +95,10 @@ static dumb_ptr call_proc(ZString name, dumb_ptr>> argvp, int line_nr, int column); static -void bind_constant(FString name, val_t *val, int line_nr); +void bind_constant(RString name, val_t *val, int line_nr); static -val_t *find_constant(FString name); +val_t *find_constant(RString name); } // %code @@ -1182,7 +1183,7 @@ dumb_ptr dot_expr(dumb_ptr expr, int id) return retval; } -dumb_ptr fun_expr(FString name, const_array> argv, int line, int column) +dumb_ptr fun_expr(AString name, const_array> argv, int line, int column) { dumb_ptr expr; fun_t *fun = magic_get_fun(name); @@ -1293,7 +1294,7 @@ dumb_ptr set_effect_continuation(dumb_ptr src, dumb_ptr op_effect(FString name, const_array> argv, int line, int column) +dumb_ptr op_effect(AString name, const_array> argv, int line, int column) { dumb_ptr effect; op_t *op = magic_get_op(name); @@ -1325,7 +1326,7 @@ dumb_ptr op_effect(FString name, const_array> argv, i } -std::map procs; +std::map procs; // I think this was a memory leak (or undefined behavior) void install_proc(dumb_ptr proc) @@ -1358,9 +1359,9 @@ dumb_ptr call_proc(ZString name, dumb_ptr return retval; } -std::map const_defm; +std::map const_defm; -void bind_constant(FString name, val_t *val, int line_nr) +void bind_constant(RString name, val_t *val, int line_nr) { if (!const_defm.insert({name, *val}).second) { @@ -1368,7 +1369,7 @@ void bind_constant(FString name, val_t *val, int line_nr) } } -val_t *find_constant(FString name) +val_t *find_constant(RString name) { auto it = const_defm.find(name); if (it != const_defm.end()) diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp index 19f8574..7e42499 100644 --- a/src/map/magic-interpreter.hpp +++ b/src/map/magic-interpreter.hpp @@ -6,7 +6,7 @@ # include # include "../strings/fwd.hpp" -# include "../strings/fstring.hpp" +# include "../strings/rstring.hpp" # include "magic.hpp" # include "map.hpp" @@ -244,8 +244,8 @@ struct letdef_t struct spell_t { - FString name; - FString invocation; + RString name; + RString invocation; SPELL_FLAG flags; int arg; SPELLARG spellarg_ty; @@ -261,8 +261,8 @@ struct spell_t struct teleport_anchor_t { - FString name; - FString invocation; + RString name; + RString invocation; dumb_ptr location; }; @@ -274,15 +274,15 @@ struct magic_conf_t { struct mcvar { - FString name; + RString name; val_t val; }; // This should probably be done by a dedicated "intern pool" class std::vector varv; - std::map> spells_by_name, spells_by_invocation; + std::map> spells_by_name, spells_by_invocation; - std::map> anchors_by_name, anchors_by_invocation; + std::map> anchors_by_name, anchors_by_invocation; }; /* Execution environment */ @@ -434,7 +434,7 @@ struct args_rec_t struct proc_t { - FString name; + RString name; std::vector argv; dumb_ptr body; diff --git a/src/map/magic.hpp b/src/map/magic.hpp index 5d4e517..1fabd6f 100644 --- a/src/map/magic.hpp +++ b/src/map/magic.hpp @@ -46,14 +46,14 @@ void spell_effect_report_termination(int invocation, int bl_id, * * Returns empty string if not found */ -FString magic_find_invocation(XString spellname); +AString magic_find_invocation(XString spellname); /** * Identifies the invocation used to denote a teleport location * * Returns empty string if not found */ -FString magic_find_anchor_invocation(XString teleport_location); +AString magic_find_anchor_invocation(XString teleport_location); /** * Execute a spell invocation and sets up timers to finish diff --git a/src/map/map.cpp b/src/map/map.cpp index 8a1d8eb..caab5b4 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -10,7 +10,7 @@ #include #include -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" #include "../strings/vstring.hpp" @@ -75,7 +75,7 @@ int first_free_object_id = 0, last_object_id = 0; interval_t autosave_time = DEFAULT_AUTOSAVE_INTERVAL; int save_settings = 0xFFFF; -FString motd_txt = "conf/motd.txt"; +AString motd_txt = "conf/motd.txt"; CharName wisp_server_name = stringish("Server"); // can be modified in char-server configuration file @@ -1351,7 +1351,7 @@ constexpr int LOGFILE_SECONDS_PER_CHUNK_SHIFT = 10; static std::unique_ptr map_logfile; static -FString map_logfile_name; +AString map_logfile_name; static long map_logfile_index; @@ -1360,7 +1360,7 @@ void map_close_logfile(void) { if (map_logfile) { - FString filename = STRPRINTF("%s.%ld", map_logfile_name, map_logfile_index); + AString filename = STRPRINTF("%s.%ld", map_logfile_name, map_logfile_index); const char *args[] = { "gzip", @@ -1386,7 +1386,7 @@ void map_start_logfile(long index) { map_logfile_index = index; - FString filename_buf = STRPRINTF( + AString filename_buf = STRPRINTF( "%s.%ld", map_logfile_name, map_logfile_index); @@ -1399,7 +1399,7 @@ void map_start_logfile(long index) } static -void map_set_logfile(FString filename) +void map_set_logfile(AString filename) { struct timeval tv; @@ -1445,7 +1445,7 @@ bool map_config_read(ZString cfgName) } bool rv = true; - FString line; + AString line; while (in.getline(line)) { if (is_comment(line)) @@ -1663,7 +1663,7 @@ bool map_confs(XString key, ZString value) return load_resnametable(value); if (key == "const_db") return read_constdb(value); - PRINTF("unknown map conf key: %s\n", FString(key)); + PRINTF("unknown map conf key: %s\n", AString(key)); return false; } diff --git a/src/map/map.hpp b/src/map/map.hpp index 897c619..092fd80 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -9,7 +9,8 @@ # include # include "../strings/fwd.hpp" -# include "../strings/fstring.hpp" +# include "../strings/rstring.hpp" +# include "../strings/astring.hpp" # include "../strings/vstring.hpp" # include "../io/cxxstdio.hpp" @@ -193,7 +194,7 @@ struct map_session_data : block_list, SessionData // but one should probably be replaced with a ScriptPointer ??? const ScriptBuffer *npc_script, *npc_scriptroot; std::vector npc_stackbuf; - FString npc_str; + RString npc_str; struct { unsigned storage:1; @@ -267,8 +268,8 @@ struct map_session_data : block_list, SessionData // Not anymore! Well, sort of. DMap regm; // can't be DMap because we want predictable .c_str()s - // This could change once FString ensures CoW. - Map regstrm; + // TODO this can change now + Map regstrm; earray sc_data; short sc_count; @@ -302,7 +303,7 @@ struct map_session_data : block_list, SessionData TimeT chat_repeat_reset_due; int chat_lines_in; int chat_total_repeats; - FString chat_lastmsg; + RString chat_lastmsg; tick_t flood_rates[0x220]; TimeT packet_flood_reset_due; @@ -347,7 +348,7 @@ struct npc_data : block_list Option option; short flag; - std::list eventqueuel; + std::list eventqueuel; Timer eventtimer[MAX_EVENTTIMER]; short arenaflag; @@ -414,7 +415,7 @@ public: class npc_data_message : public npc_data { public: - FString message; + RString message; }; constexpr int MOB_XP_BONUS_BASE = 1024; @@ -574,7 +575,7 @@ struct flooritem_data : block_list extern interval_t autosave_time; extern int save_settings; -extern FString motd_txt; +extern AString motd_txt; extern CharName wisp_server_name; diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 7a73df5..2a06cf7 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -8,7 +8,7 @@ #include -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/xstring.hpp" #include "../io/cxxstdio.hpp" @@ -3420,7 +3420,7 @@ bool mob_readdb(ZString filename) PRINTF("Unable to read mob db: %s\n", filename); return false; } - FString line; + AString line; while (in.getline(line)) { int mob_class; @@ -3631,7 +3631,7 @@ bool mob_readskilldb(ZString filename) PRINTF("can't read %s\n", filename); return false; } - FString line; + AString line; while (in.getline(line)) { int mob_id; diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 4a116b2..788d785 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -8,7 +8,7 @@ #include #include "../strings/mstring.hpp" -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -34,7 +34,7 @@ #include "../poison.hpp" static -std::list npc_srcs; +std::list npc_srcs; static int npc_id = START_NPC_NUM; @@ -903,7 +903,7 @@ void npc_clearsrcfile(void) * 読み込むnpcファイルの追加 *------------------------------------------ */ -void npc_addsrcfile(FString name) +void npc_addsrcfile(AString name) { if (name == "clear") { @@ -918,7 +918,7 @@ void npc_addsrcfile(FString name) * 読み込むnpcファイルの削除 *------------------------------------------ */ -void npc_delsrcfile(FString name) +void npc_delsrcfile(XString name) { if (name == "all") { @@ -1209,7 +1209,7 @@ int npc_parse_script(XString w1, XString w2, NpcName w3, ZString w4, if (it != srcbuf.rend() && *it == '}') break; - FString line; + AString line; if (!fp.getline(line)) // eof break; @@ -1226,7 +1226,7 @@ int npc_parse_script(XString w1, XString w2, NpcName w3, ZString w4, srcbuf += line; srcbuf += '\n'; } - script = parse_script(FString(srcbuf), startline); + script = parse_script(AString(srcbuf), startline); if (script == NULL) // script parse error? return 1; @@ -1404,7 +1404,7 @@ int npc_parse_function(XString, XString, XString w3, ZString, if (it != srcbuf.rend() && *it == '}') break; - FString line; + AString line; if (!fp.getline(line)) break; (*lines)++; @@ -1417,7 +1417,7 @@ int npc_parse_function(XString, XString, XString w3, ZString, srcbuf += line; srcbuf += '\n'; } - std::unique_ptr script = parse_script(FString(srcbuf), startline); + std::unique_ptr script = parse_script(AString(srcbuf), startline); if (script == NULL) { // script parse error? @@ -1636,7 +1636,7 @@ int npc_parse_mapflag(XString w1, XString, XString w3, ZString w4) } dumb_ptr npc_spawn_text(map_local *m, int x, int y, - int npc_class, NpcName name, FString message) + int npc_class, NpcName name, AString message) { dumb_ptr retval; retval.new_(); @@ -1678,7 +1678,7 @@ void npc_free_internal(dumb_ptr nd_) else if (nd_->npc_subtype == NpcSubtype::MESSAGE) { dumb_ptr nd = nd_->is_message(); - nd->message = FString(); + nd->message = AString(); } nd_.delete_(); } @@ -1722,7 +1722,7 @@ bool do_init_npc(void) for (; !npc_srcs.empty(); npc_srcs.pop_front()) { - FString nsl = npc_srcs.front(); + AString nsl = npc_srcs.front(); io::ReadFile fp(nsl); if (!fp.is_open()) { @@ -1733,7 +1733,7 @@ bool do_init_npc(void) PRINTF("\rLoading NPCs [%d]: %-54s", npc_id - START_NPC_NUM, nsl); int lines = 0; - FString zline; + AString zline; while (fp.getline(zline)) { XString w1, w2, w3, w4x; diff --git a/src/map/npc.hpp b/src/map/npc.hpp index 17eea04..4d4cef1 100644 --- a/src/map/npc.hpp +++ b/src/map/npc.hpp @@ -39,15 +39,15 @@ int npc_get_new_npc_id(void); * \param message The message to speak. If message is NULL, the NPC will not do anything at all. */ dumb_ptr npc_spawn_text(map_local *m, int x, int y, - int class_, NpcName name, FString message); + int class_, NpcName name, AString message); /** * Uninstalls and frees an NPC */ void npc_free(dumb_ptr npc); -void npc_addsrcfile(FString); -void npc_delsrcfile(FString); +void npc_addsrcfile(AString); +void npc_delsrcfile(XString); bool do_init_npc(void); int npc_event_do_oninit(void); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 8d242ae..c9588bb 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -4,7 +4,8 @@ #include #include -#include "../strings/fstring.hpp" +#include "../strings/rstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../io/cxxstdio.hpp" @@ -751,7 +752,7 @@ int pc_authok(int id, int login_id2, TimeT connect_until_time, sd->chat_reset_due = TimeT(); sd->chat_lines_in = sd->chat_total_repeats = 0; sd->chat_repeat_reset_due = TimeT(); - sd->chat_lastmsg = FString(); + sd->chat_lastmsg = RString(); for (tick_t& t : sd->flood_rates) t = tick_t(); @@ -780,7 +781,7 @@ void pc_show_motd(dumb_ptr sd) io::ReadFile in(motd_txt); if (in.is_open()) { - FString buf; + AString buf; while (in.getline(buf)) { clif_displaymessage(sd->sess, buf); @@ -3094,7 +3095,7 @@ int pc_gainexp_reason(dumb_ptr sd, int base_exp, int job_exp, if (battle_config.disp_experience) { - FString output = STRPRINTF( + AString output = STRPRINTF( "Experienced Gained Base:%d Job:%d", base_exp, job_exp); clif_displaymessage(sd->sess, output); @@ -4123,7 +4124,7 @@ ZString pc_readregstr(dumb_ptr sd, SIR reg) { nullpo_retr(ZString(), sd); - FString *s = sd->regstrm.search(reg); + RString *s = sd->regstrm.search(reg); if (s) return *s; @@ -4134,7 +4135,7 @@ ZString pc_readregstr(dumb_ptr sd, SIR reg) * script用文字列変数の値を設定 *------------------------------------------ */ -void pc_setregstr(dumb_ptr sd, SIR reg, FString str) +void pc_setregstr(dumb_ptr sd, SIR reg, RString str) { nullpo_retv(sd); diff --git a/src/map/pc.hpp b/src/map/pc.hpp index 48ba8f3..be66cc4 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -123,7 +123,7 @@ int pc_setparam(dumb_ptr, SP, int); int pc_readreg(dumb_ptr, SIR); void pc_setreg(dumb_ptr, SIR, int); ZString pc_readregstr(dumb_ptr sd, SIR reg); -void pc_setregstr(dumb_ptr sd, SIR reg, FString str); +void pc_setregstr(dumb_ptr sd, SIR reg, RString str); int pc_readglobalreg(dumb_ptr, VarName ); int pc_setglobalreg(dumb_ptr, VarName , int); int pc_readaccountreg(dumb_ptr, VarName ); diff --git a/src/map/script.cpp b/src/map/script.cpp index c154182..36ceb8c 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -8,7 +8,8 @@ #include #include "../strings/mstring.hpp" -#include "../strings/fstring.hpp" +#include "../strings/rstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -49,27 +50,27 @@ constexpr bool DEBUG_RUN = false; struct str_data_t { ByteCode type; - FString strs; + RString strs; int backpatch; int label_; int val; }; static -Map str_datam; +Map str_datam; static str_data_t LABEL_NEXTLINE_; static DMap mapreg_db; static -Map mapregstr_db; +Map mapregstr_db; static int mapreg_dirty = -1; -FString mapreg_txt = "save/mapreg.txt"; +AString mapreg_txt = "save/mapreg.txt"; constexpr std::chrono::milliseconds MAPREG_AUTOSAVE_INTERVAL = std::chrono::seconds(10); Map scriptlabel_db; -UPMap userfunc_db; +UPMap userfunc_db; static const char *pos_str[11] = @@ -157,7 +158,7 @@ str_data_t *add_strp(XString p) if (str_data_t *rv = search_strp(p)) return rv; - FString p2 = p; + RString p2 = p; str_data_t *datum = str_datam.init(p2); datum->type = ByteCode::NOP; datum->strs = p2; @@ -699,13 +700,13 @@ bool read_constdb(ZString filename) } bool rv = true; - FString line; + AString line; while (in.getline(line)) { if (is_comment(line)) continue; - FString name; + AString name; int val; int type = 0; // if not provided // TODO get rid of SSCANF - this is the last serious use @@ -908,7 +909,7 @@ void get_val(ScriptState *st, struct script_data *data) } else if (prefix == '$') { - FString *s = mapregstr_db.search(data->u.reg); + RString *s = mapregstr_db.search(data->u.reg); data->u.str = s ? dumb_string::fake(*s) : dumb_string(); } else @@ -1059,7 +1060,7 @@ dumb_string conv_str(ScriptState *st, struct script_data *data) assert (data->type != ByteCode::RETINFO); if (data->type == ByteCode::INT) { - FString buf = STRPRINTF("%d", data->u.numi); + AString buf = STRPRINTF("%d", data->u.numi); data->type = ByteCode::STR; data->u.str = dumb_string::copys(buf); } @@ -1340,7 +1341,7 @@ void builtin_menu(ScriptState *st) buf += ':'; } - clif_scriptmenu(script_rid2sd(st), st->oid, FString(buf)); + clif_scriptmenu(script_rid2sd(st), st->oid, AString(buf)); } else { @@ -2233,7 +2234,7 @@ void builtin_getequipname(ScriptState *st) dumb_ptr sd; struct item_data *item; - FString buf; + AString buf; sd = script_rid2sd(st); num = conv_num(st, &AARGO2(2)); @@ -3572,7 +3573,7 @@ void builtin_getspellinvocation(ScriptState *st) { dumb_string name = conv_str(st, &AARGO2(2)); - FString invocation = magic_find_invocation(name.str()); + AString invocation = magic_find_invocation(name.str()); if (!invocation) invocation = "..."; @@ -3938,7 +3939,7 @@ void builtin_npctalk(ScriptState *st) message += nd->name; message += " : "; message += ZString(str); - clif_message(nd, FString(message)); + clif_message(nd, AString(message)); } } @@ -4275,7 +4276,7 @@ void op_add(ScriptState *st) if (back.type == ByteCode::STR) back.u.str.delete_(); back1.type = ByteCode::STR; - back1.u.str = dumb_string::copys(FString(buf)); + back1.u.str = dumb_string::copys(AString(buf)); } } @@ -4921,7 +4922,7 @@ void script_load_mapreg(void) if (!in.is_open()) return; - FString line; + AString line; while (in.getline(line)) { XString buf1, buf2; @@ -4952,7 +4953,7 @@ void script_load_mapreg(void) else { borken: - PRINTF("%s: %s broken data !\n", mapreg_txt, FString(buf1)); + PRINTF("%s: %s broken data !\n", mapreg_txt, AString(buf1)); continue; } } diff --git a/src/map/script.hpp b/src/map/script.hpp index ec52f65..22a079b 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -6,7 +6,8 @@ # include -# include "../strings/fstring.hpp" +# include "../strings/rstring.hpp" +# include "../strings/astring.hpp" # include "../strings/zstring.hpp" # include "../common/db.hpp" @@ -157,12 +158,12 @@ struct ScriptLabel; extern Map scriptlabel_db; extern -UPMap userfunc_db; +UPMap userfunc_db; void do_init_script(void); void do_final_script(void); -extern FString mapreg_txt; +extern AString mapreg_txt; extern int script_errors; diff --git a/src/map/skill.cpp b/src/map/skill.cpp index 2253d9d..0222202 100644 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -6,7 +6,7 @@ #include #include "../strings/mstring.hpp" -#include "../strings/fstring.hpp" +#include "../strings/rstring.hpp" #include "../strings/xstring.hpp" #include "../io/cxxstdio.hpp" @@ -1169,7 +1169,7 @@ SP scan_stat(XString statname) if (statname == "none") return SP::ZERO; - FPRINTF(stderr, "Unknown stat `%s'\n", FString(statname)); + FPRINTF(stderr, "Unknown stat `%s'\n", AString(statname)); return SP::ZERO; } @@ -1183,7 +1183,7 @@ bool skill_readdb(ZString filename) } bool rv = true; - FString line_; + AString line_; while (in.getline(line_)) { // is_comment only works for whole-line comments @@ -1267,7 +1267,7 @@ bool skill_readdb(ZString filename) c = ' '; skill_db[i] = skdb; - skill_lookup_by_id(i).desc = FString(tmp); + skill_lookup_by_id(i).desc = RString(tmp); } PRINTF("read %s done\n", filename); diff --git a/src/map/skill.hpp b/src/map/skill.hpp index 5f29443..e8f36ab 100644 --- a/src/map/skill.hpp +++ b/src/map/skill.hpp @@ -5,7 +5,8 @@ # include "skill-pools.hpp" # include "../strings/fwd.hpp" -# include "../strings/fstring.hpp" +# include "../strings/rstring.hpp" +# include "../strings/astring.hpp" # include "map.hpp" @@ -39,11 +40,11 @@ earray skill_db; struct skill_name_db { SkillID id; // skill id - FString name; // search strings - FString desc; // description that shows up for searches + RString name; // search strings + RString desc; // description that shows up for searches // this makes const char(&)[] not decay into const char * in {} - skill_name_db(SkillID i, FString n, FString d) + skill_name_db(SkillID i, RString n, RString d) : id(i), name(n), desc(d) {} }; @@ -129,7 +130,7 @@ bool skill_pool_is_activated(dumb_ptr sd, SkillID skill); int skill_pool_deactivate(dumb_ptr sd, SkillID skill); // Yield configurable skill name inline -const FString& skill_name(SkillID skill) +const RString& skill_name(SkillID skill) { return skill_lookup_by_id(skill).desc; } diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp index 7e661bb..72cfa2b 100644 --- a/src/map/tmw.cpp +++ b/src/map/tmw.cpp @@ -3,7 +3,7 @@ #include #include -#include "../strings/fstring.hpp" +#include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -95,16 +95,16 @@ void tmw_AutoBan(dumb_ptr sd, ZString reason, int length) sd->auto_ban_info.in_progress = 1; - FString hack_msg = STRPRINTF("[GM] %s has been autobanned for %s spam", + AString hack_msg = STRPRINTF("[GM] %s has been autobanned for %s spam", sd->status.name, reason); tmw_GmHackMsg(hack_msg); - FString fake_command = STRPRINTF("@autoban %s %dh (%s spam)", + AString fake_command = STRPRINTF("@autoban %s %dh (%s spam)", sd->status.name, length, reason); log_atcommand(sd, fake_command); - FString anotherbuf = STRPRINTF("You have been banned for %s spamming. Please do not spam.", + AString anotherbuf = STRPRINTF("You have been banned for %s spamming. Please do not spam.", reason); clif_displaymessage(sd->sess, anotherbuf); -- cgit v1.2.3-70-g09d2