From 56e149a51562b9d2620bc9037a81735c29ea95af Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Mon, 14 Apr 2014 11:02:47 -0700 Subject: Ditch gcc 4.6 support --- .travis.yml | 7 - src/admin/ladmin.cpp | 1430 ++++++++++++++++++------------------ src/char/char.cpp | 330 ++++----- src/char/int_party.cpp | 39 +- src/char/int_storage.cpp | 16 +- src/char/inter.cpp | 20 +- src/generic/intern-pool_test.cpp | 14 +- src/generic/md5_test.cpp | 14 +- src/io/cxxstdio.hpp | 8 +- src/io/line.cpp | 34 +- src/io/line.hpp | 12 +- src/io/line_test.cpp | 202 ++--- src/io/lock.cpp | 10 +- src/io/read.cpp | 6 +- src/io/read_test.cpp | 20 +- src/io/write_test.cpp | 18 +- src/login/login.cpp | 828 +++++++++++---------- src/map/atcommand.cpp | 1397 ++++++++++++++++++----------------- src/map/battle.cpp | 27 +- src/map/chrif.cpp | 122 ++- src/map/clif.cpp | 94 ++- src/map/grfio.cpp | 8 +- src/map/intif.cpp | 38 +- src/map/itemdb.cpp | 6 +- src/map/magic-expr.cpp | 210 +++--- src/map/magic-expr.hpp | 4 +- src/map/magic-interpreter-base.cpp | 6 +- src/map/magic-stmt.cpp | 116 +-- src/map/magic-v2.cpp | 330 ++++----- src/map/magic.cpp | 6 +- src/map/map.cpp | 122 +-- src/map/map.hpp | 4 +- src/map/map.t.hpp | 2 + src/map/mapflag.cpp | 64 +- src/map/mob.cpp | 82 +-- src/map/mob.hpp | 6 +- src/map/npc.cpp | 135 ++-- src/map/party.cpp | 12 +- src/map/path.cpp | 4 +- src/map/pc.cpp | 136 ++-- src/map/script.cpp | 590 +++++++-------- src/map/skill-pools.cpp | 6 +- src/map/skill.cpp | 96 +-- src/map/skill.hpp | 4 +- src/map/tmw.cpp | 12 +- src/map/trade.cpp | 8 +- src/mmo/config_parse.cpp | 18 +- src/mmo/core.cpp | 2 +- src/mmo/extract_test.cpp | 378 +++++----- src/mmo/human_time_diff.hpp | 14 +- src/mmo/human_time_diff_test.cpp | 32 +- src/mmo/ip.cpp | 4 +- src/mmo/ip_test.cpp | 278 +++---- src/mmo/md5more.cpp | 4 +- src/mmo/mmo.hpp | 2 +- src/mmo/socket.cpp | 14 +- src/mmo/utils.cpp | 20 +- src/monitor/main.cpp | 48 +- src/sanity.hpp | 9 +- src/sexpr/lexer.cpp | 60 +- src/sexpr/lexer.hpp | 2 +- src/sexpr/lexer_test.cpp | 84 +-- src/sexpr/parser_test.cpp | 36 +- src/strings/astring.cpp | 7 + src/strings/astring.hpp | 7 +- src/strings/astring.tcc | 17 - src/strings/base_test.cpp | 22 +- src/strings/fwd.hpp | 12 + src/strings/literal.cpp | 56 ++ src/strings/literal.hpp | 82 +++ src/strings/pair.hpp | 21 +- src/strings/rstring.cpp | 5 + src/strings/rstring.hpp | 7 +- src/strings/rstring.tcc | 6 - src/strings/sstring.cpp | 4 + src/strings/sstring.hpp | 5 +- src/strings/sstring.tcc | 5 - src/strings/strings2_test.cpp | 86 +-- src/strings/strings_test.cpp | 60 +- src/strings/tstring.cpp | 4 + src/strings/tstring.hpp | 5 +- src/strings/tstring.tcc | 4 - src/strings/vstring.hpp | 5 +- src/strings/vstring.tcc | 8 +- src/strings/xstring.cpp | 3 + src/strings/xstring.hpp | 6 +- src/strings/xstring.tcc | 4 - src/strings/zstring.cpp | 5 +- src/strings/zstring.hpp | 6 +- src/strings/zstring.tcc | 5 - 90 files changed, 4080 insertions(+), 4037 deletions(-) create mode 100644 src/strings/literal.cpp create mode 100644 src/strings/literal.hpp diff --git a/.travis.yml b/.travis.yml index dd58b51..301fb20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,22 +74,15 @@ env: - ignore=this matrix: - allow_failures: - - compiler: clang - env: REAL_CC=clang-3.1 REAL_CXX=clang++-3.1 PPA=ppa:h-rayflood/llvm PACKAGE=clang-3.1 exclude: - env: ignore=this include: - - compiler: clang - env: REAL_CC=clang-3.1 REAL_CXX=clang++-3.1 PPA=ppa:h-rayflood/llvm PACKAGE=clang-3.1 - compiler: clang env: REAL_CC=clang-3.2 REAL_CXX=clang++-3.2 PPA=ppa:h-rayflood/llvm PACKAGE=clang-3.2 - compiler: clang env: REAL_CC=clang-3.3 REAL_CXX=clang++-3.3 PPA=ppa:h-rayflood/llvm PACKAGE=clang-3.3 - compiler: clang env: REAL_CC=clang-3.4 REAL_CXX=clang++-3.4 PPA=ppa:h-rayflood/llvm PACKAGE=clang-3.4 - - compiler: gcc - env: REAL_CC=gcc-4.6 REAL_CXX=g++-4.6 PPA= PACKAGE=g++-4.6 - compiler: gcc env: REAL_CC=gcc-4.7 REAL_CXX=g++-4.7 PPA=ppa:ubuntu-toolchain-r/test PACKAGE=g++-4.7 - compiler: gcc diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp index 5d772e3..c635379 100644 --- a/src/admin/ladmin.cpp +++ b/src/admin/ladmin.cpp @@ -68,9 +68,9 @@ IP4Address login_ip = IP4_LOCALHOST; // IP of login-server static int login_port = 6900; // Port of login-server static -AccountPass admin_pass = stringish("admin"); // Administration password +AccountPass admin_pass = stringish("admin"_s); // Administration password static -AString ladmin_log_filename = "log/ladmin.log"; +AString ladmin_log_filename = "log/ladmin.log"_s; //------------------------------------------------------------------------- // LIST of COMMANDs that you can type at the prompt: // To use these commands you can only type only the first letters. @@ -267,7 +267,7 @@ int already_exit_function = 0; // sometimes, the exit function is called twice.. #pragma GCC diagnostic ignored "-Wmissing-noreturn" void SessionDeleter::operator()(SessionData *) { - assert(false && "ladmin does not have sessions"); + assert(false && "ladmin does not have sessions"_s); } #pragma GCC diagnostic pop @@ -340,315 +340,315 @@ void display_help(ZString param) XString command = param.xislice_h(std::find(param.begin(), param.end(), ' ')); if (command.startswith('?')) - command = "help"; + command = "help"_s; - LADMIN_LOG("Displaying of the commands or a command.\n"); + LADMIN_LOG("Displaying of the commands or a command.\n"_fmt); - if (command == "help") + if (command == "help"_s) { - PRINTF("help/?\n"); - PRINTF(" Display the description of the commands\n"); - PRINTF("help/? [command]\n"); - PRINTF(" Display the description of the specified command\n"); + PRINTF("help/?\n"_fmt); + PRINTF(" Display the description of the commands\n"_fmt); + PRINTF("help/? [command]\n"_fmt); + PRINTF(" Display the description of the specified command\n"_fmt); } - else if (command == "add") + else if (command == "add"_s) { - PRINTF("add \n"); - PRINTF(" Create an account with the default email (a@a.com).\n"); - PRINTF(" Concerning the sex, only the first letter is used (F or M).\n"); - PRINTF(" The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail.\n"); - PRINTF(" When the password is omitted,\n"); - PRINTF(" the input is done without displaying of the pressed keys.\n"); - PRINTF(" add testname Male testpass\n"); + PRINTF("add \n"_fmt); + PRINTF(" Create an account with the default email (a@a.com).\n"_fmt); + PRINTF(" Concerning the sex, only the first letter is used (F or M).\n"_fmt); + PRINTF(" The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail.\n"_fmt); + PRINTF(" When the password is omitted,\n"_fmt); + PRINTF(" the input is done without displaying of the pressed keys.\n"_fmt); + PRINTF(" add testname Male testpass\n"_fmt); } - else if (command == "ban") + else if (command == "ban"_s) { - PRINTF("ban yyyy/mm/dd hh:mm:ss \n"); - PRINTF(" Changes the final date of a banishment of an account.\n"); - PRINTF(" Like banset, but is at end.\n"); + PRINTF("ban yyyy/mm/dd hh:mm:ss \n"_fmt); + PRINTF(" Changes the final date of a banishment of an account.\n"_fmt); + PRINTF(" Like banset, but is at end.\n"_fmt); } - else if (command == "banadd") + else if (command == "banadd"_s) { - PRINTF("banadd \n"); - PRINTF(" Adds or substracts time from the final date of a banishment of an account.\n"); - PRINTF(" Modifier is done as follows:\n"); - PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"); - PRINTF(" Modified element:\n"); - PRINTF(" a or y: year\n"); - PRINTF(" m: month\n"); - PRINTF(" j or d: day\n"); - PRINTF(" h: hour\n"); - PRINTF(" mn: minute\n"); - PRINTF(" s: second\n"); - PRINTF(" banadd testname +1m-2mn1s-6y\n"); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - PRINTF(" and 6 years at the same time.\n"); - PRINTF("NOTE: If you modify the final date of a non-banished account,\n"); - PRINTF(" you fix the final date to (actual time +- adjustments)\n"); + PRINTF("banadd \n"_fmt); + PRINTF(" Adds or substracts time from the final date of a banishment of an account.\n"_fmt); + PRINTF(" Modifier is done as follows:\n"_fmt); + PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"_fmt); + PRINTF(" Modified element:\n"_fmt); + PRINTF(" a or y: year\n"_fmt); + PRINTF(" m: month\n"_fmt); + PRINTF(" j or d: day\n"_fmt); + PRINTF(" h: hour\n"_fmt); + PRINTF(" mn: minute\n"_fmt); + PRINTF(" s: second\n"_fmt); + PRINTF(" banadd testname +1m-2mn1s-6y\n"_fmt); + PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); + PRINTF(" and 6 years at the same time.\n"_fmt); + PRINTF("NOTE: If you modify the final date of a non-banished account,\n"_fmt); + PRINTF(" you fix the final date to (actual time +- adjustments)\n"_fmt); } - else if (command == "banset") + else if (command == "banset"_s) { - PRINTF("banset yyyy/mm/dd [hh:mm:ss]\n"); - PRINTF(" Changes the final date of a banishment of an account.\n"); - PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"); - PRINTF("banset 0\n"); - PRINTF(" Set a non-banished account (0 = unbanished).\n"); + PRINTF("banset yyyy/mm/dd [hh:mm:ss]\n"_fmt); + PRINTF(" Changes the final date of a banishment of an account.\n"_fmt); + PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"_fmt); + PRINTF("banset 0\n"_fmt); + PRINTF(" Set a non-banished account (0 = unbanished).\n"_fmt); } - else if (command == "block") + else if (command == "block"_s) { - PRINTF("block \n"); - PRINTF(" Set state 5 (You have been blocked by the GM Team) to an account.\n"); - PRINTF(" This command works like state 5.\n"); + PRINTF("block \n"_fmt); + PRINTF(" Set state 5 (You have been blocked by the GM Team) to an account.\n"_fmt); + PRINTF(" This command works like state 5.\n"_fmt); } - else if (command == "check") + else if (command == "check"_s) { - PRINTF("check \n"); - PRINTF(" Check the validity of a password for an account.\n"); - PRINTF(" NOTE: Server will never sends back a password.\n"); - PRINTF(" It's the only method you have to know if a password is correct.\n"); - PRINTF(" The other method is to have a ('physical') access to the accounts file.\n"); + PRINTF("check \n"_fmt); + PRINTF(" Check the validity of a password for an account.\n"_fmt); + PRINTF(" NOTE: Server will never sends back a password.\n"_fmt); + PRINTF(" It's the only method you have to know if a password is correct.\n"_fmt); + PRINTF(" The other method is to have a ('physical') access to the accounts file.\n"_fmt); } - else if (command == "create") + else if (command == "create"_s) { - PRINTF("create \n"); - PRINTF(" Like the 'add' command, but with e-mail moreover.\n"); - PRINTF(" create testname Male my@mail.com testpass\n"); + PRINTF("create \n"_fmt); + PRINTF(" Like the 'add' command, but with e-mail moreover.\n"_fmt); + PRINTF(" create testname Male my@mail.com testpass\n"_fmt); } - else if (command == "delete") + else if (command == "delete"_s) { - PRINTF("delete \n"); - PRINTF(" Remove an account.\n"); - PRINTF(" This order requires confirmation. After confirmation, the account is deleted.\n"); + PRINTF("delete \n"_fmt); + PRINTF(" Remove an account.\n"_fmt); + PRINTF(" This order requires confirmation. After confirmation, the account is deleted.\n"_fmt); } - else if (command == "email") + else if (command == "email"_s) { - PRINTF("email \n"); - PRINTF(" Modify the e-mail of an account.\n"); + PRINTF("email \n"_fmt); + PRINTF(" Modify the e-mail of an account.\n"_fmt); } - else if (command == "getcount") + else if (command == "getcount"_s) { - PRINTF("getcount\n"); - PRINTF(" Give the number of players online on all char-servers.\n"); + PRINTF("getcount\n"_fmt); + PRINTF(" Give the number of players online on all char-servers.\n"_fmt); } - else if (command == "gm") + else if (command == "gm"_s) { - PRINTF("gm [GM_level]\n"); - PRINTF(" Modify the GM level of an account.\n"); - PRINTF(" Default value remove GM level (GM level = 0).\n"); - PRINTF(" gm testname 80\n"); + PRINTF("gm [GM_level]\n"_fmt); + PRINTF(" Modify the GM level of an account.\n"_fmt); + PRINTF(" Default value remove GM level (GM level = 0).\n"_fmt); + PRINTF(" gm testname 80\n"_fmt); } - else if (command == "id") + else if (command == "id"_s) { - PRINTF("id \n"); - PRINTF(" Give the id of an account.\n"); + PRINTF("id \n"_fmt); + PRINTF(" Give the id of an account.\n"_fmt); } - else if (command == "info") + else if (command == "info"_s) { - PRINTF("info \n"); - PRINTF(" Display complete information of an account.\n"); + PRINTF("info \n"_fmt); + PRINTF(" Display complete information of an account.\n"_fmt); } - else if (command == "kami") + else if (command == "kami"_s) { - PRINTF("kami \n"); - PRINTF(" Sends a broadcast message on all map-server (in yellow).\n"); + PRINTF("kami \n"_fmt); + PRINTF(" Sends a broadcast message on all map-server (in yellow).\n"_fmt); } - else if (command == "kamib") + else if (command == "kamib"_s) { - PRINTF("kamib \n"); - PRINTF(" Sends a broadcast message on all map-server (in blue).\n"); + PRINTF("kamib \n"_fmt); + PRINTF(" Sends a broadcast message on all map-server (in blue).\n"_fmt); } - else if (command == "list") + else if (command == "list"_s) { - PRINTF("list/ls [start_id [end_id]]\n"); - PRINTF(" Display a list of accounts.\n"); - PRINTF(" 'start_id', 'end_id': indicate end and start identifiers.\n"); - PRINTF(" Research by name is not possible with this command.\n"); - PRINTF(" list 10 9999999\n"); + PRINTF("list/ls [start_id [end_id]]\n"_fmt); + PRINTF(" Display a list of accounts.\n"_fmt); + PRINTF(" 'start_id', 'end_id': indicate end and start identifiers.\n"_fmt); + PRINTF(" Research by name is not possible with this command.\n"_fmt); + PRINTF(" list 10 9999999\n"_fmt); } - else if (command == "itemfrob") + else if (command == "itemfrob"_s) { - PRINTF("itemfrob \n"); - PRINTF(" Translates item IDs for all accounts.\n"); - PRINTF(" Any items matching the source item ID will be mapped to the dest-id.\n"); - PRINTF(" itemfrob 500 700\n"); + PRINTF("itemfrob \n"_fmt); + PRINTF(" Translates item IDs for all accounts.\n"_fmt); + PRINTF(" Any items matching the source item ID will be mapped to the dest-id.\n"_fmt); + PRINTF(" itemfrob 500 700\n"_fmt); } - else if (command == "listban") + else if (command == "listban"_s) { - PRINTF("listban [start_id [end_id]]\n"); - PRINTF(" Like list/ls, but only for accounts with state or banished.\n"); + PRINTF("listban [start_id [end_id]]\n"_fmt); + PRINTF(" Like list/ls, but only for accounts with state or banished.\n"_fmt); } - else if (command == "listgm") + else if (command == "listgm"_s) { - PRINTF("listgm [start_id [end_id]]\n"); - PRINTF(" Like list/ls, but only for GM accounts.\n"); + PRINTF("listgm [start_id [end_id]]\n"_fmt); + PRINTF(" Like list/ls, but only for GM accounts.\n"_fmt); } - else if (command == "listok") + else if (command == "listok"_s) { - PRINTF("listok [start_id [end_id]]\n"); - PRINTF(" Like list/ls, but only for accounts without state and not banished.\n"); + PRINTF("listok [start_id [end_id]]\n"_fmt); + PRINTF(" Like list/ls, but only for accounts without state and not banished.\n"_fmt); } - else if (command == "memo") + else if (command == "memo"_s) { - PRINTF("memo \n"); - PRINTF(" Modify the memo of an account.\n"); - PRINTF(" 'memo': it can have until 253 characters (with spaces or not).\n"); + PRINTF("memo \n"_fmt); + PRINTF(" Modify the memo of an account.\n"_fmt); + PRINTF(" 'memo': it can have until 253 characters (with spaces or not).\n"_fmt); } - else if (command == "name") + else if (command == "name"_s) { - PRINTF("name \n"); - PRINTF(" Give the name of an account.\n"); + PRINTF("name \n"_fmt); + PRINTF(" Give the name of an account.\n"_fmt); } - else if (command == "password") + else if (command == "password"_s) { - PRINTF("password \n"); - PRINTF(" Change the password of an account.\n"); - PRINTF(" When new password is omitted,\n"); - PRINTF(" the input is done without displaying of the pressed keys.\n"); + PRINTF("password \n"_fmt); + PRINTF(" Change the password of an account.\n"_fmt); + PRINTF(" When new password is omitted,\n"_fmt); + PRINTF(" the input is done without displaying of the pressed keys.\n"_fmt); } - else if (command == "reloadgm") + else if (command == "reloadgm"_s) { - PRINTF("reloadGM\n"); - PRINTF(" Reload GM configuration file\n"); + PRINTF("reloadGM\n"_fmt); + PRINTF(" Reload GM configuration file\n"_fmt); } - else if (command == "search") + else if (command == "search"_s) { - PRINTF("search \n"); - PRINTF(" Seek accounts.\n"); - PRINTF(" Displays the accounts whose names correspond.\n"); + PRINTF("search \n"_fmt); + PRINTF(" Seek accounts.\n"_fmt); + PRINTF(" Displays the accounts whose names correspond.\n"_fmt); } - else if (command == "sex") + else if (command == "sex"_s) { - PRINTF("sex \n"); - PRINTF(" Modify the sex of an account.\n"); - PRINTF(" sex testname Male\n"); + PRINTF("sex \n"_fmt); + PRINTF(" Modify the sex of an account.\n"_fmt); + PRINTF(" sex testname Male\n"_fmt); } - else if (command == "state") + else if (command == "state"_s) { - PRINTF("state \n"); - PRINTF(" Change the state of an account.\n"); - PRINTF(" 'new_state': state is the state of the packet 0x006a + 1.\n"); - PRINTF(" The possibilities are:\n"); - PRINTF(" 0 = Account ok\n"); - PRINTF(" 1 = Unregistered ID\n"); - PRINTF(" 2 = Incorrect Password\n"); - PRINTF(" 3 = This ID is expired\n"); - PRINTF(" 4 = Rejected from Server\n"); - PRINTF(" 5 = You have been blocked by the GM Team\n"); - PRINTF(" 6 = Your Game's EXE file is not the latest version\n"); - PRINTF(" 7 = You are Prohibited to log in until...\n"); - PRINTF(" 8 = Server is jammed due to over populated\n"); - PRINTF(" 9 = No MSG\n"); - PRINTF(" 100 = This ID has been totally erased\n"); - PRINTF(" all other values are 'No MSG', then use state 9 please.\n"); - PRINTF(" 'error_message_#7': message of the code error 6\n"); - PRINTF(" = Your are Prohibited to log in until... (packet 0x006a)\n"); + PRINTF("state \n"_fmt); + PRINTF(" Change the state of an account.\n"_fmt); + PRINTF(" 'new_state': state is the state of the packet 0x006a + 1.\n"_fmt); + PRINTF(" The possibilities are:\n"_fmt); + PRINTF(" 0 = Account ok\n"_fmt); + PRINTF(" 1 = Unregistered ID\n"_fmt); + PRINTF(" 2 = Incorrect Password\n"_fmt); + PRINTF(" 3 = This ID is expired\n"_fmt); + PRINTF(" 4 = Rejected from Server\n"_fmt); + PRINTF(" 5 = You have been blocked by the GM Team\n"_fmt); + PRINTF(" 6 = Your Game's EXE file is not the latest version\n"_fmt); + PRINTF(" 7 = You are Prohibited to log in until...\n"_fmt); + PRINTF(" 8 = Server is jammed due to over populated\n"_fmt); + PRINTF(" 9 = No MSG\n"_fmt); + PRINTF(" 100 = This ID has been totally erased\n"_fmt); + PRINTF(" all other values are 'No MSG', then use state 9 please.\n"_fmt); + PRINTF(" 'error_message_#7': message of the code error 6\n"_fmt); + PRINTF(" = Your are Prohibited to log in until... (packet 0x006a)\n"_fmt); } - else if (command == "timeadd") + else if (command == "timeadd"_s) { - PRINTF("timeadd \n"); - PRINTF(" Adds or substracts time from the validity limit of an account.\n"); - PRINTF(" Modifier is done as follows:\n"); - PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"); - PRINTF(" Modified element:\n"); - PRINTF(" a or y: year\n"); - PRINTF(" m: month\n"); - PRINTF(" j or d: day\n"); - PRINTF(" h: hour\n"); - PRINTF(" mn: minute\n"); - PRINTF(" s: second\n"); - PRINTF(" timeadd testname +1m-2mn1s-6y\n"); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - PRINTF(" and 6 years at the same time.\n"); - PRINTF("NOTE: You can not modify a unlimited validity limit.\n"); - PRINTF(" If you want modify it, you want probably create a limited validity limit.\n"); - PRINTF(" So, at first, you must set the validity limit to a date/time.\n"); + PRINTF("timeadd \n"_fmt); + PRINTF(" Adds or substracts time from the validity limit of an account.\n"_fmt); + PRINTF(" Modifier is done as follows:\n"_fmt); + PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"_fmt); + PRINTF(" Modified element:\n"_fmt); + PRINTF(" a or y: year\n"_fmt); + PRINTF(" m: month\n"_fmt); + PRINTF(" j or d: day\n"_fmt); + PRINTF(" h: hour\n"_fmt); + PRINTF(" mn: minute\n"_fmt); + PRINTF(" s: second\n"_fmt); + PRINTF(" timeadd testname +1m-2mn1s-6y\n"_fmt); + PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); + PRINTF(" and 6 years at the same time.\n"_fmt); + PRINTF("NOTE: You can not modify a unlimited validity limit.\n"_fmt); + PRINTF(" If you want modify it, you want probably create a limited validity limit.\n"_fmt); + PRINTF(" So, at first, you must set the validity limit to a date/time.\n"_fmt); } - else if (command == "timeadd") + else if (command == "timeadd"_s) { - PRINTF("timeset yyyy/mm/dd [hh:mm:ss]\n"); - PRINTF(" Changes the validity limit of an account.\n"); - PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"); - PRINTF("timeset 0\n"); - PRINTF(" Gives an unlimited validity limit (0 = unlimited).\n"); + PRINTF("timeset yyyy/mm/dd [hh:mm:ss]\n"_fmt); + PRINTF(" Changes the validity limit of an account.\n"_fmt); + PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"_fmt); + PRINTF("timeset 0\n"_fmt); + PRINTF(" Gives an unlimited validity limit (0 = unlimited).\n"_fmt); } - else if (command == "unban") + else if (command == "unban"_s) { - PRINTF("unban/unbanish \n"); - PRINTF(" Remove the banishment of an account.\n"); - PRINTF(" This command works like banset 0.\n"); + PRINTF("unban/unbanish \n"_fmt); + PRINTF(" Remove the banishment of an account.\n"_fmt); + PRINTF(" This command works like banset 0.\n"_fmt); } - else if (command == "unblock") + else if (command == "unblock"_s) { - PRINTF("unblock \n"); - PRINTF(" Set state 0 (Account ok) to an account.\n"); - PRINTF(" This command works like state 0.\n"); + PRINTF("unblock \n"_fmt); + PRINTF(" Set state 0 (Account ok) to an account.\n"_fmt); + PRINTF(" This command works like state 0.\n"_fmt); } - else if (command == "version") + else if (command == "version"_s) { - PRINTF("version\n"); - PRINTF(" Display the version of the login-server.\n"); + PRINTF("version\n"_fmt); + PRINTF(" Display the version of the login-server.\n"_fmt); } - else if (command == "who") + else if (command == "who"_s) { - PRINTF("who \n"); - PRINTF(" Displays complete information of an account.\n"); + PRINTF("who \n"_fmt); + PRINTF(" Displays complete information of an account.\n"_fmt); } - else if (command == "quit" - || command == "exit" - || command == "end") - { - PRINTF("quit/end/exit\n"); - PRINTF(" End of the program of administration.\n"); + else if (command == "quit"_s + || command == "exit"_s + || command == "end"_s) + { + PRINTF("quit/end/exit\n"_fmt); + PRINTF(" End of the program of administration.\n"_fmt); } else { if (command) - PRINTF("Unknown command [%s] for help. Displaying of all commands.\n", + PRINTF("Unknown command [%s] for help. Displaying of all commands.\n"_fmt, AString(command)); - PRINTF(" help/? -- Display this help\n"); - PRINTF(" help/? [command] -- Display the help of the command\n"); - PRINTF(" add -- Create an account with default email\n"); - PRINTF(" ban yyyy/mm/dd hh:mm:ss -- Change final date of a ban\n"); - PRINTF(" banadd -- Add or substract time from the final\n"); - PRINTF(" example: ba apple +1m-2mn1s-2y date of a banishment of an account\n"); - PRINTF(" banset yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban\n"); - PRINTF(" banset 0 -- Un-banish an account\n"); - PRINTF(" block -- Set state 5 (blocked by the GM Team) to an account\n"); - PRINTF(" check -- Check the validity of a password\n"); - PRINTF(" create -- Create an account with email\n"); - PRINTF(" delete -- Remove an account\n"); - PRINTF(" email -- Modify an email of an account\n"); - PRINTF(" getcount -- Give the number of players online\n"); - PRINTF(" gm [GM_level] -- Modify the GM level of an account\n"); - PRINTF(" id -- Give the id of an account\n"); - PRINTF(" info -- Display all information of an account\n"); - PRINTF(" itemfrob -- Map all items from one item ID to another\n"); - PRINTF(" kami -- Sends a broadcast message (in yellow)\n"); - PRINTF(" kamib -- Sends a broadcast message (in blue)\n"); - PRINTF(" list [First_id [Last_id]] -- Display a list of accounts\n"); - PRINTF(" listban [First_id [Last_id] ] -- Display a list of accounts\n"); - PRINTF(" with state or banished\n"); - PRINTF(" listgm [First_id [Last_id]] -- Display a list of GM accounts\n"); - PRINTF(" listok [First_id [Last_id] ] -- Display a list of accounts\n"); - PRINTF(" without state and not banished\n"); - PRINTF(" memo -- Modify the memo of an account\n"); - PRINTF(" name -- Give the name of an account\n"); - PRINTF(" password -- Change the password of an account\n"); - PRINTF(" quit/end/exit -- End of the program of administation\n"); - PRINTF(" reloadGM -- Reload GM configuration file\n"); - PRINTF(" search -- Seek accounts\n"); - PRINTF(" sex -- Modify the sex of an account\n"); - PRINTF(" state -- Change the state\n"); - PRINTF(" timeadd -- Add or substract time from the\n"); - PRINTF(" example: ta apple +1m-2mn1s-2y validity limit of an account\n"); - PRINTF(" timeset yyyy/mm/dd [hh:mm:ss] -- Change the validify limit\n"); - PRINTF(" timeset 0 -- Give a unlimited validity limit\n"); - PRINTF(" unban -- Remove the banishment of an account\n"); - PRINTF(" unblock -- Set state 0 (Account ok) to an account\n"); - PRINTF(" version -- Gives the version of the login-server\n"); - PRINTF(" who -- Display all information of an account\n"); - PRINTF(" who -- Display all information of an account\n"); - PRINTF(" Note: To use spaces in an account name, type \"\" (or ').\n"); + PRINTF(" help/? -- Display this help\n"_fmt); + PRINTF(" help/? [command] -- Display the help of the command\n"_fmt); + PRINTF(" add -- Create an account with default email\n"_fmt); + PRINTF(" ban yyyy/mm/dd hh:mm:ss -- Change final date of a ban\n"_fmt); + PRINTF(" banadd -- Add or substract time from the final\n"_fmt); + PRINTF(" example: ba apple +1m-2mn1s-2y date of a banishment of an account\n"_fmt); + PRINTF(" banset yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban\n"_fmt); + PRINTF(" banset 0 -- Un-banish an account\n"_fmt); + PRINTF(" block -- Set state 5 (blocked by the GM Team) to an account\n"_fmt); + PRINTF(" check -- Check the validity of a password\n"_fmt); + PRINTF(" create -- Create an account with email\n"_fmt); + PRINTF(" delete -- Remove an account\n"_fmt); + PRINTF(" email -- Modify an email of an account\n"_fmt); + PRINTF(" getcount -- Give the number of players online\n"_fmt); + PRINTF(" gm [GM_level] -- Modify the GM level of an account\n"_fmt); + PRINTF(" id -- Give the id of an account\n"_fmt); + PRINTF(" info -- Display all information of an account\n"_fmt); + PRINTF(" itemfrob -- Map all items from one item ID to another\n"_fmt); + PRINTF(" kami -- Sends a broadcast message (in yellow)\n"_fmt); + PRINTF(" kamib -- Sends a broadcast message (in blue)\n"_fmt); + PRINTF(" list [First_id [Last_id]] -- Display a list of accounts\n"_fmt); + PRINTF(" listban [First_id [Last_id] ] -- Display a list of accounts\n"_fmt); + PRINTF(" with state or banished\n"_fmt); + PRINTF(" listgm [First_id [Last_id]] -- Display a list of GM accounts\n"_fmt); + PRINTF(" listok [First_id [Last_id] ] -- Display a list of accounts\n"_fmt); + PRINTF(" without state and not banished\n"_fmt); + PRINTF(" memo -- Modify the memo of an account\n"_fmt); + PRINTF(" name -- Give the name of an account\n"_fmt); + PRINTF(" password -- Change the password of an account\n"_fmt); + PRINTF(" quit/end/exit -- End of the program of administation\n"_fmt); + PRINTF(" reloadGM -- Reload GM configuration file\n"_fmt); + PRINTF(" search -- Seek accounts\n"_fmt); + PRINTF(" sex -- Modify the sex of an account\n"_fmt); + PRINTF(" state -- Change the state\n"_fmt); + PRINTF(" timeadd -- Add or substract time from the\n"_fmt); + PRINTF(" example: ta apple +1m-2mn1s-2y validity limit of an account\n"_fmt); + PRINTF(" timeset yyyy/mm/dd [hh:mm:ss] -- Change the validify limit\n"_fmt); + PRINTF(" timeset 0 -- Give a unlimited validity limit\n"_fmt); + PRINTF(" unban -- Remove the banishment of an account\n"_fmt); + PRINTF(" unblock -- Set state 0 (Account ok) to an account\n"_fmt); + PRINTF(" version -- Gives the version of the login-server\n"_fmt); + PRINTF(" who -- Display all information of an account\n"_fmt); + PRINTF(" who -- Display all information of an account\n"_fmt); + PRINTF(" Note: To use spaces in an account name, type \"\" (or ').\n"_fmt); } } @@ -668,9 +668,9 @@ void addaccount(ZString param, int emailflag) // add command if (!qsplit(param, &name, &sex_, &password)) { - PRINTF("Please input an account name, a sex and a password.\n"); - PRINTF(" add testname Male testpass\n"); - LADMIN_LOG("Incomplete parameters to create an account ('add' command).\n"); + PRINTF("Please input an account name, a sex and a password.\n"_fmt); + PRINTF(" add testname Male testpass\n"_fmt); + LADMIN_LOG("Incomplete parameters to create an account ('add' command).\n"_fmt); return; } email_ = DEFAULT_EMAIL; @@ -680,9 +680,9 @@ void addaccount(ZString param, int emailflag) // 1: create command if (!qsplit(param, &name, &sex_, &email_, &password)) { - PRINTF("Please input an account name, a sex and a password.\n"); - PRINTF(" create testname Male my@mail.com testpass\n"); - LADMIN_LOG("Incomplete parameters to create an account ('create' command).\n"); + PRINTF("Please input an account name, a sex and a password.\n"_fmt); + PRINTF(" create testname Male my@mail.com testpass\n"_fmt); + LADMIN_LOG("Incomplete parameters to create an account ('create' command).\n"_fmt); return; } } @@ -690,18 +690,18 @@ void addaccount(ZString param, int emailflag) if (!name.is_print()) return; - if (!XString("MF").contains(sex)) + if (!"MF"_s.contains(sex)) { - PRINTF("Illegal gender [%c]. Please input M or F.\n", sex); - LADMIN_LOG("Illegal gender [%c]. Please input M or F.\n", sex); + PRINTF("Illegal gender [%c]. Please input M or F.\n"_fmt, sex); + LADMIN_LOG("Illegal gender [%c]. Please input M or F.\n"_fmt, sex); return; } if (!e_mail_check(email_)) { - PRINTF("Invalid email [%s]. Please input a valid e-mail.\n", + PRINTF("Invalid email [%s]. Please input a valid e-mail.\n"_fmt, AString(email_)); - LADMIN_LOG("Invalid email [%s]. Please input a valid e-mail.\n", + LADMIN_LOG("Invalid email [%s]. Please input a valid e-mail.\n"_fmt, AString(email_)); return; } @@ -710,7 +710,7 @@ void addaccount(ZString param, int emailflag) if (!password.is_print()) return; - LADMIN_LOG("Request to login-server to create an account.\n"); + LADMIN_LOG("Request to login-server to create an account.\n"_fmt); WFIFOW(login_session, 0) = 0x7930; WFIFO_STRING(login_session, 2, name, 24); @@ -732,11 +732,11 @@ void banaddaccount(ZString param) if (!qsplit(param, &name, &modif)) { - PRINTF("Please input an account name and a modifier.\n"); - PRINTF(" : banadd testname +1m-2mn1s-6y\n"); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - PRINTF(" and 6 years at the same time.\n"); - LADMIN_LOG("Incomplete parameters to modify the ban date/time of an account ('banadd' command).\n"); + PRINTF("Please input an account name and a modifier.\n"_fmt); + PRINTF(" : banadd testname +1m-2mn1s-6y\n"_fmt); + PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); + PRINTF(" and 6 years at the same time.\n"_fmt); + LADMIN_LOG("Incomplete parameters to modify the ban date/time of an account ('banadd' command).\n"_fmt); return; } if (!name.is_print()) @@ -744,23 +744,23 @@ void banaddaccount(ZString param) if (!modif) { - PRINTF("Please give an adjustment with this command:\n"); - PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"); - PRINTF(" Modified element:\n"); - PRINTF(" a or y: year\n"); - PRINTF(" m: month\n"); - PRINTF(" j or d: day\n"); - PRINTF(" h: hour\n"); - PRINTF(" mn: minute\n"); - PRINTF(" s: second\n"); - PRINTF(" banadd testname +1m-2mn1s-6y\n"); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - PRINTF(" and 6 years at the same time.\n"); - LADMIN_LOG("No adjustment isn't an adjustment ('banadd' command).\n"); + PRINTF("Please give an adjustment with this command:\n"_fmt); + PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"_fmt); + PRINTF(" Modified element:\n"_fmt); + PRINTF(" a or y: year\n"_fmt); + PRINTF(" m: month\n"_fmt); + PRINTF(" j or d: day\n"_fmt); + PRINTF(" h: hour\n"_fmt); + PRINTF(" mn: minute\n"_fmt); + PRINTF(" s: second\n"_fmt); + PRINTF(" banadd testname +1m-2mn1s-6y\n"_fmt); + PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); + PRINTF(" and 6 years at the same time.\n"_fmt); + LADMIN_LOG("No adjustment isn't an adjustment ('banadd' command).\n"_fmt); return; } - LADMIN_LOG("Request to login-server to modify a ban date/time.\n"); + LADMIN_LOG("Request to login-server to modify a ban date/time.\n"_fmt); WFIFOW(login_session, 0) = 0x794c; WFIFO_STRING(login_session, 2, name, 24); @@ -786,19 +786,19 @@ void bansetaccountsub(AccountName name, XString date, XString time_) if (!name.is_print()) return; - if (date != "0" + if (date != "0"_s && ((!extract(date, record<'/'>(&year, &month, &day)) && !extract(date, record<'-'>(&year, &month, &day)) && !extract(date, record<'.'>(&year, &month, &day))) || !extract(time_, record<':'>(&hour, &minute, &second)))) { - PRINTF("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"); - PRINTF("You can imput 0 instead of if you use 'banset' command.\n"); - LADMIN_LOG("Invalid format for the date/time ('banset' or 'ban' command).\n"); + PRINTF("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"_fmt); + PRINTF("You can imput 0 instead of if you use 'banset' command.\n"_fmt); + LADMIN_LOG("Invalid format for the date/time ('banset' or 'ban' command).\n"_fmt); return; } - if (date == "0") + if (date == "0"_s) { ban_until_time = TimeT(); } @@ -814,41 +814,41 @@ void bansetaccountsub(AccountName name, XString date, XString time_) } if (month < 1 || month > 12) { - PRINTF("Please give a correct value for the month (from 1 to 12).\n"); - LADMIN_LOG("Invalid month for the date ('banset' or 'ban' command).\n"); + PRINTF("Please give a correct value for the month (from 1 to 12).\n"_fmt); + LADMIN_LOG("Invalid month for the date ('banset' or 'ban' command).\n"_fmt); return; } month = month - 1; if (day < 1 || day > 31) { - PRINTF("Please give a correct value for the day (from 1 to 31).\n"); - LADMIN_LOG("Invalid day for the date ('banset' or 'ban' command).\n"); + PRINTF("Please give a correct value for the day (from 1 to 31).\n"_fmt); + LADMIN_LOG("Invalid day for the date ('banset' or 'ban' command).\n"_fmt); return; } if (((month == 3 || month == 5 || month == 8 || month == 10) && day > 30) || (month == 1 && day > 29)) { - PRINTF("Please give a correct value for a day of this month (%d).\n", + PRINTF("Please give a correct value for a day of this month (%d).\n"_fmt, month); - LADMIN_LOG("Invalid day for this month ('banset' or 'ban' command).\n"); + LADMIN_LOG("Invalid day for this month ('banset' or 'ban' command).\n"_fmt); return; } if (hour < 0 || hour > 23) { - PRINTF("Please give a correct value for the hour (from 0 to 23).\n"); - LADMIN_LOG("Invalid hour for the time ('banset' or 'ban' command).\n"); + PRINTF("Please give a correct value for the hour (from 0 to 23).\n"_fmt); + LADMIN_LOG("Invalid hour for the time ('banset' or 'ban' command).\n"_fmt); return; } if (minute < 0 || minute > 59) { - PRINTF("Please give a correct value for the minutes (from 0 to 59).\n"); - LADMIN_LOG("Invalid minute for the time ('banset' or 'ban' command).\n"); + PRINTF("Please give a correct value for the minutes (from 0 to 59).\n"_fmt); + LADMIN_LOG("Invalid minute for the time ('banset' or 'ban' command).\n"_fmt); return; } if (second < 0 || second > 59) { - PRINTF("Please give a correct value for the seconds (from 0 to 59).\n"); - LADMIN_LOG("Invalid second for the time ('banset' or 'ban' command).\n"); + PRINTF("Please give a correct value for the seconds (from 0 to 59).\n"_fmt); + LADMIN_LOG("Invalid second for the time ('banset' or 'ban' command).\n"_fmt); return; } tmtime.tm_year = year; @@ -861,15 +861,15 @@ void bansetaccountsub(AccountName name, XString date, XString time_) ban_until_time = tmtime; if (ban_until_time.error()) { - PRINTF("Invalid date.\n"); - PRINTF("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"); - PRINTF("You can imput 0 instead of if you use 'banset' command.\n"); - LADMIN_LOG("Invalid date. ('banset' or 'ban' command).\n"); + PRINTF("Invalid date.\n"_fmt); + PRINTF("Please input a date and a time (format: yyyy/mm/dd hh:mm:ss).\n"_fmt); + PRINTF("You can imput 0 instead of if you use 'banset' command.\n"_fmt); + LADMIN_LOG("Invalid date. ('banset' or 'ban' command).\n"_fmt); return; } } - LADMIN_LOG("Request to login-server to set a ban.\n"); + LADMIN_LOG("Request to login-server to set a ban.\n"_fmt); WFIFOW(login_session, 0) = 0x794a; WFIFO_STRING(login_session, 2, name, 24); @@ -890,18 +890,18 @@ void banaccount(ZString param) if (!qsplit(param, &date, &time_, &name)) { - PRINTF("Please input an account name, a date and a hour.\n"); - PRINTF(": banset yyyy/mm/dd [hh:mm:ss]\n"); - PRINTF(" banset 0 (0 = un-banished)\n"); - PRINTF(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - PRINTF(" unban/unbanish \n"); - PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"); - LADMIN_LOG("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"); + PRINTF("Please input an account name, a date and a hour.\n"_fmt); + PRINTF(": banset yyyy/mm/dd [hh:mm:ss]\n"_fmt); + PRINTF(" banset 0 (0 = un-banished)\n"_fmt); + PRINTF(" ban/banish yyyy/mm/dd hh:mm:ss \n"_fmt); + PRINTF(" unban/unbanish \n"_fmt); + PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"_fmt); + LADMIN_LOG("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"_fmt); return; } if (!time_) - time_ = "23:59:59"; + time_ = "23:59:59"_s; bansetaccountsub(name, date, time_); } @@ -919,18 +919,18 @@ void bansetaccount(ZString param) if (!qsplit(param, &name, &date, &time_) && !qsplit(param, &name, &date)) { - PRINTF("Please input an account name, a date and a hour.\n"); - PRINTF(": banset yyyy/mm/dd [hh:mm:ss]\n"); - PRINTF(" banset 0 (0 = un-banished)\n"); - PRINTF(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - PRINTF(" unban/unbanish \n"); - PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"); - LADMIN_LOG("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"); + PRINTF("Please input an account name, a date and a hour.\n"_fmt); + PRINTF(": banset yyyy/mm/dd [hh:mm:ss]\n"_fmt); + PRINTF(" banset 0 (0 = un-banished)\n"_fmt); + PRINTF(" ban/banish yyyy/mm/dd hh:mm:ss \n"_fmt); + PRINTF(" unban/unbanish \n"_fmt); + PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"_fmt); + LADMIN_LOG("Incomplete parameters to set a ban ('banset' or 'ban' command).\n"_fmt); return; } if (!time_) - time_ = "23:59:59"; + time_ = "23:59:59"_s; bansetaccountsub(name, date, time_); } @@ -945,17 +945,17 @@ void unbanaccount(ZString param) if (!qsplit(param, &name)) { - PRINTF("Please input an account name.\n"); - PRINTF(": banset yyyy/mm/dd [hh:mm:ss]\n"); - PRINTF(" banset 0 (0 = un-banished)\n"); - PRINTF(" ban/banish yyyy/mm/dd hh:mm:ss \n"); - PRINTF(" unban/unbanish \n"); - PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"); - LADMIN_LOG("Incomplete parameters to set a ban ('unban' command).\n"); + PRINTF("Please input an account name.\n"_fmt); + PRINTF(": banset yyyy/mm/dd [hh:mm:ss]\n"_fmt); + PRINTF(" banset 0 (0 = un-banished)\n"_fmt); + PRINTF(" ban/banish yyyy/mm/dd hh:mm:ss \n"_fmt); + PRINTF(" unban/unbanish \n"_fmt); + PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"_fmt); + LADMIN_LOG("Incomplete parameters to set a ban ('unban' command).\n"_fmt); return; } - bansetaccountsub(name, "0", ""); + bansetaccountsub(name, "0"_s, ""_s); } //--------------------------------------------------------- @@ -970,9 +970,9 @@ void checkaccount(ZString param) if (!qsplit(param, &name, &password)) { - PRINTF("Please input an account name.\n"); - PRINTF(" check testname password\n"); - LADMIN_LOG("Incomplete parameters to check the password of an account ('check' command).\n"); + PRINTF("Please input an account name.\n"_fmt); + PRINTF(" check testname password\n"_fmt); + LADMIN_LOG("Incomplete parameters to check the password of an account ('check' command).\n"_fmt); return; } @@ -982,7 +982,7 @@ void checkaccount(ZString param) if (!password.is_print()) return; - LADMIN_LOG("Request to login-server to check a password.\n"); + LADMIN_LOG("Request to login-server to check a password.\n"_fmt); WFIFOW(login_session, 0) = 0x793a; WFIFO_STRING(login_session, 2, name, 24); @@ -1001,9 +1001,9 @@ void delaccount(ZString param) if (!qsplit(param, &name)) { - PRINTF("Please input an account name.\n"); - PRINTF(" delete testnametodelete\n"); - LADMIN_LOG("No name given to delete an account ('delete' command).\n"); + PRINTF("Please input an account name.\n"_fmt); + PRINTF(" delete testnametodelete\n"_fmt); + LADMIN_LOG("No name given to delete an account ('delete' command).\n"_fmt); return; } @@ -1013,7 +1013,7 @@ void delaccount(ZString param) char confirm; do { - PRINTF(SGR_BOLD SGR_CYAN " ** Are you really sure to DELETE account [%s]? (y/n) > " SGR_RESET, name); + PRINTF(SGR_BOLD SGR_CYAN " ** Are you really sure to DELETE account [%s]? (y/n) > " SGR_RESET ""_fmt, name); fflush(stdout); int seek = getchar(); confirm = seek; @@ -1023,16 +1023,16 @@ void delaccount(ZString param) while (seek != '\n' && seek != EOF) seek = getchar(); } - while (!XString("yn").contains(confirm)); + while (!"yn"_s.contains(confirm)); if (confirm == 'n') { - PRINTF("Deletion canceled.\n"); - LADMIN_LOG("Deletion canceled by user ('delete' command).\n"); + PRINTF("Deletion canceled.\n"_fmt); + LADMIN_LOG("Deletion canceled by user ('delete' command).\n"_fmt); return; } - LADMIN_LOG("Request to login-server to delete an acount.\n"); + LADMIN_LOG("Request to login-server to delete an acount.\n"_fmt); WFIFOW(login_session, 0) = 0x7932; WFIFO_STRING(login_session, 2, name, 24); @@ -1050,9 +1050,9 @@ void changeemail(ZString param) XString email_; if (!qsplit(param, &name, &email_)) { - PRINTF("Please input an account name and an email.\n"); - PRINTF(" email testname newemail\n"); - LADMIN_LOG("Incomplete parameters to change the email of an account ('email' command).\n"); + PRINTF("Please input an account name and an email.\n"_fmt); + PRINTF(" email testname newemail\n"_fmt); + LADMIN_LOG("Incomplete parameters to change the email of an account ('email' command).\n"_fmt); return; } @@ -1061,15 +1061,15 @@ void changeemail(ZString param) if (!e_mail_check(email_)) { - PRINTF("Invalid email [%s]. Please input a valid e-mail.\n", + PRINTF("Invalid email [%s]. Please input a valid e-mail.\n"_fmt, AString(email_)); - LADMIN_LOG("Invalid email [%s]. Please input a valid e-mail.\n", + LADMIN_LOG("Invalid email [%s]. Please input a valid e-mail.\n"_fmt, AString(email_)); return; } AccountEmail email = stringish(email_); - LADMIN_LOG("Request to login-server to change an email.\n"); + LADMIN_LOG("Request to login-server to change an email.\n"_fmt); WFIFOW(login_session, 0) = 0x7940; WFIFO_STRING(login_session, 2, name, 24); @@ -1084,7 +1084,7 @@ void changeemail(ZString param) static void getlogincount(void) { - LADMIN_LOG("Request to login-server to obtain the # of online players.\n"); + LADMIN_LOG("Request to login-server to obtain the # of online players.\n"_fmt); WFIFOW(login_session, 0) = 0x7938; WFIFOSET(login_session, 2); @@ -1102,9 +1102,9 @@ void changegmlevel(ZString param) if (!qsplit(param, &name, &GM_level)) { - PRINTF("Please input an account name and a GM level.\n"); - PRINTF(" gm testname 80\n"); - LADMIN_LOG("Incomplete parameters to change the GM level of an account ('gm' command).\n"); + PRINTF("Please input an account name and a GM level.\n"_fmt); + PRINTF(" gm testname 80\n"_fmt); + LADMIN_LOG("Incomplete parameters to change the GM level of an account ('gm' command).\n"_fmt); return; } @@ -1113,14 +1113,14 @@ void changegmlevel(ZString param) if (GM_level < 0 || GM_level > 99) { - PRINTF("Illegal GM level [%d]. Please input a value from 0 to 99.\n", + PRINTF("Illegal GM level [%d]. Please input a value from 0 to 99.\n"_fmt, GM_level); - LADMIN_LOG("Illegal GM level [%d]. The value can be from 0 to 99.\n", + LADMIN_LOG("Illegal GM level [%d]. The value can be from 0 to 99.\n"_fmt, GM_level); return; } - LADMIN_LOG("Request to login-server to change a GM level.\n"); + LADMIN_LOG("Request to login-server to change a GM level.\n"_fmt); WFIFOW(login_session, 0) = 0x793e; WFIFO_STRING(login_session, 2, name, 24); @@ -1139,9 +1139,9 @@ void idaccount(ZString param) if (!qsplit(param, &name)) { - PRINTF("Please input an account name.\n"); - PRINTF(" id testname\n"); - LADMIN_LOG("No name given to search an account id ('id' command).\n"); + PRINTF("Please input an account name.\n"_fmt); + PRINTF(" id testname\n"_fmt); + LADMIN_LOG("No name given to search an account id ('id' command).\n"_fmt); return; } @@ -1150,7 +1150,7 @@ void idaccount(ZString param) return; } - LADMIN_LOG("Request to login-server to know an account id.\n"); + LADMIN_LOG("Request to login-server to know an account id.\n"_fmt); WFIFOW(login_session, 0) = 0x7944; WFIFO_STRING(login_session, 2, name, 24); @@ -1166,12 +1166,12 @@ void infoaccount(int account_id) { if (account_id < 0) { - PRINTF("Please input a positive value for the id.\n"); - LADMIN_LOG("Negative value was given to found the account.\n"); + PRINTF("Please input a positive value for the id.\n"_fmt); + LADMIN_LOG("Negative value was given to found the account.\n"_fmt); return; } - LADMIN_LOG("Request to login-server to obtain information about an account (by its id).\n"); + LADMIN_LOG("Request to login-server to obtain information about an account (by its id).\n"_fmt); WFIFOW(login_session, 0) = 0x7954; WFIFOL(login_session, 2) = account_id; @@ -1187,11 +1187,11 @@ void sendbroadcast(ZString message) { if (!message) { - PRINTF("Please input a message.\n"); + PRINTF("Please input a message.\n"_fmt); { - PRINTF(" kami a message\n"); + PRINTF(" kami a message\n"_fmt); } - LADMIN_LOG("The message is void ('kami' command).\n"); + LADMIN_LOG("The message is void ('kami' command).\n"_fmt); return; } @@ -1244,7 +1244,7 @@ void listaccount(ZString param, int type) list_last = 0; } - LADMIN_LOG("Request to login-server to obtain the list of accounts from %d to %d.\n", + LADMIN_LOG("Request to login-server to obtain the list of accounts from %d to %d.\n"_fmt, list_first, list_last); WFIFOW(login_session, 0) = 0x7920; @@ -1254,8 +1254,8 @@ void listaccount(ZString param, int type) bytes_to_read = 1; // 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567 - Iprintf("account_id GM user_name sex count state\n"); - Iprintf("-------------------------------------------------------------------------------\n"); + Iprintf("account_id GM user_name sex count state\n"_fmt); + Iprintf("-------------------------------------------------------------------------------\n"_fmt); list_count = 0; } @@ -1269,7 +1269,7 @@ int itemfrob(ZString param) if (!extract(param, record<' '>(&source_id, &dest_id))) { - PRINTF("You must provide the source and destination item IDs.\n"); + PRINTF("You must provide the source and destination item IDs.\n"_fmt); return 1; } @@ -1293,9 +1293,9 @@ void changememo(ZString param) if (!qsplit(param, &name, &memo) && !qsplit(param, &name)) { - PRINTF("Please input an account name and a memo.\n"); - PRINTF(" memo testname new memo\n"); - LADMIN_LOG("Incomplete parameters to change the memo of an account ('email' command).\n"); + PRINTF("Please input an account name and a memo.\n"_fmt); + PRINTF(" memo testname new memo\n"_fmt); + LADMIN_LOG("Incomplete parameters to change the memo of an account ('email' command).\n"_fmt); return; } @@ -1306,14 +1306,14 @@ void changememo(ZString param) size_t len1 = len + 1; if (len > 254) { - PRINTF("Memo is too long (%zu characters).\n", len); - PRINTF("Please input a memo of 254 bytes at the maximum.\n"); - LADMIN_LOG("Email is too long (%zu characters). Please input a memo of 254 bytes at the maximum.\n", + PRINTF("Memo is too long (%zu characters).\n"_fmt, len); + PRINTF("Please input a memo of 254 bytes at the maximum.\n"_fmt); + LADMIN_LOG("Email is too long (%zu characters). Please input a memo of 254 bytes at the maximum.\n"_fmt, len); return; } - LADMIN_LOG("Request to login-server to change a memo.\n"); + LADMIN_LOG("Request to login-server to change a memo.\n"_fmt); WFIFOW(login_session, 0) = 0x7942; WFIFO_STRING(login_session, 2, name, 24); @@ -1331,12 +1331,12 @@ void nameaccount(int id) { if (id < 0) { - PRINTF("Please input a positive value for the id.\n"); - LADMIN_LOG("Negativ id given to search an account name ('name' command).\n"); + PRINTF("Please input a positive value for the id.\n"_fmt); + LADMIN_LOG("Negativ id given to search an account name ('name' command).\n"_fmt); return; } - LADMIN_LOG("Request to login-server to know an account name.\n"); + LADMIN_LOG("Request to login-server to know an account name.\n"_fmt); WFIFOW(login_session, 0) = 0x7946; WFIFOL(login_session, 2) = id; @@ -1356,9 +1356,9 @@ void changepasswd(ZString param) if (!qsplit(param, &name, &password)) { - PRINTF("Please input an account name.\n"); - PRINTF(" password testname newpassword\n"); - LADMIN_LOG("Incomplete parameters to change the password of an account ('password' command).\n"); + PRINTF("Please input an account name.\n"_fmt); + PRINTF(" password testname newpassword\n"_fmt); + LADMIN_LOG("Incomplete parameters to change the password of an account ('password' command).\n"_fmt); return; } @@ -1370,7 +1370,7 @@ void changepasswd(ZString param) if (!password.is_print()) return; - LADMIN_LOG("Request to login-server to change a password.\n"); + LADMIN_LOG("Request to login-server to change a password.\n"_fmt); WFIFOW(login_session, 0) = 0x7934; WFIFO_STRING(login_session, 2, name, 24); @@ -1390,9 +1390,9 @@ void reloadGM(ZString params) WFIFOSET(login_session, 2); bytes_to_read = 0; - LADMIN_LOG("Request to reload the GM configuration file sended.\n"); - PRINTF("Request to reload the GM configuration file sended.\n"); - PRINTF("Check the actual GM accounts (after reloading):\n"); + LADMIN_LOG("Request to reload the GM configuration file sended.\n"_fmt); + PRINTF("Request to reload the GM configuration file sended.\n"_fmt); + PRINTF("Check the actual GM accounts (after reloading):\n"_fmt); listaccount(params, 1); // 1: to list only GM } @@ -1407,27 +1407,27 @@ void changesex(ZString param) if (!qsplit(param, &name, &sex_)) { - PRINTF("Please input an account name and a sex.\n"); - PRINTF(" sex testname Male\n"); - LADMIN_LOG("Incomplete parameters to change the sex of an account ('sex' command).\n"); + PRINTF("Please input an account name and a sex.\n"_fmt); + PRINTF(" sex testname Male\n"_fmt); + LADMIN_LOG("Incomplete parameters to change the sex of an account ('sex' command).\n"_fmt); return; } char sex = sex_.front(); if (!name.is_print()) { - PRINTF("bad name\n"); + PRINTF("bad name\n"_fmt); return; } - if (!XString("MF").contains(sex)) + if (!"MF"_s.contains(sex)) { - PRINTF("Illegal gender [%c]. Please input M or F.\n", sex); - LADMIN_LOG("Illegal gender [%c]. Please input M or F.\n", sex); + PRINTF("Illegal gender [%c]. Please input M or F.\n"_fmt, sex); + LADMIN_LOG("Illegal gender [%c]. Please input M or F.\n"_fmt, sex); return; } - LADMIN_LOG("Request to login-server to change a sex.\n"); + LADMIN_LOG("Request to login-server to change a sex.\n"_fmt); WFIFOW(login_session, 0) = 0x793c; WFIFO_STRING(login_session, 2, name, 24); @@ -1445,18 +1445,18 @@ void changestatesub(AccountName name, int state, XString error_message) { if ((state < 0 || state > 9) && state != 100) { // Valid values: 0: ok, or value of the 0x006a packet + 1 - PRINTF("Please input one of these states:\n"); - PRINTF(" 0 = Account ok 6 = Your Game's EXE file is not the latest version\n"); - PRINTF(" 1 = Unregistered ID 7 = You are Prohibited to log in until + message\n"); - PRINTF(" 2 = Incorrect Password 8 = Server is jammed due to over populated\n"); - PRINTF(" 3 = This ID is expired 9 = No MSG\n"); - PRINTF(" 4 = Rejected from Server 100 = This ID has been totally erased\n"); - PRINTF(" 5 = You have been blocked by the GM Team\n"); - PRINTF(" state testname 5\n"); - PRINTF(" state testname 7 end of your ban\n"); - PRINTF(" block \n"); - PRINTF(" unblock \n"); - LADMIN_LOG("Invalid value for the state of an account ('state', 'block' or 'unblock' command).\n"); + PRINTF("Please input one of these states:\n"_fmt); + PRINTF(" 0 = Account ok 6 = Your Game's EXE file is not the latest version\n"_fmt); + PRINTF(" 1 = Unregistered ID 7 = You are Prohibited to log in until + message\n"_fmt); + PRINTF(" 2 = Incorrect Password 8 = Server is jammed due to over populated\n"_fmt); + PRINTF(" 3 = This ID is expired 9 = No MSG\n"_fmt); + PRINTF(" 4 = Rejected from Server 100 = This ID has been totally erased\n"_fmt); + PRINTF(" 5 = You have been blocked by the GM Team\n"_fmt); + PRINTF(" state testname 5\n"_fmt); + PRINTF(" state testname 7 end of your ban\n"_fmt); + PRINTF(" block \n"_fmt); + PRINTF(" unblock \n"_fmt); + LADMIN_LOG("Invalid value for the state of an account ('state', 'block' or 'unblock' command).\n"_fmt); return; } @@ -1465,25 +1465,25 @@ void changestatesub(AccountName name, int state, XString error_message) if (state != 7) { - error_message = "-"; + error_message = "-"_s; } else { if (error_message.size() < 1) { - PRINTF("Error message is too short. Please input a message of 1-19 bytes.\n"); - LADMIN_LOG("Error message is too short. Please input a message of 1-19 bytes.\n"); + PRINTF("Error message is too short. Please input a message of 1-19 bytes.\n"_fmt); + LADMIN_LOG("Error message is too short. Please input a message of 1-19 bytes.\n"_fmt); return; } if (error_message.size() > 19) { - PRINTF("Error message is too long. Please input a message of 1-19 bytes.\n"); - LADMIN_LOG("Error message is too long. Please input a message of 1-19 bytes.\n"); + PRINTF("Error message is too long. Please input a message of 1-19 bytes.\n"_fmt); + LADMIN_LOG("Error message is too long. Please input a message of 1-19 bytes.\n"_fmt); return; } } - LADMIN_LOG("Request to login-server to change a state.\n"); + LADMIN_LOG("Request to login-server to change a state.\n"_fmt); WFIFOW(login_session, 0) = 0x7936; WFIFO_STRING(login_session, 2, name, 24); @@ -1505,12 +1505,12 @@ void changestate(ZString param) if (!qsplit(param, &name, &state, &error_message) && !qsplit(param, &name, &state)) { - PRINTF("Please input an account name and a state.\n"); - PRINTF(" state testname 5\n"); - PRINTF(" state testname 7 end of your ban\n"); - PRINTF(" block \n"); - PRINTF(" unblock \n"); - LADMIN_LOG("Incomplete parameters to change the state of an account ('state' command).\n"); + PRINTF("Please input an account name and a state.\n"_fmt); + PRINTF(" state testname 5\n"_fmt); + PRINTF(" state testname 7 end of your ban\n"_fmt); + PRINTF(" block \n"_fmt); + PRINTF(" unblock \n"_fmt); + LADMIN_LOG("Incomplete parameters to change the state of an account ('state' command).\n"_fmt); return; } @@ -1527,16 +1527,16 @@ void unblockaccount(ZString param) if (!qsplit(param, &name)) { - PRINTF("Please input an account name.\n"); - PRINTF(" state testname 5\n"); - PRINTF(" state testname 7 end of your ban\n"); - PRINTF(" block \n"); - PRINTF(" unblock \n"); - LADMIN_LOG("Incomplete parameters to change the state of an account ('unblock' command).\n"); + PRINTF("Please input an account name.\n"_fmt); + PRINTF(" state testname 5\n"_fmt); + PRINTF(" state testname 7 end of your ban\n"_fmt); + PRINTF(" block \n"_fmt); + PRINTF(" unblock \n"_fmt); + LADMIN_LOG("Incomplete parameters to change the state of an account ('unblock' command).\n"_fmt); return; } - changestatesub(name, 0, "-"); // state 0, no error message + changestatesub(name, 0, "-"_s); // state 0, no error message } //------------------------------------------- @@ -1549,16 +1549,16 @@ void blockaccount(ZString param) if (!qsplit(param, &name)) { - PRINTF("Please input an account name.\n"); - PRINTF(" state testname 5\n"); - PRINTF(" state testname 7 end of your ban\n"); - PRINTF(" block \n"); - PRINTF(" unblock \n"); - LADMIN_LOG("Incomplete parameters to change the state of an account ('block' command).\n"); + PRINTF("Please input an account name.\n"_fmt); + PRINTF(" state testname 5\n"_fmt); + PRINTF(" state testname 7 end of your ban\n"_fmt); + PRINTF(" block \n"_fmt); + PRINTF(" unblock \n"_fmt); + LADMIN_LOG("Incomplete parameters to change the state of an account ('block' command).\n"_fmt); return; } - changestatesub(name, 5, "-"); // state 5, no error message + changestatesub(name, 5, "-"_s); // state 5, no error message } //--------------------------------------------------------------------- @@ -1572,11 +1572,11 @@ void timeaddaccount(ZString param) if (!qsplit(param, &name, &modif)) { - PRINTF("Please input an account name and a modifier.\n"); - PRINTF(" : timeadd testname +1m-2mn1s-6y\n"); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - PRINTF(" and 6 years at the same time.\n"); - LADMIN_LOG("Incomplete parameters to modify a limit time ('timeadd' command).\n"); + PRINTF("Please input an account name and a modifier.\n"_fmt); + PRINTF(" : timeadd testname +1m-2mn1s-6y\n"_fmt); + PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); + PRINTF(" and 6 years at the same time.\n"_fmt); + LADMIN_LOG("Incomplete parameters to modify a limit time ('timeadd' command).\n"_fmt); return; } if (name.is_print()) @@ -1586,23 +1586,23 @@ void timeaddaccount(ZString param) if (!modif) { - PRINTF("Please give an adjustment with this command:\n"); - PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"); - PRINTF(" Modified element:\n"); - PRINTF(" a or y: year\n"); - PRINTF(" m: month\n"); - PRINTF(" j or d: day\n"); - PRINTF(" h: hour\n"); - PRINTF(" mn: minute\n"); - PRINTF(" s: second\n"); - PRINTF(" timeadd testname +1m-2mn1s-6y\n"); - PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"); - PRINTF(" and 6 years at the same time.\n"); - LADMIN_LOG("No adjustment isn't an adjustment ('timeadd' command).\n"); + PRINTF("Please give an adjustment with this command:\n"_fmt); + PRINTF(" Adjustment value (-1, 1, +1, etc...)\n"_fmt); + PRINTF(" Modified element:\n"_fmt); + PRINTF(" a or y: year\n"_fmt); + PRINTF(" m: month\n"_fmt); + PRINTF(" j or d: day\n"_fmt); + PRINTF(" h: hour\n"_fmt); + PRINTF(" mn: minute\n"_fmt); + PRINTF(" s: second\n"_fmt); + PRINTF(" timeadd testname +1m-2mn1s-6y\n"_fmt); + PRINTF(" this example adds 1 month and 1 second, and substracts 2 minutes\n"_fmt); + PRINTF(" and 6 years at the same time.\n"_fmt); + LADMIN_LOG("No adjustment isn't an adjustment ('timeadd' command).\n"_fmt); return; } - LADMIN_LOG("Request to login-server to modify a time limit.\n"); + LADMIN_LOG("Request to login-server to modify a time limit.\n"_fmt); WFIFOW(login_session, 0) = 0x7950; WFIFO_STRING(login_session, 2, name, 24); @@ -1631,31 +1631,31 @@ void timesetaccount(ZString param) if (!qsplit(param, &name, &date, &time_) && !qsplit(param, &name, &date)) { - PRINTF("Please input an account name, a date and a hour.\n"); - PRINTF(": timeset yyyy/mm/dd [hh:mm:ss]\n"); - PRINTF(" timeset 0 (0 = unlimited)\n"); - PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"); - LADMIN_LOG("Incomplete parameters to set a limit time ('timeset' command).\n"); + PRINTF("Please input an account name, a date and a hour.\n"_fmt); + PRINTF(": timeset yyyy/mm/dd [hh:mm:ss]\n"_fmt); + PRINTF(" timeset 0 (0 = unlimited)\n"_fmt); + PRINTF(" Default time [hh:mm:ss]: 23:59:59.\n"_fmt); + LADMIN_LOG("Incomplete parameters to set a limit time ('timeset' command).\n"_fmt); return; } if (!name.is_print()) return; if (!time_) - time_ = "23:59:59"; + time_ = "23:59:59"_s; - if (date != "0" + if (date != "0"_s && ((!extract(date, record<'/'>(&year, &month, &day)) && !extract(date, record<'-'>(&year, &month, &day)) && !extract(date, record<'.'>(&year, &month, &day))) || !extract(time_, record<':'>(&hour, &minute, &second)))) { - PRINTF("Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"); - LADMIN_LOG("Invalid format for the date/time ('timeset' command).\n"); + PRINTF("Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"_fmt); + LADMIN_LOG("Invalid format for the date/time ('timeset' command).\n"_fmt); return; } - if (date == "0") + if (date == "0"_s) { connect_until_time = TimeT(); } @@ -1671,41 +1671,41 @@ void timesetaccount(ZString param) } if (month < 1 || month > 12) { - PRINTF("Please give a correct value for the month (from 1 to 12).\n"); - LADMIN_LOG("Invalid month for the date ('timeset' command).\n"); + PRINTF("Please give a correct value for the month (from 1 to 12).\n"_fmt); + LADMIN_LOG("Invalid month for the date ('timeset' command).\n"_fmt); return; } month = month - 1; if (day < 1 || day > 31) { - PRINTF("Please give a correct value for the day (from 1 to 31).\n"); - LADMIN_LOG("Invalid day for the date ('timeset' command).\n"); + PRINTF("Please give a correct value for the day (from 1 to 31).\n"_fmt); + LADMIN_LOG("Invalid day for the date ('timeset' command).\n"_fmt); return; } if (((month == 3 || month == 5 || month == 8 || month == 10) && day > 30) ||(month == 1 && day > 29)) { - PRINTF("Please give a correct value for a day of this month (%d).\n", + PRINTF("Please give a correct value for a day of this month (%d).\n"_fmt, month); - LADMIN_LOG("Invalid day for this month ('timeset' command).\n"); + LADMIN_LOG("Invalid day for this month ('timeset' command).\n"_fmt); return; } if (hour < 0 || hour > 23) { - PRINTF("Please give a correct value for the hour (from 0 to 23).\n"); - LADMIN_LOG("Invalid hour for the time ('timeset' command).\n"); + PRINTF("Please give a correct value for the hour (from 0 to 23).\n"_fmt); + LADMIN_LOG("Invalid hour for the time ('timeset' command).\n"_fmt); return; } if (minute < 0 || minute > 59) { - PRINTF("Please give a correct value for the minutes (from 0 to 59).\n"); - LADMIN_LOG("Invalid minute for the time ('timeset' command).\n"); + PRINTF("Please give a correct value for the minutes (from 0 to 59).\n"_fmt); + LADMIN_LOG("Invalid minute for the time ('timeset' command).\n"_fmt); return; } if (second < 0 || second > 59) { - PRINTF("Please give a correct value for the seconds (from 0 to 59).\n"); - LADMIN_LOG("Invalid second for the time ('timeset' command).\n"); + PRINTF("Please give a correct value for the seconds (from 0 to 59).\n"_fmt); + LADMIN_LOG("Invalid second for the time ('timeset' command).\n"_fmt); return; } tmtime.tm_year = year; @@ -1718,14 +1718,14 @@ void timesetaccount(ZString param) connect_until_time = tmtime; if (connect_until_time.error()) { - PRINTF("Invalid date.\n"); - PRINTF("Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"); - LADMIN_LOG("Invalid date. ('timeset' command).\n"); + PRINTF("Invalid date.\n"_fmt); + PRINTF("Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n"_fmt); + LADMIN_LOG("Invalid date. ('timeset' command).\n"_fmt); return; } } - LADMIN_LOG("Request to login-server to set a time limit.\n"); + LADMIN_LOG("Request to login-server to set a time limit.\n"_fmt); WFIFOW(login_session, 0) = 0x7948; WFIFO_STRING(login_session, 2, name, 24); @@ -1744,9 +1744,9 @@ void whoaccount(ZString param) if (!qsplit(param, &name)) { - PRINTF("Please input an account name.\n"); - PRINTF(" who testname\n"); - LADMIN_LOG("No name was given to found the account.\n"); + PRINTF("Please input an account name.\n"_fmt); + PRINTF(" who testname\n"_fmt); + LADMIN_LOG("No name was given to found the account.\n"_fmt); return; } if (!name.is_print()) @@ -1754,7 +1754,7 @@ void whoaccount(ZString param) return; } - LADMIN_LOG("Request to login-server to obtain information about an account (by its name).\n"); + LADMIN_LOG("Request to login-server to obtain information about an account (by its name).\n"_fmt); WFIFOW(login_session, 0) = 0x7952; WFIFO_STRING(login_session, 2, name, 24); @@ -1768,7 +1768,7 @@ void whoaccount(ZString param) static void checkloginversion(void) { - LADMIN_LOG("Request to login-server to obtain its version.\n"); + LADMIN_LOG("Request to login-server to obtain its version.\n"_fmt); WFIFOW(login_session, 0) = 0x7530; WFIFOSET(login_session, 2); @@ -1786,10 +1786,10 @@ void prompt(void) // while we don't wait new packets while (bytes_to_read == 0) { - Iprintf("\n"); - Iprintf(SGR_GREEN "To list the commands, type 'enter'." SGR_RESET "\n"); - Iprintf(SGR_CYAN "Ladmin-> " SGR_RESET); - Iprintf(SGR_BOLD); + Iprintf("\n"_fmt); + Iprintf(SGR_GREEN "To list the commands, type 'enter'." SGR_RESET "\n"_fmt); + Iprintf(SGR_CYAN "Ladmin-> " SGR_RESET ""_fmt); + Iprintf(SGR_BOLD ""_fmt); fflush(stdout); // get command and parameter @@ -1798,7 +1798,7 @@ void prompt(void) AString buf; cin->getline(buf); - Iprintf(SGR_RESET); + Iprintf(SGR_RESET ""_fmt); fflush(stdout); if (!cin->is_open()) @@ -1806,8 +1806,8 @@ void prompt(void) if (!buf.is_print()) { - printf("Cowardly refusing to execute a command that includes control or non-ascii characters\n"); - LADMIN_LOG("Cowardly refusing to execute a command that includes control or non-ascii characters\n"); + PRINTF("Cowardly refusing to execute a command that includes control or non-ascii characters\n"_fmt); + LADMIN_LOG("Cowardly refusing to execute a command that includes control or non-ascii characters\n"_fmt); continue; } @@ -1820,116 +1820,116 @@ void prompt(void) parameters = buf.xislice_t(space); if (!command || command.startswith('?')) - command = "help"; + command = "help"_s; if (!parameters) { - LADMIN_LOG("Command: '%s' (without parameters)\n", + LADMIN_LOG("Command: '%s' (without parameters)\n"_fmt, command); } else { // We don't want passwords in the log - Camel - if (command == "create" || command == "add" || command == "password") { + if (command == "create"_s || command == "add"_s || command == "password"_s) { AString name, email_, password; VString<1> sex_; if (qsplit(parameters, &name, &sex_, &email_, &password)) - LADMIN_LOG("Command: '%s', parameters: '%s %s %s ***'\n", + LADMIN_LOG("Command: '%s', parameters: '%s %s %s ***'\n"_fmt, command, name, sex_, email_); else if (qsplit(parameters, &name, &sex_, &password)) - LADMIN_LOG("Command: '%s', parameters: '%s %s ***'\n", + LADMIN_LOG("Command: '%s', parameters: '%s %s ***'\n"_fmt, command, name, sex_); else if (qsplit(parameters, &name, &password)) - LADMIN_LOG("Command: '%s', parameters: '%s ***'\n", + LADMIN_LOG("Command: '%s', parameters: '%s ***'\n"_fmt, command, name); else - LADMIN_LOG("Command: '%s' (invalid parameters)\n", command); + LADMIN_LOG("Command: '%s' (invalid parameters)\n"_fmt, command); } else { - LADMIN_LOG("Command: '%s', parameters: '%s'\n", + LADMIN_LOG("Command: '%s', parameters: '%s'\n"_fmt, command, parameters); } } // Analyse of the command - if (command == "help") + if (command == "help"_s) display_help(parameters); - else if (command == "add") + else if (command == "add"_s) addaccount(parameters, 0); // 0: no email - else if (command == "ban") + else if (command == "ban"_s) banaccount(parameters); - else if (command == "banadd") + else if (command == "banadd"_s) banaddaccount(parameters); - else if (command == "banset") + else if (command == "banset"_s) bansetaccount(parameters); - else if (command == "block") + else if (command == "block"_s) blockaccount(parameters); - else if (command == "check") + else if (command == "check"_s) checkaccount(parameters); - else if (command == "create") + else if (command == "create"_s) addaccount(parameters, 1); // 1: with email - else if (command == "delete") + else if (command == "delete"_s) delaccount(parameters); - else if (command == "email") + else if (command == "email"_s) changeemail(parameters); - else if (command == "getcount") + else if (command == "getcount"_s) getlogincount(); - else if (command == "gm") + else if (command == "gm"_s) changegmlevel(parameters); - else if (command == "id") + else if (command == "id"_s) idaccount(parameters); - else if (command == "info") + else if (command == "info"_s) infoaccount(atoi(parameters.c_str())); - else if (command == "kami") + else if (command == "kami"_s) sendbroadcast(parameters); // flag for normal - else if (command == "itemfrob") + else if (command == "itemfrob"_s) itemfrob(parameters); // 0: to list all - else if (command == "list") + else if (command == "list"_s) listaccount(parameters, 0); // 0: to list all - else if (command == "listban") + else if (command == "listban"_s) listaccount(parameters, 3); // 3: to list only accounts with state or bannished - else if (command == "listgm") + else if (command == "listgm"_s) listaccount(parameters, 1); // 1: to list only GM - else if (command == "listok") + else if (command == "listok"_s) listaccount(parameters, 4); // 4: to list only accounts without state and not bannished - else if (command == "memo") + else if (command == "memo"_s) changememo(parameters); - else if (command == "name") + else if (command == "name"_s) nameaccount(atoi(parameters.c_str())); - else if (command == "password") + else if (command == "password"_s) changepasswd(parameters); - else if (command == "reloadgm") + else if (command == "reloadgm"_s) reloadGM(parameters); - else if (command == "search") + else if (command == "search"_s) listaccount(parameters, 2); // 2: to list with pattern - else if (command == "sex") + else if (command == "sex"_s) changesex(parameters); - else if (command == "state") + else if (command == "state"_s) changestate(parameters); - else if (command == "timeadd") + else if (command == "timeadd"_s) timeaddaccount(parameters); - else if (command == "timeset") + else if (command == "timeset"_s) timesetaccount(parameters); - else if (command == "unban") + else if (command == "unban"_s) unbanaccount(parameters); - else if (command == "unblock") + else if (command == "unblock"_s) unblockaccount(parameters); - else if (command == "version") + else if (command == "version"_s) checkloginversion(); - else if (command == "who") + else if (command == "who"_s) whoaccount(parameters); - else if (command == "quit" - || command == "exit" - || command == "end") + else if (command == "quit"_s + || command == "exit"_s + || command == "end"_s) { - PRINTF("Bye.\n"); + PRINTF("Bye.\n"_fmt); exit(0); } else { - PRINTF("Unknown command [%s].\n", buf); - LADMIN_LOG("Unknown command [%s].\n", buf); + PRINTF("Unknown command [%s].\n"_fmt, buf); + LADMIN_LOG("Unknown command [%s].\n"_fmt, buf); } } } @@ -1942,16 +1942,14 @@ void parse_fromlogin(Session *s) { if (s->eof) { - PRINTF("Impossible to have a connection with the login-server [%s:%d] !\n", + PRINTF("Impossible to have a connection with the login-server [%s:%d] !\n"_fmt, login_ip, login_port); - LADMIN_LOG("Impossible to have a connection with the login-server [%s:%d] !\n", + LADMIN_LOG("Impossible to have a connection with the login-server [%s:%d] !\n"_fmt, login_ip, login_port); delete_session(s); exit(0); } -// PRINTF("parse_fromlogin : %d %d %d\n", fd, RFIFOREST(fd), RFIFOW(fd,0)); - while (RFIFOREST(s) >= 2) { switch (RFIFOW(s, 0)) @@ -1961,20 +1959,20 @@ void parse_fromlogin(Session *s) return; if (RFIFOB(s, 2) != 0) { - PRINTF("Error at login:\n"); - PRINTF(" - incorrect password,\n"); - PRINTF(" - administration system not activated, or\n"); - PRINTF(" - unauthorised IP.\n"); - LADMIN_LOG("Error at login: incorrect password, administration system not activated, or unauthorised IP.\n"); + PRINTF("Error at login:\n"_fmt); + PRINTF(" - incorrect password,\n"_fmt); + PRINTF(" - administration system not activated, or\n"_fmt); + PRINTF(" - unauthorised IP.\n"_fmt); + LADMIN_LOG("Error at login: incorrect password, administration system not activated, or unauthorised IP.\n"_fmt); s->eof = 1; //bytes_to_read = 1; // not stop at prompt } else { - Iprintf("Established connection.\n"); - LADMIN_LOG("Established connection.\n"); - Iprintf("Reading of the version of the login-server...\n"); - LADMIN_LOG("Reading of the version of the login-server...\n"); + Iprintf("Established connection.\n"_fmt); + LADMIN_LOG("Established connection.\n"_fmt); + Iprintf("Reading of the version of the login-server...\n"_fmt); + LADMIN_LOG("Reading of the version of the login-server...\n"_fmt); //bytes_to_read = 1; // unchanged checkloginversion(); } @@ -1985,11 +1983,11 @@ void parse_fromlogin(Session *s) if (RFIFOREST(s) < 10) return; { - Iprintf(" Login-Server [%s:%d]\n", + Iprintf(" Login-Server [%s:%d]\n"_fmt, login_ip, login_port); Version version; RFIFO_STRUCT(login_session, 2, version); - Iprintf(" tmwA version %hhu.%hhu.%hhu (dev? %hhu) (flags %hhx) (which %hhx) (vend %hu)\n", + Iprintf(" tmwA version %hhu.%hhu.%hhu (dev? %hhu) (flags %hhx) (which %hhx) (vend %hu)\n"_fmt, version.major, version.minor, version.patch, version.devel, @@ -2010,23 +2008,23 @@ void parse_fromlogin(Session *s) return; if (RFIFOW(s, 2) < 5) { - LADMIN_LOG(" Receiving of a void accounts list.\n"); + LADMIN_LOG(" Receiving of a void accounts list.\n"_fmt); if (list_count == 0) { - Iprintf("No account found.\n"); + Iprintf("No account found.\n"_fmt); } else if (list_count == 1) { - Iprintf("1 account found.\n"); + Iprintf("1 account found.\n"_fmt); } else - Iprintf("%d accounts found.\n", list_count); + Iprintf("%d accounts found.\n"_fmt, list_count); bytes_to_read = 0; } else { int i; - LADMIN_LOG(" Receiving of a accounts list.\n"); + LADMIN_LOG(" Receiving of a accounts list.\n"_fmt); for (i = 4; i < RFIFOW(s, 2); i += 38) { AccountName userid = stringish(RFIFO_STRING<24>(s, i + 5)); @@ -2039,63 +2037,63 @@ void parse_fromlogin(Session *s) || (list_type == 3 && RFIFOL(s, i + 34) != 0) || (list_type == 4 && RFIFOL(s, i + 34) == 0)) { - PRINTF("%10d ", RFIFOL(s, i)); + PRINTF("%10d "_fmt, RFIFOL(s, i)); if (RFIFOB(s, i + 4) == 0) - PRINTF(" "); + PRINTF(" "_fmt); else - PRINTF("%2d ", RFIFOB(s, i + 4)); - PRINTF("%-24s", userid); + PRINTF("%2d "_fmt, RFIFOB(s, i + 4)); + PRINTF("%-24s"_fmt, userid); if (RFIFOB(s, i + 29) == 0) - PRINTF("%-5s ", "Femal"); + PRINTF("%-5s "_fmt, "Femal"_s); else if (RFIFOB(s, i + 29) == 1) - PRINTF("%-5s ", "Male"); + PRINTF("%-5s "_fmt, "Male"_s); else - PRINTF("%-5s ", "Servr"); - PRINTF("%6d ", RFIFOL(s, i + 30)); + PRINTF("%-5s "_fmt, "Servr"_s); + PRINTF("%6d "_fmt, RFIFOL(s, i + 30)); switch (RFIFOL(s, i + 34)) { case 0: - PRINTF("%-27s\n", "Account OK"); + PRINTF("%-27s\n"_fmt, "Account OK"_s); break; case 1: - PRINTF("%-27s\n", "Unregistered ID"); + PRINTF("%-27s\n"_fmt, "Unregistered ID"_s); break; case 2: - PRINTF("%-27s\n", "Incorrect Password"); + PRINTF("%-27s\n"_fmt, "Incorrect Password"_s); break; case 3: - PRINTF("%-27s\n", "This ID is expired"); + PRINTF("%-27s\n"_fmt, "This ID is expired"_s); break; case 4: - PRINTF("%-27s\n", - "Rejected from Server"); + PRINTF("%-27s\n"_fmt, + "Rejected from Server"_s); break; case 5: - PRINTF("%-27s\n", "Blocked by the GM Team"); // You have been blocked by the GM Team + PRINTF("%-27s\n"_fmt, "Blocked by the GM Team"_s); // You have been blocked by the GM Team break; case 6: - PRINTF("%-27s\n", "Your EXE file is too old"); // Your Game's EXE file is not the latest version + PRINTF("%-27s\n"_fmt, "Your EXE file is too old"_s); // Your Game's EXE file is not the latest version break; case 7: - PRINTF("%-27s\n", "Banishement or"); - PRINTF(" Prohibited to login until...\n"); // You are Prohibited to log in until %s + PRINTF("%-27s\n"_fmt, "Banishement or"_s); + PRINTF(" Prohibited to login until...\n"_fmt); // You are Prohibited to log in until %s break; case 8: - PRINTF("%-27s\n", - "Server is over populated"); + PRINTF("%-27s\n"_fmt, + "Server is over populated"_s); break; case 9: - PRINTF("%-27s\n", "No MSG"); + PRINTF("%-27s\n"_fmt, "No MSG"_s); break; default: // 100 - PRINTF("%-27s\n", "This ID is totally erased"); // This ID has been totally erased + PRINTF("%-27s\n"_fmt, "This ID is totally erased"_s); // This ID has been totally erased break; } list_count++; } } // asking of the following acounts - LADMIN_LOG("Request to login-server to obtain the list of accounts from %d to %d (complement).\n", + LADMIN_LOG("Request to login-server to obtain the list of accounts from %d to %d (complement).\n"_fmt, list_first, list_last); WFIFOW(login_session, 0) = 0x7920; WFIFOL(login_session, 2) = list_first; @@ -2114,16 +2112,16 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (accid == -1) { - PRINTF("Account [%s] creation failed. Same account already exists.\n", + PRINTF("Account [%s] creation failed. Same account already exists.\n"_fmt, name); - LADMIN_LOG("Account [%s] creation failed. Same account already exists.\n", + LADMIN_LOG("Account [%s] creation failed. Same account already exists.\n"_fmt, name); } else { - PRINTF("Account [%s] is successfully created [id: %d].\n", + PRINTF("Account [%s] is successfully created [id: %d].\n"_fmt, name, accid); - LADMIN_LOG("Account [%s] is successfully created [id: %d].\n", + LADMIN_LOG("Account [%s] is successfully created [id: %d].\n"_fmt, name, accid); } bytes_to_read = 0; @@ -2139,16 +2137,16 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (accid == -1) { - PRINTF("Account [%s] deletion failed. Account doesn't exist.\n", + PRINTF("Account [%s] deletion failed. Account doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account [%s] deletion failed. Account doesn't exist.\n", + LADMIN_LOG("Account [%s] deletion failed. Account doesn't exist.\n"_fmt, name); } else { - PRINTF("Account [%s][id: %d] is successfully DELETED.\n", + PRINTF("Account [%s][id: %d] is successfully DELETED.\n"_fmt, name, accid); - LADMIN_LOG("Account [%s][id: %d] is successfully DELETED.\n", + LADMIN_LOG("Account [%s][id: %d] is successfully DELETED.\n"_fmt, name, accid); } bytes_to_read = 0; @@ -2164,18 +2162,18 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (accid == -1) { - PRINTF("Account [%s] password changing failed.\n", + PRINTF("Account [%s] password changing failed.\n"_fmt, name); - PRINTF("Account [%s] doesn't exist.\n", + PRINTF("Account [%s] doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account password changing failed. The compte [%s] doesn't exist.\n", + LADMIN_LOG("Account password changing failed. The compte [%s] doesn't exist.\n"_fmt, name); } else { - PRINTF("Account [%s][id: %d] password successfully changed.\n", + PRINTF("Account [%s][id: %d] password successfully changed.\n"_fmt, name, accid); - LADMIN_LOG("Account [%s][id: %d] password successfully changed.\n", + LADMIN_LOG("Account [%s][id: %d] password successfully changed.\n"_fmt, name, accid); } bytes_to_read = 0; @@ -2192,57 +2190,57 @@ void parse_fromlogin(Session *s) int state = RFIFOL(s, 30); if (accid == -1) { - PRINTF("Account [%s] state changing failed. Account doesn't exist.\n", + PRINTF("Account [%s] state changing failed. Account doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account [%s] state changing failed. Account doesn't exist.\n", + LADMIN_LOG("Account [%s] state changing failed. Account doesn't exist.\n"_fmt, name); } else { MString tmpstr; tmpstr += STRPRINTF( - "Account [%s] state successfully changed in [", + "Account [%s] state successfully changed in ["_fmt, name); switch (state) { case 0: - tmpstr += "0: Account OK"; + tmpstr += "0: Account OK"_s; break; case 1: - tmpstr += "1: Unregistered ID"; + tmpstr += "1: Unregistered ID"_s; break; case 2: - tmpstr += "2: Incorrect Password"; + tmpstr += "2: Incorrect Password"_s; break; case 3: - tmpstr += "3: This ID is expired"; + tmpstr += "3: This ID is expired"_s; break; case 4: - tmpstr += "4: Rejected from Server"; + tmpstr += "4: Rejected from Server"_s; break; case 5: - tmpstr += "5: You have been blocked by the GM Team"; + tmpstr += "5: You have been blocked by the GM Team"_s; break; case 6: - tmpstr += "6: [Your Game's EXE file is not the latest version"; + tmpstr += "6: [Your Game's EXE file is not the latest version"_s; break; case 7: - tmpstr += "7: You are Prohibited to log in until..."; + tmpstr += "7: You are Prohibited to log in until..."_s; break; case 8: - tmpstr += "8: Server is jammed due to over populated"; + tmpstr += "8: Server is jammed due to over populated"_s; break; case 9: - tmpstr += "9: No MSG"; + tmpstr += "9: No MSG"_s; break; default: // 100 - tmpstr += "100: This ID is totally erased"; + tmpstr += "100: This ID is totally erased"_s; break; } tmpstr += ']'; AString tmpstr_ = AString(tmpstr); - PRINTF("%s\n", tmpstr_); - LADMIN_LOG("%s\n", tmpstr_); + PRINTF("%s\n"_fmt, tmpstr_); + LADMIN_LOG("%s\n"_fmt, tmpstr_); } bytes_to_read = 0; } @@ -2254,20 +2252,20 @@ void parse_fromlogin(Session *s) return; { // Get length of the received packet - LADMIN_LOG(" Receiving of the number of online players.\n"); + LADMIN_LOG(" Receiving of the number of online players.\n"_fmt); // Read information of the servers if (RFIFOW(s, 2) < 5) { - PRINTF(" No server is connected to the login-server.\n"); + PRINTF(" No server is connected to the login-server.\n"_fmt); } else { - PRINTF(" Number of online players (server: number).\n"); + PRINTF(" Number of online players (server: number).\n"_fmt); // Displaying of result for (int i = 4; i < RFIFOW(s, 2); i += 32) { ServerName name = stringish(RFIFO_STRING<20>(s, i + 6)); - PRINTF(" %-20s : %5d\n", name, + PRINTF(" %-20s : %5d\n"_fmt, name, RFIFOW(s, i + 26)); } } @@ -2284,16 +2282,16 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("The account [%s] doesn't exist or the password is incorrect.\n", + PRINTF("The account [%s] doesn't exist or the password is incorrect.\n"_fmt, name); - LADMIN_LOG("The account [%s] doesn't exist or the password is incorrect.\n", + LADMIN_LOG("The account [%s] doesn't exist or the password is incorrect.\n"_fmt, name); } else { - PRINTF("The proposed password is correct for the account [%s][id: %d].\n", + PRINTF("The proposed password is correct for the account [%s][id: %d].\n"_fmt, name, account_id); - LADMIN_LOG("The proposed password is correct for the account [%s][id: %d].\n", + LADMIN_LOG("The proposed password is correct for the account [%s][id: %d].\n"_fmt, name, account_id); } bytes_to_read = 0; @@ -2309,18 +2307,18 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("Account [%s] sex changing failed.\n", + PRINTF("Account [%s] sex changing failed.\n"_fmt, name); - PRINTF("Account [%s] doesn't exist or the sex is already the good sex.\n", + PRINTF("Account [%s] doesn't exist or the sex is already the good sex.\n"_fmt, name); - LADMIN_LOG("Account sex changing failed. The compte [%s] doesn't exist or the sex is already the good sex.\n", + LADMIN_LOG("Account sex changing failed. The compte [%s] doesn't exist or the sex is already the good sex.\n"_fmt, name); } else { - PRINTF("Account [%s][id: %d] sex successfully changed.\n", + PRINTF("Account [%s][id: %d] sex successfully changed.\n"_fmt, name, account_id); - LADMIN_LOG("Account [%s][id: %d] sex successfully changed.\n", + LADMIN_LOG("Account [%s][id: %d] sex successfully changed.\n"_fmt, name, account_id); } bytes_to_read = 0; @@ -2336,19 +2334,19 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("Account [%s] GM level changing failed.\n", + PRINTF("Account [%s] GM level changing failed.\n"_fmt, name); - PRINTF("Account [%s] doesn't exist, the GM level is already the good GM level\n", + PRINTF("Account [%s] doesn't exist, the GM level is already the good GM level\n"_fmt, name); - PRINTF("or it's impossible to modify the GM accounts file.\n"); - LADMIN_LOG("Account GM level changing failed. The compte [%s] doesn't exist, the GM level is already the good sex or it's impossible to modify the GM accounts file.\n", + PRINTF("or it's impossible to modify the GM accounts file.\n"_fmt); + LADMIN_LOG("Account GM level changing failed. The compte [%s] doesn't exist, the GM level is already the good sex or it's impossible to modify the GM accounts file.\n"_fmt, name); } else { - PRINTF("Account [%s][id: %d] GM level successfully changed.\n", + PRINTF("Account [%s][id: %d] GM level successfully changed.\n"_fmt, name, account_id); - LADMIN_LOG("Account [%s][id: %d] GM level successfully changed.\n", + LADMIN_LOG("Account [%s][id: %d] GM level successfully changed.\n"_fmt, name, account_id); } bytes_to_read = 0; @@ -2364,18 +2362,18 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("Account [%s] e-mail changing failed.\n", + PRINTF("Account [%s] e-mail changing failed.\n"_fmt, name); - PRINTF("Account [%s] doesn't exist.\n", + PRINTF("Account [%s] doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account e-mail changing failed. The compte [%s] doesn't exist.\n", + LADMIN_LOG("Account e-mail changing failed. The compte [%s] doesn't exist.\n"_fmt, name); } else { - PRINTF("Account [%s][id: %d] e-mail successfully changed.\n", + PRINTF("Account [%s][id: %d] e-mail successfully changed.\n"_fmt, name, account_id); - LADMIN_LOG("Account [%s][id: %d] e-mail successfully changed.\n", + LADMIN_LOG("Account [%s][id: %d] e-mail successfully changed.\n"_fmt, name, account_id); } bytes_to_read = 0; @@ -2391,16 +2389,16 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("Account [%s] memo changing failed. Account doesn't exist.\n", + PRINTF("Account [%s] memo changing failed. Account doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account [%s] memo changing failed. Account doesn't exist.\n", + LADMIN_LOG("Account [%s] memo changing failed. Account doesn't exist.\n"_fmt, name); } else { - PRINTF("Account [%s][id: %d] memo successfully changed.\n", + PRINTF("Account [%s][id: %d] memo successfully changed.\n"_fmt, name, account_id); - LADMIN_LOG("Account [%s][id: %d] memo successfully changed.\n", + LADMIN_LOG("Account [%s][id: %d] memo successfully changed.\n"_fmt, name, account_id); } bytes_to_read = 0; @@ -2416,16 +2414,16 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("Unable to find the account [%s] id. Account doesn't exist.\n", + PRINTF("Unable to find the account [%s] id. Account doesn't exist.\n"_fmt, name); - LADMIN_LOG("Unable to find the account [%s] id. Account doesn't exist.\n", + LADMIN_LOG("Unable to find the account [%s] id. Account doesn't exist.\n"_fmt, name); } else { - PRINTF("The account [%s] have the id: %d.\n", + PRINTF("The account [%s] have the id: %d.\n"_fmt, name, account_id); - LADMIN_LOG("The account [%s] have the id: %d.\n", + LADMIN_LOG("The account [%s] have the id: %d.\n"_fmt, name, account_id); } bytes_to_read = 0; @@ -2441,16 +2439,16 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (!name) { - PRINTF("Unable to find the account [%d] name. Account doesn't exist.\n", + PRINTF("Unable to find the account [%d] name. Account doesn't exist.\n"_fmt, account_id); - LADMIN_LOG("Unable to find the account [%d] name. Account doesn't exist.\n", + LADMIN_LOG("Unable to find the account [%d] name. Account doesn't exist.\n"_fmt, account_id); } else { - PRINTF("The account [id: %d] have the name: %s.\n", + PRINTF("The account [id: %d] have the name: %s.\n"_fmt, account_id, name); - LADMIN_LOG("The account [id: %d] have the name: %s.\n", + LADMIN_LOG("The account [id: %d] have the name: %s.\n"_fmt, account_id, name); } bytes_to_read = 0; @@ -2466,9 +2464,9 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (RFIFOL(s, 2) == -1) { - PRINTF("Account [%s] validity limit changing failed. Account doesn't exist.\n", + PRINTF("Account [%s] validity limit changing failed. Account doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account [%s] validity limit changing failed. Account doesn't exist.\n", + LADMIN_LOG("Account [%s] validity limit changing failed. Account doesn't exist.\n"_fmt, name); } else @@ -2476,18 +2474,18 @@ void parse_fromlogin(Session *s) TimeT timestamp = static_cast(RFIFOL(s, 30)); if (!timestamp) { - PRINTF("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n", + PRINTF("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n"_fmt, name, account_id); - LADMIN_LOG("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n", + LADMIN_LOG("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n"_fmt, name, account_id); } else { timestamp_seconds_buffer tmpstr; stamp_time(tmpstr, ×tamp); - PRINTF("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n", + PRINTF("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, name, account_id, tmpstr); - LADMIN_LOG("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n", + LADMIN_LOG("Validity Limit of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, name, account_id, tmpstr); } @@ -2505,9 +2503,9 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", + PRINTF("Account [%s] final date of banishment changing failed. Account doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", + LADMIN_LOG("Account [%s] final date of banishment changing failed. Account doesn't exist.\n"_fmt, name); } else @@ -2515,18 +2513,18 @@ void parse_fromlogin(Session *s) TimeT timestamp = static_cast(RFIFOL(s, 30)); if (!timestamp) { - PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", + PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n"_fmt, name, account_id); - LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", + LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n"_fmt, name, account_id); } else { timestamp_seconds_buffer tmpstr; stamp_time(tmpstr, ×tamp); - PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", + PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, name, RFIFOL(s, 2), tmpstr); - LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", + LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, name, RFIFOL(s, 2), tmpstr); } @@ -2544,9 +2542,9 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", + PRINTF("Account [%s] final date of banishment changing failed. Account doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account [%s] final date of banishment changing failed. Account doesn't exist.\n", + LADMIN_LOG("Account [%s] final date of banishment changing failed. Account doesn't exist.\n"_fmt, name); } else @@ -2554,19 +2552,19 @@ void parse_fromlogin(Session *s) TimeT timestamp = static_cast(RFIFOL(s, 30)); if (!timestamp) { - PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", + PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n"_fmt, name, account_id); - LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n", + LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n"_fmt, name, account_id); } else { timestamp_seconds_buffer tmpstr; stamp_time(tmpstr, ×tamp); - PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", + PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, name, account_id, tmpstr); - LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n", + LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, name, account_id, tmpstr); } @@ -2581,13 +2579,13 @@ void parse_fromlogin(Session *s) return; if (RFIFOW(s, 2) == static_cast(-1)) { - PRINTF("Message sending failed. No online char-server.\n"); - LADMIN_LOG("Message sending failed. No online char-server.\n"); + PRINTF("Message sending failed. No online char-server.\n"_fmt); + LADMIN_LOG("Message sending failed. No online char-server.\n"_fmt); } else { - PRINTF("Message successfully sended to login-server.\n"); - LADMIN_LOG("Message successfully sended to login-server.\n"); + PRINTF("Message successfully sended to login-server.\n"_fmt); + LADMIN_LOG("Message successfully sended to login-server.\n"_fmt); } bytes_to_read = 0; RFIFOSKIP(s, 4); @@ -2601,9 +2599,9 @@ void parse_fromlogin(Session *s) AccountName name = stringish(RFIFO_STRING<24>(s, 6)); if (account_id == -1) { - PRINTF("Account [%s] validity limit changing failed. Account doesn't exist.\n", + PRINTF("Account [%s] validity limit changing failed. Account doesn't exist.\n"_fmt, name); - LADMIN_LOG("Account [%s] validity limit changing failed. Account doesn't exist.\n", + LADMIN_LOG("Account [%s] validity limit changing failed. Account doesn't exist.\n"_fmt, name); } else @@ -2611,21 +2609,21 @@ void parse_fromlogin(Session *s) TimeT timestamp = static_cast(RFIFOL(s, 30)); if (!timestamp) { - PRINTF("Validity limit of the account [%s][id: %d] unchanged.\n", + PRINTF("Validity limit of the account [%s][id: %d] unchanged.\n"_fmt, name, account_id); - PRINTF("The account have an unlimited validity limit or\n"); - PRINTF("the changing is impossible with the proposed adjustments.\n"); - LADMIN_LOG("Validity limit of the account [%s][id: %d] unchanged. The account have an unlimited validity limit or the changing is impossible with the proposed adjustments.\n", + PRINTF("The account have an unlimited validity limit or\n"_fmt); + PRINTF("the changing is impossible with the proposed adjustments.\n"_fmt); + LADMIN_LOG("Validity limit of the account [%s][id: %d] unchanged. The account have an unlimited validity limit or the changing is impossible with the proposed adjustments.\n"_fmt, name, account_id); } else { timestamp_seconds_buffer tmpstr; stamp_time(tmpstr, ×tamp); - PRINTF("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n", + PRINTF("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, name, account_id, tmpstr); - LADMIN_LOG("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n", + LADMIN_LOG("Validity limit of the account [%s][id: %d] successfully changed to be until %s.\n"_fmt, name, account_id, tmpstr); } @@ -2655,107 +2653,107 @@ void parse_fromlogin(Session *s) AString memo = RFIFO_STRING(s, 150, RFIFOW(s, 148)); if (account_id == -1) { - PRINTF("Unabled to find the account [%s]. Account doesn't exist.\n", + PRINTF("Unabled to find the account [%s]. Account doesn't exist.\n"_fmt, userid); - LADMIN_LOG("Unabled to find the account [%s]. Account doesn't exist.\n", + LADMIN_LOG("Unabled to find the account [%s]. Account doesn't exist.\n"_fmt, userid); } else if (!userid) { - PRINTF("Unabled to find the account [id: %d]. Account doesn't exist.\n", + PRINTF("Unabled to find the account [id: %d]. Account doesn't exist.\n"_fmt, account_id); - LADMIN_LOG("Unabled to find the account [id: %d]. Account doesn't exist.\n", + LADMIN_LOG("Unabled to find the account [id: %d]. Account doesn't exist.\n"_fmt, account_id); } else { - LADMIN_LOG("Receiving information about an account.\n"); - PRINTF("The account is set with:\n"); + LADMIN_LOG("Receiving information about an account.\n"_fmt); + PRINTF("The account is set with:\n"_fmt); if (!gm) { - PRINTF(" Id: %d (non-GM)\n", account_id); + PRINTF(" Id: %d (non-GM)\n"_fmt, account_id); } else { - PRINTF(" Id: %d (GM level %d)\n", + PRINTF(" Id: %d (GM level %d)\n"_fmt, account_id, gm); } - PRINTF(" Name: '%s'\n", userid); + PRINTF(" Name: '%s'\n"_fmt, userid); if (sex == 0) - PRINTF(" Sex: Female\n"); + PRINTF(" Sex: Female\n"_fmt); else if (sex == 1) - PRINTF(" Sex: Male\n"); + PRINTF(" Sex: Male\n"_fmt); else - PRINTF(" Sex: Server\n"); - PRINTF(" E-mail: %s\n", email); + PRINTF(" Sex: Server\n"_fmt); + PRINTF(" E-mail: %s\n"_fmt, email); switch (state) { case 0: - PRINTF(" Statut: 0 [Account OK]\n"); + PRINTF(" Statut: 0 [Account OK]\n"_fmt); break; case 1: - PRINTF(" Statut: 1 [Unregistered ID]\n"); + PRINTF(" Statut: 1 [Unregistered ID]\n"_fmt); break; case 2: - PRINTF(" Statut: 2 [Incorrect Password]\n"); + PRINTF(" Statut: 2 [Incorrect Password]\n"_fmt); break; case 3: - PRINTF(" Statut: 3 [This ID is expired]\n"); + PRINTF(" Statut: 3 [This ID is expired]\n"_fmt); break; case 4: - PRINTF(" Statut: 4 [Rejected from Server]\n"); + PRINTF(" Statut: 4 [Rejected from Server]\n"_fmt); break; case 5: - PRINTF(" Statut: 5 [You have been blocked by the GM Team]\n"); + PRINTF(" Statut: 5 [You have been blocked by the GM Team]\n"_fmt); break; case 6: - PRINTF(" Statut: 6 [Your Game's EXE file is not the latest version]\n"); + PRINTF(" Statut: 6 [Your Game's EXE file is not the latest version]\n"_fmt); break; case 7: - PRINTF(" Statut: 7 [You are Prohibited to log in until %s]\n", + PRINTF(" Statut: 7 [You are Prohibited to log in until %s]\n"_fmt, error_message); break; case 8: - PRINTF(" Statut: 8 [Server is jammed due to over populated]\n"); + PRINTF(" Statut: 8 [Server is jammed due to over populated]\n"_fmt); break; case 9: - PRINTF(" Statut: 9 [No MSG]\n"); + PRINTF(" Statut: 9 [No MSG]\n"_fmt); break; default: // 100 - PRINTF(" Statut: %d [This ID is totally erased]\n", + PRINTF(" Statut: %d [This ID is totally erased]\n"_fmt, state); break; } if (!ban_until_time) { - PRINTF(" Banishment: not banished.\n"); + PRINTF(" Banishment: not banished.\n"_fmt); } else { timestamp_seconds_buffer tmpstr; stamp_time(tmpstr, &ban_until_time); - PRINTF(" Banishment: until %s.\n", tmpstr); + PRINTF(" Banishment: until %s.\n"_fmt, tmpstr); } if (connections > 1) - PRINTF(" Count: %d connections.\n", + PRINTF(" Count: %d connections.\n"_fmt, connections); else - PRINTF(" Count: %d connection.\n", + PRINTF(" Count: %d connection.\n"_fmt, connections); - PRINTF(" Last connection at: %s (ip: %s)\n", + PRINTF(" Last connection at: %s (ip: %s)\n"_fmt, lastlogin, last_ip_); if (!connect_until_time) { - PRINTF(" Validity limit: unlimited.\n"); + PRINTF(" Validity limit: unlimited.\n"_fmt); } else { timestamp_seconds_buffer tmpstr; stamp_time(tmpstr, &connect_until_time); - PRINTF(" Validity limit: until %s.\n", + PRINTF(" Validity limit: until %s.\n"_fmt, tmpstr); } - PRINTF(" Memo: '%s'\n", memo); + PRINTF(" Memo: '%s'\n"_fmt, memo); } } bytes_to_read = 0; @@ -2763,8 +2761,8 @@ void parse_fromlogin(Session *s) break; default: - PRINTF("Remote administration has been disconnected (unknown packet).\n"); - LADMIN_LOG("'End of connection, unknown packet.\n"); + PRINTF("Remote administration has been disconnected (unknown packet).\n"_fmt); + LADMIN_LOG("'End of connection, unknown packet.\n"_fmt); s->eof = 1; return; } @@ -2780,8 +2778,8 @@ void parse_fromlogin(Session *s) static int Connect_login_server(void) { - Iprintf("Attempt to connect to login-server...\n"); - LADMIN_LOG("Attempt to connect to login-server...\n"); + Iprintf("Attempt to connect to login-server...\n"_fmt); + LADMIN_LOG("Attempt to connect to login-server...\n"_fmt); login_session = make_connection(login_ip, login_port); if (!login_session) @@ -2794,8 +2792,8 @@ int Connect_login_server(void) WFIFOSET(login_session, 28); bytes_to_read = 1; - Iprintf("Sending of the password...\n"); - LADMIN_LOG("Sending of the password...\n"); + Iprintf("Sending of the password...\n"_fmt); + LADMIN_LOG("Sending of the password...\n"_fmt); } return 0; @@ -2805,12 +2803,12 @@ static bool admin_confs(XString w1, ZString w2) { { - if (w1 == "login_ip") + if (w1 == "login_ip"_s) { struct hostent *h = gethostbyname(w2.c_str()); if (h != NULL) { - Iprintf("Login server IP address: %s -> %s\n", + Iprintf("Login server IP address: %s -> %s\n"_fmt, w2, login_ip); login_ip = IP4Address({ static_cast(h->h_addr[0]), @@ -2820,21 +2818,21 @@ bool admin_confs(XString w1, ZString w2) }); } } - else if (w1 == "login_port") + else if (w1 == "login_port"_s) { login_port = atoi(w2.c_str()); } - else if (w1 == "admin_pass") + else if (w1 == "admin_pass"_s) { admin_pass = stringish(w2); } - else if (w1 == "ladmin_log_filename") + else if (w1 == "ladmin_log_filename"_s) { ladmin_log_filename = w2; } else { - PRINTF("WARNING: unknown ladmin config key: %s\n", AString(w1)); + PRINTF("WARNING: unknown ladmin config key: %s\n"_fmt, AString(w1)); return false; } } @@ -2851,8 +2849,8 @@ void term_func(void) { delete_session(login_session); - Iprintf(SGR_RESET "----End of Ladmin (normal end with closing of all files).\n"); - LADMIN_LOG("----End of Ladmin (normal end with closing of all files).\n"); + Iprintf(SGR_RESET "----End of Ladmin (normal end with closing of all files).\n"_fmt); + LADMIN_LOG("----End of Ladmin (normal end with closing of all files).\n"_fmt); already_exit_function = 1; } @@ -2870,20 +2868,20 @@ int do_init(Slice argv) ZString argvi = argv.pop_front(); if (argvi.startswith('-')) { - if (argvi == "--help") + if (argvi == "--help"_s) { - PRINTF("Usage: %s [--help] [--version] [files...]\n", + PRINTF("Usage: %s [--help] [--version] [files...]\n"_fmt, argv0); exit(0); } - else if (argvi == "--version") + else if (argvi == "--version"_s) { - PRINTF("%s\n", CURRENT_VERSION_STRING); + PRINTF("%s\n"_fmt, CURRENT_VERSION_STRING); exit(0); } else { - FPRINTF(stderr, "Unknown argument: %s\n", argvi); + FPRINTF(stderr, "Unknown argument: %s\n"_fmt, argvi); runflag = false; } } @@ -2895,26 +2893,26 @@ int do_init(Slice argv) } if (!loaded_config_yet) - runflag &= load_config_file("conf/tmwa-admin.conf", admin_confs); + runflag &= load_config_file("conf/tmwa-admin.conf"_s, admin_confs); eathena_interactive_session = isatty(0); - LADMIN_LOG(""); - LADMIN_LOG("Configuration file readed.\n"); + LADMIN_LOG(""_fmt); + LADMIN_LOG("Configuration file readed.\n"_fmt); set_defaultparse(parse_fromlogin); - Iprintf("EAthena login-server administration tool.\n"); + Iprintf("EAthena login-server administration tool.\n"_fmt); Version version = CURRENT_LOGIN_SERVER_VERSION; - Iprintf("for tmwA version %hhu.%hhu.%hhu (dev? %hhu) (flags %hhx) (which %hhx) (vend %hu)\n", + Iprintf("for tmwA version %hhu.%hhu.%hhu (dev? %hhu) (flags %hhx) (which %hhx) (vend %hu)\n"_fmt, version.major, version.minor, version.patch, version.devel, version.flags, version.which, version.vend); - LADMIN_LOG("Ladmin is ready.\n"); - Iprintf("Ladmin is " SGR_BOLD SGR_GREEN "ready" SGR_RESET ".\n\n"); + LADMIN_LOG("Ladmin is ready.\n"_fmt); + Iprintf("Ladmin is " SGR_BOLD SGR_GREEN "ready" SGR_RESET ".\n\n"_fmt); Connect_login_server(); diff --git a/src/char/char.cpp b/src/char/char.cpp index d7849af..123ce3c 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -91,7 +91,7 @@ AccountPass passwd; static ServerName server_name; static -CharName wisp_server_name = stringish("Server"); +CharName wisp_server_name = stringish("Server"_s); static IP4Address login_ip; static @@ -103,9 +103,9 @@ int char_port = 6121; static AString char_txt; static -CharName unknown_char_name = stringish("Unknown"); +CharName unknown_char_name = stringish("Unknown"_s); static -AString char_log_filename = "log/char.log"; +AString char_log_filename = "log/char.log"_s; //Added for lan support static IP4Address lan_map_ip = IP4_LOCALHOST; @@ -160,16 +160,16 @@ std::chrono::milliseconds autosave_time = DEFAULT_AUTOSAVE_INTERVAL; // Initial position (it's possible to set it in conf file) static -struct point start_point = { {"001-1.gat"}, 273, 354 }; +struct point start_point = { {"001-1.gat"_s}, 273, 354 }; static std::vector gm_accounts; // online players by [Yor] static -AString online_txt_filename = "online.txt"; +AString online_txt_filename = "online.txt"_s; static -AString online_html_filename = "online.html"; +AString online_html_filename = "online.html"_s; static int online_sorting_option = 0; // sorting option to display online players in online files static @@ -285,7 +285,7 @@ AString mmo_char_tostr(struct CharPair *cp) "%d,%d,%d\t" "%d,%d,%d,%d,%d\t" "%s,%d,%d\t" - "%s,%d,%d,%d\t", + "%s,%d,%d,%d\t"_fmt, k->char_id, k->account_id, k->char_num, k->name, @@ -307,7 +307,7 @@ AString mmo_char_tostr(struct CharPair *cp) for (int i = 0; i < MAX_INVENTORY; i++) if (p->inventory[i].nameid) { - str_p += STRPRINTF("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", + str_p += STRPRINTF("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d "_fmt, p->inventory[i].id, p->inventory[i].nameid, p->inventory[i].amount, @@ -329,7 +329,7 @@ AString mmo_char_tostr(struct CharPair *cp) for (SkillID i : erange(SkillID(), MAX_SKILL)) if (p->skill[i].lv) { - str_p += STRPRINTF("%d,%d ", + str_p += STRPRINTF("%d,%d "_fmt, i, p->skill[i].lv | (uint16_t(p->skill[i].flags) << 16)); } @@ -338,7 +338,7 @@ AString mmo_char_tostr(struct CharPair *cp) assert (p->global_reg_num < GLOBAL_REG_NUM); for (int i = 0; i < p->global_reg_num; i++) if (p->global_reg[i].str) - str_p += STRPRINTF("%s,%d ", + str_p += STRPRINTF("%s,%d "_fmt, p->global_reg[i].str, p->global_reg[i].value); str_p += '\t'; @@ -467,9 +467,9 @@ int mmo_char_init(void) io::ReadFile in(char_txt); if (!in.is_open()) { - PRINTF("Characters file not found: %s.\n", char_txt); - CHAR_LOG("Characters file not found: %s.\n", char_txt); - CHAR_LOG("Id for the next created character: %d.\n", + PRINTF("Characters file not found: %s.\n"_fmt, char_txt); + CHAR_LOG("Characters file not found: %s.\n"_fmt, char_txt); + CHAR_LOG("Id for the next created character: %d.\n"_fmt, char_id_count); return 0; } @@ -485,7 +485,7 @@ int mmo_char_init(void) { int i, j = 0; - if (SSCANF(line, "%d\t%%newid%%%n", &i, &j) == 1 && j > 0) + if (SSCANF(line, "%d\t%%newid%%%n"_fmt, &i, &j) == 1 && j > 0) { if (char_id_count < i) char_id_count = i; @@ -496,7 +496,7 @@ int mmo_char_init(void) CharPair cd; if (!extract(line, &cd)) { - CHAR_LOG("Char skipped\n%s", line); + CHAR_LOG("Char skipped\n%s"_fmt, line); continue; } if (cd.key.char_id >= char_id_count) @@ -505,12 +505,12 @@ int mmo_char_init(void) online_chars.push_back(nullptr); } - PRINTF("mmo_char_init: %zu characters read in %s.\n", + PRINTF("mmo_char_init: %zu characters read in %s.\n"_fmt, char_keys.size(), char_txt); - CHAR_LOG("mmo_char_init: %zu characters read in %s.\n", + CHAR_LOG("mmo_char_init: %zu characters read in %s.\n"_fmt, char_keys.size(), char_txt); - CHAR_LOG("Id for the next created character: %d.\n", + CHAR_LOG("Id for the next created character: %d.\n"_fmt, char_id_count); return 0; @@ -525,8 +525,8 @@ void mmo_char_sync(void) io::WriteLock fp(char_txt); if (!fp.is_open()) { - PRINTF("WARNING: Server can't not save characters.\n"); - CHAR_LOG("WARNING: Server can't not save characters.\n"); + PRINTF("WARNING: Server can't not save characters.\n"_fmt); + CHAR_LOG("WARNING: Server can't not save characters.\n"_fmt); return; } { @@ -536,7 +536,7 @@ void mmo_char_sync(void) AString line = mmo_char_tostr(&cd); fp.put_line(line); } - FPRINTF(fp, "%d\t%%newid%%\n", char_id_count); + FPRINTF(fp, "%d\t%%newid%%\n"_fmt, char_id_count); } } @@ -588,7 +588,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui // remove control characters from the name if (!name.to__actual().is_print()) { - CHAR_LOG("Make new char error (control char received in the name): (connection #%d, account: %d).\n", + CHAR_LOG("Make new char error (control char received in the name): (connection #%d, account: %d).\n"_fmt, s, sd->account_id); return nullptr; } @@ -596,7 +596,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui // Eliminate whitespace if (name.to__actual() != name.to__actual().strip()) { - CHAR_LOG("Make new char error (leading/trailing whitespace): (connection #%d, account: %d, name: '%s'.\n", + CHAR_LOG("Make new char error (leading/trailing whitespace): (connection #%d, account: %d, name: '%s'.\n"_fmt, s, sd->account_id, name); return nullptr; } @@ -604,7 +604,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui // check lenght of character name if (name.to__actual().size() < 4) { - CHAR_LOG("Make new char error (character name too small): (connection #%d, account: %d, name: '%s').\n", + CHAR_LOG("Make new char error (character name too small): (connection #%d, account: %d, name: '%s').\n"_fmt, s, sd->account_id, name); return nullptr; } @@ -616,7 +616,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui for (uint8_t c : name.to__actual()) if (!char_name_letters[c]) { - CHAR_LOG("Make new char error (invalid letter in the name): (connection #%d, account: %d), name: %s, invalid letter: %c.\n", + CHAR_LOG("Make new char error (invalid letter in the name): (connection #%d, account: %d), name: %s, invalid letter: %c.\n"_fmt, s, sd->account_id, name, c); return nullptr; } @@ -627,7 +627,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui for (uint8_t c : name.to__actual()) if (char_name_letters[c]) { - CHAR_LOG("Make new char error (invalid letter in the name): (connection #%d, account: %d), name: %s, invalid letter: %c.\n", + CHAR_LOG("Make new char error (invalid letter in the name): (connection #%d, account: %d), name: %s, invalid letter: %c.\n"_fmt, s, sd->account_id, name, c); return nullptr; } @@ -639,7 +639,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui hair_style >= 20 || hair_color >= 12) { - CHAR_LOG("Make new char error (invalid values): (connection #%d, account: %d) slot %d, name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d\n", + CHAR_LOG("Make new char error (invalid values): (connection #%d, account: %d) slot %d, name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d\n"_fmt, s, sd->account_id, slot, name, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5], @@ -652,7 +652,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui { if (stats[i] < 1 || stats[i] > 9) { - CHAR_LOG("Make new char error (invalid stat value: not between 1 to 9): (connection #%d, account: %d) slot %d, name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d\n", + CHAR_LOG("Make new char error (invalid stat value: not between 1 to 9): (connection #%d, account: %d) slot %d, name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d\n"_fmt, s, sd->account_id, slot, name, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5], @@ -665,7 +665,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui { if (cd.key.name == name) { - CHAR_LOG("Make new char error (name already exists): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n", + CHAR_LOG("Make new char error (name already exists): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n"_fmt, s, sd->account_id, slot, name, cd.key.name, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5], @@ -675,7 +675,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui if (cd.key.account_id == sd->account_id && cd.key.char_num == slot) { - CHAR_LOG("Make new char error (slot already used): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n", + CHAR_LOG("Make new char error (slot already used): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n"_fmt, s, sd->account_id, slot, name, cd.key.name, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5], @@ -686,7 +686,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui if (wisp_server_name == name) { - CHAR_LOG("Make new char error (name used is wisp name for server): (connection #%d, account: %d) slot %d, name: %s (actual name whisper server: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n", + CHAR_LOG("Make new char error (name used is wisp name for server): (connection #%d, account: %d) slot %d, name: %s (actual name whisper server: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n"_fmt, s, sd->account_id, slot, name, wisp_server_name, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5], @@ -696,7 +696,7 @@ CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], ui IP4Address ip = s->client_ip; - CHAR_LOG("Creation of New Character: (connection #%d, account: %d) slot %d, character Name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d. [%s]\n", + CHAR_LOG("Creation of New Character: (connection #%d, account: %d) slot %d, character Name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d. [%s]\n"_fmt, s, sd->account_id, slot, name, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5], @@ -767,17 +767,17 @@ void create_online_files(void) timestamp_seconds_buffer timetemp; stamp_time(timetemp); // write heading - FPRINTF(fp2, "\n"); - FPRINTF(fp2, " \n", online_refresh_html); // update on client explorer every x seconds - FPRINTF(fp2, " \n"); - FPRINTF(fp2, " Online Players on %s\n", + FPRINTF(fp2, "\n"_fmt); + FPRINTF(fp2, " \n"_fmt, online_refresh_html); // update on client explorer every x seconds + FPRINTF(fp2, " \n"_fmt); + FPRINTF(fp2, " Online Players on %s\n"_fmt, server_name); - FPRINTF(fp2, " \n"); - FPRINTF(fp2, " \n"); - FPRINTF(fp2, "

Online Players on %s (%s):

\n", + FPRINTF(fp2, " \n"_fmt); + FPRINTF(fp2, " \n"_fmt); + FPRINTF(fp2, "

Online Players on %s (%s):

\n"_fmt, server_name, timetemp); - FPRINTF(fp, "Online Players on %s (%s):\n", server_name, timetemp); - FPRINTF(fp, "\n"); + FPRINTF(fp, "Online Players on %s (%s):\n"_fmt, server_name, timetemp); + FPRINTF(fp, "\n"_fmt); int players = 0; // This used to be conditional on having any players, @@ -785,20 +785,20 @@ void create_online_files(void) //if (players > 0) { int j = 0; // count the number of characters for the txt version and to set the separate line - FPRINTF(fp2, " \n"); - FPRINTF(fp2, " \n"); + FPRINTF(fp2, "
\n"_fmt); + FPRINTF(fp2, " \n"_fmt); { - FPRINTF(fp2, " \n"); + FPRINTF(fp2, " \n"_fmt); { - FPRINTF(fp, "Name "); // 30 + FPRINTF(fp, "Name "_fmt); // 30 j += 30; } } - FPRINTF(fp2, " \n"); - FPRINTF(fp, "\n"); + FPRINTF(fp2, " \n"_fmt); + FPRINTF(fp, "\n"_fmt); for (int k = 0; k < j; k++) - FPRINTF(fp, "-"); - FPRINTF(fp, "\n"); + FPRINTF(fp, "-"_fmt); + FPRINTF(fp, "\n"_fmt); // display each player. for (CharPair& cd : char_keys) @@ -806,55 +806,55 @@ void create_online_files(void) if (!server_for(&cd)) continue; players++; - FPRINTF(fp2, " \n"); + FPRINTF(fp2, " \n"_fmt); // displaying the character name { // without/with 'GM' display int gml = isGM(cd.key.account_id); { if (gml >= online_gm_display_min_level) - FPRINTF(fp, "%-24s (GM) ", cd.key.name); + FPRINTF(fp, "%-24s (GM) "_fmt, cd.key.name); else - FPRINTF(fp, "%-24s ", cd.key.name); + FPRINTF(fp, "%-24s "_fmt, cd.key.name); } // name of the character in the html (no < >, because that create problem in html code) - FPRINTF(fp2, " \n"); + FPRINTF(fp2, " (GM)"_fmt); + FPRINTF(fp2, "\n"_fmt); } - FPRINTF(fp, "\n"); - FPRINTF(fp2, " \n"); + FPRINTF(fp, "\n"_fmt); + FPRINTF(fp2, " \n"_fmt); } - FPRINTF(fp2, "
NameName
"); + FPRINTF(fp2, " "_fmt); if (gml >= online_gm_display_min_level) - FPRINTF(fp2, ""); + FPRINTF(fp2, ""_fmt); for (char c : cd.key.name.to__actual()) { switch (c) { case '&': - FPRINTF(fp2, "&"); + FPRINTF(fp2, "&"_fmt); break; case '<': - FPRINTF(fp2, "<"); + FPRINTF(fp2, "<"_fmt); break; case '>': - FPRINTF(fp2, ">"); + FPRINTF(fp2, ">"_fmt); break; default: - FPRINTF(fp2, "%c", c); + FPRINTF(fp2, "%c"_fmt, c); break; }; } if (gml >= online_gm_display_min_level) - FPRINTF(fp2, " (GM)"); - FPRINTF(fp2, "
\n"); - FPRINTF(fp, "\n"); + FPRINTF(fp2, " \n"_fmt); + FPRINTF(fp, "\n"_fmt); } // Displaying number of online players if (players == 0) { - FPRINTF(fp2, "

No user is online.

\n"); - FPRINTF(fp, "No user is online.\n"); + FPRINTF(fp2, "

No user is online.

\n"_fmt); + FPRINTF(fp, "No user is online.\n"_fmt); } else if (players == 1) { @@ -862,11 +862,11 @@ void create_online_files(void) } else { - FPRINTF(fp2, "

%d users are online.

\n", players); - FPRINTF(fp, "%d users are online.\n", players); + FPRINTF(fp2, "

%d users are online.

\n"_fmt, players); + FPRINTF(fp, "%d users are online.\n"_fmt, players); } - FPRINTF(fp2, " \n"); - FPRINTF(fp2, "\n"); + FPRINTF(fp2, " \n"_fmt); + FPRINTF(fp2, "\n"_fmt); } } @@ -1120,7 +1120,7 @@ void parse_tologin(Session *ls) { if (ls == login_session) { - PRINTF("Char-server can't connect to login-server (connection #%d).\n", + PRINTF("Char-server can't connect to login-server (connection #%d).\n"_fmt, ls); login_session = nullptr; } @@ -1132,8 +1132,6 @@ void parse_tologin(Session *ls) while (RFIFOREST(ls) >= 2) { -// PRINTF("parse_tologin: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd)); - switch (RFIFOW(ls, 0)) { case 0x2711: @@ -1141,16 +1139,15 @@ void parse_tologin(Session *ls) return; if (RFIFOB(ls, 2)) { -// PRINTF("connect login server error : %d\n", RFIFOB(fd,2)); - PRINTF("Can not connect to login-server.\n"); - PRINTF("The server communication passwords (default s1/p1) is probably invalid.\n"); - PRINTF("Also, please make sure your accounts file (default: accounts.txt) has those values present.\n"); - PRINTF("If you changed the communication passwords, change them back at map_athena.conf and char_athena.conf\n"); + PRINTF("Can not connect to login-server.\n"_fmt); + PRINTF("The server communication passwords (default s1/p1) is probably invalid.\n"_fmt); + PRINTF("Also, please make sure your accounts file (default: accounts.txt) has those values present.\n"_fmt); + PRINTF("If you changed the communication passwords, change them back at map_athena.conf and char_athena.conf\n"_fmt); exit(1); } else { - PRINTF("Connected to login-server (connection #%d).\n", + PRINTF("Connected to login-server (connection #%d).\n"_fmt, ls); // if no map-server already connected, display a message... int i; @@ -1158,7 +1155,7 @@ void parse_tologin(Session *ls) if (server_session[i] && server[i].maps[0]) // if map-server online and at least 1 map break; if (i == MAX_MAP_SERVERS) - PRINTF("Awaiting maps from map-server.\n"); + PRINTF("Awaiting maps from map-server.\n"_fmt); } RFIFOSKIP(ls, 3); break; @@ -1166,7 +1163,6 @@ void parse_tologin(Session *ls) case 0x2713: if (RFIFOREST(ls) < 51) return; -// PRINTF("parse_tologin 2713 : %d\n", RFIFOB(fd,6)); for (io::FD i : iter_fds()) { Session *s2 = get_session(i); @@ -1184,10 +1180,6 @@ void parse_tologin(Session *ls) else if (max_connect_user == 0 || count_users() < max_connect_user) { -// if (max_connect_user == 0) -// PRINTF("max_connect_user (unlimited) -> accepted.\n"); -// else -// PRINTF("count_users(): %d < max_connect_user (%d) -> accepted.\n", count_users(), max_connect_user); sd->email = stringish(RFIFO_STRING<40>(ls, 7)); if (!e_mail_check(sd->email)) sd->email = DEFAULT_EMAIL; @@ -1198,7 +1190,6 @@ void parse_tologin(Session *ls) else { // refuse connection: too much online players -// PRINTF("count_users(): %d < max_connect_use (%d) -> fail...\n", count_users(), max_connect_user); WFIFOW(s2, 0) = 0x6c; WFIFOB(s2, 2) = 0; WFIFOSET(s2, 3); @@ -1243,7 +1234,6 @@ void parse_tologin(Session *ls) WBUFL(buf, 2) = RFIFOL(ls, 2); // account WBUFL(buf, 6) = RFIFOL(ls, 6); // GM level mapif_sendall(buf, 10); -// PRINTF("parse_tologin: To become GM answer: char -> map.\n"); } RFIFOSKIP(ls, 10); break; @@ -1295,7 +1285,7 @@ void parse_tologin(Session *ls) || RFIFOREST(ls) < (8 + RFIFOL(ls, 4))) return; if (RFIFOL(ls, 4) < 1) - CHAR_LOG("Receiving a message for broadcast, but message is void.\n"); + CHAR_LOG("Receiving a message for broadcast, but message is void.\n"_fmt); else { int i; @@ -1304,18 +1294,18 @@ void parse_tologin(Session *ls) if (server_session[i]) break; if (i == MAX_MAP_SERVERS) - CHAR_LOG("'ladmin': Receiving a message for broadcast, but no map-server is online.\n"); + CHAR_LOG("'ladmin': Receiving a message for broadcast, but no map-server is online.\n"_fmt); else { size_t len = RFIFOL(ls, 4); AString message = RFIFO_STRING(ls, 8, len).to_print().lstrip(); // if message is only composed of spaces if (!message) - CHAR_LOG("Receiving a message for broadcast, but message is only a lot of spaces.\n"); + CHAR_LOG("Receiving a message for broadcast, but message is only a lot of spaces.\n"_fmt); // else send message to all map-servers else { - CHAR_LOG("'ladmin': Receiving a message for broadcast (message (in yellow): %s)\n", + CHAR_LOG("'ladmin': Receiving a message for broadcast (message (in yellow): %s)\n"_fmt, message); // send broadcast to all map-servers uint8_t buf[4 + len]; @@ -1351,7 +1341,6 @@ void parse_tologin(Session *ls) RFIFO_BUF_CLONE(ls, buf, len); WBUFW(buf, 0) = 0x2b11; mapif_sendall(buf, len); -// PRINTF("char: save_account_reg_reply\n"); } RFIFOSKIP(ls, RFIFOW(ls, 2)); break; @@ -1392,7 +1381,7 @@ void parse_tologin(Session *ls) FIX(s->storage_[j].nameid); #undef FIX if (changes) - CHAR_LOG("itemfrob(%d -> %d): `%s'(%d, account %d): changed %d times\n", + CHAR_LOG("itemfrob(%d -> %d): `%s'(%d, account %d): changed %d times\n"_fmt, source_id, dest_id, k->name, k->char_id, k->account_id, changes); @@ -1478,9 +1467,9 @@ void parse_tologin(Session *ls) { gm_accounts.push_back({static_cast(RFIFOL(ls, i)), RFIFOB(ls, i + 4)}); } - PRINTF("From login-server: receiving of %zu GM accounts information.\n", + PRINTF("From login-server: receiving of %zu GM accounts information.\n"_fmt, gm_accounts.size()); - CHAR_LOG("From login-server: receiving of %zu GM accounts information.\n", + CHAR_LOG("From login-server: receiving of %zu GM accounts information.\n"_fmt, gm_accounts.size()); create_online_files(); // update online players files (perhaps some online players change of GM level) // send new gm acccounts level to map-servers @@ -1534,17 +1523,15 @@ void map_anti_freeze_system(TimerData *, tick_t) { int i; - //PRINTF("Entering in map_anti_freeze_system function to check freeze of servers.\n"); for (i = 0; i < MAX_MAP_SERVERS; i++) { if (server_session[i]) { // if map-server is online - //PRINTF("map_anti_freeze_system: server #%d, flag: %d.\n", i, server_freezeflag[i]); if (server_freezeflag[i]-- < 1) { // Map-server anti-freeze system. Counter. 5 ok, 4...0 freezed - PRINTF("Map-server anti-freeze system: char-server #%d is freezed -> disconnection.\n", + PRINTF("Map-server anti-freeze system: char-server #%d is freezed -> disconnection.\n"_fmt, i); - CHAR_LOG("Map-server anti-freeze system: char-server #%d is freezed -> disconnection.\n", + CHAR_LOG("Map-server anti-freeze system: char-server #%d is freezed -> disconnection.\n"_fmt, i); server_session[i]->eof = 1; } @@ -1563,7 +1550,7 @@ void parse_frommap(Session *ms) { if (id < MAX_MAP_SERVERS) { - PRINTF("Map-server %d (session #%d) has disconnected.\n", id, + PRINTF("Map-server %d (session #%d) has disconnected.\n"_fmt, id, ms); server[id] = mmo_map_server{}; server_session[id] = nullptr; @@ -1578,8 +1565,6 @@ void parse_frommap(Session *ms) while (RFIFOREST(ms) >= 2) { -// PRINTF("parse_frommap: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd)); - switch (RFIFOW(ms, 0)) { // request from map-server to reload GM accounts. Transmission to login-server (by Yor) @@ -1606,10 +1591,10 @@ void parse_frommap(Session *ms) j++; } { - PRINTF("Map-Server %d connected: %d maps, from IP %s port %d.\n", + PRINTF("Map-Server %d connected: %d maps, from IP %s port %d.\n"_fmt, id, j, server[id].ip, server[id].port); - PRINTF("Map-server %d loading complete.\n", id); - CHAR_LOG("Map-Server %d connected: %d maps, from IP %s port %d. Map-server %d loading complete.\n", + PRINTF("Map-server %d loading complete.\n"_fmt, id); + CHAR_LOG("Map-Server %d connected: %d maps, from IP %s port %d. Map-server %d loading complete.\n"_fmt, id, j, server[id].ip, server[id].port, id); } @@ -1621,8 +1606,8 @@ void parse_frommap(Session *ms) unsigned char buf[16384]; if (j == 0) { - PRINTF("WARNING: Map-Server %d have NO map.\n", id); - CHAR_LOG("WARNING: Map-Server %d have NO map.\n", + PRINTF("WARNING: Map-Server %d have NO map.\n"_fmt, id); + CHAR_LOG("WARNING: Map-Server %d have NO map.\n"_fmt, id); // Transmitting maps information to the other map-servers } @@ -1671,7 +1656,6 @@ void parse_frommap(Session *ms) int login_id1 = RFIFOL(ms, 10); int login_id2 = RFIFOL(ms, 14); IP4Address ip = RFIFOIP(ms, 18); - //PRINTF("auth_fifo search: account: %d, char: %d, secure: %08x-%08x\n", RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14)); for (AuthFifoEntry& afi : auth_fifo) { if (afi.account_id == account_id && @@ -1691,7 +1675,7 @@ void parse_frommap(Session *ms) break; } } - assert (cp && "uh-oh - deleted while in queue?"); + assert (cp && "uh-oh - deleted while in queue?"_s); CharKey *ck = &cp->key; CharData *cd = cp->data.get(); @@ -1705,12 +1689,11 @@ void parse_frommap(Session *ms) cd->sex = afi.sex; WFIFOW(ms, 16) = afi.packet_tmw_version; FPRINTF(stderr, - "From queue index %zd: recalling packet version %d\n", + "From queue index %zd: recalling packet version %d\n"_fmt, (&afi - &auth_fifo.front()), afi.packet_tmw_version); WFIFO_STRUCT(ms, 18, *ck); WFIFO_STRUCT(ms, 18 + sizeof(*ck), *cd); WFIFOSET(ms, WFIFOW(ms, 2)); - //PRINTF("auth_fifo search success (auth #%d, account %d, character: %d).\n", i, RFIFOL(fd,2), RFIFOL(fd,6)); goto x2afc_out; } } @@ -1718,7 +1701,7 @@ void parse_frommap(Session *ms) WFIFOW(ms, 0) = 0x2afe; WFIFOL(ms, 2) = account_id; WFIFOSET(ms, 6); - PRINTF("auth_fifo search error! account %d not authentified.\n", + PRINTF("auth_fifo search error! account %d not authentified.\n"_fmt, account_id); } } @@ -2055,7 +2038,7 @@ void parse_frommap(Session *ms) return; } // inter server処理でもない場合は切断 - PRINTF("char: unknown packet 0x%04x (%zu bytes to read in buffer)! (from map).\n", + PRINTF("char: unknown packet 0x%04x (%zu bytes to read in buffer)! (from map).\n"_fmt, RFIFOW(ms, 0), RFIFOREST(ms)); ms->eof = 1; return; @@ -2089,8 +2072,8 @@ int lan_ip_check(IP4Address addr) { bool lancheck = lan_subnet.covers(addr); - PRINTF("LAN test (result): %s.\n", - (lancheck) ? SGR_BOLD SGR_CYAN "LAN source" SGR_RESET : SGR_BOLD SGR_GREEN "WAN source" SGR_RESET); + PRINTF("LAN test (result): %s.\n"_fmt, + (lancheck) ? SGR_BOLD SGR_CYAN "LAN source" SGR_RESET ""_s : SGR_BOLD SGR_GREEN "WAN source" SGR_RESET ""_s); return lancheck; } @@ -2112,7 +2095,7 @@ void handle_x0066(Session *s, struct char_session_data *sd, uint8_t rfifob_2, IP CharKey *ck = &cp->key; CharData *cd = cp->data.get(); - CHAR_LOG("Character Selected, Account ID: %d, Character Slot: %d, Character Name: %s [%s]\n", + CHAR_LOG("Character Selected, Account ID: %d, Character Slot: %d, Character Name: %s [%s]\n"_fmt, sd->account_id, rfifob_2, ck->name, ip); // searching map server @@ -2129,7 +2112,7 @@ void handle_x0066(Session *s, struct char_session_data *sd, uint8_t rfifob_2, IP { // change save point to one of map found on the server (the first) i = j; cd->last_point.map_ = server[j].maps[0]; - PRINTF("Map-server #%d found with a map: '%s'.\n", + PRINTF("Map-server #%d found with a map: '%s'.\n"_fmt, j, server[j].maps[0]); // coordonates are unknown break; @@ -2146,10 +2129,10 @@ void handle_x0066(Session *s, struct char_session_data *sd, uint8_t rfifob_2, IP WFIFOW(s, 0) = 0x71; WFIFOL(s, 2) = ck->char_id; WFIFO_STRING(s, 6, cd->last_point.map_, 16); - PRINTF("Character selection '%s' (account: %d, slot: %d) [%s]\n", + PRINTF("Character selection '%s' (account: %d, slot: %d) [%s]\n"_fmt, ck->name, sd->account_id, ck->char_num, ip); - PRINTF("--Send IP of map-server. "); + PRINTF("--Send IP of map-server. "_fmt); if (lan_ip_check(ip)) WFIFOIP(s, 22) = lan_map_ip; else @@ -2189,9 +2172,6 @@ void parse_char(Session *s) while (RFIFOREST(s) >= 2) { -// if (RFIFOW(fd,0) < 30000) -// PRINTF("parse_char: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd)); - switch (RFIFOW(s, 0)) { case 0x20b: //20040622暗号化ragexe対応 @@ -2222,16 +2202,16 @@ void parse_char(Session *s) int account_id = RFIFOL(s, 2); int GM_value = isGM(account_id); if (GM_value) - PRINTF("Account Logged On; Account ID: %d (GM level %d).\n", + PRINTF("Account Logged On; Account ID: %d (GM level %d).\n"_fmt, account_id, GM_value); else - PRINTF("Account Logged On; Account ID: %d.\n", + PRINTF("Account Logged On; Account ID: %d.\n"_fmt, account_id); if (sd == NULL) { s->session_data = make_unique(); sd = static_cast(s->session_data.get()); - sd->email = stringish("no mail"); // put here a mail without '@' to refuse deletion if we don't receive the e-mail + sd->email = stringish("no mail"_s); // put here a mail without '@' to refuse deletion if we don't receive the e-mail sd->connect_until_time = TimeT(); // unknow or illimited (not displaying on map-server) } sd->account_id = account_id; @@ -2585,7 +2565,7 @@ void check_connect_login_server(TimerData *, tick_t) { if (!login_session) { - PRINTF("Attempt to connect to login-server...\n"); + PRINTF("Attempt to connect to login-server...\n"_fmt); login_session = make_connection(login_ip, login_port); if (!login_session) return; @@ -2615,7 +2595,7 @@ bool char_lan_config(XString w1, ZString w2) struct hostent *h = NULL; { - if (w1 == "lan_map_ip") + if (w1 == "lan_map_ip"_s) { // Read map-server Lan IP Address h = gethostbyname(w2.c_str()); @@ -2630,20 +2610,20 @@ bool char_lan_config(XString w1, ZString w2) } else { - PRINTF("Bad IP value: %s\n", w2); + PRINTF("Bad IP value: %s\n"_fmt, w2); return false; } - PRINTF("LAN IP of map-server: %s.\n", lan_map_ip); + PRINTF("LAN IP of map-server: %s.\n"_fmt, lan_map_ip); } - else if (w1 == "subnet" /*backward compatibility*/ - || w1 == "lan_subnet") + else if (w1 == "subnet"_s /*backward compatibility*/ + || w1 == "lan_subnet"_s) { if (!extract(w2, &lan_subnet)) { - PRINTF("Bad IP mask: %s\n", w2); + PRINTF("Bad IP mask: %s\n"_fmt, w2); return false; } - PRINTF("Sub-network of the map-server: %s.\n", + PRINTF("Sub-network of the map-server: %s.\n"_fmt, lan_subnet); } else @@ -2659,10 +2639,10 @@ bool lan_check() { // sub-network check of the map-server { - PRINTF("LAN test of LAN IP of the map-server: "); + PRINTF("LAN test of LAN IP of the map-server: "_fmt); if (!lan_ip_check(lan_map_ip)) { - PRINTF(SGR_BOLD SGR_RED "***ERROR: LAN IP of the map-server doesn't belong to the specified Sub-network." SGR_RESET "\n"); + PRINTF(SGR_BOLD SGR_RED "***ERROR: LAN IP of the map-server doesn't belong to the specified Sub-network." SGR_RESET "\n"_fmt); return false; } } @@ -2676,21 +2656,21 @@ bool char_config(XString w1, ZString w2) struct hostent *h = NULL; { - if (w1 == "userid") + if (w1 == "userid"_s) userid = stringish(w2); - else if (w1 == "passwd") + else if (w1 == "passwd"_s) passwd = stringish(w2); - else if (w1 == "server_name") + else if (w1 == "server_name"_s) { server_name = stringish(w2); - PRINTF("%s server has been intialized\n", w2); + PRINTF("%s server has been intialized\n"_fmt, w2); } - else if (w1 == "wisp_server_name") + else if (w1 == "wisp_server_name"_s) { if (w2.size() >= 4) wisp_server_name = stringish(w2); } - else if (w1 == "login_ip") + else if (w1 == "login_ip"_s) { h = gethostbyname(w2.c_str()); if (h != NULL) @@ -2701,20 +2681,20 @@ bool char_config(XString w1, ZString w2) static_cast(h->h_addr[2]), static_cast(h->h_addr[3]), }); - PRINTF("Login server IP address : %s -> %s\n", + PRINTF("Login server IP address : %s -> %s\n"_fmt, w2, login_ip); } else { - PRINTF("Bad IP value: %s\n", w2); + PRINTF("Bad IP value: %s\n"_fmt, w2); return false; } } - else if (w1 == "login_port") + else if (w1 == "login_port"_s) { login_port = atoi(w2.c_str()); } - else if (w1 == "char_ip") + else if (w1 == "char_ip"_s) { h = gethostbyname(w2.c_str()); if (h != NULL) @@ -2725,56 +2705,56 @@ bool char_config(XString w1, ZString w2) static_cast(h->h_addr[2]), static_cast(h->h_addr[3]), }); - PRINTF("Character server IP address : %s -> %s\n", + PRINTF("Character server IP address : %s -> %s\n"_fmt, w2, char_ip); } else { - PRINTF("Bad IP value: %s\n", w2); + PRINTF("Bad IP value: %s\n"_fmt, w2); return false; } } - else if (w1 == "char_port") + else if (w1 == "char_port"_s) { char_port = atoi(w2.c_str()); } - else if (w1 == "char_txt") + else if (w1 == "char_txt"_s) { char_txt = w2; } - else if (w1 == "max_connect_user") + else if (w1 == "max_connect_user"_s) { max_connect_user = atoi(w2.c_str()); if (max_connect_user < 0) max_connect_user = 0; // unlimited online players } - else if (w1 == "check_ip_flag") + else if (w1 == "check_ip_flag"_s) { check_ip_flag = config_switch(w2); } - else if (w1 == "autosave_time") + else if (w1 == "autosave_time"_s) { autosave_time = std::chrono::seconds(atoi(w2.c_str())); if (autosave_time <= std::chrono::seconds::zero()) autosave_time = DEFAULT_AUTOSAVE_INTERVAL; } - else if (w1 == "start_point") + else if (w1 == "start_point"_s) { extract(w2, &start_point); } - else if (w1 == "unknown_char_name") + else if (w1 == "unknown_char_name"_s) { unknown_char_name = stringish(w2); } - else if (w1 == "char_log_filename") + else if (w1 == "char_log_filename"_s) { char_log_filename = w2; } - else if (w1 == "char_name_option") + else if (w1 == "char_name_option"_s) { char_name_option = atoi(w2.c_str()); } - else if (w1 == "char_name_letters") + else if (w1 == "char_name_letters"_s) { if (!w2) char_name_letters.reset(); @@ -2782,35 +2762,35 @@ bool char_config(XString w1, ZString w2) for (uint8_t c : w2) char_name_letters[c] = true; } - else if (w1 == "online_txt_filename") + else if (w1 == "online_txt_filename"_s) { online_txt_filename = w2; } - else if (w1 == "online_html_filename") + else if (w1 == "online_html_filename"_s) { online_html_filename = w2; } - else if (w1 == "online_sorting_option") + else if (w1 == "online_sorting_option"_s) { online_sorting_option = atoi(w2.c_str()); } - else if (w1 == "online_gm_display_min_level") + else if (w1 == "online_gm_display_min_level"_s) { // minimum GM level to display 'GM' when we want to display it online_gm_display_min_level = atoi(w2.c_str()); if (online_gm_display_min_level < 5) // send online file every 5 seconds to player is enough online_gm_display_min_level = 5; } - else if (w1 == "online_refresh_html") + else if (w1 == "online_refresh_html"_s) { online_refresh_html = atoi(w2.c_str()); if (online_refresh_html < 1) online_refresh_html = 1; } - else if (w1 == "anti_freeze_enable") + else if (w1 == "anti_freeze_enable"_s) { anti_freeze_enable = config_switch(w2); } - else if (w1 == "anti_freeze_interval") + else if (w1 == "anti_freeze_interval"_s) { anti_freeze_interval = std::max( std::chrono::seconds(atoi(w2.c_str())), @@ -2841,7 +2821,7 @@ void term_func(void) delete_session(login_session); delete_session(char_session); - CHAR_LOG("----End of char-server (normal end with closing of all files).\n"); + CHAR_LOG("----End of char-server (normal end with closing of all files).\n"_fmt); } static @@ -2866,20 +2846,20 @@ int do_init(Slice argv) ZString argvi = argv.pop_front(); if (argvi.startswith('-')) { - if (argvi == "--help") + if (argvi == "--help"_s) { - PRINTF("Usage: %s [--help] [--version] [files...]\n", + PRINTF("Usage: %s [--help] [--version] [files...]\n"_fmt, argv0); exit(0); } - else if (argvi == "--version") + else if (argvi == "--version"_s) { - PRINTF("%s\n", CURRENT_VERSION_STRING); + PRINTF("%s\n"_fmt, CURRENT_VERSION_STRING); exit(0); } else { - FPRINTF(stderr, "Unknown argument: %s\n", argvi); + FPRINTF(stderr, "Unknown argument: %s\n"_fmt, argvi); runflag = false; } } @@ -2891,11 +2871,11 @@ int do_init(Slice argv) } if (!loaded_config_yet) - runflag &= load_config_file("conf/tmwa-char.conf", char_confs); + runflag &= load_config_file("conf/tmwa-char.conf"_s, char_confs); // a newline in the log... - CHAR_LOG(""); - CHAR_LOG("The char-server starting...\n"); + CHAR_LOG(""_fmt); + CHAR_LOG("The char-server starting...\n"_fmt); runflag &= lan_check(); @@ -2931,10 +2911,10 @@ int do_init(Slice argv) ).detach(); } - CHAR_LOG("The char-server is ready (Server is listening on the port %d).\n", + CHAR_LOG("The char-server is ready (Server is listening on the port %d).\n"_fmt, char_port); - PRINTF("The char-server is " SGR_BOLD SGR_GREEN "ready" SGR_RESET " (Server is listening on the port %d).\n\n", + PRINTF("The char-server is " SGR_BOLD SGR_GREEN "ready" SGR_RESET " (Server is listening on the port %d).\n\n"_fmt, char_port); return 0; diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp index c9965dc..952788c 100644 --- a/src/char/int_party.cpp +++ b/src/char/int_party.cpp @@ -42,7 +42,7 @@ #include "../poison.hpp" -AString party_txt = "save/party.txt"; +AString party_txt = "save/party.txt"_s; static Map party_db; @@ -64,7 +64,7 @@ AString inter_party_tostr(struct party *p) str += STRPRINTF( "%d\t" "%s\t" - "%d,%d\t", + "%d,%d\t"_fmt, p->party_id, p->name, p->exp, p->item); @@ -75,7 +75,7 @@ AString inter_party_tostr(struct party *p) continue; str += STRPRINTF( "%d,%d\t" - "%s\t", + "%s\t"_fmt, m->account_id, m->leader, m->name); } @@ -132,10 +132,10 @@ void party_check_deleted_init(struct party *p) const CharPair *c = search_character(p->member[i].name); if (!c || c->key.account_id != p->member[i].account_id) { - CHAR_LOG("WARNING: deleting obsolete party member %d %s of %d %s\n", + CHAR_LOG("WARNING: deleting obsolete party member %d %s of %d %s\n"_fmt, p->member[i].account_id, p->member[i].name, p->party_id, p->name); - PRINTF("WARNING: deleting obsolete party member %d %s of %d %s\n", + PRINTF("WARNING: deleting obsolete party member %d %s of %d %s\n"_fmt, p->member[i].account_id, p->member[i].name, p->party_id, p->name); p->member[i] = party_member{}; @@ -156,7 +156,7 @@ void inter_party_init(void) while (in.getline(line)) { int i, j = 0; - if (SSCANF(line, "%d\t%%newid%%\n%n", &i, &j) == 1 && j > 0 + if (SSCANF(line, "%d\t%%newid%%\n%n"_fmt, &i, &j) == 1 && j > 0 && party_newid <= i) { party_newid = i; @@ -174,7 +174,7 @@ void inter_party_init(void) } else { - PRINTF("int_party: broken data [%s] line %d\n", party_txt, + PRINTF("int_party: broken data [%s] line %d\n"_fmt, party_txt, c + 1); } c++; @@ -195,7 +195,7 @@ int inter_party_save(void) io::WriteLock fp(party_txt); if (!fp.is_open()) { - PRINTF("int_party: cant write [%s] !!! data is lost !!!\n", + PRINTF("int_party: cant write [%s] !!! data is lost !!!\n"_fmt, party_txt); return 1; } @@ -251,10 +251,8 @@ int party_check_empty(struct party *p) { int i; -// PRINTF("party check empty %08X\n", (int)p); for (i = 0; i < MAX_PARTY; i++) { -// PRINTF("%d acc=%d\n", i, p->member[i].account_id); if (p->member[i].account_id > 0) { return 0; @@ -283,7 +281,7 @@ void party_check_conflict_sub(struct party *p, && p->member[i].name == nick) { // 別のパーティに偽の所属データがあるので脱退 - PRINTF("int_party: party conflict! %d %d %d\n", account_id, + PRINTF("int_party: party conflict! %d %d %d\n"_fmt, account_id, party_id, p->party_id); mapif_parse_PartyLeave(nullptr, p->party_id, account_id); } @@ -313,13 +311,13 @@ void mapif_party_created(Session *s, int account_id, struct party *p) WFIFOB(s, 6) = 0; WFIFOL(s, 7) = p->party_id; WFIFO_STRING(s, 11, p->name, 24); - PRINTF("int_party: created! %d %s\n", p->party_id, p->name); + PRINTF("int_party: created! %d %s\n"_fmt, p->party_id, p->name); } else { WFIFOB(s, 6) = 1; WFIFOL(s, 7) = 0; - WFIFO_STRING(s, 11, "error", 24); + WFIFO_STRING(s, 11, "error"_s, 24); } WFIFOSET(s, 35); } @@ -332,7 +330,7 @@ void mapif_party_noinfo(Session *s, int party_id) WFIFOW(s, 2) = 8; WFIFOL(s, 4) = party_id; WFIFOSET(s, 8); - PRINTF("int_party: info not found %d\n", party_id); + PRINTF("int_party: info not found %d\n"_fmt, party_id); } // パーティ情報まとめ送り @@ -348,7 +346,6 @@ void mapif_party_info(Session *s, struct party *p) mapif_sendall(buf, WBUFW(buf, 2)); else mapif_send(s, buf, WBUFW(buf, 2)); -// PRINTF("int_party: info %d %s\n", p->party_id, p->name); } // パーティメンバ追加可否 @@ -379,7 +376,7 @@ void mapif_party_optionchanged(Session *s, struct party *p, int account_id, mapif_sendall(buf, 15); else mapif_send(s, buf, 15); - PRINTF("int_party: option changed %d %d %d %d %d\n", p->party_id, + PRINTF("int_party: option changed %d %d %d %d %d\n"_fmt, p->party_id, account_id, p->exp, p->item, flag); } @@ -394,7 +391,7 @@ void mapif_party_leaved(int party_id, int account_id, CharName name) WBUFL(buf, 6) = account_id; WBUF_STRING(buf, 10, name.to__actual(), 24); mapif_sendall(buf, 34); - PRINTF("int_party: party leaved %d %d %s\n", party_id, account_id, name); + PRINTF("int_party: party leaved %d %d %s\n"_fmt, party_id, account_id, name); } // パーティマップ更新通知 @@ -421,8 +418,8 @@ void mapif_party_broken(int party_id, int flag) WBUFL(buf, 2) = party_id; WBUFB(buf, 6) = flag; mapif_sendall(buf, 7); - PRINTF("int_party: broken %d\n", party_id); - CHAR_LOG("int_party: broken %d\n", party_id); + PRINTF("int_party: broken %d\n"_fmt, party_id); + CHAR_LOG("int_party: broken %d\n"_fmt, party_id); } // パーティ内発言 @@ -451,7 +448,7 @@ void mapif_parse_CreateParty(Session *s, int account_id, PartyName name, CharNam { if (!name.is_print()) { - PRINTF("int_party: illegal party name [%s]\n", name); + PRINTF("int_party: illegal party name [%s]\n"_fmt, name); mapif_party_created(s, account_id, NULL); return; } @@ -459,7 +456,7 @@ void mapif_parse_CreateParty(Session *s, int account_id, PartyName name, CharNam if (search_partyname(name) != NULL) { - PRINTF("int_party: same name party exists [%s]\n", name); + PRINTF("int_party: same name party exists [%s]\n"_fmt, name); mapif_party_created(s, account_id, NULL); return; } diff --git a/src/char/int_storage.cpp b/src/char/int_storage.cpp index c7c1343..6021d54 100644 --- a/src/char/int_storage.cpp +++ b/src/char/int_storage.cpp @@ -43,7 +43,7 @@ // ファイル名のデフォルト // inter_config_read()で再設定される -AString storage_txt = "save/storage.txt"; +AString storage_txt = "save/storage.txt"_s; static Map storage_db; @@ -54,7 +54,7 @@ AString storage_tostr(struct storage *p) { MString str; str += STRPRINTF( - "%d,%d\t", + "%d,%d\t"_fmt, p->account_id, p->storage_amount); int f = 0; @@ -62,7 +62,7 @@ AString storage_tostr(struct storage *p) if (p->storage_[i].nameid && p->storage_[i].amount) { str += STRPRINTF( - "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", + "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d "_fmt, p->storage_[i].id, p->storage_[i].nameid, p->storage_[i].amount, @@ -106,7 +106,7 @@ bool extract(XString str, struct storage *p) std::copy(storage_items.begin(), storage_items.end(), p->storage_.begin()); if (p->storage_amount != storage_items.size()) - PRINTF("WARNING: storage desync for %d\n", p->account_id); + PRINTF("WARNING: storage desync for %d\n"_fmt, p->account_id); return true; } @@ -131,7 +131,7 @@ void inter_storage_init(void) io::ReadFile in(storage_txt); if (!in.is_open()) { - PRINTF("cant't read : %s\n", storage_txt); + PRINTF("cant't read : %s\n"_fmt, storage_txt); return; } @@ -145,7 +145,7 @@ void inter_storage_init(void) } else { - PRINTF("int_storage: broken data [%s] line %d\n", + PRINTF("int_storage: broken data [%s] line %d\n"_fmt, storage_txt, c); } c++; @@ -168,7 +168,7 @@ int inter_storage_save(void) if (!fp.is_open()) { - PRINTF("int_storage: cant write [%s] !!! data is lost !!!\n", + PRINTF("int_storage: cant write [%s] !!! data is lost !!!\n"_fmt, storage_txt); return 1; } @@ -227,7 +227,7 @@ void mapif_parse_SaveStorage(Session *ss) int len = RFIFOW(ss, 2); if (sizeof(struct storage) != len - 8) { - PRINTF("inter storage: data size error %zu %d\n", + PRINTF("inter storage: data size error %zu %d\n"_fmt, sizeof(struct storage), len - 8); } else diff --git a/src/char/inter.cpp b/src/char/inter.cpp index 204a0e2..f7b3184 100644 --- a/src/char/inter.cpp +++ b/src/char/inter.cpp @@ -50,7 +50,7 @@ #include "../poison.hpp" static -AString accreg_txt = "save/accreg.txt"; +AString accreg_txt = "save/accreg.txt"_s; struct accreg { @@ -85,9 +85,9 @@ AString inter_accreg_tostr(struct accreg *reg) { assert(reg->reg_num < ACCOUNT_REG_NUM); MString str; - str += STRPRINTF("%d\t", reg->account_id); + str += STRPRINTF("%d\t"_fmt, reg->account_id); for (int j = 0; j < reg->reg_num; j++) - str += STRPRINTF("%s,%d ", reg->reg[j].str, reg->reg[j].value); + str += STRPRINTF("%s,%d "_fmt, reg->reg[j].str, reg->reg[j].value); return AString(str); } @@ -130,7 +130,7 @@ void inter_accreg_init(void) } else { - PRINTF("inter: accreg: broken data [%s] line %d\n", accreg_txt, + PRINTF("inter: accreg: broken data [%s] line %d\n"_fmt, accreg_txt, c); } c++; @@ -155,7 +155,7 @@ int inter_accreg_save(void) io::WriteLock fp(accreg_txt); if (!fp.is_open()) { - PRINTF("int_accreg: cant write [%s] !!! data is lost !!!\n", + PRINTF("int_accreg: cant write [%s] !!! data is lost !!!\n"_fmt, accreg_txt); return 1; } @@ -168,19 +168,19 @@ int inter_accreg_save(void) bool inter_config(XString w1, ZString w2) { { - if (w1 == "storage_txt") + if (w1 == "storage_txt"_s) { storage_txt = w2; } - else if (w1 == "party_txt") + else if (w1 == "party_txt"_s) { party_txt = w2; } - else if (w1 == "accreg_txt") + else if (w1 == "accreg_txt"_s) { accreg_txt = w2; } - else if (w1 == "party_share_level") + else if (w1 == "party_share_level"_s) { party_share_level = atoi(w2.c_str()); if (party_share_level < 0) @@ -316,7 +316,7 @@ void mapif_parse_WisRequest(Session *sms) { if (RFIFOW(sms, 2) - 52 <= 0) { // normaly, impossible, but who knows... - PRINTF("inter: Wis message doesn't exist.\n"); + PRINTF("inter: Wis message doesn't exist.\n"_fmt); return; } diff --git a/src/generic/intern-pool_test.cpp b/src/generic/intern-pool_test.cpp index b72ab04..3207792 100644 --- a/src/generic/intern-pool_test.cpp +++ b/src/generic/intern-pool_test.cpp @@ -28,13 +28,13 @@ TEST(InternPool, whydoesthisalwaysneedasecondname) { InternPool p; EXPECT_EQ(0, p.size()); - EXPECT_EQ(0, p.intern("hello")); - EXPECT_EQ(0, p.intern("hello")); + EXPECT_EQ(0, p.intern("hello"_s)); + EXPECT_EQ(0, p.intern("hello"_s)); EXPECT_EQ(1, p.size()); - EXPECT_EQ(1, p.intern("world")); - EXPECT_EQ(0, p.intern("hello")); - EXPECT_EQ(1, p.intern("world")); + EXPECT_EQ(1, p.intern("world"_s)); + EXPECT_EQ(0, p.intern("hello"_s)); + EXPECT_EQ(1, p.intern("world"_s)); EXPECT_EQ(2, p.size()); - EXPECT_EQ("hello", p.outtern(0)); - EXPECT_EQ("world", p.outtern(1)); + EXPECT_EQ("hello"_s, p.outtern(0)); + EXPECT_EQ("world"_s, p.outtern(1)); } diff --git a/src/generic/md5_test.cpp b/src/generic/md5_test.cpp index f6a2324..047b082 100644 --- a/src/generic/md5_test.cpp +++ b/src/generic/md5_test.cpp @@ -38,11 +38,11 @@ VString<32> MD5(XString in) TEST(md5calc, rfc1321) { - EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e", MD5("")); - EXPECT_EQ("0cc175b9c0f1b6a831c399e269772661", MD5("a")); - EXPECT_EQ("900150983cd24fb0d6963f7d28e17f72", MD5("abc")); - EXPECT_EQ("f96b697d7cb7938d525a2f31aaf161d0", MD5("message digest")); - EXPECT_EQ("c3fcd3d76192e4007dfb496cca67e13b", MD5("abcdefghijklmnopqrstuvwxyz")); - EXPECT_EQ("d174ab98d277d9f5a5611c2c9f419d9f", MD5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")); - EXPECT_EQ("57edf4a22be3c955ac49da2e2107b67a", MD5("12345678901234567890123456789012345678901234567890123456789012345678901234567890")); + EXPECT_EQ("d41d8cd98f00b204e9800998ecf8427e"_s, MD5(""_s)); + EXPECT_EQ("0cc175b9c0f1b6a831c399e269772661"_s, MD5("a"_s)); + EXPECT_EQ("900150983cd24fb0d6963f7d28e17f72"_s, MD5("abc"_s)); + EXPECT_EQ("f96b697d7cb7938d525a2f31aaf161d0"_s, MD5("message digest"_s)); + EXPECT_EQ("c3fcd3d76192e4007dfb496cca67e13b"_s, MD5("abcdefghijklmnopqrstuvwxyz"_s)); + EXPECT_EQ("d174ab98d277d9f5a5611c2c9f419d9f"_s, MD5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"_s)); + EXPECT_EQ("57edf4a22be3c955ac49da2e2107b67a"_s, MD5("12345678901234567890123456789012345678901234567890123456789012345678901234567890"_s)); } diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp index 66419df..a2faa18 100644 --- a/src/io/cxxstdio.hpp +++ b/src/io/cxxstdio.hpp @@ -192,7 +192,7 @@ namespace cxxstdio int print(T&& t, A&&... a) { constexpr static - const char *print_format = Format::print_format(); + const char *print_format = Format::print_format().format_string(); return do_print(std::forward(t), print_format, decay_for_printf(convert_for_printf(std::forward(a)))...); } @@ -207,7 +207,7 @@ namespace cxxstdio int scan(T&& t, A&&... a) { constexpr static - const char *scan_format = Format::scan_format(); + const char *scan_format = Format::scan_format().format_string(); return do_scan(std::forward(t), scan_format, &convert_for_scanf(*a)...); } @@ -218,7 +218,7 @@ namespace cxxstdio struct format_impl \ { \ constexpr static \ - const char *print_format() { return fmt; } \ + FormatString print_format() { return fmt; } \ }; \ cxxstdio::PrintFormatter::print(out, ## __VA_ARGS__); \ }) @@ -228,7 +228,7 @@ namespace cxxstdio struct format_impl \ { \ constexpr static \ - const char *scan_format() { return fmt; } \ + FormatString scan_format() { return fmt; } \ }; \ cxxstdio::ScanFormatter::scan(out, ## __VA_ARGS__); \ }) diff --git a/src/io/line.cpp b/src/io/line.cpp index f7470a6..8451b87 100644 --- a/src/io/line.cpp +++ b/src/io/line.cpp @@ -36,26 +36,26 @@ namespace io { MString out; if (column) - out += STRPRINTF("%s:%u:%u: %s: %s\n", + out += STRPRINTF("%s:%u:%u: %s: %s\n"_fmt, filename, line, column, cat, msg); else - out += STRPRINTF("%s:%u: %s: %s\n", + out += STRPRINTF("%s:%u: %s: %s\n"_fmt, filename, line, cat, msg); - out += STRPRINTF("%s\n", text); - out += STRPRINTF("%*c\n", column, '^'); + out += STRPRINTF("%s\n"_fmt, text); + out += STRPRINTF("%*c\n"_fmt, column, '^'); return AString(out); } void Line::message(ZString cat, ZString msg) const { if (column) - FPRINTF(stderr, "%s:%u:%u: %s: %s\n", + FPRINTF(stderr, "%s:%u:%u: %s: %s\n"_fmt, filename, line, column, cat, msg); else - FPRINTF(stderr, "%s:%u: %s: %s\n", + FPRINTF(stderr, "%s:%u: %s: %s\n"_fmt, filename, line, cat, msg); - FPRINTF(stderr, "%s\n", text); - FPRINTF(stderr, "%*c\n", column, '^'); + FPRINTF(stderr, "%s\n"_fmt, text); + FPRINTF(stderr, "%*c\n"_fmt, column, '^'); } AString LineSpan::message_str(ZString cat, ZString msg) const @@ -67,24 +67,24 @@ namespace io MString out; if (begin.line == end.line) { - out += STRPRINTF("%s:%u:%u: %s: %s\n", + out += STRPRINTF("%s:%u:%u: %s: %s\n"_fmt, begin.filename, begin.line, begin.column, cat, msg); - out += STRPRINTF("%s\n", begin.text); - out += STRPRINTF("%*c", begin.column, '^'); + out += STRPRINTF("%s\n"_fmt, begin.text); + out += STRPRINTF("%*c"_fmt, begin.column, '^'); for (unsigned c = begin.column; c != end.column; ++c) out += '~'; out += '\n'; } else { - out += STRPRINTF("%s:%u:%u: %s: %s\n", + out += STRPRINTF("%s:%u:%u: %s: %s\n"_fmt, begin.filename, begin.line, begin.column, cat, msg); - out += STRPRINTF("%s\n", begin.text); - out += STRPRINTF("%*c", begin.column, '^'); + out += STRPRINTF("%s\n"_fmt, begin.text); + out += STRPRINTF("%*c"_fmt, begin.column, '^'); for (unsigned c = begin.column; c != begin.text.size(); ++c) out += '~'; - out += " ...\n"; - out += STRPRINTF("%s\n", end.text); + out += " ...\n"_s; + out += STRPRINTF("%s\n"_fmt, end.text); for (unsigned c = 0; c != end.column; ++c) out += '~'; out += '\n'; @@ -94,7 +94,7 @@ namespace io void LineSpan::message(ZString cat, ZString msg) const { - FPRINTF(stderr, "%s", message_str(cat, msg)); + FPRINTF(stderr, "%s"_fmt, message_str(cat, msg)); } LineReader::LineReader(ZString name) diff --git a/src/io/line.hpp b/src/io/line.hpp index a9e8944..bb002b8 100644 --- a/src/io/line.hpp +++ b/src/io/line.hpp @@ -42,9 +42,9 @@ namespace io AString message_str(ZString cat, ZString msg) const; void message(ZString cat, ZString msg) const; - void note(ZString msg) const { message("note", msg); } - void warning(ZString msg) const { message("warning", msg); } - void error(ZString msg) const { message("error", msg); } + void note(ZString msg) const { message("note"_s, msg); } + void warning(ZString msg) const { message("warning"_s, msg); } + void error(ZString msg) const { message("error"_s, msg); } }; // psst, don't tell anyone @@ -65,9 +65,9 @@ namespace io AString message_str(ZString cat, ZString msg) const; void message(ZString cat, ZString msg) const; - void note(ZString msg) const { message("note", msg); } - void warning(ZString msg) const { message("warning", msg); } - void error(ZString msg) const { message("error", msg); } + void note(ZString msg) const { message("note"_s, msg); } + void warning(ZString msg) const { message("warning"_s, msg); } + void error(ZString msg) const { message("error"_s, msg); } }; class LineReader diff --git a/src/io/line_test.cpp b/src/io/line_test.cpp index feee1fb..921e4c8 100644 --- a/src/io/line_test.cpp +++ b/src/io/line_test.cpp @@ -42,80 +42,80 @@ io::FD string_pipe(ZString sz) TEST(io, line1) { - io::LineReader lr("", string_pipe("Hello World\n")); + io::LineReader lr(""_s, string_pipe("Hello World\n"_s)); io::Line hi; EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "Hello World"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "Hello World"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 1); EXPECT_EQ(hi.column, 0); EXPECT_FALSE(lr.read_line(hi)); } TEST(io, line2) { - io::LineReader lr("", string_pipe("Hello\nWorld")); + io::LineReader lr(""_s, string_pipe("Hello\nWorld"_s)); io::Line hi; EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "Hello"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "Hello"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 1); EXPECT_EQ(hi.column, 0); EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "World"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "World"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 2); EXPECT_EQ(hi.column, 0); EXPECT_FALSE(lr.read_line(hi)); } TEST(io, line3) { - io::LineReader lr("", string_pipe("Hello\rWorld")); + io::LineReader lr(""_s, string_pipe("Hello\rWorld"_s)); io::Line hi; EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "Hello"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "Hello"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 1); EXPECT_EQ(hi.column, 0); EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "World"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "World"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 2); EXPECT_EQ(hi.column, 0); EXPECT_FALSE(lr.read_line(hi)); } TEST(io, line4) { - io::LineReader lr("", string_pipe("Hello\r\nWorld")); + io::LineReader lr(""_s, string_pipe("Hello\r\nWorld"_s)); io::Line hi; EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "Hello"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "Hello"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 1); EXPECT_EQ(hi.column, 0); EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "World"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "World"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 2); EXPECT_EQ(hi.column, 0); EXPECT_FALSE(lr.read_line(hi)); } TEST(io, line5) { - io::LineReader lr("", string_pipe("Hello\n\rWorld")); + io::LineReader lr(""_s, string_pipe("Hello\n\rWorld"_s)); io::Line hi; EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "Hello"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "Hello"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 1); EXPECT_EQ(hi.column, 0); EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, ""); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, ""_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 2); EXPECT_EQ(hi.column, 0); EXPECT_TRUE(lr.read_line(hi)); - EXPECT_EQ(hi.text, "World"); - EXPECT_EQ(hi.filename, ""); + EXPECT_EQ(hi.text, "World"_s); + EXPECT_EQ(hi.filename, ""_s); EXPECT_EQ(hi.line, 3); EXPECT_EQ(hi.column, 0); EXPECT_FALSE(lr.read_line(hi)); @@ -123,47 +123,47 @@ TEST(io, line5) TEST(io, linechar1) { - io::LineCharReader lr("", string_pipe("Hi Wu\n")); + io::LineCharReader lr(""_s, string_pipe("Hi Wu\n"_s)); io::LineChar c; EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'H'); - EXPECT_EQ(c.text, "Hi Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'i'); - EXPECT_EQ(c.text, "Hi Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), ' '); - EXPECT_EQ(c.text, "Hi Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 3); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'W'); - EXPECT_EQ(c.text, "Hi Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 4); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'u'); - EXPECT_EQ(c.text, "Hi Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 5); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Hi Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 6); lr.adv(); @@ -171,47 +171,47 @@ TEST(io, linechar1) } TEST(io, linechar2) { - io::LineCharReader lr("", string_pipe("Hi\nWu")); + io::LineCharReader lr(""_s, string_pipe("Hi\nWu"_s)); io::LineChar c; EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'H'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'i'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 3); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'W'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'u'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 3); lr.adv(); @@ -219,47 +219,47 @@ TEST(io, linechar2) } TEST(io, linechar3) { - io::LineCharReader lr("", string_pipe("Hi\rWu")); + io::LineCharReader lr(""_s, string_pipe("Hi\rWu"_s)); io::LineChar c; EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'H'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'i'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 3); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'W'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'u'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 3); lr.adv(); @@ -267,47 +267,47 @@ TEST(io, linechar3) } TEST(io, linechar4) { - io::LineCharReader lr("", string_pipe("Hi\r\nWu")); + io::LineCharReader lr(""_s, string_pipe("Hi\r\nWu"_s)); io::LineChar c; EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'H'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'i'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 3); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'W'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'u'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 3); lr.adv(); @@ -315,54 +315,54 @@ TEST(io, linechar4) } TEST(io, linechar5) { - io::LineCharReader lr("", string_pipe("Hi\n\rWu")); + io::LineCharReader lr(""_s, string_pipe("Hi\n\rWu"_s)); io::LineChar c; EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'H'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'i'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Hi"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Hi"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 1); EXPECT_EQ(c.column, 3); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, ""); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, ""_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 2); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'W'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 3); EXPECT_EQ(c.column, 1); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), 'u'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 3); EXPECT_EQ(c.column, 2); lr.adv(); EXPECT_TRUE(lr.get(c)); EXPECT_EQ(c.ch(), '\n'); - EXPECT_EQ(c.text, "Wu"); - EXPECT_EQ(c.filename, ""); + EXPECT_EQ(c.text, "Wu"_s); + EXPECT_EQ(c.filename, ""_s); EXPECT_EQ(c.line, 3); EXPECT_EQ(c.column, 3); lr.adv(); @@ -371,7 +371,7 @@ TEST(io, linechar5) TEST(io, linespan) { - io::LineCharReader lr("", string_pipe("Hello,\nWorld!\n")); + io::LineCharReader lr(""_s, string_pipe("Hello,\nWorld!\n"_s)); io::LineSpan span; do { @@ -385,10 +385,10 @@ TEST(io, linespan) lr.adv(); } while (span.end.ch() != 'o'); - EXPECT_EQ(span.message_str("info", "meh"), + EXPECT_EQ(span.message_str("info"_s, "meh"_s), ":1:2: info: meh\n" "Hello,\n" - " ^~~~\n" + " ^~~~\n"_s ); span.begin = span.end; do @@ -398,21 +398,21 @@ TEST(io, linespan) } while (span.end.ch() != 'r'); - EXPECT_EQ(span.begin.message_str("note", "foo"), + EXPECT_EQ(span.begin.message_str("note"_s, "foo"_s), ":1:5: note: foo\n" "Hello,\n" - " ^\n" + " ^\n"_s ); - EXPECT_EQ(span.end.message_str("warning", "bar"), + EXPECT_EQ(span.end.message_str("warning"_s, "bar"_s), ":2:3: warning: bar\n" "World!\n" - " ^\n" + " ^\n"_s ); - EXPECT_EQ(span.message_str("error", "qux"), + EXPECT_EQ(span.message_str("error"_s, "qux"_s), ":1:5: error: qux\n" "Hello,\n" " ^~ ...\n" "World!\n" - "~~~\n" + "~~~\n"_s ); } diff --git a/src/io/lock.cpp b/src/io/lock.cpp index 96c3649..1342915 100644 --- a/src/io/lock.cpp +++ b/src/io/lock.cpp @@ -49,7 +49,7 @@ namespace io AString newfile; do { - newfile = STRPRINTF("%s_%d.tmp", filename, no++); + newfile = STRPRINTF("%s_%d.tmp"_fmt, filename, no++); fd = FD::open(newfile, O_WRONLY | O_CREAT | O_EXCL, 0666); } while (fd == FD() && errno == EEXIST); @@ -67,21 +67,21 @@ namespace io if (!WriteFile::close()) { // leave partial file - FPRINTF(stderr, "Warning: failed to write replacement for %s\n", filename); + FPRINTF(stderr, "Warning: failed to write replacement for %s\n"_fmt, filename); abort(); } int n = backup_count; - AString old_filename = STRPRINTF("%s.%d", filename, n); + AString old_filename = STRPRINTF("%s.%d"_fmt, filename, n); while (--n) { - AString newer_filename = STRPRINTF("%s.%d", filename, n); + AString newer_filename = STRPRINTF("%s.%d"_fmt, filename, n); rename(newer_filename.c_str(), old_filename.c_str()); old_filename = std::move(newer_filename); } rename(filename.c_str(), old_filename.c_str()); - AString tmpfile = STRPRINTF("%s_%d.tmp", filename, tmp_suffix); + AString tmpfile = STRPRINTF("%s_%d.tmp"_fmt, filename, tmp_suffix); rename(tmpfile.c_str(), filename.c_str()); } } // namespace io diff --git a/src/io/read.cpp b/src/io/read.cpp index 2ef35cc..61a6256 100644 --- a/src/io/read.cpp +++ b/src/io/read.cpp @@ -105,12 +105,12 @@ namespace io if (unhappy) { if (happy) - PRINTF("warning: file contains CR\n"); + PRINTF("warning: file contains CR\n"_fmt); else - PRINTF("warning: file contains bare CR\n"); + PRINTF("warning: file contains bare CR\n"_fmt); } else if (!happy && anything) - PRINTF("warning: file does not contain a trailing newline\n"); + PRINTF("warning: file does not contain a trailing newline\n"_fmt); line = AString(tmp); return anything; } diff --git a/src/io/read_test.cpp b/src/io/read_test.cpp index 87f95ba..398c01e 100644 --- a/src/io/read_test.cpp +++ b/src/io/read_test.cpp @@ -42,42 +42,42 @@ io::FD string_pipe(ZString sz) TEST(io, read1) { - io::ReadFile rf(string_pipe("Hello")); + io::ReadFile rf(string_pipe("Hello"_s)); AString hi; EXPECT_TRUE(rf.getline(hi)); - EXPECT_EQ(hi, "Hello"); + EXPECT_EQ(hi, "Hello"_s); EXPECT_FALSE(rf.getline(hi)); } TEST(io, read2) { - io::ReadFile rf(string_pipe("Hello\n")); + io::ReadFile rf(string_pipe("Hello\n"_s)); AString hi; EXPECT_TRUE(rf.getline(hi)); - EXPECT_EQ(hi, "Hello"); + EXPECT_EQ(hi, "Hello"_s); EXPECT_FALSE(rf.getline(hi)); } TEST(io, read3) { - io::ReadFile rf(string_pipe("Hello\r")); + io::ReadFile rf(string_pipe("Hello\r"_s)); AString hi; EXPECT_TRUE(rf.getline(hi)); - EXPECT_EQ(hi, "Hello"); + EXPECT_EQ(hi, "Hello"_s); EXPECT_FALSE(rf.getline(hi)); } TEST(io, read4) { - io::ReadFile rf(string_pipe("Hello\r\n")); + io::ReadFile rf(string_pipe("Hello\r\n"_s)); AString hi; EXPECT_TRUE(rf.getline(hi)); - EXPECT_EQ(hi, "Hello"); + EXPECT_EQ(hi, "Hello"_s); EXPECT_FALSE(rf.getline(hi)); } TEST(io, read5) { - io::ReadFile rf(string_pipe("Hello\n\r")); + io::ReadFile rf(string_pipe("Hello\n\r"_s)); AString hi; EXPECT_TRUE(rf.getline(hi)); - EXPECT_EQ(hi, "Hello"); + EXPECT_EQ(hi, "Hello"_s); EXPECT_TRUE(rf.getline(hi)); EXPECT_FALSE(hi); EXPECT_FALSE(rf.getline(hi)); diff --git a/src/io/write_test.cpp b/src/io/write_test.cpp index ae8eccd..5419501 100644 --- a/src/io/write_test.cpp +++ b/src/io/write_test.cpp @@ -65,7 +65,7 @@ public: if (rv == -1) { if (errno != EAGAIN) - return {"Error, read failed :("}; + return "Error, read failed :("_s; rv = 0; } if (rv == 0) @@ -81,11 +81,11 @@ TEST(io, write1) PipeWriter pw(false); io::WriteFile& wf = pw.wf; wf.really_put("Hello, ", 7); - EXPECT_EQ("", pw.slurp()); - wf.put_line("World!\n"); - EXPECT_EQ("", pw.slurp()); + EXPECT_EQ(""_s, pw.slurp()); + wf.put_line("World!\n"_s); + EXPECT_EQ(""_s, pw.slurp()); EXPECT_TRUE(wf.close()); - EXPECT_EQ("Hello, World!\n", pw.slurp()); + EXPECT_EQ("Hello, World!\n"_s, pw.slurp()); } TEST(io, write2) @@ -93,10 +93,10 @@ TEST(io, write2) PipeWriter pw(true); io::WriteFile& wf = pw.wf; wf.really_put("Hello, ", 7); - EXPECT_EQ("", pw.slurp()); - wf.put_line("World!"); + EXPECT_EQ(""_s, pw.slurp()); + wf.put_line("World!"_s); wf.really_put("XXX", 3); - EXPECT_EQ("Hello, World!\n", pw.slurp()); + EXPECT_EQ("Hello, World!\n"_s, pw.slurp()); EXPECT_TRUE(wf.close()); - EXPECT_EQ("XXX", pw.slurp()); + EXPECT_EQ("XXX"_s, pw.slurp()); } diff --git a/src/login/login.cpp b/src/login/login.cpp index f784c6a..e061e63 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -114,13 +114,13 @@ static ServerName main_server; static -AString account_filename = "save/account.txt"; +AString account_filename = "save/account.txt"_s; static -AString gm_account_filename = "save/gm_account.txt"; +AString gm_account_filename = "save/gm_account.txt"_s; static -AString login_log_filename = "log/login.log"; +AString login_log_filename = "log/login.log"_s; static -AString login_log_unknown_packets_filename = "log/login_unknown_packets.log"; +AString login_log_unknown_packets_filename = "log/login_unknown_packets.log"_s; static int save_unknown_packets = 0; static @@ -175,7 +175,7 @@ int check_ip_flag = 1; // It's to check IP of a player between login-ser #pragma GCC diagnostic ignored "-Wmissing-noreturn" void SessionDeleter::operator()(SessionData *) { - assert(false && "login server does not have sessions anymore"); + assert(false && "login server does not have sessions anymore"_s); } #pragma GCC diagnostic pop @@ -285,12 +285,12 @@ int read_gm_account(void) io::ReadFile fp(gm_account_filename); if (!fp.is_open()) { - PRINTF("read_gm_account: GM accounts file [%s] not found.\n", + PRINTF("read_gm_account: GM accounts file [%s] not found.\n"_fmt, gm_account_filename); - PRINTF(" Actually, there is no GM accounts on the server.\n"); - LOGIN_LOG("read_gm_account: GM accounts file [%s] not found.\n", + PRINTF(" Actually, there is no GM accounts on the server.\n"_fmt); + LOGIN_LOG("read_gm_account: GM accounts file [%s] not found.\n"_fmt, gm_account_filename); - LOGIN_LOG(" Actually, there is no GM accounts on the server.\n"); + LOGIN_LOG(" Actually, there is no GM accounts on the server.\n"_fmt); return 1; } // limited to 4000, because we send information to char-servers (more than 4000 GM accounts???) @@ -302,48 +302,47 @@ int read_gm_account(void) continue; GM_Account p {}; if (!extract(line, record<' '>(&p.account_id, &p.level))) - PRINTF("read_gm_account: file [%s], invalid 'id_acount level' format: '%s'\n", + PRINTF("read_gm_account: file [%s], invalid 'id_acount level' format: '%s'\n"_fmt, gm_account_filename, line); else if (p.level <= 0) - PRINTF("read_gm_account: file [%s] %dth account (invalid level [0 or negative]: %d).\n", + PRINTF("read_gm_account: file [%s] %dth account (invalid level [0 or negative]: %d).\n"_fmt, gm_account_filename, c + 1, p.level); else { if (p.level > 99) { - PRINTF("read_gm_account: file [%s] %dth account (invalid level, but corrected: %d->99).\n", + PRINTF("read_gm_account: file [%s] %dth account (invalid level, but corrected: %d->99).\n"_fmt, gm_account_filename, c + 1, p.level); p.level = 99; } if ((GM_level = isGM(p.account_id)) > 0) { // if it's not a new account if (GM_level == p.level) - PRINTF("read_gm_account: GM account %d defined twice (same level: %d).\n", + PRINTF("read_gm_account: GM account %d defined twice (same level: %d).\n"_fmt, p.account_id, p.level); else - PRINTF("read_gm_account: GM account %d defined twice (levels: %d and %d).\n", + PRINTF("read_gm_account: GM account %d defined twice (levels: %d and %d).\n"_fmt, p.account_id, GM_level, p.level); } if (GM_level != p.level) { // if new account or new level gm_account_db.insert(p.account_id, p); - //PRINTF("GM account:%d, level: %d->%d\n", p.account_id, GM_level, p.level); if (GM_level == 0) { // if new account c++; if (c >= 4000) { - PRINTF("***WARNING: 4000 GM accounts found. Next GM accounts are not readed.\n"); - LOGIN_LOG("***WARNING: 4000 GM accounts found. Next GM accounts are not readed.\n"); + PRINTF("***WARNING: 4000 GM accounts found. Next GM accounts are not readed.\n"_fmt); + LOGIN_LOG("***WARNING: 4000 GM accounts found. Next GM accounts are not readed.\n"_fmt); } } } } } - PRINTF("read_gm_account: file '%s' readed (%d GM accounts found).\n", + PRINTF("read_gm_account: file '%s' readed (%d GM accounts found).\n"_fmt, gm_account_filename, c); - LOGIN_LOG("read_gm_account: file '%s' readed (%d GM accounts found).\n", + LOGIN_LOG("read_gm_account: file '%s' readed (%d GM accounts found).\n"_fmt, gm_account_filename, c); return 0; @@ -456,7 +455,7 @@ AString mmo_auth_tostr(const AuthData *p) "%lld\t" "%s\t" "%s\t" - "%lld\t", + "%lld\t"_fmt, p->account_id, p->userid, p->pass, @@ -474,7 +473,7 @@ AString mmo_auth_tostr(const AuthData *p) assert (p->account_reg2_num < ACCOUNT_REG2_NUM); for (int i = 0; i < p->account_reg2_num; i++) if (p->account_reg2[i].str) - str += STRPRINTF("%s,%d ", + str += STRPRINTF("%s,%d "_fmt, p->account_reg2[i].str, p->account_reg2[i].value); return AString(str); @@ -504,7 +503,7 @@ bool extract(XString line, AuthData *ad) vrec<' '>(&vars)))) return false; ad->last_ip = IP4Address(); - if (ip != "-" && !extract(ip, &ad->last_ip)) + if (ip != "-"_s && !extract(ip, &ad->last_ip)) return false; if (ad->account_id > END_ACCOUNT_NUM) return false; @@ -543,7 +542,7 @@ bool extract(XString line, AuthData *ad) if (!ad->error_message || ad->state != 7) // 7, because state is packet 0x006a value + 1 - ad->error_message = stringish("-"); + ad->error_message = stringish("-"_s); if (vars.size() > ACCOUNT_REG2_NUM) return false; @@ -566,7 +565,7 @@ int mmo_auth_init(void) { // no account file -> no account -> no login, including char-server (ERROR) // not anymore! :-) - PRINTF(SGR_BOLD SGR_RED "mmo_auth_init: Accounts file [%s] not found." SGR_RESET "\n", + PRINTF(SGR_BOLD SGR_RED "mmo_auth_init: Accounts file [%s] not found." SGR_RESET "\n"_fmt, account_filename); return 0; } @@ -585,11 +584,11 @@ int mmo_auth_init(void) if (!extract(line, &ad)) { int i = 0; - if (SSCANF(line, "%d\t%%newid%%\n%n", &ad.account_id, &i) == 1 + if (SSCANF(line, "%d\t%%newid%%\n%n"_fmt, &ad.account_id, &i) == 1 && i > 0 && ad.account_id > account_id_count) account_id_count = ad.account_id; else - LOGIN_LOG("Account skipped\n%s", line); + LOGIN_LOG("Account skipped\n%s"_fmt, line); continue; } @@ -602,10 +601,10 @@ int mmo_auth_init(void) account_id_count = ad.account_id + 1; } - AString str = STRPRINTF("%s has %zu accounts (%d GMs)\n", + AString str = STRPRINTF("%s has %zu accounts (%d GMs)\n"_fmt, account_filename, auth_data.size(), gm_count); - PRINTF("%s: %s\n", __PRETTY_FUNCTION__, str); - LOGIN_LOG("%s\n", line); + PRINTF("%s: %s\n"_fmt, __PRETTY_FUNCTION__, str); + LOGIN_LOG("%s\n"_fmt, line); return 0; } @@ -620,30 +619,30 @@ void mmo_auth_sync(void) if (!fp.is_open()) { - PRINTF("uh-oh - unable to save accounts\n"); + PRINTF("uh-oh - unable to save accounts\n"_fmt); return; } FPRINTF(fp, - "// Accounts file: here are saved all information about the accounts.\n"); + "// Accounts file: here are saved all information about the accounts.\n"_fmt); FPRINTF(fp, - "// Structure: ID, account name, password, last login time, sex, # of logins, state, email, error message for state 7, validity time, last (accepted) login ip, memo field, ban timestamp, repeated(register text, register value)\n"); - FPRINTF(fp, "// Some explanations:\n"); + "// Structure: ID, account name, password, last login time, sex, # of logins, state, email, error message for state 7, validity time, last (accepted) login ip, memo field, ban timestamp, repeated(register text, register value)\n"_fmt); + FPRINTF(fp, "// Some explanations:\n"_fmt); FPRINTF(fp, - "// account name : between 4 to 23 char for a normal account (standard client can't send less than 4 char).\n"); - FPRINTF(fp, "// account password: between 4 to 23 char\n"); + "// account name : between 4 to 23 char for a normal account (standard client can't send less than 4 char).\n"_fmt); + FPRINTF(fp, "// account password: between 4 to 23 char\n"_fmt); FPRINTF(fp, - "// sex : M or F for normal accounts, S for server accounts\n"); + "// sex : M or F for normal accounts, S for server accounts\n"_fmt); FPRINTF(fp, - "// state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1\n"); + "// state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1\n"_fmt); FPRINTF(fp, - "// email : between 3 to 39 char (a@a.com is like no email)\n"); + "// email : between 3 to 39 char (a@a.com is like no email)\n"_fmt); FPRINTF(fp, - "// error message : text for the state 7: 'Your are Prohibited to login until '. Max 19 char\n"); + "// error message : text for the state 7: 'Your are Prohibited to login until '. Max 19 char\n"_fmt); FPRINTF(fp, - "// valitidy time : 0: unlimited account, : date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970)\n"); - FPRINTF(fp, "// memo field : max 254 char\n"); + "// valitidy time : 0: unlimited account, : date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970)\n"_fmt); + FPRINTF(fp, "// memo field : max 254 char\n"_fmt); FPRINTF(fp, - "// ban time : 0: no ban, : banned until the date: date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970)\n"); + "// ban time : 0: no ban, : banned until the date: date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970)\n"_fmt); for (const AuthData& ad : auth_data) { if (ad.account_id < 0) @@ -652,7 +651,7 @@ void mmo_auth_sync(void) AString line = mmo_auth_tostr(&ad); fp.put_line(line); } - FPRINTF(fp, "%d\t%%newid%%\n", account_id_count); + FPRINTF(fp, "%d\t%%newid%%\n"_fmt, account_id_count); } // We want to sync the DB to disk as little as possible as it's fairly @@ -767,7 +766,7 @@ int mmo_auth_new(struct mmo_account *account, SEX sex, AccountEmail email) ad.userid = account->userid; ad.pass = MD5_saltcrypt(account->passwd, make_salt()); - ad.lastlogin = stringish("-"); + ad.lastlogin = stringish("-"_s); ad.sex = sex; ad.logincount = 0; ad.state = 0; @@ -777,7 +776,7 @@ int mmo_auth_new(struct mmo_account *account, SEX sex, AccountEmail email) else ad.email = email; - ad.error_message = stringish("-"); + ad.error_message = stringish("-"_s); ad.ban_until_time = TimeT(); if (start_limited_time < 0) @@ -792,7 +791,7 @@ int mmo_auth_new(struct mmo_account *account, SEX sex, AccountEmail email) } ad.last_ip = IP4Address(); - ad.memo = "!"; + ad.memo = "!"_s; ad.account_reg2_num = 0; auth_data.push_back(ad); @@ -811,7 +810,7 @@ int mmo_auth(struct mmo_account *account, Session *s) // Account creation with _M/_F if (account->passwdenc == 0 - && (account->userid.endswith("_F") || account->userid.endswith("_M")) + && (account->userid.endswith("_F"_s) || account->userid.endswith("_M"_s)) && new_account == 1 && account_id_count <= END_ACCOUNT_NUM && (account->userid.size() - 2) >= 4 && account->passwd.size() >= 4) { @@ -827,14 +826,14 @@ int mmo_auth(struct mmo_account *account, Session *s) int encpasswdok = 0; if (new_account_sex) { - LOGIN_LOG("Attempt of creation of an already existant account (account: %s_%c, ip: %s)\n", + LOGIN_LOG("Attempt of creation of an already existant account (account: %s_%c, ip: %s)\n"_fmt, account->userid, new_account_sex, ip); return 9; // 9 = Account already exists } if ((!pass_ok(account->passwd, ad->pass)) && !encpasswdok) { if (account->passwdenc == 0) - LOGIN_LOG("Invalid password (account: %s, ip: %s)\n", + LOGIN_LOG("Invalid password (account: %s, ip: %s)\n"_fmt, account->userid, ip); return 1; // 1 = Incorrect Password @@ -842,7 +841,7 @@ int mmo_auth(struct mmo_account *account, Session *s) if (ad->state) { - LOGIN_LOG("Connection refused (account: %s, state: %d, ip: %s)\n", + LOGIN_LOG("Connection refused (account: %s, state: %d, ip: %s)\n"_fmt, account->userid, ad->state, ip); switch (ad->state) @@ -871,14 +870,14 @@ int mmo_auth(struct mmo_account *account, Session *s) if (ad->ban_until_time > TimeT::now()) { // always banned - LOGIN_LOG("Connection refused (account: %s, banned until %s, ip: %s)\n", + LOGIN_LOG("Connection refused (account: %s, banned until %s, ip: %s)\n"_fmt, account->userid, tmpstr, ip); return 6; // 6 = Your are Prohibited to log in until %s } else { // ban is finished - LOGIN_LOG("End of ban (account: %s, previously banned until %s -> not more banned, ip: %s)\n", + LOGIN_LOG("End of ban (account: %s, previously banned until %s -> not more banned, ip: %s)\n"_fmt, account->userid, tmpstr, ip); ad->ban_until_time = TimeT(); // reset the ban time } @@ -887,26 +886,26 @@ int mmo_auth(struct mmo_account *account, Session *s) if (ad->connect_until_time && ad->connect_until_time < TimeT::now()) { - LOGIN_LOG("Connection refused (account: %s, expired ID, ip: %s)\n", + LOGIN_LOG("Connection refused (account: %s, expired ID, ip: %s)\n"_fmt, account->userid, ip); return 2; // 2 = This ID is expired } - LOGIN_LOG("Authentification accepted (account: %s (id: %d), ip: %s)\n", + LOGIN_LOG("Authentification accepted (account: %s (id: %d), ip: %s)\n"_fmt, account->userid, ad->account_id, ip); } else { if (new_account_sex == '\0') { - LOGIN_LOG("Unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("Unknown account (account: %s, ip: %s)\n"_fmt, account->userid, ip); return 0; // 0 = Unregistered ID } else { int new_id = mmo_auth_new(account, sex_from_char(new_account_sex), DEFAULT_EMAIL); - LOGIN_LOG("Account creation and authentification accepted (account %s (id: %d), sex: %c, connection with _F/_M, ip: %s)\n", + LOGIN_LOG("Account creation and authentification accepted (account %s (id: %d), sex: %c, connection with _F/_M, ip: %s)\n"_fmt, account->userid, new_id, new_account_sex, ip); ad = &auth_data.back(); @@ -936,17 +935,15 @@ void char_anti_freeze_system(TimerData *, tick_t) { int i; - //PRINTF("Entering in char_anti_freeze_system function to check freeze of servers.\n"); for (i = 0; i < MAX_SERVERS; i++) { if (server_session[i]) { // if char-server is online - //PRINTF("char_anti_freeze_system: server #%d '%s', flag: %d.\n", i, server[i].name, server_freezeflag[i]); if (server_freezeflag[i]-- < 1) { // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed - PRINTF("Char-server anti-freeze system: char-server #%d '%s' is freezed -> disconnection.\n", + PRINTF("Char-server anti-freeze system: char-server #%d '%s' is freezed -> disconnection.\n"_fmt, i, server[i].name); - LOGIN_LOG("Char-server anti-freeze system: char-server #%d '%s' is freezed -> disconnection.\n", + LOGIN_LOG("Char-server anti-freeze system: char-server #%d '%s' is freezed -> disconnection.\n"_fmt, i, server[i].name); server_session[i]->eof = 1; } @@ -970,8 +967,8 @@ void parse_fromchar(Session *s) { if (id < MAX_SERVERS) { - PRINTF("Char-server '%s' has disconnected.\n", server[id].name); - LOGIN_LOG("Char-server '%s' has disconnected (ip: %s).\n", + PRINTF("Char-server '%s' has disconnected.\n"_fmt, server[id].name); + LOGIN_LOG("Char-server '%s' has disconnected (ip: %s).\n"_fmt, server[id].name, ip); server_session[id] = nullptr; server[id] = mmo_char_server{}; @@ -983,14 +980,14 @@ void parse_fromchar(Session *s) while (RFIFOREST(s) >= 2) { if (display_parse_fromchar == 2 || (display_parse_fromchar == 1 && RFIFOW(s, 0) != 0x2714)) // 0x2714 is done very often (number of players) - PRINTF("parse_fromchar: connection #%d, packet: 0x%x (with being read: %zu bytes).\n", + PRINTF("parse_fromchar: connection #%d, packet: 0x%x (with being read: %zu bytes).\n"_fmt, s, RFIFOW(s, 0), RFIFOREST(s)); switch (RFIFOW(s, 0)) { // request from map-server via char-server to reload GM accounts (by Yor). case 0x2709: - LOGIN_LOG("Char-server '%s': Request to re-load GM configuration file (ip: %s).\n", + LOGIN_LOG("Char-server '%s': Request to re-load GM configuration file (ip: %s).\n"_fmt, server[id].name, ip); read_gm_account(); // send GM accounts to all char-servers @@ -1016,7 +1013,7 @@ void parse_fromchar(Session *s) { int p; auth_fifo[i].delflag = 1; - LOGIN_LOG("Char-server '%s': authentification of the account %d accepted (ip: %s).\n", + LOGIN_LOG("Char-server '%s': authentification of the account %d accepted (ip: %s).\n"_fmt, server[id].name, acc, ip); for (const AuthData& ad : auth_data) { @@ -1034,7 +1031,6 @@ void parse_fromchar(Session *s) } WFIFOW(s, 2) = p; WFIFOSET(s, p); -// PRINTF("parse_fromchar: Sending of account_reg2: login->char (auth fifo)\n"); WFIFOW(s, 0) = 0x2713; WFIFOL(s, 2) = acc; WFIFOB(s, 6) = 0; @@ -1050,7 +1046,7 @@ void parse_fromchar(Session *s) // authentification not found if (i == AUTH_FIFO_SIZE) { - LOGIN_LOG("Char-server '%s': authentification of the account %d REFUSED (ip: %s).\n", + LOGIN_LOG("Char-server '%s': authentification of the account %d REFUSED (ip: %s).\n"_fmt, server[id].name, acc, ip); WFIFOW(s, 0) = 0x2713; WFIFOL(s, 2) = acc; @@ -1066,7 +1062,6 @@ void parse_fromchar(Session *s) case 0x2714: if (RFIFOREST(s) < 6) return; - //PRINTF("parse_fromchar: Receiving of the users number of the server '%s': %d\n", server[id].name, RFIFOL(fd,2)); server[id].users = RFIFOL(s, 2); if (anti_freeze_enable) server_freezeflag[id] = 5; // Char anti-freeze system. Counter. 5 ok, 4...0 freezed @@ -1081,7 +1076,7 @@ void parse_fromchar(Session *s) int acc = RFIFOL(s, 2); AccountEmail email = stringish(RFIFO_STRING<40>(s, 6)); if (!e_mail_check(email)) - LOGIN_LOG("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", + LOGIN_LOG("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n"_fmt, server[id].name, acc, ip); else { @@ -1091,12 +1086,12 @@ void parse_fromchar(Session *s) && (ad.email == DEFAULT_EMAIL || !ad.email)) { ad.email = email; - LOGIN_LOG("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n"_fmt, server[id].name, acc, email, ip); goto x2715_out; } } - LOGIN_LOG("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n"_fmt, server[id].name, acc, ip); } x2715_out: @@ -1110,12 +1105,11 @@ void parse_fromchar(Session *s) return; { int account_id = RFIFOL(s, 2); - //PRINTF("parse_fromchar: E-mail/limited time request from '%s' server (concerned account: %d)\n", server[id].name, RFIFOL(fd,2)); for (const AuthData& ad : auth_data) { if (ad.account_id == account_id) { - LOGIN_LOG("Char-server '%s': e-mail of the account %d found (ip: %s).\n", + LOGIN_LOG("Char-server '%s': e-mail of the account %d found (ip: %s).\n"_fmt, server[id].name, account_id, ip); WFIFOW(s, 0) = 0x2717; WFIFOL(s, 2) = account_id; @@ -1125,7 +1119,7 @@ void parse_fromchar(Session *s) goto x2716_end; } } - LOGIN_LOG("Char-server '%s': e-mail of the account %d NOT found (ip: %s).\n", + LOGIN_LOG("Char-server '%s': e-mail of the account %d NOT found (ip: %s).\n"_fmt, server[id].name, account_id, ip); } x2716_end: @@ -1139,7 +1133,6 @@ void parse_fromchar(Session *s) int acc; unsigned char buf[10]; acc = RFIFOL(s, 4); - //PRINTF("parse_fromchar: Request to become a GM acount from %d account.\n", acc); WBUFW(buf, 0) = 0x2721; WBUFL(buf, 2) = acc; WBUFL(buf, 6) = 0; @@ -1161,51 +1154,51 @@ void parse_fromchar(Session *s) timestamp_seconds_buffer tmpstr; stamp_time(tmpstr); FPRINTF(fp, - "\n// %s: @GM command on account %d\n%d %d\n", + "\n// %s: @GM command on account %d\n%d %d\n"_fmt, tmpstr, acc, acc, level_new_gm); if (!fp.close()) { - PRINTF("warning: didn't actually save GM file\n"); + PRINTF("warning: didn't actually save GM file\n"_fmt); } WBUFL(buf, 6) = level_new_gm; read_gm_account(); send_GM_accounts(); - PRINTF("GM Change of the account %d: level 0 -> %d.\n", + PRINTF("GM Change of the account %d: level 0 -> %d.\n"_fmt, acc, level_new_gm); - LOGIN_LOG("Char-server '%s': GM Change of the account %d: level 0 -> %d (ip: %s).\n", + LOGIN_LOG("Char-server '%s': GM Change of the account %d: level 0 -> %d (ip: %s).\n"_fmt, server[id].name, acc, level_new_gm, ip); } else { - PRINTF("Error of GM change (suggested account: %d, correct password, unable to add a GM account in GM accounts file)\n", + PRINTF("Error of GM change (suggested account: %d, correct password, unable to add a GM account in GM accounts file)\n"_fmt, acc); - LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d, correct password, unable to add a GM account in GM accounts file, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d, correct password, unable to add a GM account in GM accounts file, ip: %s).\n"_fmt, server[id].name, acc, ip); } } else { - PRINTF("Error of GM change (suggested account: %d, correct password, but GM creation is disable (level_new_gm = 0))\n", + PRINTF("Error of GM change (suggested account: %d, correct password, but GM creation is disable (level_new_gm = 0))\n"_fmt, acc); - LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d, correct password, but GM creation is disable (level_new_gm = 0), ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d, correct password, but GM creation is disable (level_new_gm = 0), ip: %s).\n"_fmt, server[id].name, acc, ip); } } else { - PRINTF("Error of GM change (suggested account: %d (already GM), correct password).\n", + PRINTF("Error of GM change (suggested account: %d (already GM), correct password).\n"_fmt, acc); - LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d (already GM), correct password, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d (already GM), correct password, ip: %s).\n"_fmt, server[id].name, acc, ip); } } else { - PRINTF("Error of GM change (suggested account: %d, invalid password).\n", + PRINTF("Error of GM change (suggested account: %d, invalid password).\n"_fmt, acc); - LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d, invalid password, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d, invalid password, ip: %s).\n"_fmt, server[id].name, acc, ip); } charif_sendallwos(nullptr, buf, 10); @@ -1222,13 +1215,13 @@ void parse_fromchar(Session *s) AccountEmail actual_email = stringish(RFIFO_STRING<40>(s, 6).to_print()); AccountEmail new_email = stringish(RFIFO_STRING<40>(s, 46)); if (!e_mail_check(actual_email)) - LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", + LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n"_fmt, server[id].name, acc, ip); else if (!e_mail_check(new_email)) - LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", + LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n"_fmt, server[id].name, acc, ip); else if (new_email == DEFAULT_EMAIL) - LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", + LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n"_fmt, server[id].name, acc, ip); else { @@ -1239,19 +1232,19 @@ void parse_fromchar(Session *s) if (ad.email == actual_email) { ad.email = new_email; - LOGIN_LOG("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n"_fmt, server[id].name, acc, ad.userid, new_email, ip); } else - LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n"_fmt, server[id].name, acc, ad.userid, ad.email, actual_email, ip); goto x2722_out; } } - LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n"_fmt, server[id].name, acc, ip); } } @@ -1273,7 +1266,7 @@ void parse_fromchar(Session *s) { if (ad.state != statut) { - LOGIN_LOG("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n"_fmt, server[id].name, acc, statut, ip); if (statut != 0) @@ -1291,13 +1284,13 @@ void parse_fromchar(Session *s) ad.state = statut; } else - LOGIN_LOG("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %d, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %d, ip: %s).\n"_fmt, server[id].name, acc, statut, ip); goto x2724_out; } } - LOGIN_LOG("Char-server '%s': Error of Status change (account: %d not found, suggested status %d, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of Status change (account: %d not found, suggested status %d, ip: %s).\n"_fmt, server[id].name, acc, statut, ip); x2724_out: RFIFOSKIP(s, 10); @@ -1343,7 +1336,7 @@ void parse_fromchar(Session *s) timestamp_seconds_buffer tmpstr; if (timestamp) stamp_time(tmpstr, ×tamp); - LOGIN_LOG("Char-server '%s': Ban request (account: %d, new final date of banishment: %lld (%s), ip: %s).\n", + LOGIN_LOG("Char-server '%s': Ban request (account: %d, new final date of banishment: %lld (%s), ip: %s).\n"_fmt, server[id].name, acc, timestamp, tmpstr, @@ -1360,7 +1353,7 @@ void parse_fromchar(Session *s) } else { - LOGIN_LOG("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n"_fmt, server[id].name, acc, ip); } @@ -1368,19 +1361,19 @@ void parse_fromchar(Session *s) } else { - LOGIN_LOG("Char-server '%s': Error of ban request (account: %d, no change for ban date, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of ban request (account: %d, no change for ban date, ip: %s).\n"_fmt, server[id].name, acc, ip); } } else { - LOGIN_LOG("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n"_fmt, server[id].name, acc, ip); } goto x2725_out; } } - LOGIN_LOG("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n"_fmt, server[id].name, acc, ip); x2725_out: RFIFOSKIP(s, 18); @@ -1404,7 +1397,7 @@ void parse_fromchar(Session *s) sex = SEX::MALE; else sex = SEX::FEMALE; - LOGIN_LOG("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n"_fmt, server[id].name, acc, sex_to_char(sex), ip); @@ -1420,7 +1413,7 @@ void parse_fromchar(Session *s) goto x2727_out; } } - LOGIN_LOG("Char-server '%s': Error of sex change (account: %d not found, sex would be reversed, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of sex change (account: %d not found, sex would be reversed, ip: %s).\n"_fmt, server[id].name, acc, ip); x2727_out: RFIFOSKIP(s, 6); @@ -1437,7 +1430,7 @@ void parse_fromchar(Session *s) { if (ad.account_id == acc) { - LOGIN_LOG("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s).\n", + LOGIN_LOG("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s).\n"_fmt, server[id].name, acc, ip); size_t len = RFIFOW(s, 2); int j; @@ -1454,11 +1447,10 @@ void parse_fromchar(Session *s) RFIFO_BUF_CLONE(s, buf, len); WBUFW(buf, 0) = 0x2729; charif_sendallwos(s, buf, WBUFW(buf, 2)); -// PRINTF("parse_fromchar: receiving (from the char-server) of account_reg2 (account id: %d).\n", acc); goto x2728_out; } } - LOGIN_LOG("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", + LOGIN_LOG("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n"_fmt, server[id].name, acc, ip); } x2728_out: @@ -1477,18 +1469,18 @@ void parse_fromchar(Session *s) if (ad.ban_until_time) { ad.ban_until_time = TimeT(); - LOGIN_LOG("Char-server '%s': UnBan request (account: %d, ip: %s).\n", + LOGIN_LOG("Char-server '%s': UnBan request (account: %d, ip: %s).\n"_fmt, server[id].name, acc, ip); } else { - LOGIN_LOG("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s).\n"_fmt, server[id].name, acc, ip); } goto x272a_out; } } - LOGIN_LOG("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s).\n", + LOGIN_LOG("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s).\n"_fmt, server[id].name, acc, ip); x272a_out: RFIFOSKIP(s, 6); @@ -1518,7 +1510,7 @@ void parse_fromchar(Session *s) { status = 1; ad.pass = MD5_saltcrypt(new_pass, make_salt()); - LOGIN_LOG("Char-server '%s': Change pass success (account: %d (%s), ip: %s.\n", + LOGIN_LOG("Char-server '%s': Change pass success (account: %d (%s), ip: %s.\n"_fmt, server[id].name, acc, ad.userid, ip); } @@ -1526,7 +1518,7 @@ void parse_fromchar(Session *s) else { status = 2; - LOGIN_LOG("Char-server '%s': Attempt to modify a pass failed, wrong password. (account: %d (%s), ip: %s).\n", + LOGIN_LOG("Char-server '%s': Attempt to modify a pass failed, wrong password. (account: %d (%s), ip: %s).\n"_fmt, server[id].name, acc, ad.userid, ip); } @@ -1551,30 +1543,30 @@ void parse_fromchar(Session *s) timestamp_milliseconds_buffer timestr; stamp_time(timestr); FPRINTF(logfp, - "%s: receiving of an unknown packet -> disconnection\n", + "%s: receiving of an unknown packet -> disconnection\n"_fmt, timestr); FPRINTF(logfp, - "parse_fromchar: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n", + "parse_fromchar: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n"_fmt, s, ip, RFIFOW(s, 0), RFIFOREST(s)); - FPRINTF(logfp, "Detail (in hex):\n"); + FPRINTF(logfp, "Detail (in hex):\n"_fmt); FPRINTF(logfp, - "---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n"); + "---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n"_fmt); char tmpstr[16 + 1] {}; int i; for (i = 0; i < RFIFOREST(s); i++) { if ((i & 15) == 0) - FPRINTF(logfp, "%04X ", i); - FPRINTF(logfp, "%02x ", RFIFOB(s, i)); + FPRINTF(logfp, "%04X "_fmt, i); + FPRINTF(logfp, "%02x "_fmt, RFIFOB(s, i)); if (RFIFOB(s, i) > 0x1f) tmpstr[i % 16] = RFIFOB(s, i); else tmpstr[i % 16] = '.'; if ((i - 7) % 16 == 0) // -8 + 1 - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); else if ((i + 1) % 16 == 0) { - FPRINTF(logfp, " %s\n", tmpstr); + FPRINTF(logfp, " %s\n"_fmt, tmpstr); std::fill(tmpstr + 0, tmpstr + 17, '\0'); } } @@ -1582,19 +1574,19 @@ void parse_fromchar(Session *s) { for (int j = i; j % 16 != 0; j++) { - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); if ((j - 7) % 16 == 0) // -8 + 1 - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); } - FPRINTF(logfp, " %s\n", tmpstr); + FPRINTF(logfp, " %s\n"_fmt, tmpstr); } - FPRINTF(logfp, "\n"); + FPRINTF(logfp, "\n"_fmt); } } - PRINTF("parse_fromchar: Unknown packet 0x%x (from a char-server)! -> disconnection.\n", + PRINTF("parse_fromchar: Unknown packet 0x%x (from a char-server)! -> disconnection.\n"_fmt, RFIFOW(s, 0)); s->eof = 1; - PRINTF("Char-server has been disconnected (unknown packet).\n"); + PRINTF("Char-server has been disconnected (unknown packet).\n"_fmt); return; } } @@ -1612,7 +1604,7 @@ void parse_admin(Session *s) if (s->eof) { delete_session(s); - PRINTF("Remote administration has disconnected (session #%d).\n", + PRINTF("Remote administration has disconnected (session #%d).\n"_fmt, s); return; } @@ -1620,13 +1612,13 @@ void parse_admin(Session *s) while (RFIFOREST(s) >= 2) { if (display_parse_admin == 1) - PRINTF("parse_admin: connection #%d, packet: 0x%x (with being read: %zu).\n", + PRINTF("parse_admin: connection #%d, packet: 0x%x (with being read: %zu).\n"_fmt, s, RFIFOW(s, 0), RFIFOREST(s)); switch (RFIFOW(s, 0)) { case 0x7530: // Request of the server version - LOGIN_LOG("'ladmin': Sending of the server version (ip: %s)\n", + LOGIN_LOG("'ladmin': Sending of the server version (ip: %s)\n"_fmt, ip); WFIFOW(s, 0) = 0x7531; WFIFO_STRUCT(s, 2, CURRENT_LOGIN_SERVER_VERSION); @@ -1635,7 +1627,7 @@ void parse_admin(Session *s) break; case 0x7532: // Request of end of connection - LOGIN_LOG("'ladmin': End of connection (ip: %s)\n", + LOGIN_LOG("'ladmin': End of connection (ip: %s)\n"_fmt, ip); RFIFOSKIP(s, 2); s->eof = 1; @@ -1654,7 +1646,7 @@ void parse_admin(Session *s) st = 0; if (ed > END_ACCOUNT_NUM || ed < st || ed <= 0) ed = END_ACCOUNT_NUM; - LOGIN_LOG("'ladmin': Sending an accounts list (ask: from %d to %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Sending an accounts list (ask: from %d to %d, ip: %s)\n"_fmt, st, ed, ip); // Sending accounts information len = 4; @@ -1703,24 +1695,24 @@ void parse_admin(Session *s) struct mmo_account ma; ma.userid = stringish(RFIFO_STRING<24>(s, 2).to_print()); ma.passwd = stringish(RFIFO_STRING<24>(s, 26).to_print()); - ma.lastlogin = stringish("-"); + ma.lastlogin = stringish("-"_s); ma.sex = sex_from_char(RFIFOB(s, 50)); WFIFOW(s, 0) = 0x7931; WFIFOL(s, 2) = -1; WFIFO_STRING(s, 6, ma.userid, 24); if (ma.userid.size() < 4 || ma.passwd.size() < 4) { - LOGIN_LOG("'ladmin': Attempt to create an invalid account (account or pass is too short, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to create an invalid account (account or pass is too short, ip: %s)\n"_fmt, ip); } else if (ma.sex != SEX::FEMALE && ma.sex != SEX::MALE) { - LOGIN_LOG("'ladmin': Attempt to create an invalid account (account: %s, invalid sex, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to create an invalid account (account: %s, invalid sex, ip: %s)\n"_fmt, ma.userid, ip); } else if (account_id_count > END_ACCOUNT_NUM) { - LOGIN_LOG("'ladmin': Attempt to create an account, but there is no more available id number (account: %s, sex: %c, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to create an account, but there is no more available id number (account: %s, sex: %c, ip: %s)\n"_fmt, ma.userid, ma.sex, ip); } else @@ -1729,7 +1721,7 @@ void parse_admin(Session *s) { if (ad.userid == ma.userid) { - LOGIN_LOG("'ladmin': Attempt to create an already existing account (account: %s ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to create an already existing account (account: %s ip: %s)\n"_fmt, ad.userid, ip); goto x7930_out; } @@ -1737,7 +1729,7 @@ void parse_admin(Session *s) { AccountEmail email = stringish(RFIFO_STRING<40>(s, 51)); int new_id = mmo_auth_new(&ma, ma.sex, email); - LOGIN_LOG("'ladmin': Account creation (account: %s (id: %d), sex: %c, email: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Account creation (account: %s (id: %d), sex: %c, email: %s, ip: %s)\n"_fmt, ma.userid, new_id, ma.sex, auth_data.back().email, ip); WFIFOL(s, 2) = new_id; @@ -1768,12 +1760,12 @@ void parse_admin(Session *s) WFIFO_STRING(s, 6, ad->userid, 24); WFIFOL(s, 2) = ad->account_id; // save deleted account in log file - LOGIN_LOG("'ladmin': Account deletion (account: %s, id: %d, ip: %s) - saved in next line:\n", + LOGIN_LOG("'ladmin': Account deletion (account: %s, id: %d, ip: %s) - saved in next line:\n"_fmt, ad->userid, ad->account_id, ip); { AString buf2 = mmo_auth_tostr(ad); - LOGIN_LOG("%s\n", buf2); + LOGIN_LOG("%s\n"_fmt, buf2); } // delete account ad->userid = AccountName(); @@ -1782,7 +1774,7 @@ void parse_admin(Session *s) else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to delete an unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to delete an unknown account (account: %s, ip: %s)\n"_fmt, account_name, ip); } WFIFOSET(s, 30); @@ -1804,13 +1796,13 @@ void parse_admin(Session *s) AccountPass plain = stringish(RFIFO_STRING<24>(s, 26)); ad->pass = MD5_saltcrypt(plain, make_salt()); WFIFOL(s, 2) = ad->account_id; - LOGIN_LOG("'ladmin': Modification of a password (account: %s, new password: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of a password (account: %s, new password: %s, ip: %s)\n"_fmt, ad->userid, ad->pass, ip); } else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to modify the password of an unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify the password of an unknown account (account: %s, ip: %s)\n"_fmt, account_name, ip); } WFIFOSET(s, 30); @@ -1830,7 +1822,7 @@ void parse_admin(Session *s) if (statut != 7 || !error_message) { // 7: // 6 = Your are Prohibited to log in until %s - error_message = stringish("-"); + error_message = stringish("-"_s); } AuthData *ad = search_account(account_name); if (ad) @@ -1839,16 +1831,16 @@ void parse_admin(Session *s) WFIFOL(s, 2) = ad->account_id; if (ad->state == statut && ad->error_message == error_message) - LOGIN_LOG("'ladmin': Modification of a state, but the state of the account is already the good state (account: %s, received state: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of a state, but the state of the account is already the good state (account: %s, received state: %d, ip: %s)\n"_fmt, account_name, statut, ip); else { if (statut == 7) - LOGIN_LOG("'ladmin': Modification of a state (account: %s, new state: %d - prohibited to login until '%s', ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of a state (account: %s, new state: %d - prohibited to login until '%s', ip: %s)\n"_fmt, ad->userid, statut, error_message, ip); else - LOGIN_LOG("'ladmin': Modification of a state (account: %s, new state: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of a state (account: %s, new state: %d, ip: %s)\n"_fmt, ad->userid, statut, ip); if (ad->state == 0) { @@ -1870,7 +1862,7 @@ void parse_admin(Session *s) else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to modify the state of an unknown account (account: %s, received state: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify the state of an unknown account (account: %s, received state: %d, ip: %s)\n"_fmt, account_name, statut, ip); } WFIFOL(s, 30) = statut; @@ -1880,7 +1872,7 @@ void parse_admin(Session *s) break; case 0x7938: // Request for servers list and # of online players - LOGIN_LOG("'ladmin': Sending of servers list (ip: %s)\n", ip); + LOGIN_LOG("'ladmin': Sending of servers list (ip: %s)\n"_fmt, ip); server_num = 0; for (int i = 0; i < MAX_SERVERS; i++) { @@ -1916,20 +1908,20 @@ void parse_admin(Session *s) if (pass_ok(pass, ad->pass)) { WFIFOL(s, 2) = ad->account_id; - LOGIN_LOG("'ladmin': Check of password OK (account: %s, password: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Check of password OK (account: %s, password: %s, ip: %s)\n"_fmt, ad->userid, ad->pass, ip); } else { - LOGIN_LOG("'ladmin': Failure of password check (account: %s, proposed pass: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Failure of password check (account: %s, proposed pass: %s, ip: %s)\n"_fmt, ad->userid, pass.to_print(), ip); } } else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to check the password of an unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to check the password of an unknown account (account: %s, ip: %s)\n"_fmt, account_name, ip); } WFIFOSET(s, 30); @@ -1949,7 +1941,7 @@ void parse_admin(Session *s) SEX sex = sex_from_char(RFIFOB(s, 26)); if (sex != SEX::FEMALE && sex != SEX::MALE) { - LOGIN_LOG("'ladmin': Attempt to give an invalid sex (account: %s, received sex: %c, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to give an invalid sex (account: %s, received sex: %c, ip: %s)\n"_fmt, account_name, sex_to_char(sex), ip); } else @@ -1967,7 +1959,7 @@ void parse_admin(Session *s) ad->account_id) auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification) ad->sex = sex; - LOGIN_LOG("'ladmin': Modification of a sex (account: %s, new sex: %c, ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of a sex (account: %s, new sex: %c, ip: %s)\n"_fmt, ad->userid, sex_to_char(sex), ip); // send to all char-server the change WBUFW(buf, 0) = 0x2723; @@ -1977,13 +1969,13 @@ void parse_admin(Session *s) } else { - LOGIN_LOG("'ladmin': Modification of a sex, but the sex is already the good sex (account: %s, sex: %c, ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of a sex, but the sex is already the good sex (account: %s, sex: %c, ip: %s)\n"_fmt, ad->userid, sex_to_char(sex), ip); } } else { - LOGIN_LOG("'ladmin': Attempt to modify the sex of an unknown account (account: %s, received sex: %c, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify the sex of an unknown account (account: %s, received sex: %c, ip: %s)\n"_fmt, account_name, sex_to_char(sex), ip); } } @@ -2007,7 +1999,7 @@ void parse_admin(Session *s) new_gm_level = RFIFOB(s, 26); if (new_gm_level < 0 || new_gm_level > 99) { - LOGIN_LOG("'ladmin': Attempt to give an invalid GM level (account: %s, received GM level: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to give an invalid GM level (account: %s, received GM level: %d, ip: %s)\n"_fmt, account_name, new_gm_level, ip); } else @@ -2046,7 +2038,7 @@ void parse_admin(Session *s) else if (new_gm_level == 0) { FPRINTF(fp2, - "// %s: 'ladmin' GM level removed on account %d '%s' (previous level: %d)\n//%d %d\n", + "// %s: 'ladmin' GM level removed on account %d '%s' (previous level: %d)\n//%d %d\n"_fmt, tmpstr, acc, ad->userid, @@ -2057,7 +2049,7 @@ void parse_admin(Session *s) else { FPRINTF(fp2, - "// %s: 'ladmin' GM level on account %d '%s' (previous level: %d)\n%d %d\n", + "// %s: 'ladmin' GM level on account %d '%s' (previous level: %d)\n%d %d\n"_fmt, tmpstr, acc, ad->userid, @@ -2069,40 +2061,40 @@ void parse_admin(Session *s) } if (modify_flag == 0) FPRINTF(fp2, - "// %s: 'ladmin' GM level on account %d '%s' (previous level: 0)\n%d %d\n", + "// %s: 'ladmin' GM level on account %d '%s' (previous level: 0)\n%d %d\n"_fmt, tmpstr, acc, ad->userid, acc, new_gm_level); } else { - LOGIN_LOG("'ladmin': Attempt to modify of a GM level - impossible to read GM accounts file (account: %s (%d), received GM level: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify of a GM level - impossible to read GM accounts file (account: %s (%d), received GM level: %d, ip: %s)\n"_fmt, ad->userid, acc, new_gm_level, ip); } WFIFOL(s, 2) = acc; - LOGIN_LOG("'ladmin': Modification of a GM level (account: %s (%d), new GM level: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of a GM level (account: %s (%d), new GM level: %d, ip: %s)\n"_fmt, ad->userid, acc, new_gm_level, ip); reread = true; } else { - LOGIN_LOG("'ladmin': Attempt to modify of a GM level - impossible to write GM accounts file (account: %s (%d), received GM level: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify of a GM level - impossible to write GM accounts file (account: %s (%d), received GM level: %d, ip: %s)\n"_fmt, ad->userid, acc, new_gm_level, ip); } } else { - LOGIN_LOG("'ladmin': Attempt to modify of a GM level, but the GM level is already the good GM level (account: %s (%d), GM level: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify of a GM level, but the GM level is already the good GM level (account: %s (%d), GM level: %d, ip: %s)\n"_fmt, ad->userid, acc, new_gm_level, ip); } } else { - LOGIN_LOG("'ladmin': Attempt to modify the GM level of an unknown account (account: %s, received GM level: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify the GM level of an unknown account (account: %s, received GM level: %d, ip: %s)\n"_fmt, account_name, new_gm_level, ip); } @@ -2131,7 +2123,7 @@ void parse_admin(Session *s) AccountEmail email = stringish(RFIFO_STRING<40>(s, 26)); if (!e_mail_check(email)) { - LOGIN_LOG("'ladmin': Attempt to give an invalid e-mail (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to give an invalid e-mail (account: %s, ip: %s)\n"_fmt, account_name, ip); } else @@ -2142,12 +2134,12 @@ void parse_admin(Session *s) WFIFO_STRING(s, 6, ad->userid, 24); ad->email = email; WFIFOL(s, 2) = ad->account_id; - LOGIN_LOG("'ladmin': Modification of an email (account: %s, new e-mail: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of an email (account: %s, new e-mail: %s, ip: %s)\n"_fmt, ad->userid, email, ip); } else { - LOGIN_LOG("'ladmin': Attempt to modify the e-mail of an unknown account (account: %s, received e-mail: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify the e-mail of an unknown account (account: %s, received e-mail: %s, ip: %s)\n"_fmt, account_name, email, ip); } } @@ -2169,10 +2161,10 @@ void parse_admin(Session *s) if (ad) { WFIFO_STRING(s, 6, ad->userid, 24); - ad->memo = ""; + ad->memo = ""_s; if (RFIFOW(s, 26) == 0) { - ad->memo = "!"; + ad->memo = "!"_s; } else { @@ -2182,13 +2174,13 @@ void parse_admin(Session *s) } ad->memo = ad->memo.to_print(); WFIFOL(s, 2) = ad->account_id; - LOGIN_LOG("'ladmin': Modification of a memo field (account: %s, new memo: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Modification of a memo field (account: %s, new memo: %s, ip: %s)\n"_fmt, ad->userid, ad->memo, ip); } else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to modify the memo field of an unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to modify the memo field of an unknown account (account: %s, ip: %s)\n"_fmt, account_name, ip); } WFIFOSET(s, 30); @@ -2208,14 +2200,14 @@ void parse_admin(Session *s) { WFIFO_STRING(s, 6, ad->userid, 24); WFIFOL(s, 2) = ad->account_id; - LOGIN_LOG("'ladmin': Request (by the name) of an account id (account: %s, id: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Request (by the name) of an account id (account: %s, id: %d, ip: %s)\n"_fmt, ad->userid, ad->account_id, ip); } else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': ID request (by the name) of an unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': ID request (by the name) of an unknown account (account: %s, ip: %s)\n"_fmt, account_name, ip); } WFIFOSET(s, 30); @@ -2236,14 +2228,14 @@ void parse_admin(Session *s) if (ad.account_id == account_id) { WFIFO_STRING(s, 6, ad.userid, 24); - LOGIN_LOG("'ladmin': Request (by id) of an account name (account: %s, id: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Request (by id) of an account name (account: %s, id: %d, ip: %s)\n"_fmt, ad.userid, account_id, ip); goto x7946_out; } } - LOGIN_LOG("'ladmin': Name request (by id) of an unknown account (id: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Name request (by id) of an unknown account (id: %d, ip: %s)\n"_fmt, account_id, ip); - WFIFO_STRING(s, 6, "", 24); + WFIFO_STRING(s, 6, ""_s, 24); x7946_out: WFIFOSET(s, 30); } @@ -2258,14 +2250,14 @@ void parse_admin(Session *s) WFIFOL(s, 2) = -1; AccountName account_name = stringish(RFIFO_STRING<24>(s, 2).to_print()); TimeT timestamp = static_cast(RFIFOL(s, 26)); - timestamp_seconds_buffer tmpstr = stringish("unlimited"); + timestamp_seconds_buffer tmpstr = stringish("unlimited"_s); if (timestamp) stamp_time(tmpstr, ×tamp); AuthData *ad = search_account(account_name); if (ad) { WFIFO_STRING(s, 6, ad->userid, 24); - LOGIN_LOG("'ladmin': Change of a validity limit (account: %s, new validity: %lld (%s), ip: %s)\n", + LOGIN_LOG("'ladmin': Change of a validity limit (account: %s, new validity: %lld (%s), ip: %s)\n"_fmt, ad->userid, timestamp, tmpstr, @@ -2276,7 +2268,7 @@ void parse_admin(Session *s) else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to change the validity limit of an unknown account (account: %s, received validity: %lld (%s), ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to change the validity limit of an unknown account (account: %s, received validity: %lld (%s), ip: %s)\n"_fmt, account_name, timestamp, tmpstr, @@ -2298,7 +2290,7 @@ void parse_admin(Session *s) TimeT timestamp = static_cast(RFIFOL(s, 26)); if (timestamp <= TimeT::now()) timestamp = TimeT(); - timestamp_seconds_buffer tmpstr = stringish("no banishment"); + timestamp_seconds_buffer tmpstr = stringish("no banishment"_s); if (timestamp) stamp_time(tmpstr, ×tamp); AuthData *ad = search_account(account_name); @@ -2306,7 +2298,7 @@ void parse_admin(Session *s) { WFIFO_STRING(s, 6, ad->userid, 24); WFIFOL(s, 2) = ad->account_id; - LOGIN_LOG("'ladmin': Change of the final date of a banishment (account: %s, new final date of banishment: %lld (%s), ip: %s)\n", + LOGIN_LOG("'ladmin': Change of the final date of a banishment (account: %s, new final date of banishment: %lld (%s), ip: %s)\n"_fmt, ad->userid, timestamp, tmpstr, ip); @@ -2331,7 +2323,7 @@ void parse_admin(Session *s) else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to change the final date of a banishment of an unknown account (account: %s, received final date of banishment: %lld (%s), ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to change the final date of a banishment of an unknown account (account: %s, received final date of banishment: %lld (%s), ip: %s)\n"_fmt, account_name, timestamp, tmpstr, ip); @@ -2375,10 +2367,10 @@ void parse_admin(Session *s) { if (timestamp <= now) timestamp = TimeT(); - timestamp_seconds_buffer tmpstr = stringish("no banishment"); + timestamp_seconds_buffer tmpstr = stringish("no banishment"_s); if (timestamp) stamp_time(tmpstr, ×tamp); - LOGIN_LOG("'ladmin': Adjustment of a final date of a banishment (account: %s, (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %lld (%s), ip: %s)\n", + LOGIN_LOG("'ladmin': Adjustment of a final date of a banishment (account: %s, (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %lld (%s), ip: %s)\n"_fmt, ad->userid, ban_diff.year, ban_diff.month, ban_diff.day, ban_diff.hour, @@ -2406,10 +2398,10 @@ void parse_admin(Session *s) } else { - timestamp_seconds_buffer tmpstr = stringish("no banishment"); + timestamp_seconds_buffer tmpstr = stringish("no banishment"_s); if (ad->ban_until_time) stamp_time(tmpstr, &ad->ban_until_time); - LOGIN_LOG("'ladmin': Impossible to adjust the final date of a banishment (account: %s, %lld (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n", + LOGIN_LOG("'ladmin': Impossible to adjust the final date of a banishment (account: %s, %lld (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n"_fmt, ad->userid, ad->ban_until_time, tmpstr, @@ -2423,7 +2415,7 @@ void parse_admin(Session *s) else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to adjust the final date of a banishment of an unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to adjust the final date of a banishment of an unknown account (account: %s, ip: %s)\n"_fmt, account_name, ip); WFIFOL(s, 30) = 0; } @@ -2440,7 +2432,7 @@ void parse_admin(Session *s) WFIFOW(s, 2) = -1; if (RFIFOL(s, 4) < 1) { - LOGIN_LOG("'ladmin': Receiving a message for broadcast, but message is void (ip: %s)\n", + LOGIN_LOG("'ladmin': Receiving a message for broadcast, but message is void (ip: %s)\n"_fmt, ip); } else @@ -2449,7 +2441,7 @@ void parse_admin(Session *s) for (int i = 0; i < MAX_SERVERS; i++) if (server_session[i]) goto x794e_have_server; - LOGIN_LOG("'ladmin': Receiving a message for broadcast, but no char-server is online (ip: %s)\n", + LOGIN_LOG("'ladmin': Receiving a message for broadcast, but no char-server is online (ip: %s)\n"_fmt, ip); goto x794e_have_no_server; { @@ -2459,7 +2451,7 @@ void parse_admin(Session *s) size_t len = RFIFOL(s, 4); AString message = RFIFO_STRING(s, 8, len).to_print(); - LOGIN_LOG("'ladmin': Receiving a message for broadcast (message: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Receiving a message for broadcast (message: %s, ip: %s)\n"_fmt, message, ip); // send same message to all char-servers (no answer) uint8_t buf[len + 8]; @@ -2487,7 +2479,7 @@ void parse_admin(Session *s) WFIFO_STRING(s, 6, ad->userid, 24); if (add_to_unlimited_account == 0 && !ad->connect_until_time) { - LOGIN_LOG("'ladmin': Attempt to adjust the validity limit of an unlimited account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to adjust the validity limit of an unlimited account (account: %s, ip: %s)\n"_fmt, ad->userid, ip); WFIFOL(s, 30) = 0; } @@ -2509,13 +2501,13 @@ void parse_admin(Session *s) timestamp = tmtime; if (timestamp.okay()) { - timestamp_seconds_buffer tmpstr = stringish("unlimited"); - timestamp_seconds_buffer tmpstr2 = stringish("unlimited"); + timestamp_seconds_buffer tmpstr = stringish("unlimited"_s); + timestamp_seconds_buffer tmpstr2 = stringish("unlimited"_s); if (ad->connect_until_time) stamp_time(tmpstr, &ad->connect_until_time); if (timestamp) stamp_time(tmpstr2, ×tamp); - LOGIN_LOG("'ladmin': Adjustment of a validity limit (account: %s, %lld (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %lld (%s), ip: %s)\n", + LOGIN_LOG("'ladmin': Adjustment of a validity limit (account: %s, %lld (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %lld (%s), ip: %s)\n"_fmt, ad->userid, ad->connect_until_time, tmpstr, @@ -2533,10 +2525,10 @@ void parse_admin(Session *s) } else { - timestamp_seconds_buffer tmpstr = stringish("unlimited"); + timestamp_seconds_buffer tmpstr = stringish("unlimited"_s); if (ad->connect_until_time) stamp_time(tmpstr, &ad->connect_until_time); - LOGIN_LOG("'ladmin': Impossible to adjust a validity limit (account: %s, %lld (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n", + LOGIN_LOG("'ladmin': Impossible to adjust a validity limit (account: %s, %lld (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)\n"_fmt, ad->userid, ad->connect_until_time, tmpstr, @@ -2554,7 +2546,7 @@ void parse_admin(Session *s) else { WFIFO_STRING(s, 6, account_name, 24); - LOGIN_LOG("'ladmin': Attempt to adjust the validity limit of an unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to adjust the validity limit of an unknown account (account: %s, ip: %s)\n"_fmt, account_name, ip); WFIFOL(s, 30) = 0; } @@ -2588,7 +2580,7 @@ void parse_admin(Session *s) size_t len = ad->memo.size() + 1; WFIFOW(s, 148) = len; WFIFO_STRING(s, 150, ad->memo, len); - LOGIN_LOG("'ladmin': Sending information of an account (request by the name; account: %s, id: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Sending information of an account (request by the name; account: %s, id: %d, ip: %s)\n"_fmt, ad->userid, ad->account_id, ip); WFIFOSET(s, 150 + len); @@ -2597,7 +2589,7 @@ void parse_admin(Session *s) { WFIFO_STRING(s, 7, account_name, 24); WFIFOW(s, 148) = 0; - LOGIN_LOG("'ladmin': Attempt to obtain information (by the name) of an unknown account (account: %s, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to obtain information (by the name) of an unknown account (account: %s, ip: %s)\n"_fmt, account_name, ip); WFIFOSET(s, 150); } @@ -2617,7 +2609,7 @@ void parse_admin(Session *s) { if (ad.account_id == account_id) { - LOGIN_LOG("'ladmin': Sending information of an account (request by the id; account: %s, id: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Sending information of an account (request by the id; account: %s, id: %d, ip: %s)\n"_fmt, ad.userid, RFIFOL(s, 2), ip); WFIFOB(s, 6) = isGM(ad.account_id); WFIFO_STRING(s, 7, ad.userid, 24); @@ -2638,9 +2630,9 @@ void parse_admin(Session *s) } } { - LOGIN_LOG("'ladmin': Attempt to obtain information (by the id) of an unknown account (id: %d, ip: %s)\n", + LOGIN_LOG("'ladmin': Attempt to obtain information (by the id) of an unknown account (id: %d, ip: %s)\n"_fmt, RFIFOL(s, 2), ip); - WFIFO_STRING(s, 7, "", 24); + WFIFO_STRING(s, 7, ""_s, 24); WFIFOW(s, 148) = 0; WFIFOSET(s, 150); } @@ -2650,7 +2642,7 @@ void parse_admin(Session *s) break; case 0x7955: // Request to reload GM file (no answer) - LOGIN_LOG("'ladmin': Request to re-load GM configuration file (ip: %s).\n", + LOGIN_LOG("'ladmin': Request to re-load GM configuration file (ip: %s).\n"_fmt, ip); read_gm_account(); // send GM accounts to all char-servers @@ -2666,30 +2658,30 @@ void parse_admin(Session *s) timestamp_milliseconds_buffer timestr; stamp_time(timestr); FPRINTF(logfp, - "%s: receiving of an unknown packet -> disconnection\n", + "%s: receiving of an unknown packet -> disconnection\n"_fmt, timestr); FPRINTF(logfp, - "parse_admin: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n", + "parse_admin: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n"_fmt, s, ip, RFIFOW(s, 0), RFIFOREST(s)); - FPRINTF(logfp, "Detail (in hex):\n"); + FPRINTF(logfp, "Detail (in hex):\n"_fmt); FPRINTF(logfp, - "---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n"); + "---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n"_fmt); char tmpstr[16 + 1] {}; int i; for (i = 0; i < RFIFOREST(s); i++) { if ((i & 15) == 0) - FPRINTF(logfp, "%04X ", i); - FPRINTF(logfp, "%02x ", RFIFOB (s, i)); + FPRINTF(logfp, "%04X "_fmt, i); + FPRINTF(logfp, "%02x "_fmt, RFIFOB (s, i)); if (RFIFOB(s, i) > 0x1f) tmpstr[i % 16] = RFIFOB(s, i); else tmpstr[i % 16] = '.'; if ((i - 7) % 16 == 0) // -8 + 1 - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); else if ((i + 1) % 16 == 0) { - FPRINTF(logfp, " %s\n", tmpstr); + FPRINTF(logfp, " %s\n"_fmt, tmpstr); std::fill(tmpstr + 0, tmpstr + 17, '\0'); } } @@ -2697,19 +2689,19 @@ void parse_admin(Session *s) { for (int j = i; j % 16 != 0; j++) { - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); if ((j - 7) % 16 == 0) // -8 + 1 - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); } - FPRINTF(logfp, " %s\n", tmpstr); + FPRINTF(logfp, " %s\n"_fmt, tmpstr); } - FPRINTF(logfp, "\n"); + FPRINTF(logfp, "\n"_fmt); } } - LOGIN_LOG("'ladmin': End of connection, unknown packet (ip: %s)\n", + LOGIN_LOG("'ladmin': End of connection, unknown packet (ip: %s)\n"_fmt, ip); s->eof = 1; - PRINTF("Remote administration has been disconnected (unknown packet).\n"); + PRINTF("Remote administration has been disconnected (unknown packet).\n"_fmt); return; } //WFIFOW(fd,0) = 0x791f; @@ -2726,7 +2718,7 @@ bool lan_ip_check(IP4Address p) { bool lancheck = lan_subnet.covers(p); - PRINTF("LAN test (result): %s.\n", + PRINTF("LAN test (result): %s.\n"_fmt, (lancheck) ? SGR_BOLD SGR_CYAN "LAN source" SGR_RESET : SGR_BOLD SGR_GREEN "WAN source" SGR_RESET); return lancheck; } @@ -2757,7 +2749,7 @@ void parse_login(Session *s) if (RFIFOREST(s) >= ((RFIFOW(s, 0) == 0x64) ? 55 : 47)) { AccountName account_name = stringish(RFIFO_STRING<24>(s, 6)); - PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu), account: %s.\n", + PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu), account: %s.\n"_fmt, s, RFIFOW(s, 0), RFIFOREST(s), account_name); } @@ -2767,13 +2759,13 @@ void parse_login(Session *s) if (RFIFOREST(s) >= 86) { ServerName server_name = stringish(RFIFO_STRING<20>(s, 60)); - PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu), server: %s.\n", + PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu), server: %s.\n"_fmt, s, RFIFOW(s, 0), RFIFOREST(s), server_name); } } else - PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu).\n", + PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu).\n"_fmt, s, RFIFOW(s, 0), RFIFOREST(s)); } @@ -2799,12 +2791,12 @@ void parse_login(Session *s) account.passwd = stringish(RFIFO_STRING<24>(s, 30).to_print()); account.passwdenc = 0; - LOGIN_LOG("Request for connection (non encryption mode) of %s (ip: %s).\n", + LOGIN_LOG("Request for connection (non encryption mode) of %s (ip: %s).\n"_fmt, account.userid, ip); if (!check_ip(ip)) { - LOGIN_LOG("Connection refused: IP isn't authorised (deny/allow, ip: %s).\n", + LOGIN_LOG("Connection refused: IP isn't authorised (deny/allow, ip: %s).\n"_fmt, ip); WFIFOW(s, 0) = 0x6a; WFIFOB(s, 2) = 0x03; @@ -2827,7 +2819,7 @@ void parse_login(Session *s) int gm_level = isGM(account.account_id); if (min_level_to_connect > gm_level) { - LOGIN_LOG("Connection refused: the minimum GM level for connection is %d (account: %s, GM level: %d, ip: %s).\n", + LOGIN_LOG("Connection refused: the minimum GM level for connection is %d (account: %s, GM level: %d, ip: %s).\n"_fmt, min_level_to_connect, account.userid, gm_level, ip); WFIFOW(s, 0) = 0x81; @@ -2839,10 +2831,10 @@ void parse_login(Session *s) // int version_2 = RFIFOB(fd, 54); // version 2 if (gm_level) - PRINTF("Connection of the GM (level:%d) account '%s' accepted.\n", + PRINTF("Connection of the GM (level:%d) account '%s' accepted.\n"_fmt, gm_level, account.userid); else - PRINTF("Connection of the account '%s' accepted.\n", + PRINTF("Connection of the account '%s' accepted.\n"_fmt, account.userid); /* @@ -2916,7 +2908,7 @@ void parse_login(Session *s) } else { - LOGIN_LOG("Connection refused: there is no char-server online (account: %s, ip: %s).\n", + LOGIN_LOG("Connection refused: there is no char-server online (account: %s, ip: %s).\n"_fmt, account.userid, ip); WFIFOW(s, 0) = 0x81; WFIFOB(s, 2) = 1; // 01 = Server closed @@ -2962,7 +2954,7 @@ void parse_login(Session *s) account.passwd = stringish(RFIFO_STRING<24>(s, 26).to_print()); account.passwdenc = 0; ServerName server_name = stringish(RFIFO_STRING<20>(s, 60).to_print()); - LOGIN_LOG("Connection request of the char-server '%s' @ %s:%d (ip: %s)\n", + LOGIN_LOG("Connection request of the char-server '%s' @ %s:%d (ip: %s)\n"_fmt, server_name, RFIFOIP(s, 54), RFIFOW(s, 58), ip); if (account.userid == userid && account.passwd == passwd) { @@ -2990,10 +2982,10 @@ void parse_login(Session *s) { x2710_okay: - LOGIN_LOG("Connection of the char-server '%s' accepted (account: %s, pass: %s, ip: %s)\n", + LOGIN_LOG("Connection of the char-server '%s' accepted (account: %s, pass: %s, ip: %s)\n"_fmt, server_name, account.userid, account.passwd, ip); - PRINTF("Connection of the char-server '%s' accepted.\n", + PRINTF("Connection of the char-server '%s' accepted.\n"_fmt, server_name); server[account.account_id] = mmo_char_server{}; server[account.account_id].ip = RFIFOIP(s, 54); @@ -3027,7 +3019,7 @@ void parse_login(Session *s) } { x2710_refused: - LOGIN_LOG("Connexion of the char-server '%s' REFUSED (account: %s, pass: %s, ip: %s)\n", + LOGIN_LOG("Connexion of the char-server '%s' REFUSED (account: %s, pass: %s, ip: %s)\n"_fmt, server_name, account.userid, account.passwd, ip); WFIFOW(s, 0) = 0x2711; @@ -3040,7 +3032,7 @@ void parse_login(Session *s) return; case 0x7530: // Request of the server version - LOGIN_LOG("Sending of the server version (ip: %s)\n", + LOGIN_LOG("Sending of the server version (ip: %s)\n"_fmt, ip); WFIFOW(s, 0) = 0x7531; { @@ -3053,7 +3045,7 @@ void parse_login(Session *s) break; case 0x7532: // Request to end connection - LOGIN_LOG("End of connection (ip: %s)\n", ip); + LOGIN_LOG("End of connection (ip: %s)\n"_fmt, ip); s->eof = 1; return; @@ -3065,7 +3057,7 @@ void parse_login(Session *s) WFIFOB(s, 2) = 1; if (!check_ladminip(s->client_ip)) { - LOGIN_LOG("'ladmin'-login: Connection in administration mode refused: IP isn't authorised (ladmin_allow, ip: %s).\n", + LOGIN_LOG("'ladmin'-login: Connection in administration mode refused: IP isn't authorised (ladmin_allow, ip: %s).\n"_fmt, ip); } else @@ -3078,24 +3070,24 @@ void parse_login(Session *s) if ((admin_state == 1) && (password == admin_pass)) { - LOGIN_LOG("'ladmin'-login: Connection in administration mode accepted (non encrypted password: %s, ip: %s)\n", + LOGIN_LOG("'ladmin'-login: Connection in administration mode accepted (non encrypted password: %s, ip: %s)\n"_fmt, password, ip); - PRINTF("Connection of a remote administration accepted (non encrypted password).\n"); + PRINTF("Connection of a remote administration accepted (non encrypted password).\n"_fmt); WFIFOB(s, 2) = 0; s->func_parse = parse_admin; } else if (admin_state != 1) - LOGIN_LOG("'ladmin'-login: Connection in administration mode REFUSED - remote administration is disabled (non encrypted password: %s, ip: %s)\n", + LOGIN_LOG("'ladmin'-login: Connection in administration mode REFUSED - remote administration is disabled (non encrypted password: %s, ip: %s)\n"_fmt, password, ip); else - LOGIN_LOG("'ladmin'-login: Connection in administration mode REFUSED - invalid password (non encrypted password: %s, ip: %s)\n", + LOGIN_LOG("'ladmin'-login: Connection in administration mode REFUSED - invalid password (non encrypted password: %s, ip: %s)\n"_fmt, password, ip); } else { // encrypted password { - LOGIN_LOG("'ladmin'-login: Connection in administration mode REFUSED - encrypted login is disabled (ip: %s)\n", + LOGIN_LOG("'ladmin'-login: Connection in administration mode REFUSED - encrypted login is disabled (ip: %s)\n"_fmt, ip); } } @@ -3113,15 +3105,15 @@ void parse_login(Session *s) timestamp_milliseconds_buffer timestr; stamp_time(timestr); FPRINTF(logfp, - "%s: receiving of an unknown packet -> disconnection\n", + "%s: receiving of an unknown packet -> disconnection\n"_fmt, timestr); FPRINTF(logfp, - "parse_login: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n", + "parse_login: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n"_fmt, s, ip, RFIFOW(s, 0), RFIFOREST(s)); - FPRINTF(logfp, "Detail (in hex):\n"); + FPRINTF(logfp, "Detail (in hex):\n"_fmt); FPRINTF(logfp, - "---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n"); + "---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n"_fmt); char tmpstr[16 + 1] {}; @@ -3129,17 +3121,17 @@ void parse_login(Session *s) for (i = 0; i < RFIFOREST(s); i++) { if ((i & 15) == 0) - FPRINTF(logfp, "%04X ", i); - FPRINTF(logfp, "%02x ", RFIFOB(s, i)); + FPRINTF(logfp, "%04X "_fmt, i); + FPRINTF(logfp, "%02x "_fmt, RFIFOB(s, i)); if (RFIFOB(s, i) > 0x1f) tmpstr[i % 16] = RFIFOB(s, i); else tmpstr[i % 16] = '.'; if ((i - 7) % 16 == 0) // -8 + 1 - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); else if ((i + 1) % 16 == 0) { - FPRINTF(logfp, " %s\n", tmpstr); + FPRINTF(logfp, " %s\n"_fmt, tmpstr); std::fill(tmpstr + 0, tmpstr + 17, '\0'); } } @@ -3147,16 +3139,16 @@ void parse_login(Session *s) { for (j = i; j % 16 != 0; j++) { - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); if ((j - 7) % 16 == 0) // -8 + 1 - FPRINTF(logfp, " "); + FPRINTF(logfp, " "_fmt); } - FPRINTF(logfp, " %s\n", tmpstr); + FPRINTF(logfp, " %s\n"_fmt, tmpstr); } - FPRINTF(logfp, "\n"); + FPRINTF(logfp, "\n"_fmt); } } - LOGIN_LOG("End of connection, unknown packet (ip: %s)\n", ip); + LOGIN_LOG("End of connection, unknown packet (ip: %s)\n"_fmt, ip); s->eof = 1; return; } @@ -3173,7 +3165,7 @@ bool login_lan_config(XString w1, ZString w2) struct hostent *h = NULL; { - if (w1 == "lan_char_ip") + if (w1 == "lan_char_ip"_s) { // Read Char-Server Lan IP Address h = gethostbyname(w2.c_str()); @@ -3188,20 +3180,20 @@ bool login_lan_config(XString w1, ZString w2) } else { - PRINTF("Bad IP value: %s\n", w2); + PRINTF("Bad IP value: %s\n"_fmt, w2); return false; } - PRINTF("LAN IP of char-server: %s.\n", lan_char_ip); + PRINTF("LAN IP of char-server: %s.\n"_fmt, lan_char_ip); } - else if (w1 == "subnet" /*backward compatibility*/ - || w1 == "lan_subnet") + else if (w1 == "subnet"_s /*backward compatibility*/ + || w1 == "lan_subnet"_s) { if (!extract(w2, &lan_subnet)) { - PRINTF("Bad IP mask: %s\n", w2); + PRINTF("Bad IP mask: %s\n"_fmt, w2); return false; } - PRINTF("Sub-network of the char-server: %s.\n", + PRINTF("Sub-network of the char-server: %s.\n"_fmt, lan_subnet); } else @@ -3216,18 +3208,18 @@ static bool lan_check() { // log the LAN configuration - LOGIN_LOG("The LAN configuration of the server is set:\n"); - LOGIN_LOG("- with LAN IP of char-server: %s.\n", lan_char_ip); - LOGIN_LOG("- with the sub-network of the char-server: %s.\n", + LOGIN_LOG("The LAN configuration of the server is set:\n"_fmt); + LOGIN_LOG("- with LAN IP of char-server: %s.\n"_fmt, lan_char_ip); + LOGIN_LOG("- with the sub-network of the char-server: %s.\n"_fmt, lan_subnet); // sub-network check of the char-server { - PRINTF("LAN test of LAN IP of the char-server: "); + PRINTF("LAN test of LAN IP of the char-server: "_fmt); if (!lan_ip_check(lan_char_ip)) { - PRINTF(SGR_BOLD SGR_RED "***ERROR: LAN IP of the char-server doesn't belong to the specified Sub-network" SGR_RESET "\n"); - LOGIN_LOG("***ERROR: LAN IP of the char-server doesn't belong to the specified Sub-network.\n"); + PRINTF(SGR_BOLD SGR_RED "***ERROR: LAN IP of the char-server doesn't belong to the specified Sub-network"_fmt SGR_RESET "\n"); + LOGIN_LOG("***ERROR: LAN IP of the char-server doesn't belong to the specified Sub-network.\n"_fmt); return false; } } @@ -3242,24 +3234,24 @@ static bool login_config(XString w1, ZString w2) { { - if (w1 == "admin_state") + if (w1 == "admin_state"_s) { admin_state = config_switch(w2); } - else if (w1 == "admin_pass") + else if (w1 == "admin_pass"_s) { admin_pass = stringish(w2); } - else if (w1 == "ladminallowip") + else if (w1 == "ladminallowip"_s) { - if (w2 == "clear") + if (w2 == "clear"_s) { access_ladmin.clear(); } else { // a.b.c.d/0.0.0.0 (canonically, 0.0.0.0/0) covers all - if (w2 == "all") + if (w2 == "all"_s) { // reset all previous values access_ladmin.clear(); @@ -3274,104 +3266,104 @@ bool login_config(XString w1, ZString w2) IP4Mask n; if (!extract(w2, &n)) { - PRINTF("Bad IP mask: %s\n", w2); + PRINTF("Bad IP mask: %s\n"_fmt, w2); return false; } access_ladmin.push_back(n); } } } - else if (w1 == "gm_pass") + else if (w1 == "gm_pass"_s) { gm_pass = w2; } - else if (w1 == "level_new_gm") + else if (w1 == "level_new_gm"_s) { level_new_gm = atoi(w2.c_str()); } - else if (w1 == "new_account") + else if (w1 == "new_account"_s) { new_account = config_switch(w2); } - else if (w1 == "login_port") + else if (w1 == "login_port"_s) { login_port = atoi(w2.c_str()); } - else if (w1 == "account_filename") + else if (w1 == "account_filename"_s) { account_filename = w2; } - else if (w1 == "gm_account_filename") + else if (w1 == "gm_account_filename"_s) { gm_account_filename = w2; } - else if (w1 == "gm_account_filename_check_timer") + else if (w1 == "gm_account_filename_check_timer"_s) { gm_account_filename_check_timer = std::chrono::seconds(atoi(w2.c_str())); } - else if (w1 == "login_log_filename") + else if (w1 == "login_log_filename"_s) { login_log_filename = w2; } - else if (w1 == "login_log_unknown_packets_filename") + else if (w1 == "login_log_unknown_packets_filename"_s) { login_log_unknown_packets_filename = w2; } - else if (w1 == "save_unknown_packets") + else if (w1 == "save_unknown_packets"_s) { save_unknown_packets = config_switch(w2); } - else if (w1 == "display_parse_login") + else if (w1 == "display_parse_login"_s) { display_parse_login = config_switch(w2); // 0: no, 1: yes } - else if (w1 == "display_parse_admin") + else if (w1 == "display_parse_admin"_s) { display_parse_admin = config_switch(w2); // 0: no, 1: yes } - else if (w1 == "display_parse_fromchar") + else if (w1 == "display_parse_fromchar"_s) { display_parse_fromchar = config_switch(w2); // 0: no, 1: yes (without packet 0x2714), 2: all packets } - else if (w1 == "min_level_to_connect") + else if (w1 == "min_level_to_connect"_s) { min_level_to_connect = atoi(w2.c_str()); } - else if (w1 == "add_to_unlimited_account") + else if (w1 == "add_to_unlimited_account"_s) { add_to_unlimited_account = config_switch(w2); } - else if (w1 == "start_limited_time") + else if (w1 == "start_limited_time"_s) { start_limited_time = atoi(w2.c_str()); } - else if (w1 == "check_ip_flag") + else if (w1 == "check_ip_flag"_s) { check_ip_flag = config_switch(w2); } - else if (w1 == "order") + else if (w1 == "order"_s) { - if (w2 == "deny,allow" || w2 == "deny, allow") + if (w2 == "deny,allow"_s || w2 == "deny, allow"_s) access_order = ACO::DENY_ALLOW; - else if (w2 == "allow,deny" || w2 == "allow, deny") + else if (w2 == "allow,deny"_s || w2 == "allow, deny"_s) access_order = ACO::ALLOW_DENY; - else if (w2 == "mutual-failture" || w2 == "mutual-failure") + else if (w2 == "mutual-failture"_s || w2 == "mutual-failure"_s) access_order = ACO::MUTUAL_FAILURE; else { - PRINTF("Bad order: %s\n", w2); + PRINTF("Bad order: %s\n"_fmt, w2); return false; } } - else if (w1 == "allow") + else if (w1 == "allow"_s) { - if (w2 == "clear") + if (w2 == "clear"_s) { access_allow.clear(); } else { - if (w2 == "all") + if (w2 == "all"_s) { // reset all previous values access_allow.clear(); @@ -3386,22 +3378,22 @@ bool login_config(XString w1, ZString w2) IP4Mask n; if (!extract(w2, &n)) { - PRINTF("Bad IP mask: %s\n", w2); + PRINTF("Bad IP mask: %s\n"_fmt, w2); return false; } access_allow.push_back(n); } } } - else if (w1 == "deny") + else if (w1 == "deny"_s) { - if (w2 == "clear") + if (w2 == "clear"_s) { access_deny.clear(); } else { - if (w2 == "all") + if (w2 == "all"_s) { // reset all previous values access_deny.clear(); @@ -3416,36 +3408,36 @@ bool login_config(XString w1, ZString w2) IP4Mask n; if (!extract(w2, &n)) { - PRINTF("Bad IP mask: %s\n", w2); + PRINTF("Bad IP mask: %s\n"_fmt, w2); return false; } access_deny.push_back(n); } } } - else if (w1 == "anti_freeze_enable") + else if (w1 == "anti_freeze_enable"_s) { anti_freeze_enable = config_switch(w2); } - else if (w1 == "anti_freeze_interval") + else if (w1 == "anti_freeze_interval"_s) { anti_freeze_interval = std::max( std::chrono::seconds(atoi(w2.c_str())), std::chrono::seconds(5)); } - else if (w1 == "update_host") + else if (w1 == "update_host"_s) { update_host = w2; } - else if (w1 == "main_server") + else if (w1 == "main_server"_s) { main_server = stringish(w2); } - else if (w1 == "userid") + else if (w1 == "userid"_s) { userid = stringish(w2); } - else if (w1 == "passwd") + else if (w1 == "passwd"_s) { passwd = stringish(w2); } @@ -3467,7 +3459,7 @@ bool display_conf_warnings(void) bool rv = true; if (admin_state != 0 && admin_state != 1) { - PRINTF("***WARNING: Invalid value for admin_state parameter -> set to 0 (no remote admin).\n"); + PRINTF("***WARNING: Invalid value for admin_state parameter -> set to 0 (no remote admin).\n"_fmt); admin_state = 0; rv = false; } @@ -3476,132 +3468,132 @@ bool display_conf_warnings(void) { if (!admin_pass) { - PRINTF("***WARNING: Administrator password is void (admin_pass).\n"); + PRINTF("***WARNING: Administrator password is void (admin_pass).\n"_fmt); rv = false; } - else if (admin_pass == stringish("admin")) + else if (admin_pass == stringish("admin"_s)) { - PRINTF("***WARNING: You are using the default administrator password (admin_pass).\n"); - PRINTF(" We highly recommend that you change it.\n"); + PRINTF("***WARNING: You are using the default administrator password (admin_pass).\n"_fmt); + PRINTF(" We highly recommend that you change it.\n"_fmt); } } if (!gm_pass) { - PRINTF("***WARNING: 'To GM become' password is void (gm_pass).\n"); - PRINTF(" We highly recommend that you set one password.\n"); + PRINTF("***WARNING: 'To GM become' password is void (gm_pass).\n"_fmt); + PRINTF(" We highly recommend that you set one password.\n"_fmt); rv = false; } - else if (gm_pass == "gm") + else if (gm_pass == "gm"_s) { - PRINTF("***WARNING: You are using the default GM password (gm_pass).\n"); - PRINTF(" We highly recommend that you change it.\n"); + PRINTF("***WARNING: You are using the default GM password (gm_pass).\n"_fmt); + PRINTF(" We highly recommend that you change it.\n"_fmt); } if (level_new_gm < 0 || level_new_gm > 99) { - PRINTF("***WARNING: Invalid value for level_new_gm parameter -> set to 60 (default).\n"); + PRINTF("***WARNING: Invalid value for level_new_gm parameter -> set to 60 (default).\n"_fmt); level_new_gm = 60; rv = false; } if (new_account != 0 && new_account != 1) { - PRINTF("***WARNING: Invalid value for new_account parameter -> set to 0 (no new account).\n"); + PRINTF("***WARNING: Invalid value for new_account parameter -> set to 0 (no new account).\n"_fmt); new_account = 0; rv = false; } if (login_port < 1024 || login_port > 65535) { - PRINTF("***WARNING: Invalid value for login_port parameter -> set to 6900 (default).\n"); + PRINTF("***WARNING: Invalid value for login_port parameter -> set to 6900 (default).\n"_fmt); login_port = 6900; rv = false; } if (gm_account_filename_check_timer.count() < 0) { - PRINTF("***WARNING: Invalid value for gm_account_filename_check_timer parameter.\n"); - PRINTF(" -> set to 15 sec (default).\n"); + PRINTF("***WARNING: Invalid value for gm_account_filename_check_timer parameter.\n"_fmt); + PRINTF(" -> set to 15 sec (default).\n"_fmt); gm_account_filename_check_timer = std::chrono::seconds(15); rv = false; } else if (gm_account_filename_check_timer == std::chrono::seconds(1)) { - PRINTF("***WARNING: Invalid value for gm_account_filename_check_timer parameter.\n"); - PRINTF(" -> set to 2 sec (minimum value).\n"); + PRINTF("***WARNING: Invalid value for gm_account_filename_check_timer parameter.\n"_fmt); + PRINTF(" -> set to 2 sec (minimum value).\n"_fmt); gm_account_filename_check_timer = std::chrono::seconds(2); rv = false; } if (save_unknown_packets != 0 && save_unknown_packets != 1) { - PRINTF("WARNING: Invalid value for save_unknown_packets parameter -> set to 0-no save.\n"); + PRINTF("WARNING: Invalid value for save_unknown_packets parameter -> set to 0-no save.\n"_fmt); save_unknown_packets = 0; rv = false; } if (display_parse_login != 0 && display_parse_login != 1) { // 0: no, 1: yes - PRINTF("***WARNING: Invalid value for display_parse_login parameter\n"); - PRINTF(" -> set to 0 (no display).\n"); + PRINTF("***WARNING: Invalid value for display_parse_login parameter\n"_fmt); + PRINTF(" -> set to 0 (no display).\n"_fmt); display_parse_login = 0; rv = false; } if (display_parse_admin != 0 && display_parse_admin != 1) { // 0: no, 1: yes - PRINTF("***WARNING: Invalid value for display_parse_admin parameter\n"); - PRINTF(" -> set to 0 (no display).\n"); + PRINTF("***WARNING: Invalid value for display_parse_admin parameter\n"_fmt); + PRINTF(" -> set to 0 (no display).\n"_fmt); display_parse_admin = 0; rv = false; } if (display_parse_fromchar < 0 || display_parse_fromchar > 2) { // 0: no, 1: yes (without packet 0x2714), 2: all packets - PRINTF("***WARNING: Invalid value for display_parse_fromchar parameter\n"); - PRINTF(" -> set to 0 (no display).\n"); + PRINTF("***WARNING: Invalid value for display_parse_fromchar parameter\n"_fmt); + PRINTF(" -> set to 0 (no display).\n"_fmt); display_parse_fromchar = 0; rv = false; } if (min_level_to_connect < 0) { // 0: all players, 1-99 at least gm level x - PRINTF("***WARNING: Invalid value for min_level_to_connect (%d) parameter\n", + PRINTF("***WARNING: Invalid value for min_level_to_connect (%d) parameter\n"_fmt, min_level_to_connect); - PRINTF(" -> set to 0 (any player).\n"); + PRINTF(" -> set to 0 (any player).\n"_fmt); min_level_to_connect = 0; rv = false; } else if (min_level_to_connect > 99) { // 0: all players, 1-99 at least gm level x - PRINTF("***WARNING: Invalid value for min_level_to_connect (%d) parameter\n", + PRINTF("***WARNING: Invalid value for min_level_to_connect (%d) parameter\n"_fmt, min_level_to_connect); - PRINTF(" -> set to 99 (only GM level 99).\n"); + PRINTF(" -> set to 99 (only GM level 99).\n"_fmt); min_level_to_connect = 99; rv = false; } if (add_to_unlimited_account != 0 && add_to_unlimited_account != 1) { // 0: no, 1: yes - PRINTF("***WARNING: Invalid value for add_to_unlimited_account parameter\n"); - PRINTF(" -> set to 0 (impossible to add a time to an unlimited account).\n"); + PRINTF("***WARNING: Invalid value for add_to_unlimited_account parameter\n"_fmt); + PRINTF(" -> set to 0 (impossible to add a time to an unlimited account).\n"_fmt); add_to_unlimited_account = 0; rv = false; } if (start_limited_time < -1) { // -1: create unlimited account, 0 or more: additionnal sec from now to create limited time - PRINTF("***WARNING: Invalid value for start_limited_time parameter\n"); - PRINTF(" -> set to -1 (new accounts are created with unlimited time).\n"); + PRINTF("***WARNING: Invalid value for start_limited_time parameter\n"_fmt); + PRINTF(" -> set to -1 (new accounts are created with unlimited time).\n"_fmt); start_limited_time = -1; rv = false; } if (check_ip_flag != 0 && check_ip_flag != 1) { // 0: no, 1: yes - PRINTF("***WARNING: Invalid value for check_ip_flag parameter\n"); - PRINTF(" -> set to 1 (check players ip between login-server & char-server).\n"); + PRINTF("***WARNING: Invalid value for check_ip_flag parameter\n"_fmt); + PRINTF(" -> set to 1 (check players ip between login-server & char-server).\n"_fmt); check_ip_flag = 1; rv = false; } @@ -3610,8 +3602,8 @@ bool display_conf_warnings(void) { if (access_deny.size() == 1 && access_deny.front().mask() == IP4Address()) { - PRINTF("***WARNING: The IP security order is 'deny,allow' (allow if not deny).\n"); - PRINTF(" And you refuse ALL IP.\n"); + PRINTF("***WARNING: The IP security order is 'deny,allow' (allow if not deny).\n"_fmt); + PRINTF(" And you refuse ALL IP.\n"_fmt); rv = false; } } @@ -3619,8 +3611,8 @@ bool display_conf_warnings(void) { if (access_allow.empty()) { - PRINTF("***WARNING: The IP security order is 'allow,deny' (deny if not allow).\n"); - PRINTF(" But, NO IP IS AUTHORISED!\n"); + PRINTF("***WARNING: The IP security order is 'allow,deny' (deny if not allow).\n"_fmt); + PRINTF(" But, NO IP IS AUTHORISED!\n"_fmt); rv = false; } } @@ -3629,16 +3621,16 @@ bool display_conf_warnings(void) // ACO::MUTUAL_FAILURE if (access_allow.empty()) { - PRINTF("***WARNING: The IP security order is 'mutual-failture'\n"); - PRINTF(" (allow if in the allow list and not in the deny list).\n"); - PRINTF(" But, NO IP IS AUTHORISED!\n"); + PRINTF("***WARNING: The IP security order is 'mutual-failture'\n"_fmt); + PRINTF(" (allow if in the allow list and not in the deny list).\n"_fmt); + PRINTF(" But, NO IP IS AUTHORISED!\n"_fmt); rv = false; } else if (access_deny.size() == 1 && access_deny.front().mask() == IP4Address()) { - PRINTF("***WARNING: The IP security order is mutual-failture\n"); - PRINTF(" (allow if in the allow list and not in the deny list).\n"); - PRINTF(" But, you refuse ALL IP!\n"); + PRINTF("***WARNING: The IP security order is mutual-failture\n"_fmt); + PRINTF(" (allow if in the allow list and not in the deny list).\n"_fmt); + PRINTF(" But, you refuse ALL IP!\n"_fmt); rv = false; } } @@ -3652,168 +3644,168 @@ static void save_config_in_log(void) { // a newline in the log... - LOGIN_LOG(""); - LOGIN_LOG("The login-server starting...\n"); + LOGIN_LOG(""_fmt); + LOGIN_LOG("The login-server starting...\n"_fmt); // save configuration in log file - LOGIN_LOG("The configuration of the server is set:\n"); + LOGIN_LOG("The configuration of the server is set:\n"_fmt); if (admin_state != 1) - LOGIN_LOG("- with no remote administration.\n"); + LOGIN_LOG("- with no remote administration.\n"_fmt); else if (!admin_pass) - LOGIN_LOG("- with a remote administration with a VOID password.\n"); - else if (admin_pass == stringish("admin")) - LOGIN_LOG("- with a remote administration with the DEFAULT password.\n"); + LOGIN_LOG("- with a remote administration with a VOID password.\n"_fmt); + else if (admin_pass == stringish("admin"_s)) + LOGIN_LOG("- with a remote administration with the DEFAULT password.\n"_fmt); else - LOGIN_LOG("- with a remote administration with the password of %zu character(s).\n", + LOGIN_LOG("- with a remote administration with the password of %zu character(s).\n"_fmt, admin_pass.size()); if (access_ladmin.empty() || (access_ladmin.size() == 1 && access_ladmin.front().mask() == IP4Address())) { - LOGIN_LOG("- to accept any IP for remote administration\n"); + LOGIN_LOG("- to accept any IP for remote administration\n"_fmt); } else { - LOGIN_LOG("- to accept following IP for remote administration:\n"); + LOGIN_LOG("- to accept following IP for remote administration:\n"_fmt); for (const IP4Mask& ae : access_ladmin) - LOGIN_LOG(" %s\n", ae); + LOGIN_LOG(" %s\n"_fmt, ae); } if (!gm_pass) - LOGIN_LOG("- with a VOID 'To GM become' password (gm_pass).\n"); - else if (gm_pass == "gm") - LOGIN_LOG("- with the DEFAULT 'To GM become' password (gm_pass).\n"); + LOGIN_LOG("- with a VOID 'To GM become' password (gm_pass).\n"_fmt); + else if (gm_pass == "gm"_s) + LOGIN_LOG("- with the DEFAULT 'To GM become' password (gm_pass).\n"_fmt); else - LOGIN_LOG("- with a 'To GM become' password (gm_pass) of %zu character(s).\n", + LOGIN_LOG("- with a 'To GM become' password (gm_pass) of %zu character(s).\n"_fmt, gm_pass.size()); if (level_new_gm == 0) - LOGIN_LOG("- to refuse any creation of GM with @gm.\n"); + LOGIN_LOG("- to refuse any creation of GM with @gm.\n"_fmt); else - LOGIN_LOG("- to create GM with level '%d' when @gm is used.\n", + LOGIN_LOG("- to create GM with level '%d' when @gm is used.\n"_fmt, level_new_gm); if (new_account == 1) - LOGIN_LOG("- to ALLOW new users (with _F/_M).\n"); + LOGIN_LOG("- to ALLOW new users (with _F/_M).\n"_fmt); else - LOGIN_LOG("- to NOT ALLOW new users (with _F/_M).\n"); - LOGIN_LOG("- with port: %d.\n", login_port); - LOGIN_LOG("- with the accounts file name: '%s'.\n", + LOGIN_LOG("- to NOT ALLOW new users (with _F/_M).\n"_fmt); + LOGIN_LOG("- with port: %d.\n"_fmt, login_port); + LOGIN_LOG("- with the accounts file name: '%s'.\n"_fmt, account_filename); - LOGIN_LOG("- with the GM accounts file name: '%s'.\n", + LOGIN_LOG("- with the GM accounts file name: '%s'.\n"_fmt, gm_account_filename); if (gm_account_filename_check_timer == interval_t::zero()) - LOGIN_LOG("- to NOT check GM accounts file modifications.\n"); + LOGIN_LOG("- to NOT check GM accounts file modifications.\n"_fmt); else - LOGIN_LOG("- to check GM accounts file modifications every %lld seconds.\n", + LOGIN_LOG("- to check GM accounts file modifications every %lld seconds.\n"_fmt, maybe_cast(gm_account_filename_check_timer.count())); // not necessary to log the 'login_log_filename', we are inside :) - LOGIN_LOG("- with the unknown packets file name: '%s'.\n", + LOGIN_LOG("- with the unknown packets file name: '%s'.\n"_fmt, login_log_unknown_packets_filename); if (save_unknown_packets) - LOGIN_LOG("- to SAVE all unkown packets.\n"); + LOGIN_LOG("- to SAVE all unkown packets.\n"_fmt); else - LOGIN_LOG("- to SAVE only unkown packets sending by a char-server or a remote administration.\n"); + LOGIN_LOG("- to SAVE only unkown packets sending by a char-server or a remote administration.\n"_fmt); if (display_parse_login) - LOGIN_LOG("- to display normal parse packets on console.\n"); + LOGIN_LOG("- to display normal parse packets on console.\n"_fmt); else - LOGIN_LOG("- to NOT display normal parse packets on console.\n"); + LOGIN_LOG("- to NOT display normal parse packets on console.\n"_fmt); if (display_parse_admin) - LOGIN_LOG("- to display administration parse packets on console.\n"); + LOGIN_LOG("- to display administration parse packets on console.\n"_fmt); else - LOGIN_LOG("- to NOT display administration parse packets on console.\n"); + LOGIN_LOG("- to NOT display administration parse packets on console.\n"_fmt); if (display_parse_fromchar) - LOGIN_LOG("- to display char-server parse packets on console.\n"); + LOGIN_LOG("- to display char-server parse packets on console.\n"_fmt); else - LOGIN_LOG("- to NOT display char-server parse packets on console.\n"); + LOGIN_LOG("- to NOT display char-server parse packets on console.\n"_fmt); if (min_level_to_connect == 0) // 0: all players, 1-99 at least gm level x - LOGIN_LOG("- with no minimum level for connection.\n"); + LOGIN_LOG("- with no minimum level for connection.\n"_fmt); else if (min_level_to_connect == 99) - LOGIN_LOG("- to accept only GM with level 99.\n"); + LOGIN_LOG("- to accept only GM with level 99.\n"_fmt); else - LOGIN_LOG("- to accept only GM with level %d or more.\n", + LOGIN_LOG("- to accept only GM with level %d or more.\n"_fmt, min_level_to_connect); if (add_to_unlimited_account) - LOGIN_LOG("- to authorize adjustment (with timeadd ladmin) on an unlimited account.\n"); + LOGIN_LOG("- to authorize adjustment (with timeadd ladmin) on an unlimited account.\n"_fmt); else - LOGIN_LOG("- to refuse adjustment (with timeadd ladmin) on an unlimited account. You must use timeset (ladmin command) before.\n"); + LOGIN_LOG("- to refuse adjustment (with timeadd ladmin) on an unlimited account. You must use timeset (ladmin command) before.\n"_fmt); if (start_limited_time < 0) - LOGIN_LOG("- to create new accounts with an unlimited time.\n"); + LOGIN_LOG("- to create new accounts with an unlimited time.\n"_fmt); else if (start_limited_time == 0) - LOGIN_LOG("- to create new accounts with a limited time: time of creation.\n"); + LOGIN_LOG("- to create new accounts with a limited time: time of creation.\n"_fmt); else - LOGIN_LOG("- to create new accounts with a limited time: time of creation + %d second(s).\n", + LOGIN_LOG("- to create new accounts with a limited time: time of creation + %d second(s).\n"_fmt, start_limited_time); if (check_ip_flag) - LOGIN_LOG("- with control of players IP between login-server and char-server.\n"); + LOGIN_LOG("- with control of players IP between login-server and char-server.\n"_fmt); else - LOGIN_LOG("- to not check players IP between login-server and char-server.\n"); + LOGIN_LOG("- to not check players IP between login-server and char-server.\n"_fmt); if (access_order == ACO::DENY_ALLOW) { if (access_deny.empty()) { - LOGIN_LOG("- with the IP security order: 'deny,allow' (allow if not deny). You refuse no IP.\n"); + LOGIN_LOG("- with the IP security order: 'deny,allow' (allow if not deny). You refuse no IP.\n"_fmt); } else if (access_deny.size() == 1 && access_deny.front().mask() == IP4Address()) { - LOGIN_LOG("- with the IP security order: 'deny,allow' (allow if not deny). You refuse ALL IP.\n"); + LOGIN_LOG("- with the IP security order: 'deny,allow' (allow if not deny). You refuse ALL IP.\n"_fmt); } else { - LOGIN_LOG("- with the IP security order: 'deny,allow' (allow if not deny). Refused IP are:\n"); + LOGIN_LOG("- with the IP security order: 'deny,allow' (allow if not deny). Refused IP are:\n"_fmt); for (IP4Mask ae : access_deny) - LOGIN_LOG(" %s\n", ae); + LOGIN_LOG(" %s\n"_fmt, ae); } } else if (access_order == ACO::ALLOW_DENY) { if (access_allow.empty()) { - LOGIN_LOG("- with the IP security order: 'allow,deny' (deny if not allow). But, NO IP IS AUTHORISED!\n"); + LOGIN_LOG("- with the IP security order: 'allow,deny' (deny if not allow). But, NO IP IS AUTHORISED!\n"_fmt); } else if (access_allow.size() == 1 && access_allow.front().mask() == IP4Address()) { - LOGIN_LOG("- with the IP security order: 'allow,deny' (deny if not allow). You authorise ALL IP.\n"); + LOGIN_LOG("- with the IP security order: 'allow,deny' (deny if not allow). You authorise ALL IP.\n"_fmt); } else { - LOGIN_LOG("- with the IP security order: 'allow,deny' (deny if not allow). Authorised IP are:\n"); + LOGIN_LOG("- with the IP security order: 'allow,deny' (deny if not allow). Authorised IP are:\n"_fmt); for (IP4Mask ae : access_allow) - LOGIN_LOG(" %s\n", ae); + LOGIN_LOG(" %s\n"_fmt, ae); } } else { // ACO_MUTUAL_FAILTURE - LOGIN_LOG("- with the IP security order: 'mutual-failture' (allow if in the allow list and not in the deny list).\n"); + LOGIN_LOG("- with the IP security order: 'mutual-failture' (allow if in the allow list and not in the deny list).\n"_fmt); if (access_allow.empty()) { - LOGIN_LOG(" But, NO IP IS AUTHORISED!\n"); + LOGIN_LOG(" But, NO IP IS AUTHORISED!\n"_fmt); } else if (access_deny.size() == 1 && access_deny.front().mask() == IP4Address()) { - LOGIN_LOG(" But, you refuse ALL IP!\n"); + LOGIN_LOG(" But, you refuse ALL IP!\n"_fmt); } else { if (access_allow.size() == 1 && access_allow.front().mask() == IP4Address()) { - LOGIN_LOG(" You authorise ALL IP.\n"); + LOGIN_LOG(" You authorise ALL IP.\n"_fmt); } else { - LOGIN_LOG(" Authorised IP are:\n"); + LOGIN_LOG(" Authorised IP are:\n"_fmt); for (IP4Mask ae : access_allow) - LOGIN_LOG(" %s\n", ae); + LOGIN_LOG(" %s\n"_fmt, ae); } - LOGIN_LOG(" Refused IP are:\n"); + LOGIN_LOG(" Refused IP are:\n"_fmt); for (IP4Mask ae : access_deny) - LOGIN_LOG(" %s\n", ae); + LOGIN_LOG(" %s\n"_fmt, ae); } } } @@ -3835,7 +3827,7 @@ void term_func(void) } delete_session(login_session); - LOGIN_LOG("----End of login-server (normal end with closing of all files).\n"); + LOGIN_LOG("----End of login-server (normal end with closing of all files).\n"_fmt); } static @@ -3861,20 +3853,20 @@ int do_init(Slice argv) ZString argvi = argv.pop_front(); if (argvi.startswith('-')) { - if (argvi == "--help") + if (argvi == "--help"_s) { - PRINTF("Usage: %s [--help] [--version] [files...]\n", + PRINTF("Usage: %s [--help] [--version] [files...]\n"_fmt, argv0); exit(0); } - else if (argvi == "--version") + else if (argvi == "--version"_s) { - PRINTF("%s\n", CURRENT_VERSION_STRING); + PRINTF("%s\n"_fmt, CURRENT_VERSION_STRING); exit(0); } else { - FPRINTF(stderr, "Unknown argument: %s\n", argvi); + FPRINTF(stderr, "Unknown argument: %s\n"_fmt, argvi); runflag = false; } } @@ -3886,7 +3878,7 @@ int do_init(Slice argv) } if (!loaded_config_yet) - runflag &= load_config_file("conf/tmwa-login.conf", login_confs); + runflag &= load_config_file("conf/tmwa-login.conf"_s, login_confs); // not in login_config_read, because we can use 'import' option, and display same message twice or more // (why is that bad?) @@ -3929,10 +3921,10 @@ int do_init(Slice argv) check_GM_file, j).detach(); - LOGIN_LOG("The login-server is ready (Server is listening on the port %d).\n", + LOGIN_LOG("The login-server is ready (Server is listening on the port %d).\n"_fmt, login_port); - PRINTF("The login-server is " SGR_BOLD SGR_GREEN "ready" SGR_RESET " (Server is listening on the port %d).\n\n", + PRINTF("The login-server is " SGR_BOLD SGR_GREEN "ready" SGR_RESET " (Server is listening on the port %d).\n\n"_fmt, login_port); return 0; diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 240df8b..f721aaa 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -121,11 +121,11 @@ void atcommand_config_write(ZString cfgName) if (!out.is_open()) { - FPRINTF(stderr, "Failed to write atcommand config: %s\n", cfgName); + FPRINTF(stderr, "Failed to write atcommand config: %s\n"_fmt, cfgName); return; } - FPRINTF(out, "// Generated by %s\n", CURRENT_VERSION_STRING); + FPRINTF(out, "// Generated by %s\n"_fmt, CURRENT_VERSION_STRING); for (const auto& pair : atcommand_info) { // This XString is really a ZString, but not declared as one @@ -137,7 +137,7 @@ void atcommand_config_write(ZString cfgName) "\n" "// %s\n" "// Usage: @%s %s\n" - "%s: %d\n", + "%s: %d\n"_fmt, info.help, cmd, info.args, cmd, info.level); @@ -198,8 +198,8 @@ void log_atcommand(dumb_ptr sd, ZString cmd) stamp_time(tmpstr); MapName map = (sd->bl_m ? sd->bl_m->name_ - : stringish("undefined.gat")); - FPRINTF(*fp, "[%s] %s(%d,%d) %s(%d) : %s\n", + : stringish("undefined.gat"_s)); + FPRINTF(*fp, "[%s] %s(%d,%d) %s(%d) : %s\n"_fmt, tmpstr, map, sd->bl_x, sd->bl_y, sd->status_key.name, sd->status_key.account_id, @@ -225,7 +225,7 @@ io::AppendFile *get_gm_log() return gm_logfile.get(); last_logfile_nr = logfile_nr; - AString fullname = STRPRINTF("%s.%04d-%02d", + AString fullname = STRPRINTF("%s.%04d-%02d"_fmt, gm_log, year, month); if (gm_logfile) @@ -259,14 +259,14 @@ bool is_atcommand(Session *s, dumb_ptr sd, gmlvl = pc_isGM(sd); if (battle_config.atcommand_gm_only != 0 && !gmlvl) { - AString output = STRPRINTF("GM command is level 0, but this server disables level 0 commands: %s", + AString output = STRPRINTF("GM command is level 0, but this server disables level 0 commands: %s"_fmt, AString(command)); clif_displaymessage(s, output); return true; } if (!info) { - AString output = STRPRINTF("GM command not found: %s", + AString output = STRPRINTF("GM command not found: %s"_fmt, AString(command)); clif_displaymessage(s, output); return true; @@ -274,7 +274,7 @@ bool is_atcommand(Session *s, dumb_ptr sd, } if (info->level > gmlvl) { - AString 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"_fmt, info->level, gmlvl, AString(command)); clif_displaymessage(s, output); @@ -292,17 +292,17 @@ bool is_atcommand(Session *s, dumb_ptr sd, log_atcommand(sd, message); break; case ATCE::USAGE: - clif_displaymessage(s, "Command failed: usage error"); - clif_displaymessage(s, STRPRINTF("Usage: %s %s", AString(command), info->args)); + clif_displaymessage(s, "Command failed: usage error"_s); + clif_displaymessage(s, STRPRINTF("Usage: %s %s"_fmt, AString(command), info->args)); break; case ATCE::EXIST: - clif_displaymessage(s, "Command failed: something does not exist (or already exists)"); + clif_displaymessage(s, "Command failed: something does not exist (or already exists)"_s); break; case ATCE::RANGE: - clif_displaymessage(s, "Command failed: value out of range"); + clif_displaymessage(s, "Command failed: value out of range"_s); break; case ATCE::PERM: - clif_displaymessage(s, "Command failed: permission denied"); + clif_displaymessage(s, "Command failed: permission denied"_s); break; default: abort(); @@ -347,7 +347,7 @@ bool atcommand_config_read(ZString cfgName) io::ReadFile in(cfgName); if (!in.is_open()) { - PRINTF("At commands configuration file not found: %s\n", cfgName); + PRINTF("At commands configuration file not found: %s\n"_fmt, cfgName); return false; } @@ -361,7 +361,7 @@ bool atcommand_config_read(ZString cfgName) ZString w2; if (!config_split(line, &w1, &w2)) { - PRINTF("Bad config line: %s\n", line); + PRINTF("Bad config line: %s\n"_fmt, line); rv = false; continue; } @@ -374,11 +374,11 @@ bool atcommand_config_read(ZString cfgName) else if (p->level < 0) p->level = 0; } - else if (w1 == "import") + else if (w1 == "import"_s) rv &= atcommand_config_read(w2); else { - PRINTF("%s: bad line: %s\n", cfgName, line); + PRINTF("%s: bad line: %s\n"_fmt, cfgName, line); rv = false; } } @@ -391,7 +391,7 @@ bool atcommand_config_read(ZString cfgName) static void atc_do_help(Session *s, const char *cmd, const AtCommandInfo& info) { - auto msg = STRPRINTF("\u2007\u2007%d: @%s %s", info.level, cmd, info.args); + auto msg = STRPRINTF("\u2007\u2007%d: @%s %s"_fmt, info.level, cmd, info.args); // manually padding because *space* size_t ll = 1; if (info.level >= 10) @@ -407,9 +407,9 @@ ATCE atcommand_help(Session *s, dumb_ptr, { if (!message) { - clif_displaymessage(s, "There is too much help to display it all at once"); - clif_displaymessage(s, "Try @help <@command> or @help or @help "); - clif_displaymessage(s, "Right now the only category is 'all'"); + clif_displaymessage(s, "There is too much help to display it all at once"_s); + clif_displaymessage(s, "Try @help <@command> or @help or @help "_s); + clif_displaymessage(s, "Right now the only category is 'all'"_s); return ATCE::OKAY; } @@ -419,14 +419,14 @@ ATCE atcommand_help(Session *s, dumb_ptr, const AtCommandInfo *info = atcommand_info.search(cmd); if (!info) return ATCE::EXIST; - clif_displaymessage(s, STRPRINTF("Usage: @%s %s", cmd, info->args)); + clif_displaymessage(s, STRPRINTF("Usage: @%s %s"_fmt, cmd, info->args)); clif_displaymessage(s, info->help); return ATCE::OKAY; } - if (message == "all") + if (message == "all"_s) { - clif_displaymessage(s, "Synopses of GM commands in category 'all':"); + clif_displaymessage(s, "Synopses of GM commands in category 'all':"_s); for (const auto& pair : atcommand_info) { const char *cmd = &*pair.first.begin(); @@ -444,7 +444,7 @@ ATCE atcommand_help(Session *s, dumb_ptr, if (low < 0 || high > 100 || low >= high) return ATCE::RANGE; - clif_displaymessage(s, STRPRINTF("Synopses of GM commands in level [%d, %d):", low, high)); + clif_displaymessage(s, STRPRINTF("Synopses of GM commands in level [%d, %d):"_fmt, low, high)); for (const auto& pair : atcommand_info) { const char *cmd = &*pair.first.begin(); @@ -467,25 +467,25 @@ ATCE atcommand_setup(Session *s, dumb_ptr sd, level--; AString buf; - buf = STRPRINTF("-255 %s", character); + buf = STRPRINTF("-255 %s"_fmt, character); atcommand_character_baselevel(s, sd, buf); - buf = STRPRINTF("%d %s", level, character); + buf = STRPRINTF("%d %s"_fmt, level, character); atcommand_character_baselevel(s, sd, buf); // Emote skill - buf = STRPRINTF("1 1 %s", character); + buf = STRPRINTF("1 1 %s"_fmt, character); atcommand_skill_learn(s, sd, buf); // Trade skill - buf = STRPRINTF("2 1 %s", character); + buf = STRPRINTF("2 1 %s"_fmt, character); atcommand_skill_learn(s, sd, buf); // Party skill - STRPRINTF("2 2 %s", character); + STRPRINTF("2 2 %s"_fmt, character); atcommand_skill_learn(s, sd, buf); - STRPRINTF("018-1.gat 24 98 %s", character); + STRPRINTF("018-1.gat 24 98 %s"_fmt, character); atcommand_charwarp(s, sd, buf); return ATCE::OKAY; @@ -520,42 +520,42 @@ ATCE atcommand_charwarp(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp someone to this map."); + "You are not authorised to warp someone to this map."_s); return ATCE::PERM; } if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp this player from its actual map."); + "You are not authorised to warp this player from its actual map."_s); return ATCE::PERM; } if (pc_setpos(pl_sd, map_name, x, y, BeingRemoveWhy::WARPED) == 0) { - clif_displaymessage(pl_sd->sess, "Warped."); - clif_displaymessage(s, "Player warped (message sends to player too)."); + clif_displaymessage(pl_sd->sess, "Warped."_s); + clif_displaymessage(s, "Player warped (message sends to player too)."_s); } else { - clif_displaymessage(s, "Map not found."); + clif_displaymessage(s, "Map not found."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "Coordinates out of range."); + clif_displaymessage(s, "Coordinates out of range."_s); return ATCE::RANGE; } } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -573,7 +573,7 @@ ATCE atcommand_warp(Session *s, dumb_ptr sd, || !extract(message, record<' ', 1>(&map_name, &x, &y))) { clif_displaymessage(s, - "Please, enter a map (usage: @warp )."); + "Please, enter a map (usage: @warp )."_s); return ATCE::USAGE; } @@ -589,27 +589,27 @@ ATCE atcommand_warp(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you to this map."); + "You are not authorised to warp you to this map."_s); return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you from your actual map."); + "You are not authorised to warp you from your actual map."_s); return ATCE::PERM; } if (pc_setpos(sd, map_name, x, y, BeingRemoveWhy::WARPED) == 0) - clif_displaymessage(s, "Warped."); + clif_displaymessage(s, "Warped."_s); else { - clif_displaymessage(s, "Map not found."); + clif_displaymessage(s, "Map not found."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "Coordinates out of range."); + clif_displaymessage(s, "Coordinates out of range."_s); return ATCE::RANGE; } @@ -630,14 +630,14 @@ ATCE atcommand_where(Session *s, dumb_ptr sd, && (pc_isGM(pl_sd) > pc_isGM(sd)))) { // you can look only lower or same level - AString output = STRPRINTF("%s: %s (%d,%d)", + AString output = STRPRINTF("%s: %s (%d,%d)"_fmt, pl_sd->status_key.name, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -653,7 +653,7 @@ ATCE atcommand_goto(Session *s, dumb_ptr sd, if (!asplit(message, &character)) { clif_displaymessage(s, - "Please, enter a player name (usage: @jumpto/@warpto/@goto )."); + "Please, enter a player name (usage: @jumpto/@warpto/@goto )."_s); return ATCE::USAGE; } @@ -664,23 +664,23 @@ ATCE atcommand_goto(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you to the map of this player."); + "You are not authorised to warp you to the map of this player."_s); return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you from your actual map."); + "You are not authorised to warp you from your actual map."_s); return ATCE::PERM; } pc_setpos(sd, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y, BeingRemoveWhy::WARPED); - AString output = STRPRINTF("Jump to %s", character); + AString output = STRPRINTF("Jump to %s"_fmt, character); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -705,23 +705,23 @@ ATCE atcommand_jump(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you to your actual map."); + "You are not authorised to warp you to your actual map."_s); return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you from your actual map."); + "You are not authorised to warp you from your actual map."_s); return ATCE::PERM; } pc_setpos(sd, sd->mapname_, x, y, BeingRemoveWhy::WARPED); - AString output = STRPRINTF("Jump to %d %d", x, y); + AString output = STRPRINTF("Jump to %d %d"_fmt, x, y); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Coordinates out of range."); + clif_displaymessage(s, "Coordinates out of range."_s); return ATCE::RANGE; } @@ -761,12 +761,12 @@ ATCE atcommand_who(Session *s, dumb_ptr sd, AString output; if (pl_GM_level > 0) output = STRPRINTF( - "Name: %s (GM:%d) | Location: %s %d %d", + "Name: %s (GM:%d) | Location: %s %d %d"_fmt, pl_sd->status_key.name, pl_GM_level, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); else output = STRPRINTF( - "Name: %s | Location: %s %d %d", + "Name: %s | Location: %s %d %d"_fmt, pl_sd->status_key.name, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); clif_displaymessage(s, output); @@ -777,12 +777,12 @@ ATCE atcommand_who(Session *s, dumb_ptr sd, } if (count == 0) - clif_displaymessage(s, "No player found."); + clif_displaymessage(s, "No player found."_s); else if (count == 1) - clif_displaymessage(s, "1 player found."); + clif_displaymessage(s, "1 player found."_s); else { - AString output = STRPRINTF("%d players found.", count); + AString output = STRPRINTF("%d players found."_fmt, count); clif_displaymessage(s, output); } @@ -822,11 +822,11 @@ 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"); + PartyName temp0 = p ? p->name : stringish("None"_s); AString output; if (pl_GM_level > 0) output = STRPRINTF( - "Name: %s (GM:%d) | Party: '%s'", + "Name: %s (GM:%d) | Party: '%s'"_fmt, pl_sd->status_key.name, pl_GM_level, temp0); clif_displaymessage(s, output); count++; @@ -836,12 +836,12 @@ ATCE atcommand_whogroup(Session *s, dumb_ptr sd, } if (count == 0) - clif_displaymessage(s, "No player found."); + clif_displaymessage(s, "No player found."_s); else if (count == 1) - clif_displaymessage(s, "1 player found."); + clif_displaymessage(s, "1 player found."_s); else { - AString output = STRPRINTF("%d players found.", count); + AString output = STRPRINTF("%d players found."_fmt, count); clif_displaymessage(s, output); } @@ -886,12 +886,12 @@ ATCE atcommand_whomap(Session *s, dumb_ptr sd, AString output; if (pl_GM_level > 0) output = STRPRINTF( - "Name: %s (GM:%d) | Location: %s %d %d", + "Name: %s (GM:%d) | Location: %s %d %d"_fmt, pl_sd->status_key.name, pl_GM_level, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); else output = STRPRINTF( - "Name: %s | Location: %s %d %d", + "Name: %s | Location: %s %d %d"_fmt, pl_sd->status_key.name, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); clif_displaymessage(s, output); @@ -901,7 +901,7 @@ ATCE atcommand_whomap(Session *s, dumb_ptr sd, } } - AString output = STRPRINTF("%d players found in map '%s'.", + AString output = STRPRINTF("%d players found in map '%s'."_fmt, count, map_id->name_); clif_displaymessage(s, output); @@ -945,13 +945,13 @@ ATCE atcommand_whomapgroup(Session *s, dumb_ptr sd, if (pl_sd->bl_m == map_id) { p = party_search(pl_sd->status.party_id); - PartyName temp0 = p ? p->name : stringish("None"); + PartyName temp0 = p ? p->name : stringish("None"_s); AString output; if (pl_GM_level > 0) - output = STRPRINTF("Name: %s (GM:%d) | Party: '%s'", + output = STRPRINTF("Name: %s (GM:%d) | Party: '%s'"_fmt, pl_sd->status_key.name, pl_GM_level, temp0); else - output = STRPRINTF("Name: %s | Party: '%s'", + output = STRPRINTF("Name: %s | Party: '%s'"_fmt, pl_sd->status_key.name, temp0); clif_displaymessage(s, output); count++; @@ -962,12 +962,12 @@ ATCE atcommand_whomapgroup(Session *s, dumb_ptr sd, AString output; if (count == 0) - output = STRPRINTF("No player found in map '%s'.", map_id->name_); + output = STRPRINTF("No player found in map '%s'."_fmt, map_id->name_); else if (count == 1) - output = STRPRINTF("1 player found in map '%s'.", map_id->name_); + output = STRPRINTF("1 player found in map '%s'."_fmt, map_id->name_); else { - output = STRPRINTF("%d players found in map '%s'.", count, map_id->name_); + output = STRPRINTF("%d players found in map '%s'."_fmt, count, map_id->name_); } clif_displaymessage(s, output); @@ -1010,20 +1010,20 @@ ATCE atcommand_whogm(Session *s, dumb_ptr sd, // search with no case sensitive AString output; output = STRPRINTF( - "Name: %s (GM:%d) | Location: %s %d %d", + "Name: %s (GM:%d) | Location: %s %d %d"_fmt, pl_sd->status_key.name, pl_GM_level, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); clif_displaymessage(s, output); output = STRPRINTF( - " BLvl: %d | Job: %s (Lvl: %d)", + " BLvl: %d | Job: %s (Lvl: %d)"_fmt, pl_sd->status.base_level, - "Novice/Human", + "Novice/Human"_s, pl_sd->status.job_level); clif_displaymessage(s, output); p = party_search(pl_sd->status.party_id); - PartyName temp0 = p ? p->name : stringish("None"); + PartyName temp0 = p ? p->name : stringish("None"_s); output = STRPRINTF( - " Party: '%s'", + " Party: '%s'"_fmt, temp0); clif_displaymessage(s, output); count++; @@ -1034,12 +1034,12 @@ ATCE atcommand_whogm(Session *s, dumb_ptr sd, } if (count == 0) - clif_displaymessage(s, "No GM found."); + clif_displaymessage(s, "No GM found."_s); else if (count == 1) - clif_displaymessage(s, "1 GM found."); + clif_displaymessage(s, "1 GM found."_s); else { - AString output = STRPRINTF("%d GMs found.", count); + AString output = STRPRINTF("%d GMs found."_fmt, count); clif_displaymessage(s, output); } @@ -1053,7 +1053,7 @@ ATCE atcommand_save(Session *s, dumb_ptr sd, pc_setsavepoint(sd, sd->mapname_, sd->bl_x, sd->bl_y); pc_makesavestatus(sd); chrif_save(sd); - clif_displaymessage(s, "Character data respawn point saved."); + clif_displaymessage(s, "Character data respawn point saved."_s); return ATCE::OKAY; } @@ -1067,14 +1067,14 @@ ATCE atcommand_load(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you to your save map."); + "You are not authorised to warp you to your save map."_s); return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you from your actual map."); + "You are not authorised to warp you from your actual map."_s); return ATCE::PERM; } @@ -1089,7 +1089,7 @@ ATCE atcommand_load(Session *s, dumb_ptr sd, pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x, sd->status.save_point.y, BeingRemoveWhy::GONE); } - clif_displaymessage(s, "Warping to respawn point."); + clif_displaymessage(s, "Warping to respawn point."_s); return ATCE::OKAY; } @@ -1101,7 +1101,7 @@ ATCE atcommand_speed(Session *s, dumb_ptr sd, if (!message) { AString output = STRPRINTF( - "Please, enter a speed value (usage: @speed <%d-%d>).", + "Please, enter a speed value (usage: @speed <%d-%d>)."_fmt, static_cast(MIN_WALK_SPEED.count()), static_cast(MAX_WALK_SPEED.count())); clif_displaymessage(s, output); @@ -1115,12 +1115,12 @@ ATCE atcommand_speed(Session *s, dumb_ptr sd, //sd->walktimer = x; //この文を追加 by れ clif_updatestatus(sd, SP::SPEED); - clif_displaymessage(s, "Speed changed."); + clif_displaymessage(s, "Speed changed."_s); } else { AString output = STRPRINTF( - "Please, enter a valid speed value (usage: @speed <%d-%d>).", + "Please, enter a valid speed value (usage: @speed <%d-%d>)."_fmt, static_cast(MIN_WALK_SPEED.count()), static_cast(MAX_WALK_SPEED.count())); clif_displaymessage(s, output); @@ -1138,14 +1138,14 @@ ATCE atcommand_storage(Session *s, dumb_ptr sd, if (sd->state.storage_open) { - clif_displaymessage(s, "msg_table[250]"); + clif_displaymessage(s, "msg_table[250]"_s); return ATCE::EXIST; } if ((stor = account2storage2(sd->status_key.account_id)) != NULL && stor->storage_status == 1) { - clif_displaymessage(s, "msg_table[250]"); + clif_displaymessage(s, "msg_table[250]"_s); return ATCE::EXIST; } @@ -1171,7 +1171,7 @@ ATCE atcommand_option(Session *s, dumb_ptr sd, clif_changeoption(sd); pc_calcstatus(sd, 0); - clif_displaymessage(s, "Options changed."); + clif_displaymessage(s, "Options changed."_s); return ATCE::OKAY; } @@ -1183,12 +1183,12 @@ ATCE atcommand_hide(Session *s, dumb_ptr sd, if (bool(sd->status.option & Option::HIDE)) { sd->status.option &= ~Option::HIDE; - clif_displaymessage(s, "Invisible: Off."); + clif_displaymessage(s, "Invisible: Off."_s); } else { sd->status.option |= Option::HIDE; - clif_displaymessage(s, "Invisible: On."); + clif_displaymessage(s, "Invisible: On."_s); } clif_changeoption(sd); @@ -1200,7 +1200,7 @@ ATCE atcommand_die(Session *s, dumb_ptr sd, ZString) { pc_damage(NULL, sd, sd->status.hp + 1); - clif_displaymessage(s, "A pity! You've died."); + clif_displaymessage(s, "A pity! You've died."_s); return ATCE::OKAY; } @@ -1221,17 +1221,17 @@ ATCE atcommand_kill(Session *s, dumb_ptr sd, { // you can kill only lower or same level pc_damage(NULL, pl_sd, pl_sd->status.hp + 1); - clif_displaymessage(s, "Character killed."); + clif_displaymessage(s, "Character killed."_s); } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -1250,7 +1250,7 @@ ATCE atcommand_alive(Session *s, dumb_ptr sd, clif_updatestatus(sd, SP::HP); clif_updatestatus(sd, SP::SP); clif_resurrection(sd, 1); - clif_displaymessage(s, "You've been revived! It's a miracle!"); + clif_displaymessage(s, "You've been revived! It's a miracle!"_s); return ATCE::OKAY; } @@ -1304,13 +1304,13 @@ ATCE atcommand_heal(Session *s, dumb_ptr sd, { pc_heal(sd, hp, sp); if (hp >= 0 && sp >= 0) - clif_displaymessage(s, "HP, SP recovered."); + clif_displaymessage(s, "HP, SP recovered."_s); else - clif_displaymessage(s, "HP or/and SP modified."); + clif_displaymessage(s, "HP or/and SP modified."_s); } else { - clif_displaymessage(s, "HP and SP are already with the good value."); + clif_displaymessage(s, "HP and SP are already with the good value."_s); return ATCE::RANGE; } @@ -1329,7 +1329,7 @@ ATCE atcommand_item(Session *s, dumb_ptr sd, if (!extract(message, record<' ', 1>(&item_name, &number))) { clif_displaymessage(s, - "Please, enter an item name/id (usage: @item [quantity])."); + "Please, enter an item name/id (usage: @item [quantity])."_s); return ATCE::USAGE; } @@ -1363,11 +1363,11 @@ ATCE atcommand_item(Session *s, dumb_ptr sd, != PickupFail::OKAY) clif_additem(sd, 0, 0, flag); } - clif_displaymessage(s, "Item created."); + clif_displaymessage(s, "Item created."_s); } else { - clif_displaymessage(s, "Invalid item ID or name."); + clif_displaymessage(s, "Invalid item ID or name."_s); return ATCE::EXIST; } @@ -1386,7 +1386,7 @@ ATCE atcommand_itemreset(Session *s, dumb_ptr sd, && sd->status.inventory[i].equip == EPOS::ZERO) pc_delitem(sd, i, sd->status.inventory[i].amount, 0); } - clif_displaymessage(s, "All of your items have been removed."); + clif_displaymessage(s, "All of your items have been removed."_s); return ATCE::OKAY; } @@ -1409,7 +1409,7 @@ ATCE atcommand_baselevelup(Session *s, dumb_ptr sd, if (!extract(message, &level) || !level) { clif_displaymessage(s, - "Please, enter a level adjustement (usage: @blvl )."); + "Please, enter a level adjustement (usage: @blvl )."_s); return ATCE::USAGE; } @@ -1417,7 +1417,7 @@ ATCE atcommand_baselevelup(Session *s, dumb_ptr sd, { if (sd->status.base_level == battle_config.maximum_level) { - clif_displaymessage(s, "Base level can't go any higher."); + clif_displaymessage(s, "Base level can't go any higher."_s); return ATCE::RANGE; } if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) @@ -1432,13 +1432,13 @@ ATCE atcommand_baselevelup(Session *s, dumb_ptr sd, pc_calcstatus(sd, 0); pc_heal(sd, sd->status.max_hp, sd->status.max_sp); clif_misceffect(sd, 0); - clif_displaymessage(s, "Base level raised."); + clif_displaymessage(s, "Base level raised."_s); } else { if (sd->status.base_level == 1) { - clif_displaymessage(s, "Base level can't go any lower."); + clif_displaymessage(s, "Base level can't go any lower."_s); return ATCE::USAGE; } if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) @@ -1458,7 +1458,7 @@ ATCE atcommand_baselevelup(Session *s, dumb_ptr sd, clif_updatestatus(sd, SP::BASELEVEL); clif_updatestatus(sd, SP::NEXTBASEEXP); pc_calcstatus(sd, 0); - clif_displaymessage(s, "Base level lowered."); + clif_displaymessage(s, "Base level lowered."_s); } return ATCE::OKAY; @@ -1481,7 +1481,7 @@ ATCE atcommand_joblevelup(Session *s, dumb_ptr sd, { if (sd->status.job_level == up_level) { - clif_displaymessage(s, "Job level can't go any higher."); + clif_displaymessage(s, "Job level can't go any higher."_s); return ATCE::RANGE; } if (level > up_level || level > (up_level - sd->status.job_level)) @@ -1494,13 +1494,13 @@ ATCE atcommand_joblevelup(Session *s, dumb_ptr sd, clif_updatestatus(sd, SP::SKILLPOINT); pc_calcstatus(sd, 0); clif_misceffect(sd, 1); - clif_displaymessage(s, "Job level raised."); + clif_displaymessage(s, "Job level raised."_s); } else { if (sd->status.job_level == 1) { - clif_displaymessage(s, "Job level can't go any lower."); + clif_displaymessage(s, "Job level can't go any lower."_s); return ATCE::RANGE; } if (level < -up_level || level < (1 - sd->status.job_level)) @@ -1518,7 +1518,7 @@ ATCE atcommand_joblevelup(Session *s, dumb_ptr sd, } // to add: remove status points from skills pc_calcstatus(sd, 0); - clif_displaymessage(s, "Job level lowered."); + clif_displaymessage(s, "Job level lowered."_s); } return ATCE::OKAY; @@ -1534,7 +1534,7 @@ ATCE atcommand_gm(Session *s, dumb_ptr sd, if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!) - clif_displaymessage(s, "You already have some GM powers."); + clif_displaymessage(s, "You already have some GM powers."_s); return ATCE::PERM; } else @@ -1550,7 +1550,7 @@ ATCE atcommand_pvpoff(Session *s, dumb_ptr sd, if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris] - clif_displaymessage(s, "This option cannot be used in PK Mode."); + clif_displaymessage(s, "This option cannot be used in PK Mode."_s); return ATCE::EXIST; } @@ -1571,11 +1571,11 @@ ATCE atcommand_pvpoff(Session *s, dumb_ptr sd, } } } - clif_displaymessage(s, "PvP: Off."); + clif_displaymessage(s, "PvP: Off."_s); } else { - clif_displaymessage(s, "PvP is already Off."); + clif_displaymessage(s, "PvP is already Off."_s); return ATCE::EXIST; } @@ -1589,7 +1589,7 @@ ATCE atcommand_pvpon(Session *s, dumb_ptr sd, if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris] - clif_displaymessage(s, "This option cannot be used in PK Mode."); + clif_displaymessage(s, "This option cannot be used in PK Mode."_s); return ATCE::EXIST; } @@ -1614,11 +1614,11 @@ ATCE atcommand_pvpon(Session *s, dumb_ptr sd, } } } - clif_displaymessage(s, "PvP: On."); + clif_displaymessage(s, "PvP: On."_s); } else { - clif_displaymessage(s, "PvP is already On."); + clif_displaymessage(s, "PvP is already On."_s); return ATCE::EXIST; } @@ -1642,7 +1642,7 @@ ATCE atcommand_model(Session *s, dumb_ptr sd, pc_changelook(sd, LOOK::HAIR, hair_style); pc_changelook(sd, LOOK::HAIR_COLOR, hair_color); pc_changelook(sd, LOOK::CLOTHES_COLOR, cloth_color); - clif_displaymessage(s, "Appearence changed."); + clif_displaymessage(s, "Appearence changed."_s); } } else @@ -1664,7 +1664,7 @@ ATCE atcommand_dye(Session *s, dumb_ptr sd, { { pc_changelook(sd, LOOK::CLOTHES_COLOR, cloth_color); - clif_displaymessage(s, "Appearence changed."); + clif_displaymessage(s, "Appearence changed."_s); } } else @@ -1686,7 +1686,7 @@ ATCE atcommand_hair_style(Session *s, dumb_ptr sd, { { pc_changelook(sd, LOOK::HAIR, hair_style); - clif_displaymessage(s, "Appearence changed."); + clif_displaymessage(s, "Appearence changed."_s); } } else @@ -1708,7 +1708,7 @@ ATCE atcommand_hair_color(Session *s, dumb_ptr sd, { { pc_changelook(sd, LOOK::HAIR_COLOR, hair_color); - clif_displaymessage(s, "Appearence changed."); + clif_displaymessage(s, "Appearence changed."_s); } } else @@ -1749,7 +1749,7 @@ ATCE atcommand_spawn(Session *s, dumb_ptr sd, number = battle_config.atcommand_spawn_quantity_limit; if (battle_config.etc_log) - PRINTF("@spawn monster='%s' id=%d count=%d (%d,%d)\n", + PRINTF("@spawn monster='%s' id=%d count=%d (%d,%d)\n"_fmt, monster, mob_id, number, x, y); count = 0; @@ -1778,16 +1778,16 @@ ATCE atcommand_spawn(Session *s, dumb_ptr sd, if (count != 0) if (number == count) - clif_displaymessage(s, "All monster summoned!"); + clif_displaymessage(s, "All monster summoned!"_s); else { - AString output = STRPRINTF("%d monster(s) summoned!", + AString output = STRPRINTF("%d monster(s) summoned!"_fmt, count); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Invalid monster ID or name."); + clif_displaymessage(s, "Invalid monster ID or name."_s); return ATCE::EXIST; } @@ -1813,7 +1813,7 @@ void atcommand_killmonster_sub(Session *s, dumb_ptr sd, map_id->xs, map_id->ys, BL::MOB); - clif_displaymessage(s, "All monsters killed!"); + clif_displaymessage(s, "All monsters killed!"_s); } static @@ -1830,7 +1830,7 @@ void atlist_nearby_sub(dumb_ptr bl, Session *s) { nullpo_retv(bl); - AString buf = STRPRINTF(" - \"%s\"", + AString buf = STRPRINTF(" - \"%s\""_fmt, bl->is_player()->status_key.name); clif_displaymessage(s, buf); } @@ -1839,7 +1839,7 @@ static ATCE atcommand_list_nearby(Session *s, dumb_ptr sd, ZString) { - clif_displaymessage(s, "Nearby players:"); + clif_displaymessage(s, "Nearby players:"_s); map_foreachinarea(std::bind(atlist_nearby_sub, ph::_1, s), sd->bl_m, sd->bl_x - 1, sd->bl_y - 1, @@ -1867,7 +1867,7 @@ ATCE atcommand_gat(Session *s, dumb_ptr sd, for (y = 2; y >= -2; y--) { AString output = STRPRINTF( - "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", + "%s (x= %d, y= %d) %02X %02X %02X %02X %02X"_fmt, 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), map_getcell(sd->bl_m, sd->bl_x - 1, sd->bl_y + y), @@ -1916,7 +1916,7 @@ ATCE atcommand_statuspoint(Session *s, dumb_ptr sd, { sd->status.status_point = new_status_point; clif_updatestatus(sd, SP::STATUSPOINT); - clif_displaymessage(s, "Number of status points changed!"); + clif_displaymessage(s, "Number of status points changed!"_s); } else return ATCE::RANGE; @@ -1945,7 +1945,7 @@ ATCE atcommand_skillpoint(Session *s, dumb_ptr sd, { sd->status.skill_point = new_skill_point; clif_updatestatus(sd, SP::SKILLPOINT); - clif_displaymessage(s, "Number of skill points changed!"); + clif_displaymessage(s, "Number of skill points changed!"_s); } else return ATCE::RANGE; @@ -1974,7 +1974,7 @@ ATCE atcommand_zeny(Session *s, dumb_ptr sd, { sd->status.zeny = new_zeny; clif_updatestatus(sd, SP::ZENY); - clif_displaymessage(s, "Number of zenys changed!"); + clif_displaymessage(s, "Number of zenys changed!"_s); } else return ATCE::RANGE; @@ -2006,7 +2006,7 @@ ATCE atcommand_param(Session *s, dumb_ptr sd, clif_updatestatus(sd, attr_to_sp(attr)); clif_updatestatus(sd, attr_to_usp(attr)); pc_calcstatus(sd, 0); - clif_displaymessage(s, "Stat changed."); + clif_displaymessage(s, "Stat changed."_s); } else return ATCE::RANGE; @@ -2047,7 +2047,7 @@ ATCE atcommand_all_stats(Session *s, dumb_ptr sd, if (count > 0) // if at least 1 stat modified - clif_displaymessage(s, "All stats changed!"); + clif_displaymessage(s, "All stats changed!"_s); else return ATCE::RANGE; @@ -2073,29 +2073,29 @@ ATCE atcommand_recall(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp somenone to your actual map."); + "You are not authorised to warp somenone to your actual map."_s); return ATCE::PERM; } if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp this player from its actual map."); + "You are not authorised to warp this player from its actual map."_s); return ATCE::PERM; } pc_setpos(pl_sd, sd->mapname_, sd->bl_x, sd->bl_y, BeingRemoveWhy::QUIT); - AString output = STRPRINTF("%s recalled!", character); + AString output = STRPRINTF("%s recalled!"_fmt, character); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -2121,11 +2121,11 @@ ATCE atcommand_revive(Session *s, dumb_ptr sd, clif_updatestatus(pl_sd, SP::HP); clif_updatestatus(pl_sd, SP::SP); clif_resurrection(pl_sd, 1); - clif_displaymessage(s, "Character revived."); + clif_displaymessage(s, "Character revived."_s); } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -2145,38 +2145,38 @@ ATCE atcommand_character_stats(Session *s, dumb_ptr, if (pl_sd != NULL) { AString output; - output = STRPRINTF("'%s' stats:", pl_sd->status_key.name); + output = STRPRINTF("'%s' stats:"_fmt, pl_sd->status_key.name); clif_displaymessage(s, output); - output = STRPRINTF("Base Level - %d", pl_sd->status.base_level), + output = STRPRINTF("Base Level - %d"_fmt, pl_sd->status.base_level), clif_displaymessage(s, output); - output = STRPRINTF("Job - Novice/Human (level %d)", pl_sd->status.job_level); + output = STRPRINTF("Job - Novice/Human (level %d)"_fmt, pl_sd->status.job_level); clif_displaymessage(s, output); - output = STRPRINTF("Hp - %d", pl_sd->status.hp); + output = STRPRINTF("Hp - %d"_fmt, pl_sd->status.hp); clif_displaymessage(s, output); - output = STRPRINTF("MaxHp - %d", pl_sd->status.max_hp); + output = STRPRINTF("MaxHp - %d"_fmt, pl_sd->status.max_hp); clif_displaymessage(s, output); - output = STRPRINTF("Sp - %d", pl_sd->status.sp); + output = STRPRINTF("Sp - %d"_fmt, pl_sd->status.sp); clif_displaymessage(s, output); - output = STRPRINTF("MaxSp - %d", pl_sd->status.max_sp); + output = STRPRINTF("MaxSp - %d"_fmt, pl_sd->status.max_sp); clif_displaymessage(s, output); - output = STRPRINTF("Str - %3d", pl_sd->status.attrs[ATTR::STR]); + output = STRPRINTF("Str - %3d"_fmt, pl_sd->status.attrs[ATTR::STR]); clif_displaymessage(s, output); - output = STRPRINTF("Agi - %3d", pl_sd->status.attrs[ATTR::AGI]); + output = STRPRINTF("Agi - %3d"_fmt, pl_sd->status.attrs[ATTR::AGI]); clif_displaymessage(s, output); - output = STRPRINTF("Vit - %3d", pl_sd->status.attrs[ATTR::VIT]); + output = STRPRINTF("Vit - %3d"_fmt, pl_sd->status.attrs[ATTR::VIT]); clif_displaymessage(s, output); - output = STRPRINTF("Int - %3d", pl_sd->status.attrs[ATTR::INT]); + output = STRPRINTF("Int - %3d"_fmt, pl_sd->status.attrs[ATTR::INT]); clif_displaymessage(s, output); - output = STRPRINTF("Dex - %3d", pl_sd->status.attrs[ATTR::DEX]); + output = STRPRINTF("Dex - %3d"_fmt, pl_sd->status.attrs[ATTR::DEX]); clif_displaymessage(s, output); - output = STRPRINTF("Luk - %3d", pl_sd->status.attrs[ATTR::LUK]); + output = STRPRINTF("Luk - %3d"_fmt, pl_sd->status.attrs[ATTR::LUK]); clif_displaymessage(s, output); - output = STRPRINTF("Zeny - %d", pl_sd->status.zeny); + output = STRPRINTF("Zeny - %d"_fmt, pl_sd->status.zeny); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -2200,19 +2200,19 @@ ATCE atcommand_character_stats_all(Session *s, dumb_ptr, { AString gmlevel; if (pc_isGM(pl_sd) > 0) - gmlevel = STRPRINTF("| GM Lvl: %d", pc_isGM(pl_sd)); + gmlevel = STRPRINTF("| GM Lvl: %d"_fmt, pc_isGM(pl_sd)); else - gmlevel = " "; + gmlevel = " "_s; AString output; output = STRPRINTF( - "Name: %s | BLvl: %d | Job: Novice/Human (Lvl: %d) | HP: %d/%d | SP: %d/%d", + "Name: %s | BLvl: %d | Job: Novice/Human (Lvl: %d) | HP: %d/%d | SP: %d/%d"_fmt, pl_sd->status_key.name, pl_sd->status.base_level, pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp); clif_displaymessage(s, output); - output = STRPRINTF("STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s", + output = STRPRINTF("STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s"_fmt, pl_sd->status.attrs[ATTR::STR], pl_sd->status.attrs[ATTR::AGI], pl_sd->status.attrs[ATTR::VIT], @@ -2222,18 +2222,18 @@ ATCE atcommand_character_stats_all(Session *s, dumb_ptr, pl_sd->status.zeny, gmlevel); clif_displaymessage(s, output); - clif_displaymessage(s, "--------"); + clif_displaymessage(s, "--------"_s); count++; } } if (count == 0) - clif_displaymessage(s, "No player found."); + clif_displaymessage(s, "No player found."_s); else if (count == 1) - clif_displaymessage(s, "1 player found."); + clif_displaymessage(s, "1 player found."_s); else { - AString output = STRPRINTF("%d players found.", count); + AString output = STRPRINTF("%d players found."_fmt, count); clif_displaymessage(s, output); } @@ -2263,17 +2263,17 @@ ATCE atcommand_character_option(Session *s, dumb_ptr sd, clif_changeoption(pl_sd); pc_calcstatus(pl_sd, 0); - clif_displaymessage(s, "Character's options changed."); + clif_displaymessage(s, "Character's options changed."_s); } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -2292,7 +2292,7 @@ ATCE atcommand_char_change_sex(Session *s, dumb_ptr sd, { chrif_char_ask_name(sd->status_key.account_id, character, 5, HumanTimeDiff()); // type: 5 - changesex - clif_displaymessage(s, "Character name sends to char-server to ask it."); + clif_displaymessage(s, "Character name sends to char-server to ask it."_s); } return ATCE::OKAY; @@ -2310,7 +2310,7 @@ ATCE atcommand_char_block(Session *s, dumb_ptr sd, { chrif_char_ask_name(sd->status_key.account_id, character, 1, HumanTimeDiff()); // type: 1 - block - clif_displaymessage(s, "Character name sends to char-server to ask it."); + clif_displaymessage(s, "Character name sends to char-server to ask it."_s); } return ATCE::OKAY; @@ -2330,7 +2330,7 @@ ATCE atcommand_char_ban(Session *s, dumb_ptr sd, { chrif_char_ask_name(sd->status_key.account_id, character, 2, modif); // type: 2 - ban - clif_displaymessage(s, "Character name sends to char-server to ask it."); + clif_displaymessage(s, "Character name sends to char-server to ask it."_s); } return ATCE::OKAY; @@ -2349,7 +2349,7 @@ ATCE atcommand_char_unblock(Session *s, dumb_ptr sd, // send answer to login server via char-server chrif_char_ask_name(sd->status_key.account_id, character, 3, HumanTimeDiff()); // type: 3 - unblock - clif_displaymessage(s, "Character name sends to char-server to ask it."); + clif_displaymessage(s, "Character name sends to char-server to ask it."_s); } return ATCE::OKAY; @@ -2368,7 +2368,7 @@ ATCE atcommand_char_unban(Session *s, dumb_ptr sd, // send answer to login server via char-server chrif_char_ask_name(sd->status_key.account_id, character, 4, HumanTimeDiff()); // type: 4 - unban - clif_displaymessage(s, "Character name sends to char-server to ask it."); + clif_displaymessage(s, "Character name sends to char-server to ask it."_s); } return ATCE::OKAY; @@ -2395,7 +2395,7 @@ ATCE atcommand_character_save(Session *s, dumb_ptr sd, map_local *m = map_mapname2mapid(map_name); if (m == nullptr) { - clif_displaymessage(s, "Map not found."); + clif_displaymessage(s, "Map not found."_s); return ATCE::EXIST; } else @@ -2404,22 +2404,22 @@ ATCE atcommand_character_save(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to set this map as a save map."); + "You are not authorised to set this map as a save map."_s); return ATCE::PERM; } pc_setsavepoint(pl_sd, map_name, x, y); - clif_displaymessage(s, "Character's respawn point changed."); + clif_displaymessage(s, "Character's respawn point changed."_s); } } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -2442,10 +2442,10 @@ ATCE atcommand_doom(Session *s, dumb_ptr sd, { // you can doom only lower or same gm level pc_damage(NULL, pl_sd, pl_sd->status.hp + 1); - clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement."); + clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement."_s); } } - clif_displaymessage(s, "Judgement was made."); + clif_displaymessage(s, "Judgement was made."_s); return ATCE::OKAY; } @@ -2466,10 +2466,10 @@ ATCE atcommand_doommap(Session *s, dumb_ptr sd, { // you can doom only lower or same gm level pc_damage(NULL, pl_sd, pl_sd->status.hp + 1); - clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement."); + clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement."_s); } } - clif_displaymessage(s, "Judgement was made."); + clif_displaymessage(s, "Judgement was made."_s); return ATCE::OKAY; } @@ -2485,7 +2485,7 @@ void atcommand_raise_sub(dumb_ptr sd) clif_updatestatus(sd, SP::HP); clif_updatestatus(sd, SP::SP); clif_resurrection(sd, 1); - clif_displaymessage(sd->sess, "Mercy has been shown."); + clif_displaymessage(sd->sess, "Mercy has been shown."_s); } } @@ -2501,7 +2501,7 @@ ATCE atcommand_raise(Session *s, dumb_ptr, dumb_ptr pl_sd = dumb_ptr(static_cast(s2->session_data.get())); atcommand_raise_sub(pl_sd); } - clif_displaymessage(s, "Mercy has been granted."); + clif_displaymessage(s, "Mercy has been granted."_s); return ATCE::OKAY; } @@ -2520,7 +2520,7 @@ ATCE atcommand_raisemap(Session *s, dumb_ptr sd, && pl_sd->state.auth && sd->bl_m == pl_sd->bl_m) atcommand_raise_sub(pl_sd); } - clif_displaymessage(s, "Mercy has been granted."); + clif_displaymessage(s, "Mercy has been granted."_s); return ATCE::OKAY; } @@ -2546,7 +2546,7 @@ ATCE atcommand_character_baselevel(Session *s, dumb_ptr sd, { if (pl_sd->status.base_level == battle_config.maximum_level) { - clif_displaymessage(s, "Character's base level can't go any higher."); + clif_displaymessage(s, "Character's base level can't go any higher."_s); return ATCE::RANGE; } if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) @@ -2564,13 +2564,13 @@ ATCE atcommand_character_baselevel(Session *s, dumb_ptr sd, pc_calcstatus(pl_sd, 0); pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp); clif_misceffect(pl_sd, 0); - clif_displaymessage(s, "Character's base level raised."); + clif_displaymessage(s, "Character's base level raised."_s); } else { if (pl_sd->status.base_level == 1) { - clif_displaymessage(s, "Character's base level can't go any lower."); + clif_displaymessage(s, "Character's base level can't go any lower."_s); return ATCE::RANGE; } if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) @@ -2592,20 +2592,20 @@ ATCE atcommand_character_baselevel(Session *s, dumb_ptr sd, clif_updatestatus(pl_sd, SP::NEXTBASEEXP); clif_updatestatus(pl_sd, SP::BASEEXP); pc_calcstatus(pl_sd, 0); - clif_displaymessage(s, "Character's base level lowered."); + clif_displaymessage(s, "Character's base level lowered."_s); } // Reset their stat points to prevent extra points from stacking atcommand_charstreset(s, sd, character.to__actual()); } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -2635,7 +2635,7 @@ ATCE atcommand_character_joblevel(Session *s, dumb_ptr sd, { if (pl_sd->status.job_level == max_level) { - clif_displaymessage(s, "Character's job level can't go any higher."); + clif_displaymessage(s, "Character's job level can't go any higher."_s); return ATCE::RANGE; } if (pl_sd->status.job_level + level > max_level) @@ -2647,13 +2647,13 @@ ATCE atcommand_character_joblevel(Session *s, dumb_ptr sd, clif_updatestatus(pl_sd, SP::SKILLPOINT); pc_calcstatus(pl_sd, 0); clif_misceffect(pl_sd, 1); - clif_displaymessage(s, "character's job level raised."); + clif_displaymessage(s, "character's job level raised."_s); } else { if (pl_sd->status.job_level == 1) { - clif_displaymessage(s, "Character's job level can't go any lower."); + clif_displaymessage(s, "Character's job level can't go any lower."_s); return ATCE::RANGE; } if (pl_sd->status.job_level + level < 1) @@ -2670,18 +2670,18 @@ ATCE atcommand_character_joblevel(Session *s, dumb_ptr sd, } // to add: remove status points from skills pc_calcstatus(pl_sd, 0); - clif_displaymessage(s, "Character's job level lowered."); + clif_displaymessage(s, "Character's job level lowered."_s); } } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -2705,13 +2705,13 @@ ATCE atcommand_kick(Session *s, dumb_ptr sd, clif_GM_kick(sd, pl_sd, 1); else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -2737,7 +2737,7 @@ ATCE atcommand_kickall(Session *s, dumb_ptr sd, } } - clif_displaymessage(s, "All players have been kicked!"); + clif_displaymessage(s, "All players have been kicked!"_s); return ATCE::OKAY; } @@ -2758,23 +2758,23 @@ ATCE atcommand_questskill(Session *s, dumb_ptr sd, if (pc_checkskill(sd, skill_id) == 0) { pc_skill(sd, skill_id, 1, 0); - clif_displaymessage(s, "You have learned the skill."); + clif_displaymessage(s, "You have learned the skill."_s); } else { - clif_displaymessage(s, "You already have this quest skill."); + clif_displaymessage(s, "You already have this quest skill."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill."); + clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill."_s); return ATCE::RANGE; } } else { - clif_displaymessage(s, "This skill number doesn't exist."); + clif_displaymessage(s, "This skill number doesn't exist."_s); return ATCE::RANGE; } @@ -2801,29 +2801,29 @@ ATCE atcommand_charquestskill(Session *s, dumb_ptr, if (pc_checkskill(pl_sd, skill_id) == 0) { pc_skill(pl_sd, skill_id, 1, 0); - clif_displaymessage(s, "This player has learned the skill."); + clif_displaymessage(s, "This player has learned the skill."_s); } else { - clif_displaymessage(s, "This player already has this quest skill."); + clif_displaymessage(s, "This player already has this quest skill."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill."); + clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill."_s); return ATCE::RANGE; } } else { - clif_displaymessage(s, "This skill number doesn't exist."); + clif_displaymessage(s, "This skill number doesn't exist."_s); return ATCE::RANGE; } @@ -2848,23 +2848,23 @@ ATCE atcommand_lostskill(Session *s, dumb_ptr sd, sd->status.skill[skill_id].lv = 0; sd->status.skill[skill_id].flags = SkillFlags::ZERO; clif_skillinfoblock(sd); - clif_displaymessage(s, "You have forgotten the skill."); + clif_displaymessage(s, "You have forgotten the skill."_s); } else { - clif_displaymessage(s, "You don't have this quest skill."); + clif_displaymessage(s, "You don't have this quest skill."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill."); + clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill."_s); return ATCE::RANGE; } } else { - clif_displaymessage(s, "This skill number doesn't exist."); + clif_displaymessage(s, "This skill number doesn't exist."_s); return ATCE::RANGE; } @@ -2893,29 +2893,29 @@ ATCE atcommand_charlostskill(Session *s, dumb_ptr, pl_sd->status.skill[skill_id].lv = 0; pl_sd->status.skill[skill_id].flags = SkillFlags::ZERO; clif_skillinfoblock(pl_sd); - clif_displaymessage(s, "This player has forgotten the skill."); + clif_displaymessage(s, "This player has forgotten the skill."_s); } else { - clif_displaymessage(s, "This player doesn't have this quest skill."); + clif_displaymessage(s, "This player doesn't have this quest skill."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill."); + clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill."_s); return ATCE::RANGE; } } else { - clif_displaymessage(s, "This skill number doesn't exist."); + clif_displaymessage(s, "This skill number doesn't exist."_s); return ATCE::RANGE; } @@ -2970,7 +2970,7 @@ ATCE atcommand_idsearch(Session *s, dumb_ptr, if (!extract(message, &item_name) || !item_name) return ATCE::USAGE; - AString output = STRPRINTF("The reference result of '%s' (name: id):", item_name); + AString output = STRPRINTF("The reference result of '%s' (name: id):"_fmt, item_name); clif_displaymessage(s, output); match = 0; for (i = 0; i < 20000; i++) @@ -2979,11 +2979,11 @@ ATCE atcommand_idsearch(Session *s, dumb_ptr, && item->jname.contains_seq(item_name)) { match++; - output = STRPRINTF("%s: %d", item->jname, item->nameid); + output = STRPRINTF("%s: %d"_fmt, item->jname, item->nameid); clif_displaymessage(s, output); } } - output = STRPRINTF("It is %d affair above.", match); + output = STRPRINTF("It is %d affair above."_fmt, match); clif_displaymessage(s, output); return ATCE::OKAY; @@ -3006,18 +3006,18 @@ ATCE atcommand_charskreset(Session *s, dumb_ptr sd, // you can reset skill points only lower or same gm level pc_resetskill(pl_sd); AString output = STRPRINTF( - "'%s' skill points reseted!", character); + "'%s' skill points reseted!"_fmt, character); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3041,19 +3041,19 @@ ATCE atcommand_charstreset(Session *s, dumb_ptr sd, // you can reset stats points only lower or same gm level pc_resetstate(pl_sd); AString output = STRPRINTF( - "'%s' stats points reseted!", + "'%s' stats points reseted!"_fmt, character); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3077,23 +3077,23 @@ ATCE atcommand_charreset(Session *s, dumb_ptr sd, // you can reset a character only for lower or same GM level pc_resetstate(pl_sd); pc_resetskill(pl_sd); - pc_setglobalreg(pl_sd, stringish("MAGIC_FLAGS"), 0); + pc_setglobalreg(pl_sd, stringish("MAGIC_FLAGS"_s), 0); // [Fate] Reset magic quest variables - pc_setglobalreg(pl_sd, stringish("MAGIC_EXP"), 0); + pc_setglobalreg(pl_sd, stringish("MAGIC_EXP"_s), 0); // [Fate] Reset magic experience AString output = STRPRINTF( - "'%s' skill and stats points reseted!", character); + "'%s' skill and stats points reseted!"_fmt, character); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3157,23 +3157,23 @@ ATCE atcommand_char_wipe(Session *s, dumb_ptr sd, pc_calcstatus(pl_sd, 0); pc_resetstate(pl_sd); pc_resetskill(pl_sd); - pc_setglobalreg(pl_sd, stringish("MAGIC_FLAGS"), 0); + pc_setglobalreg(pl_sd, stringish("MAGIC_FLAGS"_s), 0); // [Fate] Reset magic quest variables - pc_setglobalreg(pl_sd, stringish("MAGIC_EXP"), 0); + pc_setglobalreg(pl_sd, stringish("MAGIC_EXP"_s), 0); // [Fate] Reset magic experience - AString output = STRPRINTF("%s: wiped.", character); + AString output = STRPRINTF("%s: wiped."_fmt, character); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3201,7 +3201,7 @@ ATCE atcommand_charmodel(Session *s, dumb_ptr, pc_changelook(pl_sd, LOOK::HAIR, hair_style); pc_changelook(pl_sd, LOOK::HAIR_COLOR, hair_color); pc_changelook(pl_sd, LOOK::CLOTHES_COLOR, cloth_color); - clif_displaymessage(s, "Appearence changed."); + clif_displaymessage(s, "Appearence changed."_s); } } else @@ -3209,7 +3209,7 @@ ATCE atcommand_charmodel(Session *s, dumb_ptr, } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3242,14 +3242,14 @@ ATCE atcommand_charskpoint(Session *s, dumb_ptr, { pl_sd->status.skill_point = new_skill_point; clif_updatestatus(pl_sd, SP::SKILLPOINT); - clif_displaymessage(s, "Character's number of skill points changed!"); + clif_displaymessage(s, "Character's number of skill points changed!"_s); } else return ATCE::RANGE; } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3282,14 +3282,14 @@ ATCE atcommand_charstpoint(Session *s, dumb_ptr, { pl_sd->status.status_point = new_status_point; clif_updatestatus(pl_sd, SP::STATUSPOINT); - clif_displaymessage(s, "Character's number of status points changed!"); + clif_displaymessage(s, "Character's number of status points changed!"_s); } else return ATCE::RANGE; } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3320,14 +3320,14 @@ ATCE atcommand_charzeny(Session *s, dumb_ptr, { pl_sd->status.zeny = new_zeny; clif_updatestatus(pl_sd, SP::ZENY); - clif_displaymessage(s, "Character's number of zenys changed!"); + clif_displaymessage(s, "Character's number of zenys changed!"_s); } else return ATCE::RANGE; } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3344,7 +3344,7 @@ ATCE atcommand_recallall(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp somenone to your actual map."); + "You are not authorised to warp somenone to your actual map."_s); return ATCE::PERM; } @@ -3369,11 +3369,11 @@ ATCE atcommand_recallall(Session *s, dumb_ptr sd, } } - clif_displaymessage(s, "All characters recalled!"); + clif_displaymessage(s, "All characters recalled!"_s); if (count) { AString output = STRPRINTF( - "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", + "Because you are not authorised to warp from some maps, %d player(s) have not been recalled."_fmt, count); clif_displaymessage(s, output); } @@ -3396,7 +3396,7 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp somenone to your actual map."); + "You are not authorised to warp somenone to your actual map."_s); return ATCE::PERM; } @@ -3422,19 +3422,19 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr sd, pc_setpos(pl_sd, sd->mapname_, sd->bl_x, sd->bl_y, BeingRemoveWhy::QUIT); } } - AString 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."_fmt, p->name); clif_displaymessage(s, output); if (count) { output = STRPRINTF( - "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", + "Because you are not authorised to warp from some maps, %d player(s) have not been recalled."_fmt, count); clif_displaymessage(s, output); } } else { - clif_displaymessage(s, "Incorrect name or ID, or no one from the party is online."); + clif_displaymessage(s, "Incorrect name or ID, or no one from the party is online."_s); return ATCE::EXIST; } @@ -3447,7 +3447,7 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr sd, { dumb_ptr nd = NULL; MapName map_name; - const char *direction = NULL; + LString direction = ""_s; int list = 0; extract(message, record<' '>(&list, &map_name)); @@ -3462,35 +3462,35 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr sd, if (m_id != nullptr) return ATCE::EXIST; - clif_displaymessage(s, "------ Map Info ------"); - AString output = STRPRINTF("Map Name: %s", map_name); + clif_displaymessage(s, "------ Map Info ------"_s); + AString output = STRPRINTF("Map Name: %s"_fmt, map_name); clif_displaymessage(s, output); - output = STRPRINTF("Players In Map: %d", m_id->users); + output = STRPRINTF("Players In Map: %d"_fmt, m_id->users); clif_displaymessage(s, output); - output = STRPRINTF("NPCs In Map: %d", m_id->npc_num); + output = STRPRINTF("NPCs In Map: %d"_fmt, m_id->npc_num); clif_displaymessage(s, output); - clif_displaymessage(s, "------ Map Flags ------"); - output = STRPRINTF("Player vs Player: %s | No Party: %s", - (m_id->flag.get(MapFlag::PVP)) ? "True" : "False", - (m_id->flag.get(MapFlag::PVP_NOPARTY)) ? "True" : "False"); + clif_displaymessage(s, "------ Map Flags ------"_s); + output = STRPRINTF("Player vs Player: %s | No Party: %s"_fmt, + (m_id->flag.get(MapFlag::PVP)) ? "True"_s : "False"_s, + (m_id->flag.get(MapFlag::PVP_NOPARTY)) ? "True"_s : "False"_s); clif_displaymessage(s, output); - output = STRPRINTF("No Penalty: %s", - (m_id->flag.get(MapFlag::NOPENALTY)) ? "True" : "False"); + output = STRPRINTF("No Penalty: %s"_fmt, + (m_id->flag.get(MapFlag::NOPENALTY)) ? "True"_s : "False"_s); clif_displaymessage(s, output); - output = STRPRINTF("No Return: %s", - (m_id->flag.get(MapFlag::NORETURN)) ? "True" : "False"); + output = STRPRINTF("No Return: %s"_fmt, + (m_id->flag.get(MapFlag::NORETURN)) ? "True"_s : "False"_s); clif_displaymessage(s, output); - output = STRPRINTF("No Save: %s", - (m_id->flag.get(MapFlag::NOSAVE)) ? "True" : "False"); + output = STRPRINTF("No Save: %s"_fmt, + (m_id->flag.get(MapFlag::NOSAVE)) ? "True"_s : "False"_s); clif_displaymessage(s, output); - output = STRPRINTF("Re Save: %s", - (m_id->flag.get(MapFlag::RESAVE)) ? "True" : "False"); + output = STRPRINTF("Re Save: %s"_fmt, + (m_id->flag.get(MapFlag::RESAVE)) ? "True"_s : "False"_s); clif_displaymessage(s, output); - output = STRPRINTF("No Teleport: %s", - (m_id->flag.get(MapFlag::NOTELEPORT)) ? "True" : "False"); + output = STRPRINTF("No Teleport: %s"_fmt, + (m_id->flag.get(MapFlag::NOTELEPORT)) ? "True"_s : "False"_s); clif_displaymessage(s, output); - output = STRPRINTF("No Monster Teleport: %s", - (m_id->flag.get(MapFlag::MONSTER_NOTELEPORT)) ? "True" : "False"); + output = STRPRINTF("No Monster Teleport: %s"_fmt, + (m_id->flag.get(MapFlag::MONSTER_NOTELEPORT)) ? "True"_s : "False"_s); clif_displaymessage(s, output); switch (list) @@ -3499,7 +3499,7 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr sd, // Do nothing. It's list 0, no additional display. break; case 1: - clif_displaymessage(s, "----- Players in Map -----"); + clif_displaymessage(s, "----- Players in Map -----"_s); for (io::FD i : iter_fds()) { Session *s2 = get_session(i); @@ -3510,54 +3510,54 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr sd, && pl_sd->mapname_ == map_name) { output = STRPRINTF( - "Player '%s' (session #%d) | Location: %d,%d", + "Player '%s' (session #%d) | Location: %d,%d"_fmt, pl_sd->status_key.name, s2, pl_sd->bl_x, pl_sd->bl_y); clif_displaymessage(s, output); } } break; case 2: - clif_displaymessage(s, "----- NPCs in Map -----"); + clif_displaymessage(s, "----- NPCs in Map -----"_s); for (int i = 0; i < m_id->npc_num;) { nd = m_id->npc[i]; switch (nd->dir) { case DIR::S: - direction = "North"; + direction = "North"_s; break; case DIR::SW: - direction = "North West"; + direction = "North West"_s; break; case DIR::W: - direction = "West"; + direction = "West"_s; break; case DIR::NW: - direction = "South West"; + direction = "South West"_s; break; case DIR::N: - direction = "South"; + direction = "South"_s; break; case DIR::NE: - direction = "South East"; + direction = "South East"_s; break; case DIR::E: - direction = "East"; + direction = "East"_s; break; case DIR::SE: - direction = "North East"; + direction = "North East"_s; break; #if 0 case 9: - direction = "North"; + direction = "North"_s; break; #endif default: - direction = "Unknown"; + direction = "Unknown"_s; break; } output = STRPRINTF( - "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d", + "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d"_fmt, ++i, nd->name, direction, nd->npc_class, nd->bl_x, nd->bl_y); clif_displaymessage(s, output); @@ -3566,7 +3566,7 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr sd, default: // normally impossible to arrive here clif_displaymessage(s, - "Please, enter at least a valid list number (usage: @mapinfo <0-2> [map])."); + "Please, enter at least a valid list number (usage: @mapinfo <0-2> [map])."_s); return ATCE::USAGE; } @@ -3590,19 +3590,19 @@ ATCE atcommand_partyspy(Session *s, dumb_ptr sd, if (sd->partyspy == p->party_id) { sd->partyspy = 0; - AString output = STRPRINTF("No longer spying on the %s party.", p->name); + AString output = STRPRINTF("No longer spying on the %s party."_fmt, p->name); clif_displaymessage(s, output); } else { sd->partyspy = p->party_id; - AString output = STRPRINTF("Spying on the %s party.", p->name); + AString output = STRPRINTF("Spying on the %s party."_fmt, p->name); clif_displaymessage(s, output); } } else { - clif_displaymessage(s, "Incorrect name or ID, or no one from the party is online."); + clif_displaymessage(s, "Incorrect name or ID, or no one from the party is online."_s); return ATCE::EXIST; } @@ -3621,11 +3621,11 @@ ATCE atcommand_enablenpc(Session *s, dumb_ptr, if (npc_name2id(NPCname) != NULL) { npc_enable(NPCname, 1); - clif_displaymessage(s, "Npc Enabled."); + clif_displaymessage(s, "Npc Enabled."_s); } else { - clif_displaymessage(s, "This NPC doesn't exist."); + clif_displaymessage(s, "This NPC doesn't exist."_s); return ATCE::EXIST; } @@ -3644,11 +3644,11 @@ ATCE atcommand_disablenpc(Session *s, dumb_ptr, if (npc_name2id(NPCname) != NULL) { npc_enable(NPCname, 0); - clif_displaymessage(s, "Npc Disabled."); + clif_displaymessage(s, "Npc Disabled."_s); } else { - clif_displaymessage(s, "This NPC doesn't exist."); + clif_displaymessage(s, "This NPC doesn't exist."_s); return ATCE::EXIST; } @@ -3661,7 +3661,7 @@ ATCE atcommand_servertime(Session *s, dumb_ptr, { timestamp_seconds_buffer tsbuf; stamp_time(tsbuf); - AString temp = STRPRINTF("Server time: %s", tsbuf); + AString temp = STRPRINTF("Server time: %s"_fmt, tsbuf); clif_displaymessage(s, temp); return ATCE::OKAY; @@ -3707,37 +3707,37 @@ ATCE atcommand_chardelitem(Session *s, dumb_ptr sd, // for next loop } AString output = STRPRINTF( - "%d item(s) removed by a GM.", + "%d item(s) removed by a GM."_fmt, count); clif_displaymessage(pl_sd->sess, output); if (number == count) - output = STRPRINTF("%d item(s) removed from the player.", count); + output = STRPRINTF("%d item(s) removed from the player."_fmt, count); else - output = STRPRINTF("%d item(s) removed. Player had only %d on %d items.", count, count, number); + output = STRPRINTF("%d item(s) removed. Player had only %d on %d items."_fmt, count, count, number); clif_displaymessage(s, output); } else { - clif_displaymessage(s, "Character does not have the item."); + clif_displaymessage(s, "Character does not have the item."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } } else { - clif_displaymessage(s, "Invalid item ID or name."); + clif_displaymessage(s, "Invalid item ID or name."_s); return ATCE::RANGE; } @@ -3751,7 +3751,7 @@ ATCE atcommand_broadcast(Session *, dumb_ptr sd, if (!message) return ATCE::USAGE; - AString output = STRPRINTF("%s : %s", sd->status_key.name, message); + AString output = STRPRINTF("%s : %s"_fmt, sd->status_key.name, message); intif_GMmessage(output); return ATCE::OKAY; @@ -3764,7 +3764,7 @@ ATCE atcommand_localbroadcast(Session *, dumb_ptr sd, if (!message) return ATCE::USAGE; - AString output = STRPRINTF("%s : %s", sd->status_key.name, message); + AString output = STRPRINTF("%s : %s"_fmt, sd->status_key.name, message); clif_GMmessage(sd, output, 1); @@ -3783,28 +3783,28 @@ ATCE atcommand_email(Session *s, dumb_ptr sd, if (!e_mail_check(actual_email)) { - clif_displaymessage(s, "Invalid actual email. If you have default e-mail, type a@a.com."); + clif_displaymessage(s, "Invalid actual email. If you have default e-mail, type a@a.com."_s); return ATCE::RANGE; } else if (!e_mail_check(new_email)) { - clif_displaymessage(s, "Invalid new email. Please enter a real e-mail."); + clif_displaymessage(s, "Invalid new email. Please enter a real e-mail."_s); return ATCE::RANGE; } else if (new_email == DEFAULT_EMAIL) { - clif_displaymessage(s, "New email must be a real e-mail."); + clif_displaymessage(s, "New email must be a real e-mail."_s); return ATCE::RANGE; } else if (actual_email == new_email) { - clif_displaymessage(s, "New email must be different of the actual e-mail."); + clif_displaymessage(s, "New email must be different of the actual e-mail."_s); return ATCE::RANGE; } else { chrif_changeemail(sd->status_key.account_id, actual_email, new_email); - clif_displaymessage(s, "Information sended to login-server via char-server."); + clif_displaymessage(s, "Information sended to login-server via char-server."_s); } return ATCE::OKAY; @@ -3821,7 +3821,7 @@ ATCE atcommand_effect(Session *s, dumb_ptr sd, if (flag <= 0) { clif_specialeffect(sd, type, flag); - clif_displaymessage(s, "Your Effect Has Changed."); + clif_displaymessage(s, "Your Effect Has Changed."_s); } else { @@ -3834,7 +3834,7 @@ ATCE atcommand_effect(Session *s, dumb_ptr sd, if (pl_sd && pl_sd->state.auth) { clif_specialeffect(pl_sd, type, flag); - clif_displaymessage(pl_sd->sess, "Your Effect Has Changed."); + clif_displaymessage(pl_sd->sess, "Your Effect Has Changed."_s); } } } @@ -3873,7 +3873,7 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, if (count == 1) { AString output = STRPRINTF( - "------ Items list of '%s' ------", + "------ Items list of '%s' ------"_fmt, pl_sd->status_key.name); clif_displaymessage(s, output); } @@ -3881,35 +3881,35 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, MString equipstr; if (bool(equip)) { - equipstr += "| equiped: "; + equipstr += "| equiped: "_s; if (bool(equip & EPOS::GLOVES)) - equipstr += "robe/gargment, "; + equipstr += "robe/gargment, "_s; if (bool(equip & EPOS::CAPE)) - equipstr += "left accessory, "; + equipstr += "left accessory, "_s; if (bool(equip & EPOS::MISC1)) - equipstr += "body/armor, "; + equipstr += "body/armor, "_s; if ((equip & (EPOS::WEAPON | EPOS::SHIELD)) == EPOS::WEAPON) - equipstr += "right hand, "; + equipstr += "right hand, "_s; if ((equip & (EPOS::WEAPON | EPOS::SHIELD)) == EPOS::SHIELD) - equipstr += "left hand, "; + equipstr += "left hand, "_s; if ((equip & (EPOS::WEAPON | EPOS::SHIELD)) == (EPOS::WEAPON | EPOS::SHIELD)) - equipstr += "both hands, "; + equipstr += "both hands, "_s; if (bool(equip & EPOS::SHOES)) - equipstr += "feet, "; + equipstr += "feet, "_s; if (bool(equip & EPOS::MISC2)) - equipstr += "right accessory, "; + equipstr += "right accessory, "_s; if ((equip & (EPOS::TORSO | EPOS::HAT | EPOS::LEGS)) == EPOS::LEGS) - equipstr += "lower head, "; + equipstr += "lower head, "_s; if ((equip & (EPOS::TORSO | EPOS::HAT | EPOS::LEGS)) == EPOS::HAT) - equipstr += "top head, "; + equipstr += "top head, "_s; if ((equip & (EPOS::TORSO | EPOS::HAT | EPOS::LEGS)) == (EPOS::HAT | EPOS::LEGS)) - equipstr += "lower/top head, "; + equipstr += "lower/top head, "_s; if ((equip & (EPOS::TORSO | EPOS::HAT | EPOS::LEGS)) == EPOS::TORSO) - equipstr += "mid head, "; + equipstr += "mid head, "_s; if ((equip & (EPOS::TORSO | EPOS::HAT | EPOS::LEGS)) == (EPOS::TORSO | EPOS::LEGS)) - equipstr += "lower/mid head, "; + equipstr += "lower/mid head, "_s; if ((equip & (EPOS::TORSO | EPOS::HAT | EPOS::LEGS)) == (EPOS::TORSO | EPOS::HAT | EPOS::LEGS)) - equipstr += "lower/mid/top head, "; + equipstr += "lower/mid/top head, "_s; // remove final ', ' equipstr.pop_back(2); } @@ -3918,7 +3918,7 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, AString output; if (true) - output = STRPRINTF("%d %s (%s, id: %d) %s", + output = STRPRINTF("%d %s (%s, id: %d) %s"_fmt, pl_sd->status.inventory[i].amount, item_data->name, item_data->jname, pl_sd->status.inventory[i].nameid, @@ -3929,24 +3929,24 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr sd, } } if (count == 0) - clif_displaymessage(s, "No item found on this player."); + clif_displaymessage(s, "No item found on this player."_s); else { AString output = STRPRINTF( - "%d item(s) found in %d kind(s) of items.", + "%d item(s) found in %d kind(s) of items."_fmt, counter, count); clif_displaymessage(s, output); } } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -3986,13 +3986,13 @@ ATCE atcommand_character_storage_list(Session *s, dumb_ptr sd, if (count == 1) { AString output = STRPRINTF( - "------ Storage items list of '%s' ------", + "------ Storage items list of '%s' ------"_fmt, pl_sd->status_key.name); clif_displaymessage(s, output); } AString output; if (true) - output = STRPRINTF("%d %s (%s, id: %d)", + output = STRPRINTF("%d %s (%s, id: %d)"_fmt, stor->storage_[i].amount, item_data->name, item_data->jname, stor->storage_[i].nameid); @@ -4001,30 +4001,30 @@ ATCE atcommand_character_storage_list(Session *s, dumb_ptr sd, } if (count == 0) clif_displaymessage(s, - "No item found in the storage of this player."); + "No item found in the storage of this player."_s); else { AString output = STRPRINTF( - "%d item(s) found in %d kind(s) of items.", + "%d item(s) found in %d kind(s) of items."_fmt, counter, count); clif_displaymessage(s, output); } } else { - clif_displaymessage(s, "This player has no storage."); + clif_displaymessage(s, "This player has no storage."_s); return ATCE::OKAY; } } else { - clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."); + clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player."_s); return ATCE::PERM; } } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -4038,9 +4038,9 @@ ATCE atcommand_killer(Session *s, dumb_ptr sd, sd->special_state.killer = !sd->special_state.killer; if (sd->special_state.killer) - clif_displaymessage(s, "You be a killa..."); + clif_displaymessage(s, "You be a killa..."_s); else - clif_displaymessage(s, "You gonna be own3d..."); + clif_displaymessage(s, "You gonna be own3d..."_s); return ATCE::OKAY; } @@ -4062,13 +4062,13 @@ ATCE atcommand_charkiller(Session *s, dumb_ptr, if (pl_sd->special_state.killer) { - clif_displaymessage(s, "The player is now a killer"); - clif_displaymessage(pl_sd->sess, "You are now a killer"); + clif_displaymessage(s, "The player is now a killer"_s); + clif_displaymessage(pl_sd->sess, "You are now a killer"_s); } else { - clif_displaymessage(s, "The player is no longer a killer"); - clif_displaymessage(pl_sd->sess, "You are no longer a killer"); + clif_displaymessage(s, "The player is no longer a killer"_s); + clif_displaymessage(pl_sd->sess, "You are no longer a killer"_s); } return ATCE::OKAY; @@ -4081,9 +4081,9 @@ ATCE atcommand_killable(Session *s, dumb_ptr sd, sd->special_state.killable = !sd->special_state.killable; if (sd->special_state.killable) - clif_displaymessage(s, "You gonna be own3d..."); + clif_displaymessage(s, "You gonna be own3d..."_s); else - clif_displaymessage(s, "You be a killa..."); + clif_displaymessage(s, "You be a killa..."_s); return ATCE::OKAY; } @@ -4104,9 +4104,9 @@ ATCE atcommand_charkillable(Session *s, dumb_ptr, pl_sd->special_state.killable = !pl_sd->special_state.killable; if (pl_sd->special_state.killable) - clif_displaymessage(s, "The player is now killable"); + clif_displaymessage(s, "The player is now killable"_s); else - clif_displaymessage(s, "The player is no longer killable"); + clif_displaymessage(s, "The player is no longer killable"_s); return ATCE::OKAY; } @@ -4146,17 +4146,17 @@ ATCE atcommand_addwarp(Session *s, dumb_ptr sd, if (!extract(message, record<' '>(&mapname, &x, &y))) return ATCE::USAGE; - 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); + AString w1 = STRPRINTF("%s,%d,%d"_fmt, sd->mapname_, sd->bl_x, sd->bl_y); + AString w3 = STRPRINTF("%s%d%d%d%d"_fmt, mapname, sd->bl_x, sd->bl_y, x, y); + AString w4 = STRPRINTF("1,1,%s.gat,%d,%d"_fmt, mapname, x, y); NpcName w3name = stringish(w3); - int ret = npc_parse_warp(w1, ZString("warp"), w3name, w4); + int ret = npc_parse_warp(w1, "warp"_s, w3name, w4); if (ret) // warp failed return ATCE::RANGE; - AString output = STRPRINTF("New warp NPC => %s", w3); + AString output = STRPRINTF("New warp NPC => %s"_fmt, w3); clif_displaymessage(s, output); return ATCE::OKAY; @@ -4177,7 +4177,7 @@ ATCE atcommand_chareffect(Session *s, dumb_ptr, return ATCE::EXIST; clif_specialeffect(pl_sd, type, 0); - clif_displaymessage(s, "Your Effect Has Changed."); + clif_displaymessage(s, "Your Effect Has Changed."_s); return ATCE::OKAY; } @@ -4220,9 +4220,8 @@ ATCE atcommand_chardropall(Session *s, dumb_ptr, } } - clif_displaymessage(pl_sd->sess, "Ever play 52 card pickup?"); - clif_displaymessage(s, "It is done"); - //clif_displaymessage(s, "It is offical.. your a jerk"); + clif_displaymessage(pl_sd->sess, "Ever play 52 card pickup?"_s); + clif_displaymessage(s, "It is official.. you're a jerk."_s); return ATCE::OKAY; } @@ -4240,12 +4239,12 @@ ATCE atcommand_storeall(Session *s, dumb_ptr sd, { case 2: //Try again - clif_displaymessage(s, "run this command again.."); + clif_displaymessage(s, "run this command again.."_s); return ATCE::OKAY; case 1: //Failure clif_displaymessage(s, - "You can't open the storage currently."); + "You can't open the storage currently."_s); return ATCE::EXIST; } } @@ -4260,7 +4259,7 @@ ATCE atcommand_storeall(Session *s, dumb_ptr sd, } storage_storageclose(sd); - clif_displaymessage(s, "It is done"); + clif_displaymessage(s, "It is done"_s); return ATCE::OKAY; } @@ -4281,8 +4280,8 @@ ATCE atcommand_charstoreall(Session *s, dumb_ptr sd, // TODO figure out what the hell this is talking about, // and especially why it's different from the other one. clif_displaymessage(s, - "Had to open the characters storage window..."); - clif_displaymessage(s, "run this command again.."); + "Had to open the characters storage window..."_s); + clif_displaymessage(s, "run this command again.."_s); return ATCE::OKAY; } for (int i = 0; i < MAX_INVENTORY; i++) @@ -4297,12 +4296,12 @@ ATCE atcommand_charstoreall(Session *s, dumb_ptr sd, storage_storageclose(pl_sd); clif_displaymessage(pl_sd->sess, - "Everything you own has been put away for safe keeping."); + "Everything you own has been put away for safe keeping."_s); clif_displaymessage(pl_sd->sess, - "go to the nearest kafka to retrieve it.."); - clif_displaymessage(pl_sd->sess, " -- the management"); + "go to the nearest kafka to retrieve it.."_s); + clif_displaymessage(pl_sd->sess, " -- the management"_s); - clif_displaymessage(s, "It is done"); + clif_displaymessage(s, "It is done"_s); return ATCE::OKAY; } @@ -4425,7 +4424,7 @@ ATCE atcommand_adjcmdlvl(Session *s, dumb_ptr, if (!extract(message, record<' '>(&newlev, &cmd))) { - clif_displaymessage(s, "usage: @adjcmdlvl ."); + clif_displaymessage(s, "usage: @adjcmdlvl ."_s); return ATCE::USAGE; } @@ -4434,12 +4433,12 @@ ATCE atcommand_adjcmdlvl(Session *s, dumb_ptr, if (it) { it->level = newlev; - clif_displaymessage(s, "@command level changed."); + clif_displaymessage(s, "@command level changed."_s); return ATCE::OKAY; } } - clif_displaymessage(s, "@command not found."); + clif_displaymessage(s, "@command not found."_s); return ATCE::EXIST; } @@ -4453,7 +4452,7 @@ ATCE atcommand_adjgmlvl(Session *s, dumb_ptr, if (!asplit(message, &newlev, &user) || newlev < 0 || newlev > 99) { - clif_displaymessage(s, "usage: @adjgmlvl ."); + clif_displaymessage(s, "usage: @adjgmlvl ."_s); return ATCE::USAGE; } @@ -4501,14 +4500,14 @@ constexpr size_t magic_skills_nr = sizeof(magic_skills) / sizeof(magic_skills[0]); static -ZString magic_skill_names[magic_skills_nr] = +LString magic_skill_names[magic_skills_nr] = { - {"magic"}, - {"life"}, - {"war"}, - {"transmute"}, - {"nature"}, - {"astral"}, + "magic"_s, + "life"_s, + "war"_s, + "transmute"_s, + "nature"_s, + "astral"_s, }; static @@ -4524,7 +4523,7 @@ ATCE atcommand_magic_info(Session *s, dumb_ptr, if (pl_sd) { AString buf = STRPRINTF( - "`%s' has the following magic skills:", + "`%s' has the following magic skills:"_fmt, character); clif_displaymessage(s, buf); @@ -4532,7 +4531,7 @@ ATCE atcommand_magic_info(Session *s, dumb_ptr, { SkillID sk = magic_skills[i]; buf = STRPRINTF( - "%d in %s", + "%d in %s"_fmt, pl_sd->status.skill[sk].lv, magic_skill_names[i]); if (pl_sd->status.skill[sk].lv) @@ -4542,7 +4541,7 @@ ATCE atcommand_magic_info(Session *s, dumb_ptr, return ATCE::OKAY; } - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -4563,12 +4562,12 @@ ATCE atcommand_set_magic(Session *s, dumb_ptr, if (!asplit(message, &magic_type, &value, &character)) { clif_displaymessage(s, - "Usage: @setmagic , where is either `magic', one of the school names, or `all'."); + "Usage: @setmagic , where is either `magic', one of the school names, or `all'."_s); return ATCE::USAGE; } SkillID skill_index = SkillID::NEGATIVE; - if ("all" == magic_type) + if ("all"_s == magic_type) skill_index = SkillID::ZERO; else { @@ -4585,7 +4584,7 @@ ATCE atcommand_set_magic(Session *s, dumb_ptr, if (skill_index == SkillID::NEGATIVE) { clif_displaymessage(s, - "Incorrect school of magic. Use `magic', `nature', `life', `war', `transmute', `ether', or `all'."); + "Incorrect school of magic. Use `magic', `nature', `life', `war', `transmute', `ether', or `all'."_s); return ATCE::RANGE; } @@ -4602,7 +4601,7 @@ ATCE atcommand_set_magic(Session *s, dumb_ptr, return ATCE::OKAY; } - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -4664,18 +4663,18 @@ ATCE atcommand_jump_iterate(Session *s, dumb_ptr sd, && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you to the map of this player."); + "You are not authorised to warp you to the map of this player."_s); return ATCE::PERM; } if (sd->bl_m && sd->bl_m->flag.get(MapFlag::NOWARP) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(s, - "You are not authorised to warp you from your actual map."); + "You are not authorised to warp you from your actual map."_s); return ATCE::PERM; } pc_setpos(sd, pl_sd->bl_m->name_, pl_sd->bl_x, pl_sd->bl_y, BeingRemoveWhy::WARPED); - AString output = STRPRINTF("Jump to %s", pl_sd->status_key.name); + AString output = STRPRINTF("Jump to %s"_fmt, pl_sd->status_key.name); clif_displaymessage(s, output); sd->followtarget = pl_sd->bl_id; @@ -4702,9 +4701,9 @@ ATCE atcommand_wgm(Session *s, dumb_ptr sd, if (tmw_CheckChatSpam(sd, message)) return ATCE::OKAY; - tmw_GmHackMsg(STRPRINTF("[GM] %s: %s", sd->status_key.name, message)); + tmw_GmHackMsg(STRPRINTF("[GM] %s: %s"_fmt, sd->status_key.name, message)); if (!pc_isGM(sd)) - clif_displaymessage(s, "Message sent."); + clif_displaymessage(s, "Message sent."_s); return ATCE::OKAY; } @@ -4727,19 +4726,19 @@ ATCE atcommand_skillpool_info(Session *s, dumb_ptr, int i; AString buf = STRPRINTF( - "Active skills %d out of %d for %s:", + "Active skills %d out of %d for %s:"_fmt, pool_skills_nr, skill_pool_max(pl_sd), character); clif_displaymessage(s, buf); for (i = 0; i < pool_skills_nr; ++i) { - buf = STRPRINTF(" - %s [%d]: power %d", + buf = STRPRINTF(" - %s [%d]: power %d"_fmt, skill_name(pool_skills[i]), pool_skills[i], skill_power(pl_sd, pool_skills[i])); clif_displaymessage(s, buf); } - buf = STRPRINTF("Learned skills out of %d for %s:", + buf = STRPRINTF("Learned skills out of %d for %s:"_fmt, skill_pool_skills_size, character); clif_displaymessage(s, buf); @@ -4750,7 +4749,7 @@ ATCE atcommand_skillpool_info(Session *s, dumb_ptr, if (lvl) { - buf = STRPRINTF(" - %s [%d]: lvl %d", + buf = STRPRINTF(" - %s [%d]: lvl %d"_fmt, name, skill_pool_skills[i], lvl); clif_displaymessage(s, buf); } @@ -4759,7 +4758,7 @@ ATCE atcommand_skillpool_info(Session *s, dumb_ptr, } else { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -4775,7 +4774,7 @@ ATCE atcommand_skillpool_focus(Session *s, dumb_ptr, if (!asplit(message, &skill, &character)) { - clif_displaymessage(s, "Usage: @sp-focus "); + clif_displaymessage(s, "Usage: @sp-focus "_s); return ATCE::USAGE; } @@ -4783,12 +4782,12 @@ ATCE atcommand_skillpool_focus(Session *s, dumb_ptr, if (pl_sd != NULL) { if (skill_pool_activate(pl_sd, skill)) - clif_displaymessage(s, "Activation failed."); + clif_displaymessage(s, "Activation failed."_s); else - clif_displaymessage(s, "Activation successful."); + clif_displaymessage(s, "Activation successful."_s); } else - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::OKAY; } @@ -4807,12 +4806,12 @@ ATCE atcommand_skillpool_unfocus(Session *s, dumb_ptr, if (pl_sd != NULL) { if (skill_pool_deactivate(pl_sd, skill)) - clif_displaymessage(s, "Deactivation failed."); + clif_displaymessage(s, "Deactivation failed."_s); else - clif_displaymessage(s, "Deactivation successful."); + clif_displaymessage(s, "Deactivation successful."_s); } else - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::OKAY; } @@ -4835,7 +4834,7 @@ ATCE atcommand_skill_learn(Session *s, dumb_ptr, clif_skillinfoblock(pl_sd); } else - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::OKAY; } @@ -4852,7 +4851,7 @@ ATCE atcommand_ipcheck(Session *s, dumb_ptr, dumb_ptr pl_sd = map_nick2sd(character); if (pl_sd == NULL) { - clif_displaymessage(s, "Character not found."); + clif_displaymessage(s, "Character not found."_s); return ATCE::EXIST; } @@ -4873,7 +4872,7 @@ ATCE atcommand_ipcheck(Session *s, dumb_ptr, if (ip == pl_sd->get_ip()) { AString output = STRPRINTF( - "Name: %s | Location: %s %d %d", + "Name: %s | Location: %s %d %d"_fmt, pl_sd->status_key.name, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y); clif_displaymessage(s, output); @@ -4881,7 +4880,7 @@ ATCE atcommand_ipcheck(Session *s, dumb_ptr, } } - clif_displaymessage(s, "End of list"); + clif_displaymessage(s, "End of list"_s); return ATCE::OKAY; } @@ -4902,10 +4901,10 @@ ATCE atcommand_doomspot(Session *s, dumb_ptr sd, { // you can doom only lower or same gm level pc_damage(NULL, pl_sd, pl_sd->status.hp + 1); - clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement."); + clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement."_s); } } - clif_displaymessage(s, "Judgement was made."); + clif_displaymessage(s, "Judgement was made."_s); return ATCE::OKAY; } @@ -4915,13 +4914,13 @@ ATCE atcommand_source(Session *s, dumb_ptr, ZString) { clif_displaymessage(s, - "This server code consists of Free Software under GPL3&AGPL3"); + "This server code consists of Free Software under GPL3&AGPL3"_s); clif_displaymessage(s, - "This is commit " VERSION_HASH ", also known as " VERSION_FULL); + "This is commit " VERSION_HASH ", also known as " VERSION_FULL ""_s); clif_displaymessage(s, - "The version is " VERSION_STRING); + "The version is " VERSION_STRING ""_s); clif_displaymessage(s, - "For source, see " VENDOR_SOURCE); + "For source, see " VENDOR_SOURCE ""_s); return ATCE::OKAY; } @@ -4931,424 +4930,424 @@ ATCE atcommand_source(Session *s, dumb_ptr, // declared extern above Map atcommand_info = { - {"help", {"[level[-level]|category|@command]", + {"help"_s, {"[level[-level]|category|@command]"_s, 0, atcommand_help, - "Show help"}}, - {"setup", {" ", + "Show help"_s}}, + {"setup"_s, {" "_s, 40, atcommand_setup, - "Safely set a chars levels and warp them to a special place (for TAW)"}}, - {"charwarp", {" ", + "Safely set a chars levels and warp them to a special place (for TAW)"_s}}, + {"charwarp"_s, {" "_s, 60, atcommand_charwarp, - "Warp a character to a point on another map"}}, - {"warp", {" [x] [y]", + "Warp a character to a point on another map"_s}}, + {"warp"_s, {" [x] [y]"_s, 40, atcommand_warp, - "Warp yourself to another map"}}, - {"where", {"[charname]", + "Warp yourself to another map"_s}}, + {"where"_s, {"[charname]"_s, 40, atcommand_where, - "Show location of a character or yourself"}}, - {"goto", {"", + "Show location of a character or yourself"_s}}, + {"goto"_s, {""_s, 40, atcommand_goto, - "Warp yourself to another character"}}, - {"jump", {"[x] [y]", + "Warp yourself to another character"_s}}, + {"jump"_s, {"[x] [y]"_s, 40, atcommand_jump, - "Warp yourself within a map"}}, - {"who", {"[subsequence]", + "Warp yourself within a map"_s}}, + {"who"_s, {"[subsequence]"_s, 40, atcommand_who, - "List matching players online, with location info"}}, - {"whogroup", {"[subsequence]", + "List matching players online, with location info"_s}}, + {"whogroup"_s, {"[subsequence]"_s, 40, atcommand_whogroup, - "List matching players online, with party info"}}, - {"whomap", {"[mapname]", + "List matching players online, with party info"_s}}, + {"whomap"_s, {"[mapname]"_s, 40, atcommand_whomap, - "List all players on the map, with location info"}}, - {"whomapgroup", {"[mapname]", + "List all players on the map, with location info"_s}}, + {"whomapgroup"_s, {"[mapname]"_s, 40, atcommand_whomapgroup, - "List all players on the map, with party info"}}, - {"whogm", {"[subsequence]", + "List all players on the map, with party info"_s}}, + {"whogm"_s, {"[subsequence]"_s, 40, atcommand_whogm, - "List matching GM players, with location, level, and party info"}}, - {"save", {"", + "List matching GM players, with location, level, and party info"_s}}, + {"save"_s, {""_s, 40, atcommand_save, - "Set your respawn point to your current location"}}, - {"return", {"", + "Set your respawn point to your current location"_s}}, + {"return"_s, {""_s, 40, atcommand_load, - "Return to your respawn point"}}, - {"load", {"", + "Return to your respawn point"_s}}, + {"load"_s, {""_s, 40, atcommand_load, - "Return to your respawn point"}}, - {"speed", {"", + "Return to your respawn point"_s}}, + {"speed"_s, {""_s, 60, atcommand_speed, - "Set walk rate"}}, - {"storage", {"", + "Set walk rate"_s}}, + {"storage"_s, {""_s, 99, atcommand_storage, - "Open your storage"}}, - {"option", {" [opt2] [option]", + "Open your storage"_s}}, + {"option"_s, {" [opt2] [option]"_s, 80, atcommand_option, - "Set your 'option' status flags"}}, - {"hide", {"", + "Set your 'option' status flags"_s}}, + {"hide"_s, {""_s, 40, atcommand_hide, - "Toggle invisibility from monsters and certain commands"}}, - {"die", {"", + "Toggle invisibility from monsters and certain commands"_s}}, + {"die"_s, {""_s, 40, atcommand_die, - "Cause fatal damage to yourself"}}, - {"kill", {"", + "Cause fatal damage to yourself"_s}}, + {"kill"_s, {""_s, 60, atcommand_kill, - "Cause fatal damage to another player"}}, - {"alive", {"", + "Cause fatal damage to another player"_s}}, + {"alive"_s, {""_s, 60, atcommand_alive, - "Restore life to yourself"}}, - {"kami", {"", + "Restore life to yourself"_s}}, + {"kami"_s, {""_s, 99, atcommand_kami, - "Send an anonymous broadcast"}}, - {"heal", {"[hp] [sp]", + "Send an anonymous broadcast"_s}}, + {"heal"_s, {"[hp] [sp]"_s, 40, atcommand_heal, - "Restore or destroy your health"}}, - {"item", {" [count]", + "Restore or destroy your health"_s}}, + {"item"_s, {" [count]"_s, 80, atcommand_item, - "Summon items out of the void"}}, - {"itemreset", {"", + "Summon items out of the void"_s}}, + {"itemreset"_s, {""_s, 40, atcommand_itemreset, - "Cast all of your itens into the void (why would you ever want this?)"}}, - {"itemcheck", {"", + "Cast all of your itens into the void (why would you ever want this?)"_s}}, + {"itemcheck"_s, {""_s, 80, atcommand_itemcheck, - "Perform an internal integrity check on your items"}}, - {"blvl", {"", + "Perform an internal integrity check on your items"_s}}, + {"blvl"_s, {""_s, 60, atcommand_baselevelup, - "Adjust your level"}}, - {"jlvl", {"", + "Adjust your level"_s}}, + {"jlvl"_s, {""_s, 60, atcommand_joblevelup, - "Adjust your job level"}}, - {"gm", {"", + "Adjust your job level"_s}}, + {"gm"_s, {""_s, 100, atcommand_gm, - "Receive GM powers"}}, - {"pvpoff", {"", + "Receive GM powers"_s}}, + {"pvpoff"_s, {""_s, 60, atcommand_pvpoff, - "Enable PvP on your map"}}, - {"pvpon", {"", + "Enable PvP on your map"_s}}, + {"pvpon"_s, {""_s, 60, atcommand_pvpon, - "Disable PvP on your map"}}, - {"model", {"