From 5cdf930c6596b778db40138726163b9dfd68ae4f Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Sun, 23 Oct 2022 15:45:32 +0000 Subject: Added get all reg2, get single reg2, set/add reg2 and del reg2 to tmwa-admin. Fixed communication from char server to login server. Added translations and comments. Minor QoL. --- src/admin/ladmin.cpp | 270 ++++++++++++++++++++++++-- src/admin/ladmin.hpp | 36 ++++ src/char/char.cpp | 13 +- src/char/inter.cpp | 4 +- src/login/login.cpp | 225 +++++++++++++++++++++- src/map/chrif.cpp | 2 + src/map/clif.cpp | 2 +- src/map/intif.cpp | 6 +- src/map/pc.cpp | 491 +++++++++++++++++++++++++++++++++++++---------- src/map/script-call.cpp | 3 + src/map/script-fun.cpp | 431 +++++++++++++++++++++++++++++++++++------ src/map/script-parse.cpp | 34 +++- tools/protocol.py | 102 +++++++++- 13 files changed, 1416 insertions(+), 203 deletions(-) diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp index bb10bae..6e8642b 100644 --- a/src/admin/ladmin.cpp +++ b/src/admin/ladmin.cpp @@ -62,7 +62,6 @@ #include "../poison.hpp" - namespace tmwa { DIAG_PUSH(); @@ -537,11 +536,40 @@ void display_help(ZString param) } else if (command == "quit"_s || command == "exit"_s - || command == "end"_s) + || command == "end"_s + || command == "q"_s) { - PRINTF("quit/end/exit\n"_fmt); + PRINTF("quit/end/exit/q\n"_fmt); PRINTF(" End of the program of administration.\n"_fmt); } + else if (command == "getallaccreg2"_s + || command == "getall"_s + || command == "ga"_s) + { + PRINTF("getallaccreg2/getall/ga \n"_fmt); + PRINTF(" Display all login-stored ##registers\n"_fmt); + } + else if (command == "getaccreg2"_s + || command == "get"_s + || command == "g"_s) + { + PRINTF("getaccreg2/get/g \n"_fmt); + PRINTF(" Display a login-stored ##register\n"_fmt); + } + else if (command == "setaccreg2"_s + || command == "set"_s + || command == "s"_s) + { + PRINTF("setaccreg2/set/s \n"_fmt); + PRINTF(" Modify or add a login-stored ##register\n"_fmt); + } + else if (command == "delaccreg2"_s + || command == "del"_s + || command == "d"_s) + { + PRINTF("delaccreg2/del/d \n"_fmt); + PRINTF(" Delete a login-stored ##register\n"_fmt); + } else { if (command) @@ -575,7 +603,7 @@ void display_help(ZString param) 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(" quit/end/exit/q -- 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); @@ -584,7 +612,10 @@ void display_help(ZString param) 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(" getallaccreg2/getall/ga -- Display all login-stored ##registers\n"_fmt); + PRINTF(" getaccreg2/get/g -- Display a login-stored ##register\n"_fmt); + PRINTF(" setaccreg2/set/s -- Modify or add a login-stored ##register\n"_fmt); + PRINTF(" delaccreg2/del/d -- Delete a login-stored ##register\n"_fmt); PRINTF(" Note: To use spaces in an account name, type \"\" (or ').\n"_fmt); } } @@ -1485,6 +1516,91 @@ void checkloginversion(void) bytes_to_read = 1; } +//----------------------------------------------- +// Sub-function: Display all login-stored ##registers +//----------------------------------------------- +static +void get_all_accreg2(AccountId account_id) +{ + Packet_Fixed<0x7956> fixed_56; + fixed_56.account_id = account_id; + send_fpacket<0x7956, 6>(login_session, fixed_56); + bytes_to_read = 1; +} + +//----------------------------------------------- +// Sub-function: Display a login-stored ##register +//----------------------------------------------- +static +void get_accreg2(ZString param) +{ + AccountId account_id; + GlobalReg reg2; + + if (!qsplit(param, &account_id, ®2.str)) + { + PRINTF("Please input an account id and a variable to delete.\n"_fmt); + PRINTF(" getaccreg2 2000000 ##GLOBAL\n"_fmt); + LADMIN_LOG("Incomplete parameters to get a login-stored ##register of an account ('get' command).\n"_fmt); + return; + } + + Packet_Fixed<0x7958> fixed_58; + fixed_58.account_id = account_id; + fixed_58.name = reg2.str; + send_fpacket<0x7958, 38>(login_session, fixed_58); + bytes_to_read = 1; +} + +//----------------------------------------------- +// Sub-function: Modify or add a login-stored ##register +//----------------------------------------------- +static +void set_accreg2(ZString param) +{ + AccountId account_id; + GlobalReg reg2; + + if (!qsplit(param, &account_id, ®2.str, ®2.value)) + { + PRINTF("Please input an account id, a variable and the value for this variable.\n"_fmt); + PRINTF(" setaccreg2 2000000 ##GLOBAL 111\n"_fmt); + LADMIN_LOG("Incomplete parameters to modify or add a login-stored ##register of an account ('set' command).\n"_fmt); + return; + } + + Packet_Fixed<0x795a> fixed_5a; + fixed_5a.account_id = account_id; + fixed_5a.name = reg2.str; + fixed_5a.value = reg2.value; + send_fpacket<0x795a, 42>(login_session, fixed_5a); + bytes_to_read = 1; +} + +//----------------------------------------------- +// Sub-function: Delete a login-stored ##register +//----------------------------------------------- +static +void del_accreg2(ZString param) +{ + AccountId account_id; + GlobalReg reg2; + + if (!qsplit(param, &account_id, ®2.str)) + { + PRINTF("Please input an account id and a variable to delete.\n"_fmt); + PRINTF(" delaccreg2 2000000 ##GLOBAL\n"_fmt); + LADMIN_LOG("Incomplete parameters to delete a login-stored ##register of an account ('del' command).\n"_fmt); + return; + } + + Packet_Fixed<0x795c> fixed_5c; + fixed_5c.account_id = account_id; + fixed_5c.name = reg2.str; + send_fpacket<0x795c, 38>(login_session, fixed_5c); + bytes_to_read = 1; +} + //--------------------------------------------- // Prompt function // this function wait until user type a command @@ -1585,6 +1701,22 @@ void prompt(void) changeemail(parameters); else if (command == "getcount"_s) getlogincount(); + else if (command == "getallaccreg2"_s + || command == "getall"_s + || command == "ga"_s) + get_all_accreg2(wrap(static_cast(atoi(parameters.c_str())))); + else if (command == "getaccreg2"_s + || command == "get"_s + || command == "g"_s) + get_accreg2(parameters); + else if (command == "setaccreg2"_s + || command == "set"_s + || command == "s"_s) + set_accreg2(parameters); + else if (command == "delaccreg2"_s + || command == "del"_s + || command == "d"_s) + del_accreg2(parameters); else if (command == "gm"_s) changegmlevel(parameters); else if (command == "id"_s) @@ -1625,7 +1757,8 @@ void prompt(void) whoaccount(parameters); else if (command == "quit"_s || command == "exit"_s - || command == "end"_s) + || command == "end"_s + || command == "q"_s) { PRINTF("Bye.\n"_fmt); exit(0); @@ -1646,6 +1779,7 @@ void parse_fromlogin(Session *s) { RecvResult rv = RecvResult::Complete; uint16_t packet_id; + while (rv == RecvResult::Complete && packet_peek_id(s, &packet_id)) { switch (packet_id) @@ -2155,9 +2289,9 @@ void parse_fromlogin(Session *s) } else { - PRINTF("The account [%s] have the id: %d.\n"_fmt, + PRINTF("The account [%s] has the id: %d.\n"_fmt, name, account_id); - LADMIN_LOG("The account [%s] have the id: %d.\n"_fmt, + LADMIN_LOG("The account [%s] has the id: %d.\n"_fmt, name, account_id); } bytes_to_read = 0; @@ -2182,9 +2316,9 @@ void parse_fromlogin(Session *s) } else { - PRINTF("The account [id: %d] have the name: %s.\n"_fmt, + PRINTF("The account [id: %d] has the name: %s.\n"_fmt, account_id, name); - LADMIN_LOG("The account [id: %d] have the name: %s.\n"_fmt, + LADMIN_LOG("The account [id: %d] has the name: %s.\n"_fmt, account_id, name); } bytes_to_read = 0; @@ -2319,16 +2453,16 @@ void parse_fromlogin(Session *s) AString& memo = repeat; if (!account_id) { - PRINTF("Unabled to find the account [%s]. Account doesn't exist.\n"_fmt, + PRINTF("Unable 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"_fmt, + LADMIN_LOG("Unable 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"_fmt, + PRINTF("Unable 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"_fmt, + LADMIN_LOG("Unable to find the account [id: %d]. Account doesn't exist.\n"_fmt, account_id); } else @@ -2420,6 +2554,114 @@ void parse_fromlogin(Session *s) break; } + case 0x7957: // Reply of the request to get all login-stored ##registers of an account (by account id) + { + Packet_Head<0x7957> head; + std::vector> repeat; + rv = recv_vpacket<0x7957, 8, 36>(s, head, repeat); + if (rv != RecvResult::Complete) + break; + + if (!head.account_id) + { + PRINTF("Unable to find the account [id: %d]. Account doesn't exist.\n"_fmt, + head.account_id); + LADMIN_LOG("Unable to find the account [id: %d]. Account doesn't exist.\n"_fmt, + head.account_id); + } + else + { + PRINTF("Variables %i of %i used.\n"_fmt, repeat.size(), ACCOUNT_REG2_NUM); + auto jlim = std::min(repeat.size(), ACCOUNT_REG2_NUM); + for (size_t j = 0; j < jlim; ++j) + PRINTF("Variable %s == `%i`\n"_fmt, repeat[j].name, repeat[j].value); + } + bytes_to_read = 0; + break; + } + + case 0x7959: // Reply of the request to get a login-stored ##register of an account (by account id) + { + Packet_Fixed<0x7959> fixed; + rv = recv_fpacket<0x7959, 42>(s, fixed); + if (rv != RecvResult::Complete) + break; + + if (!fixed.account_id) + { + PRINTF("Unable to find the account [id: %d]. Account doesn't exist.\n"_fmt, + fixed.account_id); + LADMIN_LOG("Unable to find the account [id: %d]. Account doesn't exist.\n"_fmt, + fixed.account_id); + } + else + if (fixed.name == stringish(""_s)) + PRINTF("Variable not found.\n"_fmt); + else + PRINTF("Variable %s == `%i`\n"_fmt, fixed.name, fixed.value); + bytes_to_read = 0; + break; + } + + case 0x795b: // Reply of the request to modify, add or delete a login-stored ##register of an account (by account id) + { + Packet_Fixed<0x795b> fixed; + rv = recv_fpacket<0x795b, 8>(s, fixed); + if (rv != RecvResult::Complete) + break; + + if (!fixed.account_id) + { + PRINTF("Unable to find the account [id: %d]. Account doesn't exist.\n"_fmt, + fixed.account_id); + LADMIN_LOG("Unable to find the account [id: %d]. Account doesn't exist.\n"_fmt, + fixed.account_id); + } + else + switch (fixed.operation) + { + case 0: // set + switch (fixed.result) + { + case 0: + PRINTF("Variable changed.\n"_fmt); + break; + case 1: + PRINTF("New Variable created.\n"_fmt); + break; + case 2: + PRINTF("Maximum number of Variables reached.\n"_fmt); + break; + default: + PRINTF("ERROR: Wrong value for result.\n"_fmt); + break; + } + break; + + case 1: // del + switch (fixed.result) + { + case 0: + PRINTF("Variable deleted.\n"_fmt); + break; + case 1: + PRINTF("Variable not found.\n"_fmt); + break; + default: + PRINTF("ERROR: Wrong value for result.\n"_fmt); + break; + } + break; + + default: + PRINTF("ERROR: Wrong value for operation\n"_fmt); + break; + } + + bytes_to_read = 0; + break; + } + default: { PRINTF("Remote administration has been disconnected (unknown packet).\n"_fmt); diff --git a/src/admin/ladmin.hpp b/src/admin/ladmin.hpp index 94783ac..e37511f 100644 --- a/src/admin/ladmin.hpp +++ b/src/admin/ladmin.hpp @@ -20,7 +20,43 @@ #include "fwd.hpp" +#include "../net/socket.hpp" +#include "../net/timestamp-utils.hpp" + +#include "../mmo/consts.hpp" +#include "../mmo/enums.hpp" + +#include "../proto2/net-GlobalReg.hpp" namespace tmwa { +namespace admin +{ +struct login_session_data : SessionData +{ + AccountId account_id; + int login_id1, login_id2; + IP4Address client_ip; + bool verified; + short consumed_by; +}; + +struct AuthData +{ + AccountId account_id; + SEX sex; + AccountName userid; + AccountCrypt pass; + timestamp_milliseconds_buffer lastlogin; + int logincount; + int state; // packet 0x006a value + 1 (0: compte OK) + AccountEmail email; // e-mail (by default: a@a.com) + timestamp_seconds_buffer error_message; // Message of error code #6 = Your are Prohibited to log in until %s (packet 0x006a) + TimeT ban_until_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban) + IP4Address last_ip; // save of last IP of connection + VString<254> memo; // a memo field + int account_reg2_num; + Array account_reg2; +}; +} // namespace admin } // namespace tmwa diff --git a/src/char/char.cpp b/src/char/char.cpp index 4d930f1..8b403b3 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -317,7 +317,7 @@ AString mmo_char_tostr(struct CharPair *cp) } str_p += '\t'; - assert (p->global_reg_num < GLOBAL_REG_NUM); + assert (p->global_reg_num <= GLOBAL_REG_NUM); for (int i = 0; i < p->global_reg_num; i++) { if (p->global_reg[i].str) @@ -1034,7 +1034,7 @@ static int set_account_reg2(AccountId acc, Slice reg) { size_t num = reg.size(); - assert (num < ACCOUNT_REG2_NUM); + assert (num <= ACCOUNT_REG2_NUM); int c = 0; for (CharPair& cd : char_keys) { @@ -1409,7 +1409,7 @@ void parse_tologin(Session *ls) break; } - // account_reg2変更通知 + // account_reg2変更通知 | account_reg2 Change Notification case 0x2729: { Packet_Head<0x2729> head; @@ -1459,7 +1459,7 @@ void parse_tologin(Session *ls) AccountId aid = fixed.account_id; // Deletion of all characters of the account -//#warning "This comment is a lie, but it's still true." + //#warning "This comment is a lie, but it's still true." // needs to use index because they may move during resize for (int idx = 0; idx < char_keys.size(); idx++) { @@ -2098,7 +2098,7 @@ void parse_frommap(Session *ms) } } - // account_reg保存要求 + // account_reg保存要求 | account_reg preservation requirements case 0x2b10: { Packet_Head<0x2b10> head; @@ -2117,11 +2117,12 @@ void parse_frommap(Session *ms) reg[j].value = repeat[j].value; } set_account_reg2(acc, Slice(reg.begin(), jlim)); - // loginサーバーへ送る + // loginサーバーへ送る | login Send to server if (login_session) { // don't send request if no login-server Packet_Head<0x2728> head_28; + head_28.account_id = head.account_id; std::vector> repeat_28(repeat.size()); for (size_t j = 0; j < repeat.size(); ++j) { diff --git a/src/char/inter.cpp b/src/char/inter.cpp index 3bf3bfc..3f2d1aa 100644 --- a/src/char/inter.cpp +++ b/src/char/inter.cpp @@ -68,7 +68,7 @@ namespace char_ static AString inter_accreg_tostr(struct accreg *reg) { - assert(reg->reg_num < ACCOUNT_REG_NUM); + assert(reg->reg_num <= ACCOUNT_REG_NUM); MString str; str += STRPRINTF("%d\t"_fmt, reg->account_id); for (int j = 0; j < reg->reg_num; j++) @@ -236,7 +236,7 @@ void mapif_account_reg_reply(Session *s, AccountId account_id) OMATCH_BEGIN_SOME (reg, reg_) { repeat_04.resize(reg->reg_num); - assert (reg->reg_num < ACCOUNT_REG_NUM); + assert (reg->reg_num <= ACCOUNT_REG_NUM); for (size_t j = 0; j < reg->reg_num; ++j) { repeat_04[j].name = reg->reg[j].str; diff --git a/src/login/login.cpp b/src/login/login.cpp index 8e2c776..8f3aa70 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -391,7 +391,7 @@ AString mmo_auth_tostr(const AuthData *p) p->memo, p->ban_until_time); - assert (p->account_reg2_num < ACCOUNT_REG2_NUM); + 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 "_fmt, @@ -863,7 +863,7 @@ static void parse_fromchar(Session *s) { IP4Address ip = s->client_ip; - + int id; for (id = 0; id < MAX_SERVERS; id++) if (server_session[id] == s) @@ -1116,7 +1116,6 @@ void parse_fromchar(Session *s) rv = recv_vpacket<0x2728, 8, 36>(s, head, repeat); if (rv != RecvResult::Complete) break; - { AccountId acc = head.account_id; for (AuthData& ad : auth_data) @@ -1354,8 +1353,10 @@ static void parse_admin(Session *s) { IP4Address ip = s->client_ip; + RecvResult rv = RecvResult::Complete; uint16_t packet_id; + while (rv == RecvResult::Complete && packet_peek_id(s, &packet_id)) { if (login_conf.display_parse_admin) @@ -2315,6 +2316,224 @@ void parse_admin(Session *s) break; } + case 0x7956: // Request all login-stored ##registers of an account (by account id) + { + Packet_Fixed<0x7956> fixed; + rv = recv_fpacket<0x7956, 6>(s, fixed); + if (rv != RecvResult::Complete) + break; + + AccountId account_id = fixed.account_id; + Packet_Head<0x7957> head_57; + std::vector> repeat_57; + head_57.account_id = AccountId(); + for (const AuthData& ad : auth_data) + { + if (ad.account_id == account_id) + { + head_57.account_id = ad.account_id; + LOGIN_LOG("'ladmin': Request (by id) to get all login-stored ##registers of an account (account: %s, id: %d, ip: %s)\n"_fmt, + ad.userid, account_id, ip); + for (size_t j = 0; j < ad.account_reg2_num; ++j) + { + Packet_Repeat<0x7957> info; + info.name = ad.account_reg2[j].str; + info.value = ad.account_reg2[j].value; + repeat_57.push_back(info); + } + goto x7957_out; + } + } + LOGIN_LOG("'ladmin': Request (by id) to get all login-stored ##registers of an unknown account (id: %d, ip: %s)\n"_fmt, + account_id, ip); + x7957_out: + send_vpacket<0x7957, 8, 36>(s, head_57, repeat_57); + break; + } + + case 0x7958: // Request a login-stored ##register of an account (by account id) + { + Packet_Fixed<0x7958> fixed; + rv = recv_fpacket<0x7958, 38>(s, fixed); + if (rv != RecvResult::Complete) + break; + + AccountId account_id = fixed.account_id; + Packet_Fixed<0x7959> fixed_59; + GlobalReg reg2; + fixed_59.account_id = AccountId(); + reg2.str = fixed.name; + + for (const AuthData& ad : auth_data) + { + if (ad.account_id == account_id) + { + fixed_59.account_id = ad.account_id; + LOGIN_LOG("'ladmin': Request (by id) to get a login-stored ##register of an account (account: %s, id: %d, ip: %s)\n"_fmt, + ad.userid, account_id, ip); + for (size_t j = 0; j < ad.account_reg2_num; ++j) + { + if (ad.account_reg2[j].str == reg2.str) + { + fixed_59.name = ad.account_reg2[j].str; + fixed_59.value = ad.account_reg2[j].value; + goto x7959_out; + } + } + // reg2 not found + fixed_59.name = stringish(""_s); + fixed_59.value = 0; + goto x7959_out; + } + } + LOGIN_LOG("'ladmin': Request (by id) to get a login-stored ##register of an unknown account (id: %d, ip: %s)\n"_fmt, + account_id, ip); + x7959_out: + send_fpacket<0x7959, 42>(s, fixed_59); + break; + } + + case 0x795a: // Modify a login-stored ##register of an account (by account id) + { + Packet_Fixed<0x795a> fixed; + rv = recv_fpacket<0x795a, 42>(s, fixed); + if (rv != RecvResult::Complete) + break; + + AccountId account_id = fixed.account_id; + Packet_Fixed<0x795b> fixed_5b; + GlobalReg reg2; + fixed_5b.account_id = AccountId(); + fixed_5b.operation = 0; + reg2.str = fixed.name; + reg2.value = fixed.value; + + for (AuthData& ad : auth_data) + { + if (ad.account_id == account_id) + { + fixed_5b.account_id = ad.account_id; + LOGIN_LOG("'ladmin': Request (by id) to modify or add a login-stored ##register of an account (account: %s, id: %d, ip: %s)\n"_fmt, + ad.userid, account_id, ip); + for (size_t j = 0; j < ad.account_reg2_num; ++j) + { + if (ad.account_reg2[j].str == reg2.str) + { + ad.account_reg2[j].str = fixed.name; + ad.account_reg2[j].value = fixed.value; + fixed_5b.result = 0; + goto x795a_update; + } + } + // reg2 not found create new one if possible + if ( ad.account_reg2_num < ACCOUNT_REG2_NUM ) + { + //add var + ad.account_reg2[ad.account_reg2_num].str = fixed.name; + ad.account_reg2[ad.account_reg2_num].value = fixed.value; + ++ad.account_reg2_num; + fixed_5b.result = 1; + goto x795a_update; + } + // maximum number of reg2 reached + fixed_5b.result = 2; + goto x795a_out; + + x795a_update: + // Sending information towards the other char-servers. + Packet_Head<0x2729> head_29; + std::vector> repeat_29(ad.account_reg2_num); + head_29.account_id = account_id; + for (size_t j = 0; j < ad.account_reg2_num; ++j) + { + repeat_29[j].name = ad.account_reg2[j].str; + repeat_29[j].value = ad.account_reg2[j].value; + } + + for (Session *ss : iter_char_sessions()) + { + if (ss == s) + continue; + send_vpacket<0x2729, 8, 36>(ss, head_29, repeat_29); + } + goto x795a_out; + } + } + LOGIN_LOG("'ladmin': Request (by id) to modify or add a login-stored ##register of an unknown account (id: %d, ip: %s)\n"_fmt, + account_id, ip); + x795a_out: + send_fpacket<0x795b, 8>(s, fixed_5b); + break; + } + + case 0x795c: // Delete a login-stored ##register of an account (by account id) + { + Packet_Fixed<0x795c> fixed; + rv = recv_fpacket<0x795c, 38>(s, fixed); + if (rv != RecvResult::Complete) + break; + + AccountId account_id = fixed.account_id; + Packet_Fixed<0x795b> fixed_5b; + GlobalReg reg2; + fixed_5b.account_id = AccountId(); + fixed_5b.operation = 1; + reg2.str = fixed.name; + + for (AuthData& ad : auth_data) + { + if (ad.account_id == account_id) + { + fixed_5b.account_id = ad.account_id; + LOGIN_LOG("'ladmin': Request (by id) to delete a login-stored ##register of an account (account: %s, id: %d, ip: %s)\n"_fmt, + ad.userid, account_id, ip); + for (size_t j = 0; j < ad.account_reg2_num; ++j) + { + if (ad.account_reg2[j].str == reg2.str) + { + for (size_t k = j; k < ad.account_reg2_num-1; ++k) + { + ad.account_reg2[k].str = ad.account_reg2[k+1].str; + ad.account_reg2[k].value = ad.account_reg2[k+1].value; + } + ad.account_reg2[ad.account_reg2_num-1].str = stringish(""_s); + ad.account_reg2[ad.account_reg2_num-1].value = 0; + --ad.account_reg2_num; + fixed_5b.result = 0; + goto x795c_update; + } + } + // reg2 not found + fixed_5b.result = 1; + goto x795c_out; + + x795c_update: + // Sending information towards the other char-servers. + Packet_Head<0x2729> head_29; + std::vector> repeat_29(ACCOUNT_REG2_NUM); // all elements are needed to overwrite the deleted elements on char server aswell + head_29.account_id = account_id; + for (size_t j = 0; j < ACCOUNT_REG2_NUM; ++j) + { + repeat_29[j].name = ad.account_reg2[j].str; + repeat_29[j].value = ad.account_reg2[j].value; + } + + for (Session *ss : iter_char_sessions()) + { + if (ss == s) + continue; + send_vpacket<0x2729, 8, 36>(ss, head_29, repeat_29); + } + goto x795c_out; + } + } + LOGIN_LOG("'ladmin': Name request (by id) to delete a login-stored ##register of an unknown account (id: %d, ip: %s)\n"_fmt, + account_id, ip); + x795c_out: + send_fpacket<0x795b, 8>(s, fixed_5b); + break; + } + default: { { diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 9361c2e..972bfd0 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -606,6 +606,7 @@ void chrif_changedsex(Session *, const Packet_Fixed<0x2b0d>& fixed) /*========================================== * アカウント変数保存要求 + * Account variable save request *------------------------------------------ */ int chrif_saveaccountreg2(dumb_ptr sd) @@ -637,6 +638,7 @@ int chrif_saveaccountreg2(dumb_ptr sd) /*========================================== * アカウント変数通知 + * Account variable notifications *------------------------------------------ */ static diff --git a/src/map/clif.cpp b/src/map/clif.cpp index b9e8bec..1c78cd0 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -5354,7 +5354,7 @@ void clif_sendallquest(dumb_ptr sd) Packet_Head<0x0215> head_215; std::vector> repeat_215; - assert (sd->status.global_reg_num < GLOBAL_REG_NUM); + assert (sd->status.global_reg_num <= GLOBAL_REG_NUM); for (QuestId q = wrap(0); q < wrap(-1); q = next(q)) { P quest_data_ = TRY_UNWRAP(questdb_exists(q), continue); diff --git a/src/map/intif.cpp b/src/map/intif.cpp index 379bb1d..f64f797 100644 --- a/src/map/intif.cpp +++ b/src/map/intif.cpp @@ -116,14 +116,14 @@ void intif_wis_message_to_gm(CharName Wisp_name, GmLevel min_gm_level, ZString m Wisp_name, min_gm_level, mes); } -// アカウント変数送信 +// アカウント変数送信 | Account Variable Submission void intif_saveaccountreg(dumb_ptr sd) { nullpo_retv(sd); if (!char_session) return; - assert (sd->status.account_reg_num < ACCOUNT_REG_NUM); + assert (sd->status.account_reg_num <= ACCOUNT_REG_NUM); Packet_Head<0x3004> head_04; head_04.account_id = block_to_account(sd->bl_id); @@ -136,7 +136,7 @@ void intif_saveaccountreg(dumb_ptr sd) send_vpacket<0x3004, 8, 36>(char_session, head_04, repeat_04); } -// アカウント変数要求 +// アカウント変数要求 | Account variable requests void intif_request_accountreg(dumb_ptr sd) { nullpo_retv(sd); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 77bb956..6c2f673 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -72,7 +72,7 @@ namespace tmwa { namespace map { -// PVP順位計算の間隔 +// PVP順位計算の間隔 | Interval for PVP ranking calculation constexpr std::chrono::milliseconds PVP_CALCRANK_INTERVAL = 1_s; @@ -127,24 +127,25 @@ int sp_coefficient_0 = 100; static //const earray aspd_base_0 //= {{ -650_ms, -700_ms, -750_ms, -600_ms, -2000_ms, -2000_ms, -800_ms, -2000_ms, -700_ms, -700_ms, -650_ms, -900_ms, -2000_ms, -2000_ms, -2000_ms, -2000_ms, -2000_ms, +650_ms, // 0 NONE +700_ms, // 1 BLADE or some other common weapons +750_ms, // 2 +600_ms, // 3 SETZER_AND_SCYTHE +2000_ms, // 4 +2000_ms, // 5 +800_ms, // 6 Falchion +2000_ms, // 7 +700_ms, // 8 +700_ms, // 9 +650_ms, //10 STAFF / Sandcutter +900_ms, //11 BOW +2000_ms, //12 +2000_ms, //13 +2000_ms, //14 +2000_ms, //15 +2000_ms, //16 }}; + static const int exp_table_0[MAX_LEVEL] = { @@ -191,6 +192,7 @@ int exp_table_0[MAX_LEVEL] = 993241342, 1120376234, 1263784392, 1425548794, 1608019039, 2147483647, 0 }; + // is this *actually* used anywhere? static const int exp_table_7[MAX_LEVEL] = @@ -198,6 +200,7 @@ int exp_table_7[MAX_LEVEL] = // 1 .. 9 10, 18, 28, 40, 91, 151, 205, 268, 340 }; + // TODO generate this table instead static int stat_p[MAX_LEVEL] = { @@ -271,20 +274,48 @@ earray equip_pos //= EPOS::ARROW, }}; +/*========================================== + * + *------------------------------------------ + */ static int pc_checkoverhp(dumb_ptr sd); + +/*========================================== + * + *------------------------------------------ + */ static int pc_checkoversp(dumb_ptr sd); + +/*========================================== + * + *------------------------------------------ + */ static int pc_nextbaseafter(dumb_ptr sd); + +/*========================================== + * + *------------------------------------------ + */ static int pc_nextjobafter(dumb_ptr sd); + +/*========================================== + * + *------------------------------------------ + */ static void pc_setdead(dumb_ptr sd) { sd->state.dead_sit = 1; } +/*========================================== + * + *------------------------------------------ + */ GmLevel pc_isGM(dumb_ptr sd) { nullpo_retr(GmLevel(), sd); @@ -295,6 +326,10 @@ GmLevel pc_isGM(dumb_ptr sd) return GmLevel(); } +/*========================================== + * + *------------------------------------------ + */ int pc_iskiller(dumb_ptr src, dumb_ptr target) { @@ -309,6 +344,10 @@ int pc_iskiller(dumb_ptr src, return 0; } +/*========================================== + * + *------------------------------------------ + */ void pc_set_gm_level(AccountId account_id, GmLevel level) { if (level) @@ -317,6 +356,10 @@ void pc_set_gm_level(AccountId account_id, GmLevel level) gm_accountm.erase(account_id); } +/*========================================== + * + *------------------------------------------ + */ static int distance(int x0, int y0, int x1, int y1) { @@ -327,6 +370,10 @@ int distance(int x0, int y0, int x1, int y1) return dx > dy ? dx : dy; } +/*========================================== + * + *------------------------------------------ + */ static void pc_pvp_timer(TimerData *, tick_t, BlockId id) { @@ -336,6 +383,10 @@ void pc_pvp_timer(TimerData *, tick_t, BlockId id) assert (sd->bl_type == BL::PC); } +/*========================================== + * + *------------------------------------------ + */ int pc_setpvptimer(dumb_ptr sd, interval_t val) { nullpo_retz(sd); @@ -346,6 +397,10 @@ int pc_setpvptimer(dumb_ptr sd, interval_t val) return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_delpvptimer(dumb_ptr sd) { nullpo_retz(sd); @@ -354,6 +409,10 @@ int pc_delpvptimer(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ static void pc_invincible_timer(TimerData *, tick_t, BlockId id) { @@ -363,6 +422,10 @@ void pc_invincible_timer(TimerData *, tick_t, BlockId id) assert (sd->bl_type == BL::PC); } +/*========================================== + * + *------------------------------------------ + */ int pc_setinvincibletimer(dumb_ptr sd, interval_t val) { nullpo_retz(sd); @@ -373,6 +436,10 @@ int pc_setinvincibletimer(dumb_ptr sd, interval_t val) return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_delinvincibletimer(dumb_ptr sd) { nullpo_retz(sd); @@ -381,6 +448,10 @@ int pc_delinvincibletimer(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_setrestartvalue(dumb_ptr sd, int type) { nullpo_retz(sd); @@ -418,6 +489,7 @@ int pc_setrestartvalue(dumb_ptr sd, int type) /*========================================== * 自分をロックしているMOBの数を数える(foreachclient) + * Count the number of MOBs that lock you (foreachclient) *------------------------------------------ */ static @@ -445,6 +517,10 @@ void pc_counttargeted_sub(dumb_ptr bl, } } +/*========================================== + * + *------------------------------------------ + */ int pc_counttargeted(dumb_ptr sd, dumb_ptr src, ATK target_lv) { @@ -459,6 +535,7 @@ int pc_counttargeted(dumb_ptr sd, dumb_ptr src, /*========================================== * ローカルプロトタイプ宣言 (必要な物のみ) + * Local prototype declarations (only what is needed) *------------------------------------------ */ static @@ -466,17 +543,18 @@ int pc_walktoxy_sub(dumb_ptr); /*========================================== * saveに必要なステータス修正を行なう + * Make the necessary status corrections to save *------------------------------------------ */ void pc_makesavestatus(dumb_ptr sd) { nullpo_retv(sd); - // 服の色は色々弊害が多いので保存対象にはしない + // 服の色は色々弊害が多いので保存対象にはしない | The color of clothes has many adverse effects, so do not store them if (!battle_config.save_clothcolor) sd->status.clothes_color = 0; - // 死亡状態だったのでhpを1、位置をセーブ場所に変更 + // 死亡状態だったのでhpを1、位置をセーブ場所に変更 | Since he was dead, HP 1, changed position to save location if (pc_isdead(sd)) { pc_setrestartvalue(sd, 0); @@ -496,7 +574,7 @@ void pc_makesavestatus(dumb_ptr sd) sd->status.last_point.y = sd->bl_y; } - // セーブ禁止マップだったので指定位置に移動 + // セーブ禁止マップだったので指定位置に移動 | Since it was a save prohibited map, moved to the specified position if (sd->bl_m->flag.get(MapFlag::NOSAVE)) { P m = sd->bl_m; @@ -509,6 +587,7 @@ void pc_makesavestatus(dumb_ptr sd) /*========================================== * 接続時の初期化 + * Initialization on connection *------------------------------------------ */ int pc_setnewpc(dumb_ptr sd, AccountId account_id, CharId char_id, @@ -537,6 +616,10 @@ int pc_setnewpc(dumb_ptr sd, AccountId account_id, CharId char return 0; } +/*========================================== + * + *------------------------------------------ + */ EPOS pc_equippoint(dumb_ptr sd, IOff0 n) { nullpo_retr(EPOS::ZERO, sd); @@ -544,6 +627,10 @@ EPOS pc_equippoint(dumb_ptr sd, IOff0 n) return sd->inventory_data[n].pmd_pget(&item_data::equip).copy_or(EPOS::ZERO); } +/*========================================== + * + *------------------------------------------ + */ static int pc_setinventorydata(dumb_ptr sd) { @@ -561,6 +648,10 @@ int pc_setinventorydata(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ static int pc_calcweapontype(dumb_ptr sd) { @@ -572,6 +663,10 @@ int pc_calcweapontype(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ static int pc_setequipindex(dumb_ptr sd) { @@ -623,11 +718,15 @@ int pc_setequipindex(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ static int pc_isequip(dumb_ptr sd, IOff0 n) { eptr sc_data; - //転生や養子の場合の元の職業を算出する + //転生や養子の場合の元の職業を算出する | Calculate the original occupation in case of reincarnation or adoption nullpo_retz(sd); @@ -646,6 +745,10 @@ int pc_isequip(dumb_ptr sd, IOff0 n) return 1; } +/*========================================== + * + *------------------------------------------ + */ void pc_set_weapon_icon(dumb_ptr sd, int count, StatusChange icon, ItemNameId look) { @@ -672,6 +775,10 @@ void pc_set_weapon_icon(dumb_ptr sd, int count, } } +/*========================================== + * + *------------------------------------------ + */ void pc_set_attack_info(dumb_ptr sd, interval_t speed, int range) { sd->attack_spell_delay = speed; @@ -694,6 +801,8 @@ void pc_set_attack_info(dumb_ptr sd, interval_t speed, int ran /*========================================== * session idに問題無し * char鯖から送られてきたステータスを設定 + * No problem with session id + * Set the status sent from char server *------------------------------------------ */ int pc_authok(AccountId id, int login_id2, ClientVersion client_version, @@ -718,7 +827,7 @@ int pc_authok(AccountId id, int login_id2, ClientVersion client_version, MAP_LOG_MAGIC(sd, "LOGIN"_fmt); really_memzero_this(&sd->state); - // 基本的な初期化 + // 基本的な初期化 | Basic initialization sd->state.connect_new = 1; sd->bl_prev = sd->bl_next = nullptr; @@ -755,28 +864,28 @@ int pc_authok(AccountId id, int login_id2, ClientVersion client_version, // -o11c //sd->cast_tick = tick; // + pc_readglobalreg (sd, "MAGIC_CAST_TICK"_s); - // アカウント変数の送信要求 + // アカウント変数の送信要求 | Request to send account variables intif_request_accountreg(sd); - // アイテムチェック + // アイテムチェック | Item Check pc_setinventorydata(sd); pc_checkitem(sd); - // ステータス異常の初期化 + // ステータス異常の初期化 | Initializing Status Anomalies for (StatusChange i : erange(StatusChange(), StatusChange::MAX_STATUSCHANGE)) { // sd->sc_data[i].timer = nullptr; sd->sc_data[i].val1 = 0; } - // パーティー関係の初期化 + // パーティー関係の初期化 | Initializing Party Relationships sd->party_sended = 0; sd->party_invite = PartyId(); sd->party_x = -1; sd->party_y = -1; sd->party_hp = -1; - // イベント関係の初期化 + // イベント関係の初期化 | Initializing Event Relationships sd->eventqueuel.clear(); { @@ -795,31 +904,31 @@ int pc_authok(AccountId id, int login_id2, ClientVersion client_version, clif_changeoption(sd); } - // 位置の設定 + // 位置の設定 | Setting the Position pc_setpos(sd, sd->status.last_point.map_, sd->status.last_point.x, sd->status.last_point.y, BeingRemoveWhy::GONE); - // パーティ、ギルドデータの要求 + // パーティ、ギルドデータの要求 | Request for Party, Guild Data if (sd->status.party_id && party_search(sd->status.party_id).is_none()) party_request_info(sd->status.party_id); - // pvpの設定 + // pvpの設定 | Configuring PVP sd->pvp_rank = 0; sd->pvp_point = 0; // sd->pvp_timer = nullptr; - // 通知 + // 通知 | notice clif_authok(sd); map_addnickdb(sd); if (!map_charid2nick(sd->status_key.char_id).to__actual()) map_addchariddb(sd->status_key.char_id, sd->status_key.name); - //スパノビ用死にカウンターのスクリプト変数からの読み出しとsdへのセット + //スパノビ用死にカウンターのスクリプト変数からの読み出しとsdへのセット | Reading from Counter Script Variable to Death for Spa Novi and Set to SD sd->die_counter = pc_readglobalreg(sd, stringish("PC_DIE_COUNTER"_s)); - // ステータス初期計算など + // ステータス初期計算など | Status initial calculation, etc. pc_calcstatus(sd, 1); if (pc_isGM(sd)) @@ -876,6 +985,7 @@ void pc_show_motd(dumb_ptr sd) /*========================================== * session idに問題ありなので後始末 + * There is a problem with the session id, so clean up after it *------------------------------------------ */ int pc_authfail(AccountId id) @@ -891,6 +1001,10 @@ int pc_authfail(AccountId id) return 0; } +/*========================================== + * + *------------------------------------------ + */ static int pc_calc_skillpoint(dumb_ptr sd) { @@ -910,6 +1024,7 @@ int pc_calc_skillpoint(dumb_ptr sd) /*========================================== * 重量アイコンの確認 + * Checking the weight icon *------------------------------------------ */ int pc_checkweighticon(dumb_ptr sd) @@ -946,6 +1061,10 @@ int pc_checkweighticon(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ static void pc_set_weapon_look(dumb_ptr sd) { @@ -962,6 +1081,10 @@ void pc_set_weapon_look(dumb_ptr sd) * first==0の時、計算対象のパラメータが呼び出し前から * 変 化した場合自動でsendするが、 * 能動的に変化させたパラメータは自前でsendするように + * Parameter Calculation + * When first==0, the parameter to be calculated is from before the call + * If it changes, it will automatically send it, + * Actively changed parameters should be send on their own *------------------------------------------ */ int pc_calcstatus(dumb_ptr sd, int first) @@ -1109,7 +1232,7 @@ int pc_calcstatus(dumb_ptr sd, int first) sd->paramcard = sd->parame; - // 装備品によるステータス変化はここで実行 + // 装備品によるステータス変化はここで実行 | Status changes by equipment are performed here for (EQUIP i : EQUIPs_noarrow) { IOff0 index = sd->equip_index_maybe[i]; @@ -1135,7 +1258,7 @@ int pc_calcstatus(dumb_ptr sd, int first) } else { - //二刀流武器以外 + //二刀流武器以外 | Other than two-pronged weapons argrec_t arg[2] = { {"@slotId"_s, static_cast(i)}, @@ -1176,7 +1299,7 @@ int pc_calcstatus(dumb_ptr sd, int first) { IOff0 index = aidx; OMATCH_BEGIN_SOME (sdidi, sd->inventory_data[index]) - { //まだ属性が入っていない + { //まだ属性が入っていない | Attributes not yet included argrec_t arg[2] = { {"@slotId"_s, static_cast(EQUIP::ARROW)}, @@ -1299,7 +1422,7 @@ int pc_calcstatus(dumb_ptr sd, int first) if (sd->mdef2 < 1) sd->mdef2 = 1; - // 二刀流 ASPD 修正 + //二刀流 ASPD 修正 | Two-cut ASPD correction { sd->aspd += aspd_base_0[sd->status.weapon] - (sd->paramc[ATTR::AGI] * 4 + sd->paramc[ATTR::DEX]) @@ -1308,7 +1431,7 @@ int pc_calcstatus(dumb_ptr sd, int first) aspd_rate = sd->aspd_rate; - //攻撃速度増加 + //攻撃速度増加 | Increased attack speed if (sd->attackrange > 2) { @@ -1335,7 +1458,7 @@ int pc_calcstatus(dumb_ptr sd, int first) if (sd->status.max_hp <= 0) sd->status.max_hp = 1; // end - // 最大SP計算 + // 最大SP計算 | Maximum SP calculation sd->status.max_sp += ((sp_coefficient_0 * bl) + 1000) / 100 * (100 + sd->paramc[ATTR::INT]) / 100 + (sd->parame[ATTR::INT] - sd->paramcard[ATTR::INT]); @@ -1345,9 +1468,9 @@ int pc_calcstatus(dumb_ptr sd, int first) if (sd->status.max_sp < 0 || sd->status.max_sp > battle_config.max_sp) sd->status.max_sp = battle_config.max_sp; - //自然回復HP + //自然回復HP | Natural Recovery HP sd->nhealhp = 1 + (sd->paramc[ATTR::VIT] / 5) + (sd->status.max_hp / 200); - //自然回復SP + //自然回復SP | Natural Recovery SP sd->nhealsp = 1 + (sd->paramc[ATTR::INT] / 6) + (sd->status.max_sp / 100); if (sd->paramc[ATTR::INT] >= 120) sd->nhealsp += ((sd->paramc[ATTR::INT] - 120) >> 1) + 4; @@ -1365,10 +1488,10 @@ int pc_calcstatus(dumb_ptr sd, int first) sd->nhealsp = 1; } - // スキルやステータス異常による残りのパラメータ補正 + //スキルやステータス異常による残りのパラメータ補正 | Correction of the remaining parameters due to skill or status anomalies { - // ATK/DEF変化形 - if (sd->sc_data[StatusChange::SC_POISON].timer) // 毒状態 + // ATK/DEF変化形 | ATK/DEF variants + if (sd->sc_data[StatusChange::SC_POISON].timer) // 毒状態 | Poisonous state sd->def2 = sd->def2 * 75 / 100; if (sd->sc_data[StatusChange::SC_ATKPOT].timer) @@ -1485,6 +1608,7 @@ int pc_calcstatus(dumb_ptr sd, int first) /*========================================== * 装 備品による能力等のボーナス設定 + * Bonus settings such as abilities by equipment *------------------------------------------ */ int pc_bonus(dumb_ptr sd, SP type, int val) @@ -1779,6 +1903,7 @@ int pc_bonus2(dumb_ptr sd, SP type, int type2, int val) /*========================================== * スクリプトによるスキル所得 + * Skill Income by Script *------------------------------------------ */ int pc_skill(dumb_ptr sd, SkillID id, int level, int flag) @@ -1809,6 +1934,8 @@ int pc_skill(dumb_ptr sd, SkillID id, int level, int flag) /*========================================== * アイテムを買った時に、新しいアイテム欄を使うか、 * 3万個制限にかかるか確認 + * When you buy an item, use the new item field, or + * Check if you hit the 30,000 limit *------------------------------------------ */ ADDITEM pc_checkadditem(dumb_ptr sd, ItemNameId nameid, int amount) @@ -1835,6 +1962,7 @@ ADDITEM pc_checkadditem(dumb_ptr sd, ItemNameId nameid, int am /*========================================== * 空きアイテム欄の個数 + * Number of free item fields *------------------------------------------ */ int pc_inventoryblank(dumb_ptr sd) @@ -1854,6 +1982,7 @@ int pc_inventoryblank(dumb_ptr sd) /*========================================== * お金を払う + * Pay Money *------------------------------------------ */ int pc_payzeny(dumb_ptr sd, int zeny) @@ -1871,6 +2000,7 @@ int pc_payzeny(dumb_ptr sd, int zeny) /*========================================== * お金を得る + * Get Money *------------------------------------------ */ int pc_getzeny(dumb_ptr sd, int zeny) @@ -1891,6 +2021,7 @@ int pc_getzeny(dumb_ptr sd, int zeny) /*========================================== * アイテムを探して、インデックスを返す + * Find an item and return an index *------------------------------------------ */ IOff0 pc_search_inventory(dumb_ptr sd, ItemNameId item_id) @@ -1907,6 +2038,10 @@ IOff0 pc_search_inventory(dumb_ptr sd, ItemNameId item_id) return IOff0::from(-1); } +/*========================================== + * + *------------------------------------------ + */ int pc_count_all_items(dumb_ptr player, ItemNameId item_id) { int count = 0; @@ -1922,6 +2057,10 @@ int pc_count_all_items(dumb_ptr player, ItemNameId item_id) return count; } +/*========================================== + * + *------------------------------------------ + */ int pc_remove_items(dumb_ptr player, ItemNameId item_id, int count) { nullpo_retz(player); @@ -1951,6 +2090,7 @@ int pc_remove_items(dumb_ptr player, ItemNameId item_id, int c /*========================================== * アイテム追加。個数のみitem構造体の数字を無視 + * Add Item. Ignore the number of items only in the structure *------------------------------------------ */ PickupFail pc_additem(dumb_ptr sd, Item *item_data, @@ -2011,6 +2151,7 @@ PickupFail pc_additem(dumb_ptr sd, Item *item_data, /*========================================== * アイテムを減らす + * Reduce items *------------------------------------------ */ int pc_delitem(dumb_ptr sd, IOff0 n, int amount, int type) @@ -2044,6 +2185,7 @@ int pc_delitem(dumb_ptr sd, IOff0 n, int amount, int type) /*========================================== * アイテムを落す + * Drop an item *------------------------------------------ */ int pc_dropitem(dumb_ptr sd, IOff0 n, int amount) @@ -2075,9 +2217,9 @@ int pc_dropitem(dumb_ptr sd, IOff0 n, int amount) /*========================================== * アイテムを拾う + * Pick up items *------------------------------------------ */ - static int can_pick_item_up_from(dumb_ptr self, BlockId other_id) { @@ -2116,6 +2258,10 @@ int can_pick_item_up_from(dumb_ptr self, BlockId other_id) } } +/*========================================== + * + *------------------------------------------ + */ int pc_takeitem(dumb_ptr sd, dumb_ptr fitem) { tick_t tick = gettick(); @@ -2154,11 +2300,11 @@ int pc_takeitem(dumb_ptr sd, dumb_ptr fitem) PickupFail flag = pc_additem(sd, &fitem->item_data, fitem->item_data.amount); if (flag != PickupFail::OKAY) - // 重量overで取得失敗 + //重量overで取得失敗 | Failure to get over weight clif_additem(sd, IOff0::from(0), 0, flag); else { - // 取得成功 + //取得成功 | Succeed if (sd->attacktimer) pc_stopattack(sd); clif_takeitem(sd, fitem); @@ -2172,6 +2318,10 @@ int pc_takeitem(dumb_ptr sd, dumb_ptr fitem) return 0; } +/*========================================== + * + *------------------------------------------ + */ static int pc_isUseitem(dumb_ptr sd, IOff0 n) { @@ -2195,6 +2345,7 @@ int pc_isUseitem(dumb_ptr sd, IOff0 n) /*========================================== * アイテムを使う + * Working with Items *------------------------------------------ */ int pc_useitem(dumb_ptr sd, IOff0 n) @@ -2227,11 +2378,9 @@ int pc_useitem(dumb_ptr sd, IOff0 n) return 0; } -// -// -// /*========================================== * PCの位置設定 + * PC location setting *------------------------------------------ */ int pc_setpos(dumb_ptr sd, @@ -2241,17 +2390,17 @@ int pc_setpos(dumb_ptr sd, nullpo_retz(sd); - if (sd->trade_partner) // 取引を中断する + if (sd->trade_partner) //取引を中断する | Suspend a transaction trade_tradecancel(sd); if (sd->state.storage_open) - storage_storage_quit(sd); // 倉庫を開いてるなら保存する + storage_storage_quit(sd); //倉庫を開いてるなら保存する | If you have a warehouse open, save it - if (sd->party_invite) // パーティ勧誘を拒否する + if (sd->party_invite) //パーティ勧誘を拒否する | Refuse to solicit a party party_reply_invite(sd, sd->party_invite_account, 0); - skill_castcancel(sd, 0); // 詠唱中断 - pc_stop_walking(sd, 0); // 歩行中断 - pc_stopattack(sd); // 攻撃中断 + skill_castcancel(sd, 0); //詠唱中断 | The singing is interrupted + pc_stop_walking(sd, 0); //歩行中断 | Walking interruption + pc_stopattack(sd); //攻撃中断 | Attack Interruption if (pc_issit(sd)) { @@ -2331,7 +2480,7 @@ int pc_setpos(dumb_ptr sd, sd->bl_x = x; sd->bl_y = y; -// map_addblock(sd); // ブロック登録とspawnは +// map_addblock(sd); //ブロック登録とspawnは | Block registration and spawn // clif_spawnpc(sd); return 0; @@ -2351,7 +2500,7 @@ int pc_can_reach(dumb_ptr sd, int x, int y) if (sd->bl_x == x && sd->bl_y == y) // 同じマス return 1; - // 障害物判定 + //障害物判定 | Obstacle determination wpd.path_len = 0; wpd.path_pos = 0; wpd.path_half = 0; @@ -2359,10 +2508,11 @@ int pc_can_reach(dumb_ptr sd, int x, int y) } // -// 歩 行物 +// 歩 行物 | Walks // /*========================================== * 次の1歩にかかる時間を計算 + * Calculate how long it will take to take the next step *------------------------------------------ */ static @@ -2380,6 +2530,7 @@ interval_t calc_next_walk_step(dumb_ptr sd) /*========================================== * 半歩進む(timer関数) + * Half a step forward (timer function) *------------------------------------------ */ static @@ -2399,7 +2550,7 @@ void pc_walk(TimerData *, tick_t tick, BlockId id, unsigned char data) sd->walkpath.path_half ^= 1; if (sd->walkpath.path_half == 0) - { // マス目中心へ到着 + { //マス目中心へ到着 | Arrive at the center of the grid sd->walkpath.path_pos++; if (sd->state.change_walk_target) { @@ -2408,7 +2559,7 @@ void pc_walk(TimerData *, tick_t tick, BlockId id, unsigned char data) } } else - { // マス目境界へ到着 + { //マス目境界へ到着 | Arriving at the grid boundary if (sd->walkpath.path[sd->walkpath.path_pos] >= DIR::COUNT) return; @@ -2482,7 +2633,7 @@ void pc_walk(TimerData *, tick_t tick, BlockId id, unsigned char data) // sd->walktimer = nullptr; if (sd->status.party_id) - { // パーティのHP情報通知検査 + { //パーティのHP情報通知検査 | Inspection of the party's HP information notification Option p = party_search(sd->status.party_id); if (p.is_some()) { @@ -2516,6 +2667,7 @@ void pc_walk(TimerData *, tick_t tick, BlockId id, unsigned char data) /*========================================== * 移動可能か確認して、可能なら歩行開始 + * Check if you can move and start walking if possible *------------------------------------------ */ static @@ -2547,6 +2699,7 @@ int pc_walktoxy_sub(dumb_ptr sd) /*========================================== * pc歩 行要求 + * pc step request *------------------------------------------ */ int pc_walktoxy(dumb_ptr sd, int x, int y) @@ -2562,8 +2715,8 @@ int pc_walktoxy(dumb_ptr sd, int x, int y) if (sd->walktimer && sd->state.change_walk_target == 0) { - // 現在歩いている最中の目的地変更なのでマス目の中心に来た時に - // timer関数からpc_walktoxy_subを呼ぶようにする + //現在歩いている最中の目的地変更なのでマス目の中心に来た時に | Since it is a destination change while currently walking, when you come to the center of the square + // timer関数からpc_walktoxy_subを呼ぶようにする | Make sure to call pc_walktoxy_sub from timer function sd->state.change_walk_target = 1; } else @@ -2576,6 +2729,7 @@ int pc_walktoxy(dumb_ptr sd, int x, int y) /*========================================== * 歩 行停止 + * Walk stop *------------------------------------------ */ int pc_stop_walking(dumb_ptr sd, int type) @@ -2600,6 +2754,10 @@ int pc_stop_walking(dumb_ptr sd, int type) return 0; } +/*========================================== + * + *------------------------------------------ + */ void pc_touch_all_relevant_npcs(dumb_ptr sd) { if (npc_touch_areanpc(sd, sd->bl_m, sd->bl_x, sd->bl_y) != 2) @@ -2607,10 +2765,11 @@ void pc_touch_all_relevant_npcs(dumb_ptr sd) } // -// 武器戦闘 +// 武器戦闘 | Weapons Combat // /*========================================== * スキルの検索 所有していた場合Lvが返る + * Search for a skill If you owned it, it will return Lv *------------------------------------------ */ int pc_checkskill(dumb_ptr sd, SkillID skill_id) @@ -2623,6 +2782,7 @@ int pc_checkskill(dumb_ptr sd, SkillID skill_id) /*========================================== * 装 備品のチェック + * Checking Equipment *------------------------------------------ */ IOff0 pc_checkequip(dumb_ptr sd, EPOS pos) @@ -2640,6 +2800,7 @@ IOff0 pc_checkequip(dumb_ptr sd, EPOS pos) /*========================================== * PCの攻撃 (timer関数) + * PC Attack (Timer Function) *------------------------------------------ */ static @@ -2664,12 +2825,12 @@ void pc_attack_timer(TimerData *, tick_t tick, BlockId id) if (bl->bl_type == BL::PC && pc_isdead(bl->is_player())) return; - // 同じmapでないなら攻撃しない - // PCが死んでても攻撃しない + //同じmapでないなら攻撃しない | If it's not the same map, don't attack + //PCが死んでても攻撃しない | Does not attack even if the PC is dead if (sd->bl_m != bl->bl_m || pc_isdead(sd)) return; - // 異常などで攻撃できない + //異常などで攻撃できない | Unable to attack due to abnormalities, etc. if (sd->opt1 != Opt1::ZERO) return; @@ -2720,7 +2881,7 @@ void pc_attack_timer(TimerData *, tick_t tick, BlockId id) if (sd->status.weapon != ItemLook::BOW) range++; if (dist > range) - { // 届 かないので移動 + { //届 かないので移動 | Move because it does not arrive //if(pc_can_reach(sd,bl->bl_x,bl->bl_y)) //clif_movetoattack(sd,bl); return; @@ -2737,7 +2898,7 @@ void pc_attack_timer(TimerData *, tick_t tick, BlockId id) else { if (battle_config.player_attack_direction_change) - sd->dir = sd->head_dir = map_calc_dir(sd, bl->bl_x, bl->bl_y); // 向き設定 + sd->dir = sd->head_dir = map_calc_dir(sd, bl->bl_x, bl->bl_y); //向き設定 | Orientation setting if (sd->walktimer) pc_stop_walking(sd, 1); @@ -2764,6 +2925,8 @@ void pc_attack_timer(TimerData *, tick_t tick, BlockId id) /*========================================== * 攻撃要求 * typeが1なら継続攻撃 + * Attack Requests + * If type is 1, continue attack *------------------------------------------ */ int pc_attack(dumb_ptr sd, BlockId target_id, int type) @@ -2792,14 +2955,14 @@ int pc_attack(dumb_ptr sd, BlockId target_id, int type) interval_t d = sd->attackabletime - gettick(); if (d > interval_t::zero() && d < 2_s) - { // 攻撃delay中 + { //攻撃delay中 | Attack delaying sd->attacktimer = Timer(sd->attackabletime, std::bind(pc_attack_timer, ph::_1, ph::_2, sd->bl_id)); } else { - // 本来timer関数なので引数を合わせる + //本来timer関数なので引数を合わせる | Since it is originally a timer function, match the arguments pc_attack_timer(nullptr, gettick(), sd->bl_id); } @@ -2808,6 +2971,7 @@ int pc_attack(dumb_ptr sd, BlockId target_id, int type) /*========================================== * 継続攻撃停止 + * Continuous Attack Halt *------------------------------------------ */ int pc_stopattack(dumb_ptr sd) @@ -2822,6 +2986,10 @@ int pc_stopattack(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ static int pc_checkbaselevelup(dumb_ptr sd) { @@ -2831,7 +2999,7 @@ int pc_checkbaselevelup(dumb_ptr sd) if (sd->status.base_exp >= next && next > 0) { - // base側レベルアップ処理 + //base側レベルアップ処理 | Base side level-up processing sd->status.base_exp -= next; sd->status.base_level++; @@ -2843,8 +3011,8 @@ int pc_checkbaselevelup(dumb_ptr sd) pc_heal(sd, sd->status.max_hp, sd->status.max_sp, true); clif_misceffect(sd, 0); - //レベルアップしたのでパーティー情報を更新する - //(公平範囲チェック) + //レベルアップしたのでパーティー情報を更新する | Now that you've leveled up, update your party information + //(公平範囲チェック) | (Fair Scope Check) party_send_movemap(sd); MAP_LOG_XP(sd, "LEVELUP"_fmt); return 1; @@ -2853,6 +3021,10 @@ int pc_checkbaselevelup(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ inline int RAISE_COST(int x) { @@ -2877,6 +3049,10 @@ int pc_skillpt_potential(dumb_ptr sd) return potential; } +/*========================================== + * + *------------------------------------------ + */ static int pc_checkjoblevelup(dumb_ptr sd) { @@ -2894,7 +3070,7 @@ int pc_checkjoblevelup(dumb_ptr sd) return 0; } - // job側レベルアップ処理 + //job側レベルアップ処理 | Job side level-up processing sd->status.job_exp -= next; clif_updatestatus(sd, SP::NEXTJOBEXP); sd->status.skill_point++; @@ -2914,6 +3090,10 @@ int pc_checkjoblevelup(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_gainexp_reason(dumb_ptr sd, int base_exp, int job_exp, PC_GAINEXP_REASON reason) { @@ -3004,6 +3184,10 @@ int pc_gainexp_reason(dumb_ptr sd, int base_exp, int job_exp, return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_extract_healer_exp(dumb_ptr sd, int max) { int amount; @@ -3019,6 +3203,7 @@ int pc_extract_healer_exp(dumb_ptr sd, int max) /*========================================== * base level側必要経験値計算 + * Base Level side required experience calculation *------------------------------------------ */ int pc_nextbaseexp(dumb_ptr sd) @@ -3033,6 +3218,7 @@ int pc_nextbaseexp(dumb_ptr sd) /*========================================== * job level側必要経験値計算 + * Job level side required experience calculation *------------------------------------------ */ int pc_nextjobexp(dumb_ptr sd) @@ -3075,6 +3261,7 @@ int pc_nextjobafter(dumb_ptr sd) /*========================================== * 必要ステータスポイント計算 + * Calculating Required Status Points *------------------------------------------ */ // TODO: replace SP by ATTR @@ -3093,6 +3280,7 @@ int pc_need_status_point(dumb_ptr sd, SP type) /*========================================== * 能力値成長 + * Ability Growth *------------------------------------------ */ int pc_statusup(dumb_ptr sd, SP type) @@ -3131,6 +3319,7 @@ int pc_statusup(dumb_ptr sd, SP type) /*========================================== * 能力値成長 + * Ability Growth *------------------------------------------ */ int pc_statusup2(dumb_ptr sd, SP type, int val) @@ -3158,6 +3347,7 @@ int pc_statusup2(dumb_ptr sd, SP type, int val) /*========================================== * スキルポイント割り振り + * Skill Point Allocation *------------------------------------------ */ int pc_skillup(dumb_ptr sd, SkillID skill_num) @@ -3236,6 +3426,7 @@ int pc_resetskill(dumb_ptr sd) /*========================================== * pcにダメージを与える + * Damage your PC *------------------------------------------ */ int pc_damage(dumb_ptr src, dumb_ptr sd, @@ -3243,10 +3434,10 @@ int pc_damage(dumb_ptr src, dumb_ptr sd, { nullpo_retz(sd); - // 既に死んでいたら無効 + //既に死んでいたら無効 | Invalid if already dead if (pc_isdead(sd)) return 0; - // 座ってたら立ち上がる + //座ってたら立ち上がる | Sit down and stand up if (pc_issit(sd)) { pc_setstand(sd); @@ -3269,7 +3460,7 @@ int pc_damage(dumb_ptr src, dumb_ptr sd, MAP_LOG_PC(sd, "INJURED-BY null FOR %d"_fmt, damage); pc_stop_walking(sd, 3); - // 演奏/ダンスの中断 + //演奏/ダンスの中断 | Performance/Dance Interruptions if (damage > sd->status.max_hp >> 2) skill_stop_dancing(sd, 0); @@ -3277,7 +3468,7 @@ int pc_damage(dumb_ptr src, dumb_ptr sd, if (sd->status.hp > 0) { - // まだ生きているならHP更新 + //まだ生きているならHP更新 | HP update if you're still alive clif_updatestatus(sd, SP::HP); sd->canlog_tick = gettick(); @@ -3308,10 +3499,10 @@ int pc_damage(dumb_ptr src, dumb_ptr sd, pc_setdead(sd); pc_stop_walking(sd, 0); - skill_castcancel(sd, 0); // 詠唱の中止 + skill_castcancel(sd, 0); //詠唱の中止 | Cessation of chanting clif_clearchar(sd, BeingRemoveWhy::DEAD); - pc_setglobalreg(sd, stringish("PC_DIE_COUNTER"_s), ++sd->die_counter); //死にカウンター書き込み - skill_status_change_clear(sd, 0); // ステータス異常を解除する + pc_setglobalreg(sd, stringish("PC_DIE_COUNTER"_s), ++sd->die_counter); //死にカウンター書き込み | Counter writing to death + skill_status_change_clear(sd, 0); //ステータス異常を解除する | Release status anomalies clif_updatestatus(sd, SP::HP); // [Fate] Reset magic // FIXME: make spells manage their own charge counter, and reset on death @@ -3383,14 +3574,14 @@ int pc_damage(dumb_ptr src, dumb_ptr sd, // pvp if (sd->bl_m->flag.get(MapFlag::PVP) && !battle_config.pk_mode) { // disable certain pvp functions on pk_mode [Valaris] - //ランキング計算 + //ランキング計算 | Ranking Calculation if (!sd->bl_m->flag.get(MapFlag::PVP_NOCALCRANK)) { sd->pvp_point -= 5; if (src && src->bl_type == BL::PC) src->is_player()->pvp_point++; } - // 強制送還 + //強制送還 | Deportation if (sd->pvp_point < 0) { sd->pvp_point = 0; @@ -3417,10 +3608,11 @@ int pc_damage(dumb_ptr src, dumb_ptr sd, } // -// script関 連 +// script関 連 | Script-related // /*========================================== * script用PCステータス読み出し + * Read PC status for script *------------------------------------------ */ int pc_readparam(dumb_ptr bl, SP type) @@ -3619,6 +3811,7 @@ int pc_readparam(dumb_ptr bl, SP type) /*========================================== * script用PCステータス設定 + * PC status setting for script *------------------------------------------ */ int pc_setparam(dumb_ptr bl, SP type, int val) @@ -3868,6 +4061,7 @@ int pc_setparam(dumb_ptr bl, SP type, int val) /*========================================== * HP/SP回復 + * HP/SP Recovery *------------------------------------------ */ int pc_heal(dumb_ptr sd, int hp, int sp, bool levelup) @@ -3932,11 +4126,16 @@ int pc_heal(dumb_ptr sd, int hp, int sp) /*========================================== * HP/SP回復 + * HP/SP Recovery *------------------------------------------ */ static int pc_itemheal_effect(dumb_ptr sd, int hp, int sp); +/*========================================== + * + *------------------------------------------ + */ static int // Compute how quickly we regenerate (less is faster) for that amount pc_heal_quick_speed(int amount) @@ -3959,6 +4158,10 @@ pc_heal_quick_speed(int amount) } } +/*========================================== + * + *------------------------------------------ + */ static void pc_heal_quick_accumulate(int new_amount, struct quick_regeneration *quick_regen, int max) @@ -3975,6 +4178,10 @@ void pc_heal_quick_accumulate(int new_amount, quick_regen->tickdelay = std::min(quick_regen->speed, quick_regen->tickdelay); } +/*========================================== + * + *------------------------------------------ + */ int pc_itemheal(dumb_ptr sd, int hp, int sp) { /* defer healing */ @@ -4001,8 +4208,10 @@ int pc_itemheal(dumb_ptr sd, int hp, int sp) return 0; } -/* pc_itemheal_effect is invoked once every 0.5s whenever the pc +/*========================================== + * pc_itemheal_effect is invoked once every 0.5s whenever the pc * has health recovery queued up (cf. pc_natural_heal_sub). + *------------------------------------------ */ static int pc_itemheal_effect(dumb_ptr sd, int hp, int sp) @@ -4060,6 +4269,7 @@ int pc_itemheal_effect(dumb_ptr sd, int hp, int sp) /*========================================== * 見た目変更 + * Change the look *------------------------------------------ */ int pc_changelook(dumb_ptr sd, LOOK type, int val) @@ -4102,6 +4312,7 @@ int pc_changelook(dumb_ptr sd, LOOK type, int val) /*========================================== * script用変数の値を読む + * Read the value of a variable for script *------------------------------------------ */ int pc_readreg(dumb_ptr sd, SIR reg) @@ -4113,6 +4324,7 @@ int pc_readreg(dumb_ptr sd, SIR reg) /*========================================== * script用変数の値を設定 + * Set the value of a variable for script *------------------------------------------ */ void pc_setreg(dumb_ptr sd, SIR reg, int val) @@ -4124,6 +4336,7 @@ void pc_setreg(dumb_ptr sd, SIR reg, int val) /*========================================== * script用文字列変数の値を読む + * Reading the value of a string variable for script *------------------------------------------ */ ZString pc_readregstr(dumb_ptr sd, SIR reg) @@ -4136,6 +4349,7 @@ ZString pc_readregstr(dumb_ptr sd, SIR reg) /*========================================== * script用文字列変数の値を設定 + * Set the value of a string variable for script *------------------------------------------ */ void pc_setregstr(dumb_ptr sd, SIR reg, RString str) @@ -4153,6 +4367,7 @@ void pc_setregstr(dumb_ptr sd, SIR reg, RString str) /*========================================== * script用グローバル変数の値を読む + * Read the value of a global variable for script *------------------------------------------ */ int pc_readglobalreg(dumb_ptr sd, VarName reg) @@ -4165,7 +4380,7 @@ int pc_readglobalreg(dumb_ptr sd, VarName reg) XString var = reg; VarName vr; - assert (sd->status.global_reg_num < GLOBAL_REG_NUM); + assert (sd->status.global_reg_num <= GLOBAL_REG_NUM); Option> quest_data_ = questdb_searchname(var); OMATCH_BEGIN_SOME(quest_data, quest_data_) { @@ -4196,6 +4411,7 @@ int pc_readglobalreg(dumb_ptr sd, VarName reg) /*========================================== * script用グローバル変数の値を設定 + * Set the value of a global variable for script *------------------------------------------ */ int pc_setglobalreg(dumb_ptr sd, VarName reg, int val) @@ -4209,7 +4425,7 @@ int pc_setglobalreg(dumb_ptr sd, VarName reg, int val) XString var = reg; VarName vr; - //PC_DIE_COUNTERがスクリプトなどで変更された時の処理 + //PC_DIE_COUNTERがスクリプトなどで変更された時の処理 | What to do when the PC_DIE_COUNTER is changed by script, etc. if (reg == stringish("PC_DIE_COUNTER"_s) && sd->die_counter != val) { sd->die_counter = val; @@ -4226,7 +4442,7 @@ int pc_setglobalreg(dumb_ptr sd, VarName reg, int val) assert (((1 << quest_mask) - 1) >= val); } OMATCH_END (); - assert (sd->status.global_reg_num < GLOBAL_REG_NUM); + assert (sd->status.global_reg_num <= GLOBAL_REG_NUM); if (val == 0) { for (i = 0; i < sd->status.global_reg_num; i++) @@ -4284,6 +4500,7 @@ int pc_setglobalreg(dumb_ptr sd, VarName reg, int val) /*========================================== * script用アカウント変数の値を読む + * Read the value of the account variable for script *------------------------------------------ */ int pc_readaccountreg(dumb_ptr sd, VarName reg) @@ -4292,7 +4509,7 @@ int pc_readaccountreg(dumb_ptr sd, VarName reg) nullpo_retz(sd); - assert (sd->status.account_reg_num < ACCOUNT_REG_NUM); + assert (sd->status.account_reg_num <= ACCOUNT_REG_NUM); for (i = 0; i < sd->status.account_reg_num; i++) { if (sd->status.account_reg[i].str == reg) @@ -4304,6 +4521,7 @@ int pc_readaccountreg(dumb_ptr sd, VarName reg) /*========================================== * script用アカウント変数の値を設定 + * Set the value of the account variable for script *------------------------------------------ */ int pc_setaccountreg(dumb_ptr sd, VarName reg, int val) @@ -4353,6 +4571,7 @@ int pc_setaccountreg(dumb_ptr sd, VarName reg, int val) /*========================================== * script用アカウント変数2の値を読む + * Read the value of account variable 2 for script *------------------------------------------ */ int pc_readaccountreg2(dumb_ptr sd, VarName reg) @@ -4372,6 +4591,7 @@ int pc_readaccountreg2(dumb_ptr sd, VarName reg) /*========================================== * script用アカウント変数2の値を設定 + * Set the value of account variable 2 for script *------------------------------------------ */ int pc_setaccountreg2(dumb_ptr sd, VarName reg, int val) @@ -4421,6 +4641,7 @@ int pc_setaccountreg2(dumb_ptr sd, VarName reg, int val) /*========================================== * イベントタイマー処理 + * Event Timer Processing *------------------------------------------ */ static @@ -4434,6 +4655,7 @@ void pc_eventtimer(TimerData *, tick_t, BlockId id, NpcEvent data) /*========================================== * イベントタイマー追加 + * Add Event Timer *------------------------------------------ */ int pc_addeventtimer(dumb_ptr sd, interval_t tick, NpcEvent name) @@ -4459,6 +4681,7 @@ int pc_addeventtimer(dumb_ptr sd, interval_t tick, NpcEvent na /*========================================== * イベントタイマー全削除 + * Delete all event timers *------------------------------------------ */ int pc_cleareventtimer(dumb_ptr sd) @@ -4472,10 +4695,11 @@ int pc_cleareventtimer(dumb_ptr sd) } // -// 装 備物 +// 装 備物 | Equipment // /*========================================== * アイテムを装備する + * Equip items *------------------------------------------ */ static @@ -4494,10 +4718,14 @@ int pc_signal_advanced_equipment_change(dumb_ptr sd, IOff0 n) return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_equipitem(dumb_ptr sd, IOff0 n, EPOS) { ItemNameId nameid; - //ソス]ソスソスソスソスソス{ソスqソスフ場合ソスフ鯉ソスソスフ職ソスニゑソスソスZソスoソスソスソスソス + //ソス]ソスソスソスソスソス{ソスqソスフ場合ソスフ鯉ソスソスフ職ソスニゑソスソスZソスoソスソスソスソス | Sos] sos sos sos sos sos { sos q sos if sos f (???) nullpo_retz(sd); @@ -4525,7 +4753,7 @@ int pc_equipitem(dumb_ptr sd, IOff0 n, EPOS) // if (pos == (EPOS::MISC2 | EPOS::CAPE)) { - // アクセサリ用例外処理 + //アクセサリ用例外処理 | Accessory exception handling EPOS epor = EPOS::ZERO; IOff0 midx = sd->equip_index_maybe[EQUIP::MISC2]; IOff0 cidx = sd->equip_index_maybe[EQUIP::CAPE]; @@ -4547,11 +4775,11 @@ int pc_equipitem(dumb_ptr sd, IOff0 n, EPOS) *idx = n; } } - // 弓矢装備 + //弓矢装備 | Bow and arrow equipment if (pos == EPOS::ARROW) { clif_arrowequip(sd, n); - clif_arrow_fail(sd, 3); // 3=矢が装備できました + clif_arrow_fail(sd, 3); //3=矢が装備できました | 3=Arrows can be equipped. } else { @@ -4639,6 +4867,7 @@ int pc_equipitem(dumb_ptr sd, IOff0 n, EPOS) /*========================================== * 装 備した物を外す + * Remove the attached object *------------------------------------------ */ int pc_unequipitem(dumb_ptr sd, IOff0 n, CalcStatus type) @@ -4704,6 +4933,10 @@ int pc_unequipitem(dumb_ptr sd, IOff0 n, CalcStatus type) return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_unequipinvyitem(dumb_ptr sd, IOff0 n, CalcStatus type) { nullpo_retr(1, sd); @@ -4726,6 +4959,8 @@ int pc_unequipinvyitem(dumb_ptr sd, IOff0 n, CalcStatus type) /*========================================== * アイテムのindex番号を詰めたり * 装 備品の装備可能チェックを行なう + * Stuffing the index number of the item or + * Check the equipping of equipment *------------------------------------------ */ int pc_checkitem(dumb_ptr sd) @@ -4770,6 +5005,10 @@ int pc_checkitem(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_checkoverhp(dumb_ptr sd) { nullpo_retz(sd); @@ -4786,6 +5025,10 @@ int pc_checkoverhp(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ int pc_checkoversp(dumb_ptr sd) { nullpo_retz(sd); @@ -4804,6 +5047,7 @@ int pc_checkoversp(dumb_ptr sd) /*========================================== * PVP順位計算用(foreachinarea) + * For PVP ranking calculation (foreachinarea) *------------------------------------------ */ static @@ -4821,6 +5065,7 @@ void pc_calc_pvprank_sub(dumb_ptr bl, dumb_ptr sd2 /*========================================== * PVP順位計算 + * PVP ranking calculation *------------------------------------------ */ int pc_calc_pvprank(dumb_ptr sd) @@ -4841,6 +5086,7 @@ int pc_calc_pvprank(dumb_ptr sd) /*========================================== * PVP順位計算(timer) + * PVP ranking calculation (timer) *------------------------------------------ */ void pc_calc_pvprank_timer(TimerData *, tick_t, BlockId id) @@ -4863,6 +5109,7 @@ void pc_calc_pvprank_timer(TimerData *, tick_t, BlockId id) /*========================================== * sdは結婚しているか(既婚の場合は相方のchar_idを返す) + * Is sd married (returns partner's char_id if married) *------------------------------------------ */ static @@ -4878,6 +5125,7 @@ CharId pc_ismarried(dumb_ptr sd) /*========================================== * sdがdstsdと結婚(dstsd→sdの結婚処理も同時に行う) + * sd marries dstsd (dstsd → sd marriage processing is also performed at the same time) *------------------------------------------ */ int pc_marriage(dumb_ptr sd, dumb_ptr dstsd) @@ -4892,6 +5140,7 @@ int pc_marriage(dumb_ptr sd, dumb_ptr dstsd) /*========================================== * sdが離婚(相手はsd->status.partner_idに依る)(相手も同時に離婚・結婚指輪自動剥奪) + * sd is divorced (partner depends on sd->status.partner_id) (partner is also divorced at the same time and wedding ring is automatically stripped) *------------------------------------------ */ int pc_divorce(dumb_ptr sd) @@ -4925,6 +5174,7 @@ int pc_divorce(dumb_ptr sd) /*========================================== * sdの相方のmap_session_dataを返す + * return map_session_data of sd's counterpart *------------------------------------------ */ dumb_ptr pc_get_partner(dumb_ptr sd) @@ -4945,13 +5195,13 @@ dumb_ptr pc_get_partner(dumb_ptr sd) } // -// 自然回復物 +// 自然回復物 | Natural Restoration // /*========================================== * SP回復量計算 + * SP Recovery Calculator *------------------------------------------ */ - static interval_t pc_spheal(dumb_ptr sd) { @@ -4966,6 +5216,7 @@ interval_t pc_spheal(dumb_ptr sd) /*========================================== * HP回復量計算 + * HP Recovery Calculator *------------------------------------------ */ static @@ -4980,6 +5231,10 @@ interval_t pc_hpheal(dumb_ptr sd) return a; } +/*========================================== + * + *------------------------------------------ + */ static int pc_natural_heal_hp(dumb_ptr sd) { @@ -5034,6 +5289,10 @@ int pc_natural_heal_hp(dumb_ptr sd) return 0; } +/*========================================== + * + *------------------------------------------ + */ static int pc_natural_heal_sp(dumb_ptr sd) { @@ -5082,9 +5341,9 @@ int pc_natural_heal_sp(dumb_ptr sd) /*========================================== * HP/SP 自然回復 各クライアント + * HP/SP Natural Recovery Each client *------------------------------------------ */ - static int pc_quickregenerate_effect(struct quick_regeneration *quick_regen, int heal_speed) @@ -5105,6 +5364,10 @@ int pc_quickregenerate_effect(struct quick_regeneration *quick_regen, return 0; } +/*========================================== + * + *------------------------------------------ + */ static void pc_natural_heal_sub(dumb_ptr sd) { @@ -5168,6 +5431,7 @@ void pc_natural_heal_sub(dumb_ptr sd) /*========================================== * HP/SP自然回復 (interval timer関数) + * HP/SP natural recovery (interval timer function) *------------------------------------------ */ static @@ -5182,6 +5446,7 @@ void pc_natural_heal(TimerData *, tick_t tick) /*========================================== * セーブポイントの保存 + * Saving savepoints *------------------------------------------ */ void pc_setsavepoint(dumb_ptr sd, MapName mapname, int x, int y) @@ -5195,6 +5460,7 @@ void pc_setsavepoint(dumb_ptr sd, MapName mapname, int x, int /*========================================== * 自動セーブ 各クライアント + * Autosave each client *------------------------------------------ */ static @@ -5214,6 +5480,7 @@ void pc_autosave_sub(dumb_ptr sd) /*========================================== * 自動セーブ (timer関数) + * Autosave (timer function) *------------------------------------------ */ static @@ -5232,6 +5499,10 @@ void pc_autosave(TimerData *, tick_t) ).detach(); } +/*========================================== + * + *------------------------------------------ + */ int pc_read_gm_account(Session *, const std::vector>& repeat) { gm_accountm.clear(); @@ -5245,6 +5516,10 @@ int pc_read_gm_account(Session *, const std::vector>& repe return gm_accountm.size(); } +/*========================================== + * + *------------------------------------------ + */ void pc_setstand(dumb_ptr sd) { nullpo_retv(sd); @@ -5255,6 +5530,10 @@ void pc_setstand(dumb_ptr sd) clif_gm_collision(sd, 0); } +/*========================================== + * + *------------------------------------------ + */ static void pc_calc_sigma(void) { @@ -5272,6 +5551,10 @@ void pc_calc_sigma(void) } } +/*========================================== + * + *------------------------------------------ + */ void do_init_pc(void) { pc_calc_sigma(); @@ -5285,6 +5568,10 @@ void do_init_pc(void) ).detach(); } +/*========================================== + * + *------------------------------------------ + */ void pc_invisibility(dumb_ptr sd, int enabled) { if (enabled && !bool(sd->status.option & Opt0::INVISIBILITY)) @@ -5301,6 +5588,10 @@ void pc_invisibility(dumb_ptr sd, int enabled) } } +/*========================================== + * + *------------------------------------------ + */ int pc_logout(dumb_ptr sd) // [fate] Player logs out { if (!sd) diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index 4de94d7..76bae8d 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -78,6 +78,7 @@ dumb_ptr script_rid2sd(ScriptState *st) /*========================================== * 変数の読み取り + * Reading variables *------------------------------------------ */ void get_val(dumb_ptr sd, struct script_data *data) @@ -198,6 +199,7 @@ void get_val(ScriptState *st, struct script_data *data) /*========================================== * 変数の読み取り2 + * Reading Variables2 *------------------------------------------ */ struct script_data get_val2(ScriptState *st, SIR reg) @@ -209,6 +211,7 @@ struct script_data get_val2(ScriptState *st, SIR reg) /*========================================== * 変数設定用 + * For setting variables *------------------------------------------ */ void set_reg(dumb_ptr sd, VariableCode type, SIR reg, struct script_data vd) diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index b72be56..135aef9 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -101,7 +101,7 @@ enum class MonsterAttitude FROZEN = 3, }; // -// 埋め込み関数 +// 埋め込み関数 | Embedded functions // /*========================================== * @@ -145,6 +145,7 @@ void builtin_goto(ScriptState *st) /*========================================== * ユーザー定義関数の呼び出し + * Calling user-defined functions *------------------------------------------ */ static @@ -163,10 +164,10 @@ void builtin_callfunc(ScriptState *st) for (int i = st->start + 3; i < st->end; i++, j++) push_copy(st->stack, i); #endif - push_int(st->stack, j); // 引数の数をプッシュ - push_int(st->stack, st->defsp); // 現在の基準スタックポインタをプッシュ - push_int(st->stack, st->scriptp.pos); // 現在のスクリプト位置をプッシュ - push_script(st->stack, TRY_UNWRAP(st->scriptp.code, abort())); // 現在のスクリプトをプッシュ + push_int(st->stack, j); // 引数の数をプッシュ | Push the number of arguments + push_int(st->stack, st->defsp); // 現在の基準スタックポインタをプッシュ | Push current reference stack pointer + push_int(st->stack, st->scriptp.pos); // 現在のスクリプト位置をプッシュ | Push Current Script Position + push_script(st->stack, TRY_UNWRAP(st->scriptp.code, abort())); // 現在のスクリプトをプッシュ | Push Current Script st->scriptp = ScriptPointer(scr, 0); st->defsp = st->start + 4 + j; @@ -182,6 +183,10 @@ void builtin_callfunc(ScriptState *st) OMATCH_END (); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_call(ScriptState *st) { @@ -201,10 +206,10 @@ void builtin_call(ScriptState *st) for (int i = st->start + 3; i < st->end; i++, j++) push_copy(st->stack, i); - push_int(st->stack, j); // 引数の数をプッシュ - push_int(st->stack, st->defsp); // 現在の基準スタックポインタをプッシュ - push_int(st->stack, st->scriptp.pos); // 現在のスクリプト位置をプッシュ - push_script(st->stack, TRY_UNWRAP(st->scriptp.code, abort())); // 現在のスクリプトをプッシュ + push_int(st->stack, j); // 引数の数をプッシュ | Push the number of arguments + push_int(st->stack, st->defsp); // 現在の基準スタックポインタをプッシュ | Push current reference stack pointer + push_int(st->stack, st->scriptp.pos); // 現在のスクリプト位置をプッシュ | Push Current Script Position + push_script(st->stack, TRY_UNWRAP(st->scriptp.code, abort())); // 現在のスクリプトをプッシュ | Push Current Script st->scriptp = ScriptPointer(scr, 0); st->defsp = st->start + 4 + j; @@ -228,10 +233,10 @@ void builtin_call(ScriptState *st) for (int i = st->start + 3; i < st->end; i++, j++) push_copy(st->stack, i); - push_int(st->stack, j); // 引数の数をプッシュ - push_int(st->stack, st->defsp); // 現在の基準スタックポインタをプッシュ - push_int(st->stack, st->scriptp.pos); // 現在のスクリプト位置をプッシュ - push_script(st->stack, TRY_UNWRAP(st->scriptp.code, abort())); // 現在のスクリプトをプッシュ + push_int(st->stack, j); // 引数の数をプッシュ | Push the number of arguments + push_int(st->stack, st->defsp); // 現在の基準スタックポインタをプッシュ | Push current reference stack pointer + push_int(st->stack, st->scriptp.pos); // 現在のスクリプト位置をプッシュ | Push Current Script Position + push_script(st->stack, TRY_UNWRAP(st->scriptp.code, abort())); // 現在のスクリプトをプッシュ | Push Current Script st->scriptp.pos = pos_; st->defsp = st->start + 4 + j; @@ -240,6 +245,10 @@ void builtin_call(ScriptState *st) } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getarg(ScriptState *st) { @@ -268,6 +277,10 @@ void builtin_getarg(ScriptState *st) push_copy(st->stack, (st->defsp - 4 - i) + arg); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_void(ScriptState *) { @@ -276,6 +289,7 @@ void builtin_void(ScriptState *) /*========================================== * サブルーティンの呼び出し + * Call of the Surbrutin *------------------------------------------ */ static @@ -289,10 +303,10 @@ void builtin_callsub(ScriptState *st) push_copy(st->stack, i); #endif - push_int(st->stack, j); // 引数の数をプッシュ - push_int(st->stack, st->defsp); // 現在の基準スタックポインタをプッシュ - push_int(st->stack, st->scriptp.pos); // 現在のスクリプト位置をプッシュ - push_script(st->stack, TRY_UNWRAP(st->scriptp.code, abort())); // 現在のスクリプトをプッシュ + push_int(st->stack, j); // 引数の数をプッシュ | Push the number of arguments + push_int(st->stack, st->defsp); // 現在の基準スタックポインタをプッシュ | Push current reference stack pointer + push_int(st->stack, st->scriptp.pos); // 現在のスクリプト位置をプッシュ | Push Current Script Position + push_script(st->stack, TRY_UNWRAP(st->scriptp.code, abort())); // 現在のスクリプトをプッシュ | Push Current Script st->scriptp.pos = pos_; st->defsp = st->start + 4 + j; @@ -301,6 +315,7 @@ void builtin_callsub(ScriptState *st) /*========================================== * サブルーチン/ユーザー定義関数の終了 + * Terminating Subroutines/User-Defined Functions *------------------------------------------ */ static @@ -316,7 +331,7 @@ void builtin_return(ScriptState *st) } if (HARG(0)) - { // 戻り値有り + { // 戻り値有り | Return value available push_copy(st->stack, st->start + 2); } @@ -361,6 +376,10 @@ void builtin_close(ScriptState *st) clif_npc_action(sd, st->oid, 5, 0, 0, 0); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_close2(ScriptState *st) { @@ -455,6 +474,10 @@ void builtin_rand(ScriptState *st) } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_max(ScriptState *st) { @@ -500,6 +523,10 @@ void builtin_max(ScriptState *st) push_int(st->stack, max); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_min(ScriptState *st) { @@ -546,6 +573,10 @@ void builtin_min(ScriptState *st) push_int(st->stack, min); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_average(ScriptState *st) { @@ -558,18 +589,30 @@ void builtin_average(ScriptState *st) push_int(st->stack, (total / i)); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_sqrt(ScriptState *st) { push_int(st->stack, static_cast(sqrt(conv_num(st, &AARG(0))))); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_cbrt(ScriptState *st) { push_int(st->stack, static_cast(cbrt(conv_num(st, &AARG(0))))); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_pow(ScriptState *st) { @@ -616,6 +659,7 @@ void builtin_warp(ScriptState *st) /*========================================== * エリア指定ワープ + * Area Designation Warp *------------------------------------------ */ static @@ -849,6 +893,10 @@ void builtin_input(ScriptState *st) } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_requestitem(ScriptState *st) { @@ -950,6 +998,10 @@ void builtin_requestitem(ScriptState *st) } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_requestlang(ScriptState *st) { @@ -1004,11 +1056,11 @@ void builtin_if (ScriptState *st) if (!sel) return; - // 関数名をコピー + // 関数名をコピー | Copy function name push_copy(st->stack, st->start + 3); - // 間に引数マーカを入れて + // 間に引数マーカを入れて | Put argument markers in between push_int(st->stack, 0); - // 残りの引数をコピー + // 残りの引数をコピー | Copy the remaining arguments for (i = st->start + 4; i < st->end; i++) { push_copy(st->stack, i); @@ -1016,6 +1068,10 @@ void builtin_if (ScriptState *st) run_func(st); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_if_then_else (ScriptState *st) { @@ -1023,6 +1079,10 @@ void builtin_if_then_else (ScriptState *st) push_copy(st->stack, st->start + (condition ? 3 : 4)); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_else (ScriptState *st) { @@ -1038,11 +1098,11 @@ void builtin_else (ScriptState *st) return; st->is_true = 0; - // 関数名をコピー + // 関数名をコピー | Copy function name push_copy(st->stack, st->start + 2); - // 間に引数マーカを入れて + // 間に引数マーカを入れて | Put argument markers in between push_int(st->stack, 0); - // 残りの引数をコピー + // 残りの引数をコピー | Copy the remaining arguments for (i = st->start + 3; i < st->end; i++) { push_copy(st->stack, i); @@ -1050,6 +1110,10 @@ void builtin_else (ScriptState *st) run_func(st); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_elif (ScriptState *st) { @@ -1068,11 +1132,11 @@ void builtin_elif (ScriptState *st) if (!sel) return; - // 関数名をコピー + // 関数名をコピー | Copy function name push_copy(st->stack, st->start + 3); - // 間に引数マーカを入れて + // 間に引数マーカを入れて | Put argument markers in between push_int(st->stack, 0); - // 残りの引数をコピー + // 残りの引数をコピー | Copy the remaining arguments for (i = st->start + 4; i < st->end; i++) { push_copy(st->stack, i); @@ -1094,6 +1158,11 @@ void builtin_foreach_sub(dumb_ptr bl, NpcEvent event, BlockId caster }; npc_event_do_l(event, caster, arg); } + +/*========================================== + * + *------------------------------------------ + */ static void builtin_foreach(ScriptState *st) { @@ -1182,7 +1251,6 @@ void builtin_destroy(ScriptState *st) * Creates a temp NPC *---------------------------------------- */ - static void builtin_puppet(ScriptState *st) { @@ -1298,6 +1366,7 @@ void builtin_puppet(ScriptState *st) /*========================================== * 変数設定 + * Variable settings *------------------------------------------ */ static @@ -1417,20 +1486,23 @@ void builtin_set(ScriptState *st) if (postfix == '$') { - // 文字列 + // 文字列 | string RString str = conv_str(st, &AARG(1)); set_reg(bl, VariableCode::VARIABLE, reg, str); } else { - // 数値 + // 数値 | numeric value int val = conv_num(st, &AARG(1)); set_reg(bl, VariableCode::VARIABLE, reg, val); } } -// this is a special function that returns array index for a variable stored in another being +/*========================================== + * this is a special function that returns array index for a variable stored in another being + *------------------------------------------ + */ static int getarraysize2(SIR reg, dumb_ptr bl) { @@ -1471,6 +1543,7 @@ int getarraysize2(SIR reg, dumb_ptr bl) /*========================================== * 配列変数設定 + * Array variable settings *------------------------------------------ */ static @@ -1535,6 +1608,7 @@ void builtin_setarray(ScriptState *st) /*========================================== * 配列変数クリア + * Clearing Array Variables *------------------------------------------ */ static @@ -1574,6 +1648,7 @@ void builtin_cleararray(ScriptState *st) /*========================================== * 配列変数のサイズ所得 + * Size of the array variable income *------------------------------------------ */ static @@ -1604,6 +1679,10 @@ int getarraysize(ScriptState *st, SIR reg) return c + 1; } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getarraysize(ScriptState *st) { @@ -1622,6 +1701,7 @@ void builtin_getarraysize(ScriptState *st) /*========================================== * 指定要素を表す値(キー)を所得する + * Obtain a value (key) representing the specified element *------------------------------------------ */ static @@ -1649,6 +1729,10 @@ void builtin_getelementofarray(ScriptState *st) } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_array_search(ScriptState *st) { @@ -1697,6 +1781,10 @@ void builtin_array_search(ScriptState *st) push_int(st->stack, c); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_wgm(ScriptState *st) { @@ -1707,6 +1795,10 @@ void builtin_wgm(ScriptState *st) STRPRINTF("[GM] %s"_fmt, message)); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_gmlog(ScriptState *st) { @@ -1782,6 +1874,7 @@ void builtin_countitem(ScriptState *st) /*========================================== * 重量チェック + * Weight check *------------------------------------------ */ static @@ -1869,9 +1962,9 @@ void builtin_getitem(ScriptState *st) { Item item_tmp {}; item_tmp.nameid = nameid; - if (HARG(3)) //アイテムを指定したIDに渡す + if (HARG(3)) //アイテムを指定したIDに渡す | Pass an item to the specified ID sd = map_id2sd(wrap(conv_num(st, &AARG(3)))); - if (sd == nullptr) //アイテムを渡す相手がいなかったらお帰り + if (sd == nullptr) //アイテムを渡す相手がいなかったらお帰り | If you don't have anyone to give the item to, go home return; PickupFail flag; if ((flag = pc_additem(sd, &item_tmp, amount)) != PickupFail::OKAY) @@ -2002,7 +2095,8 @@ void builtin_getversion(ScriptState *st) } /*========================================== - *キャラ関係のID取得 + * キャラ関係のID取得 + * Acquisition of ID related to characters *------------------------------------------ */ static @@ -2055,7 +2149,8 @@ void builtin_getnpcid(ScriptState *st) } /*========================================== - *指定IDのPT名取得 + * 指定IDのPT名取得 + * Obtaining PT name of specified ID *------------------------------------------ */ static @@ -2068,6 +2163,7 @@ RString builtin_getpartyname_sub(PartyId party_id) /*========================================== * キャラクタの名前 + * Character's name *------------------------------------------ */ static @@ -2076,7 +2172,7 @@ void builtin_strcharinfo(ScriptState *st) dumb_ptr sd; int num; - if (HARG(1)) //指定したキャラを状態異常にする + if (HARG(1)) //指定したキャラを状態異常にする | Make the specified character abnormal sd = map_id_is_player(wrap(conv_num(st, &AARG(1)))); else sd = script_rid2sd(st); @@ -2184,6 +2280,7 @@ void builtin_freeloop(ScriptState *st) /*========================================== * 装備品による能力値ボーナス + * Ability bonuses for equipment *------------------------------------------ */ static @@ -2203,6 +2300,7 @@ void builtin_bonus(ScriptState *st) /*========================================== * 装備品による能力値ボーナス + * Ability bonuses for equipment *------------------------------------------ */ static @@ -2223,6 +2321,7 @@ void builtin_bonus2(ScriptState *st) /*========================================== * スキル所得 + * Skill Income *------------------------------------------ */ static @@ -2265,6 +2364,7 @@ void builtin_setskill(ScriptState *st) /*========================================== * スキルレベル所得 + * Skill Level Income *------------------------------------------ */ static @@ -2348,7 +2448,6 @@ void builtin_end(ScriptState *st) * [Freeyorp] Return the current opt2 *------------------------------------------ */ - static void builtin_getopt2(ScriptState *st) { @@ -2365,7 +2464,6 @@ void builtin_getopt2(ScriptState *st) * [Freeyorp] Sets opt2 *------------------------------------------ */ - static void builtin_setopt2(ScriptState *st) { @@ -2384,7 +2482,8 @@ void builtin_setopt2(ScriptState *st) } /*========================================== - * セーブポイントの保存 + * セーブポイントの保存 + * Saving savepoints *------------------------------------------ */ static @@ -2484,6 +2583,7 @@ void builtin_gettime(ScriptState *st) /* Asgard Version */ /*========================================== * カプラ倉庫を開く + * Opening a coupler warehouse *------------------------------------------ */ static @@ -2504,6 +2604,7 @@ void builtin_openstorage(ScriptState *st) /*========================================== * NPCで経験値上げる + * Increase experience with NPCs *------------------------------------------ */ static @@ -2522,6 +2623,10 @@ void builtin_getexp(ScriptState *st) } +/*========================================== + * + *------------------------------------------ + */ static void builtin_summon(ScriptState *st) { @@ -2596,6 +2701,7 @@ void builtin_summon(ScriptState *st) /*========================================== * モンスター発生 + * Monster Outbreak *------------------------------------------ */ static @@ -2620,6 +2726,7 @@ void builtin_monster(ScriptState *st) /*========================================== * モンスター発生 + * Monster Outbreak *------------------------------------------ */ static @@ -2646,6 +2753,7 @@ void builtin_areamonster(ScriptState *st) /*========================================== * モンスター削除 + * Monster Removal *------------------------------------------ */ static @@ -2667,6 +2775,10 @@ void builtin_killmonster_sub(dumb_ptr bl, NpcEvent event) } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_killmonster(ScriptState *st) { @@ -2686,6 +2798,7 @@ void builtin_killmonster(ScriptState *st) /*========================================== * NPC主体イベント実行 + * NPC-Driven Event Execution *------------------------------------------ */ static @@ -2699,6 +2812,7 @@ void builtin_donpcevent(ScriptState *st) /*========================================== * イベントタイマー追加 + * Add Event Timer *------------------------------------------ */ static @@ -2722,6 +2836,7 @@ void builtin_addtimer(ScriptState *st) /*========================================== * NPCイベントタイマー追加 + * Add NPC Event Timer *------------------------------------------ */ static @@ -2736,6 +2851,7 @@ void builtin_addnpctimer(ScriptState *st) /*========================================== * NPCタイマー初期化 + * NPC Timer Initialization *------------------------------------------ */ static @@ -2756,6 +2872,7 @@ void builtin_initnpctimer(ScriptState *st) /*========================================== * NPCタイマー開始 + * NPC Timer Start *------------------------------------------ */ static @@ -2775,6 +2892,7 @@ void builtin_startnpctimer(ScriptState *st) /*========================================== * NPCタイマー停止 + * NPC Timer Stop *------------------------------------------ */ static @@ -2794,6 +2912,7 @@ void builtin_stopnpctimer(ScriptState *st) /*========================================== * NPCタイマー情報所得 + * NPC Timer Information Income *------------------------------------------ */ static @@ -2827,6 +2946,7 @@ void builtin_getnpctimer(ScriptState *st) /*========================================== * NPCタイマー値設定 + * Setting NPC Timer Values *------------------------------------------ */ static @@ -2845,6 +2965,10 @@ void builtin_setnpctimer(ScriptState *st) npc_settimerevent_tick(nd, tick); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_npcaction(ScriptState *st) { @@ -2870,6 +2994,10 @@ void builtin_npcaction(ScriptState *st) clif_npc_action(sd, st->oid, command, id, x, y); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_camera(ScriptState *st) { @@ -2914,6 +3042,10 @@ void builtin_camera(ScriptState *st) clif_npc_action(sd, st->oid, 3, 0, 0, 0); // return camera } +/*========================================== + * + *------------------------------------------ + */ static void builtin_setnpcdirection(ScriptState *st) { @@ -2956,6 +3088,7 @@ void builtin_setnpcdirection(ScriptState *st) /*========================================== * 天の声アナウンス + * Voice of Heaven Announcement *------------------------------------------ */ static @@ -2981,6 +3114,7 @@ void builtin_announce(ScriptState *st) /*========================================== * 天の声アナウンス(特定マップ) + * Voice of Heaven Announcement (Specific Map) *------------------------------------------ */ static @@ -2989,6 +3123,10 @@ void builtin_mapannounce_sub(dumb_ptr bl, XString str, int flag) clif_GMmessage(bl, str, flag | 3); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_mapannounce(ScriptState *st) { @@ -3008,6 +3146,7 @@ void builtin_mapannounce(ScriptState *st) /*========================================== * ユーザー数所得 + * User Revenue *------------------------------------------ */ static @@ -3030,6 +3169,7 @@ void builtin_getusers(ScriptState *st) /*========================================== * マップ指定ユーザー数所得 + * maps Designated User Income *------------------------------------------ */ static @@ -3040,6 +3180,10 @@ void builtin_getusers(ScriptState *st) (*users)++; } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getmapusers(ScriptState *st) { @@ -3058,6 +3202,10 @@ void builtin_getmapusers(ScriptState *st) push_int(st->stack, users); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_aggravate(ScriptState *st) { @@ -3075,6 +3223,7 @@ void builtin_aggravate(ScriptState *st) /*========================================== * エリア指定ユーザー数所得 + * Area Designated User Income *------------------------------------------ */ @@ -3087,6 +3236,10 @@ void builtin_getareausers_living_sub(dumb_ptr bl, int *users) (*users)++; } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getareausers(ScriptState *st) { @@ -3117,6 +3270,7 @@ void builtin_getareausers(ScriptState *st) /*========================================== * エリア指定ドロップアイテム数所得 + * Area Designated Drop Item Number Income *------------------------------------------ */ static @@ -3129,6 +3283,10 @@ void builtin_getareadropitem_sub(dumb_ptr bl, ItemNameId item, int * } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getareadropitem_sub_anddelete(dumb_ptr bl, ItemNameId item, int *amount) { @@ -3142,6 +3300,10 @@ void builtin_getareadropitem_sub_anddelete(dumb_ptr bl, ItemNameId i } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getareadropitem(ScriptState *st) { @@ -3196,6 +3358,7 @@ void builtin_getareadropitem(ScriptState *st) /*========================================== * NPCの有効化 + * Enabling NPCs *------------------------------------------ */ static @@ -3207,6 +3370,7 @@ void builtin_enablenpc(ScriptState *st) /*========================================== * NPCの無効化 + * Disabling NPCs *------------------------------------------ */ static @@ -3218,6 +3382,7 @@ void builtin_disablenpc(ScriptState *st) /*========================================== * 状態異常にかかる + * Suffering from an abnormal condition *------------------------------------------ */ static @@ -3237,7 +3402,7 @@ void builtin_sc_start(ScriptState *st) // all others used milliseconds tick *= 1000; val1 = conv_num(st, &AARG(2)); - if (HARG(3)) //指定したキャラを状態異常にする + if (HARG(3)) //指定したキャラを状態異常にする | Make the specified character abnormal bl = map_id2bl(wrap(conv_num(st, &AARG(3)))); else bl = map_id2bl(st->rid); @@ -3246,6 +3411,7 @@ void builtin_sc_start(ScriptState *st) /*========================================== * 状態異常が直る + * Abnormal condition is fixed *------------------------------------------ */ static @@ -3253,7 +3419,7 @@ void builtin_sc_end(ScriptState *st) { dumb_ptr bl; StatusChange type = StatusChange(conv_num(st, &AARG(0))); - if (HARG(1)) //指定したキャラを状態異常にする + if (HARG(1)) //指定したキャラを状態異常にする | Make the specified character abnormal bl = map_id2bl(wrap(conv_num(st, &AARG(1)))); else bl = map_id2bl(st->rid); @@ -3261,12 +3427,16 @@ void builtin_sc_end(ScriptState *st) skill_status_change_end(bl, type, nullptr); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_sc_check(ScriptState *st) { dumb_ptr bl; StatusChange type = StatusChange(conv_num(st, &AARG(0))); - if (HARG(1)) //指定したキャラを状態異常にする + if (HARG(1)) //指定したキャラを状態異常にする | Make the specified character abnormal bl = map_id2bl(wrap(conv_num(st, &AARG(1)))); else bl = map_id2bl(st->rid); @@ -3289,6 +3459,7 @@ void builtin_debugmes(ScriptState *st) /*========================================== * ステータスリセット + * Status Reset *------------------------------------------ */ static @@ -3302,6 +3473,7 @@ void builtin_resetstatus(ScriptState *st) /*========================================== * RIDのアタッチ + * Attach RID *------------------------------------------ */ static @@ -3313,6 +3485,7 @@ void builtin_attachrid(ScriptState *st) /*========================================== * RIDのデタッチ + * Detach RID *------------------------------------------ */ static @@ -3323,6 +3496,7 @@ void builtin_detachrid(ScriptState *st) /*========================================== * 存在チェック + * Existence check *------------------------------------------ */ static @@ -3332,6 +3506,10 @@ void builtin_isloggedin(ScriptState *st) map_id2sd(wrap(conv_num(st, &AARG(0)))) != nullptr); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_setmapflag(ScriptState *st) { @@ -3346,6 +3524,10 @@ void builtin_setmapflag(ScriptState *st) OMATCH_END (); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_removemapflag(ScriptState *st) { @@ -3360,6 +3542,10 @@ void builtin_removemapflag(ScriptState *st) OMATCH_END (); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getmapflag(ScriptState *st) { @@ -3378,6 +3564,10 @@ void builtin_getmapflag(ScriptState *st) push_int(st->stack, r); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_pvpon(ScriptState *st) { @@ -3412,6 +3602,10 @@ void builtin_pvpon(ScriptState *st) } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_pvpoff(ScriptState *st) { @@ -3442,6 +3636,10 @@ void builtin_pvpoff(ScriptState *st) } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_setpvpchannel(ScriptState *st) { @@ -3455,11 +3653,15 @@ void builtin_setpvpchannel(ScriptState *st) sd->state.pvpchannel = flag; } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getpvpflag(ScriptState *st) { dumb_ptr sd; - if (HARG(1)) //指定したキャラを状態異常にする + if (HARG(1)) //指定したキャラを状態異常にする | Make the specified character abnormal sd = map_id_is_player(wrap(conv_num(st, &AARG(1)))); else sd = script_rid2sd(st); @@ -3482,10 +3684,10 @@ void builtin_getpvpflag(ScriptState *st) } /*========================================== - * NPCエモーション + * NPCエモーション + * NPC Emotion *------------------------------------------ */ - static void builtin_emotion(ScriptState *st) { @@ -3507,6 +3709,10 @@ void builtin_emotion(ScriptState *st) clif_emotion(map_id2bl(st->oid), type); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_mapwarp(ScriptState *st) // Added by RoVeRT { @@ -3530,6 +3736,10 @@ void builtin_mapwarp(ScriptState *st) // Added by RoVeRT BL::PC); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_mobcount_sub(dumb_ptr bl, NpcEvent event, int *c) { @@ -3537,6 +3747,10 @@ void builtin_mobcount_sub(dumb_ptr bl, NpcEvent event, int *c) (*c)++; } +/*========================================== + * + *------------------------------------------ + */ static void builtin_mobcount(ScriptState *st) // Added by RoVeRT { @@ -3561,6 +3775,10 @@ void builtin_mobcount(ScriptState *st) // Added by RoVeRT } +/*========================================== + * + *------------------------------------------ + */ static void builtin_marriage(ScriptState *st) { @@ -3576,6 +3794,10 @@ void builtin_marriage(ScriptState *st) push_int(st->stack, 1); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_divorce(ScriptState *st) { @@ -3590,6 +3812,10 @@ void builtin_divorce(ScriptState *st) push_int(st->stack, 1); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getitemlink(ScriptState *st) { @@ -3614,6 +3840,10 @@ void builtin_getitemlink(ScriptState *st) push_str(st->stack, buf); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getpartnerid2(ScriptState *st) { @@ -3622,6 +3852,10 @@ void builtin_getpartnerid2(ScriptState *st) push_int(st->stack, unwrap(sd->status.partner_id)); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_chr(ScriptState *st) { @@ -3629,6 +3863,10 @@ void builtin_chr(ScriptState *st) push_str(st->stack, VString<1>(ascii)); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_ord(ScriptState *st) { @@ -3636,6 +3874,10 @@ void builtin_ord(ScriptState *st) push_int(st->stack, static_cast(ascii)); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_explode(ScriptState *st) { @@ -3701,6 +3943,7 @@ void builtin_explode(ScriptState *st) /*========================================== * PCの所持品情報読み取り + * Read personal belongings information on your PC *------------------------------------------ */ static @@ -3727,6 +3970,10 @@ void builtin_getinventorylist(ScriptState *st) pc_setreg(sd, SIR::from(variable_names.intern("@inventorylist_count"_s)), j); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getactivatedpoolskilllist(ScriptState *st) { @@ -3758,6 +4005,10 @@ void builtin_getactivatedpoolskilllist(ScriptState *st) } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getunactivatedpoolskilllist(ScriptState *st) { @@ -3787,6 +4038,10 @@ void builtin_getunactivatedpoolskilllist(ScriptState *st) pc_setreg(sd, SIR::from(variable_names.intern("@skilllist_count"_s)), count); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_poolskill(ScriptState *st) { @@ -3798,6 +4053,10 @@ void builtin_poolskill(ScriptState *st) } +/*========================================== + * + *------------------------------------------ + */ static void builtin_unpoolskill(ScriptState *st) { @@ -3811,6 +4070,7 @@ void builtin_unpoolskill(ScriptState *st) /*========================================== * NPCから発生するエフェクト + * Effects generated by NPCs * misceffect(effect, [target]) * * effect The effect type/ID. @@ -3883,6 +4143,10 @@ void builtin_specialeffect(ScriptState *st) } +/*========================================== + * + *------------------------------------------ + */ static void builtin_specialeffect2(ScriptState *st) { @@ -3897,6 +4161,10 @@ void builtin_specialeffect2(ScriptState *st) } +/*========================================== + * + *------------------------------------------ + */ static void builtin_get(ScriptState *st) { @@ -4033,7 +4301,6 @@ void builtin_get(ScriptState *st) * Nude [Valaris] *------------------------------------------ */ - static void builtin_nude(ScriptState *st) { @@ -4055,7 +4322,6 @@ void builtin_nude(ScriptState *st) * UnequipById [Freeyorp] *------------------------------------------ */ - static void builtin_unequipbyid(ScriptState *st) { @@ -4179,7 +4445,6 @@ void builtin_npcareawarp(ScriptState *st) * message [MouseJstr] *------------------------------------------ */ - static void builtin_message(ScriptState *st) { @@ -4193,6 +4458,10 @@ void builtin_message(ScriptState *st) } +/*========================================== + * + *------------------------------------------ + */ static void builtin_title(ScriptState *st) { @@ -4202,6 +4471,10 @@ void builtin_title(ScriptState *st) clif_npc_send_title(sd->sess, st->oid, msg); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_smsg(ScriptState *st) { @@ -4222,6 +4495,10 @@ void builtin_smsg(ScriptState *st) clif_server_message(sd, type, msg); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_remotecmd(ScriptState *st) { @@ -4240,6 +4517,10 @@ void builtin_remotecmd(ScriptState *st) clif_remote_command(sd, msg); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_sendcollision(ScriptState *st) { @@ -4273,6 +4554,10 @@ void builtin_sendcollision(ScriptState *st) clif_update_collision(sd, x1, y1, x2, y2, map_name, mask); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_music(ScriptState *st) { @@ -4282,6 +4567,10 @@ void builtin_music(ScriptState *st) clif_change_music(sd, msg); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_mapmask(ScriptState *st) { @@ -4303,6 +4592,10 @@ void builtin_mapmask(ScriptState *st) clif_send_mask(sd, map_mask); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_getmask(ScriptState *st) { @@ -4330,7 +4623,6 @@ void builtin_getmask(ScriptState *st) * area) [Valaris] *------------------------------------------ */ - static void builtin_npctalk(ScriptState *st) { @@ -4355,9 +4647,9 @@ void builtin_npctalk(ScriptState *st) } /*========================================== - * register cmd - *------------------------------------------ - */ + * register cmd + *------------------------------------------ + */ static void builtin_registercmd(ScriptState *st) { @@ -4369,9 +4661,9 @@ void builtin_registercmd(ScriptState *st) } /*========================================== - * getlook char info. getlook(arg) - *------------------------------------------ - */ + * getlook char info. getlook(arg) + *------------------------------------------ + */ static void builtin_getlook(ScriptState *st) { @@ -4414,9 +4706,9 @@ void builtin_getlook(ScriptState *st) } /*========================================== - * get char save point. argument: 0- map name, 1- x, 2- y - *------------------------------------------ -*/ + * get char save point. argument: 0- map name, 1- x, 2- y + *------------------------------------------ + */ static void builtin_getsavepoint(ScriptState *st) { @@ -4446,7 +4738,7 @@ void builtin_getsavepoint(ScriptState *st) } /*========================================== - * areatimer + * areatimer *------------------------------------------ */ static @@ -4461,6 +4753,10 @@ void builtin_areatimer_sub(dumb_ptr bl, interval_t tick, NpcEvent ev } } +/*========================================== + * + *------------------------------------------ + */ static void builtin_areatimer(ScriptState *st) { @@ -4538,7 +4834,10 @@ void builtin_iscollision(ScriptState *st) bool(map_getcell(m, x, y) & MapCell::UNWALKABLE)); } -// Trigger the shop on a (hopefully) nearby shop NPC +/*========================================== + * Trigger the shop on a (hopefully) nearby shop NPC + *------------------------------------------ + */ static void builtin_shop(ScriptState *st) { @@ -4625,15 +4924,16 @@ void builtin_getdir(ScriptState *st) push_int(st->stack, static_cast(sd->dir)); } -/* +/*========================================== * Get the PC's current map's name + *------------------------------------------ */ static void builtin_getmap(ScriptState *st) { dumb_ptr sd; - if (HARG(0)) //指定したキャラを状態異常にする + if (HARG(0)) //指定したキャラを状態異常にする | Make the specified character abnormal sd = map_id_is_player(wrap(conv_num(st, &AARG(0)))); else sd = script_rid2sd(st); @@ -4646,8 +4946,9 @@ void builtin_getmap(ScriptState *st) push_str(st->stack, sd->bl_m->name_); } -/* +/*========================================== * Get the NPC's info + *------------------------------------------ */ static void builtin_strnpcinfo(ScriptState *st) @@ -4739,6 +5040,10 @@ void builtin_getnpcy(ScriptState *st) push_int(st->stack, nd->bl_y); } +/*========================================== + * + *------------------------------------------ + */ static void builtin_mapexit(ScriptState *) { diff --git a/src/map/script-parse.cpp b/src/map/script-parse.cpp index f8d7b6b..25177dd 100644 --- a/src/map/script-parse.cpp +++ b/src/map/script-parse.cpp @@ -142,6 +142,7 @@ Borrowed add_strp(XString p) /*========================================== * スクリプトバッファに1バイト書き込む + * Write 1 byte to script buffer *------------------------------------------ */ void ScriptBuffer::add_scriptc(ByteCode a) @@ -151,6 +152,7 @@ void ScriptBuffer::add_scriptc(ByteCode a) /*========================================== * スクリプトバッファにデータタイプを書き込む + * Write the data type to the script buffer *------------------------------------------ */ void ScriptBuffer::add_scriptb(uint8_t a) @@ -160,6 +162,7 @@ void ScriptBuffer::add_scriptb(uint8_t a) /*========================================== * スクリプトバッファに整数を書き込む + * Writing an integer to the script buffer *------------------------------------------ */ void ScriptBuffer::add_scripti(uint32_t a) @@ -174,6 +177,7 @@ void ScriptBuffer::add_scripti(uint32_t a) /*========================================== * スクリプトバッファにラベル/変数/関数を書き込む + * Write labels/variables/functions to script buffer *------------------------------------------ */ // 最大16Mまで @@ -219,6 +223,7 @@ void ScriptBuffer::add_scriptl(P ld) /*========================================== * ラベルを解決する + * Resolving labels *------------------------------------------ */ void ScriptBuffer::set_label(Borrowed ld, int pos_) @@ -243,6 +248,7 @@ void ScriptBuffer::set_label(Borrowed ld, int pos_) /*========================================== * スペース/コメント読み飛ばし + * Space/Comment Skipping *------------------------------------------ */ static @@ -273,6 +279,7 @@ ZString::iterator skip_space(ZString::iterator p) /*========================================== * 1単語スキップ + * 1 word skip *------------------------------------------ */ static @@ -280,30 +287,31 @@ ZString::iterator skip_word(ZString::iterator p) { // prefix if (*p == '$') - p++; // MAP鯖内共有変数用 + p++; // MAP鯖内共有変数用 | For shared variables in MAP server if (*p == '@') - p++; // 一時的変数用(like weiss) + p++; // 一時的変数用(like weiss) | For temporary variables if (*p == '.') p++; // npc if (*p == '@') p++; // scope if (*p == '#') - p++; // account変数用 + p++; // account変数用 | For account variable if (*p == '#') - p++; // ワールドaccount変数用 + p++; // ワールドaccount変数用 | For World Account variables while (isalnum(*p) || *p == '_') p++; // postfix if (*p == '$') - p++; // 文字列変数 + p++; // 文字列変数 | String variables return p; } /*========================================== * エラーメッセージ出力 + * Error message output *------------------------------------------ */ static @@ -339,6 +347,7 @@ void disp_error_message(ZString mes, ZString::iterator pos_) /*========================================== * 項の解析 + * Analyzing Terms *------------------------------------------ */ ZString::iterator ScriptBuffer::parse_simpleexpr(ZString::iterator p) @@ -442,6 +451,7 @@ ZString::iterator ScriptBuffer::parse_simpleexpr(ZString::iterator p) /*========================================== * 式の解析 + * Analyzing Expressions *------------------------------------------ */ ZString::iterator ScriptBuffer::parse_subexpr(ZString::iterator p, int limit) @@ -566,6 +576,7 @@ ZString::iterator ScriptBuffer::parse_subexpr(ZString::iterator p, int limit) /*========================================== * 式の評価 + * Evaluating Expressions *------------------------------------------ */ ZString::iterator ScriptBuffer::parse_expr(ZString::iterator p) @@ -587,6 +598,7 @@ ZString::iterator ScriptBuffer::parse_expr(ZString::iterator p) /*========================================== * 行の解析 + * Parsing Rows *------------------------------------------ */ ZString::iterator ScriptBuffer::parse_line(ZString::iterator p, bool *can_step) @@ -602,9 +614,9 @@ ZString::iterator ScriptBuffer::parse_line(ZString::iterator p, bool *can_step) return p; } - parse_cmd_if = 0; // warn_cmd_no_commaのために必要 + parse_cmd_if = 0; // warn_cmd_no_commaのために必要 | Needed for warn_cmd_no_comma - // 最初は関数名 + // 最初は関数名 | Initially, the function name ZString::iterator p2 = p; p = parse_simpleexpr(p); p = skip_space(p); @@ -640,7 +652,7 @@ ZString::iterator ScriptBuffer::parse_line(ZString::iterator p, bool *can_step) p = parse_expr(p); p = skip_space(p); - // 引数区切りの,処理 + // 引数区切りの,処理 | Argument-delimited,processing if (*p == ',') p++; else if (*p != ';' && script_config.warn_cmd_no_comma @@ -689,6 +701,7 @@ ZString::iterator ScriptBuffer::parse_line(ZString::iterator p, bool *can_step) /*========================================== * 組み込み関数の追加 + * Adding built-in functions *------------------------------------------ */ static @@ -711,6 +724,7 @@ std::unique_ptr compile_script(RString debug_name, const ast /*========================================== * スクリプトの解析 + * Parsing Scripts *------------------------------------------ */ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) @@ -736,7 +750,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) } } - // 外部用label dbの初期化 + // 外部用label dbの初期化 | Initializing an external label db scriptlabel_db.clear(); // for error message @@ -786,7 +800,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) { disp_error_message("error: unreachable statement"_s, p); } - // 他は全部一緒くた + // 他は全部一緒くた | Everything else is crap together p = parse_line(p, &can_step); p = skip_space(p); add_scriptc(ByteCode::EOL); diff --git a/tools/protocol.py b/tools/protocol.py index df6e2fb..7419639 100755 --- a/tools/protocol.py +++ b/tools/protocol.py @@ -6837,7 +6837,107 @@ def build_context(): Reload GM file request. ''', ) - + login_admin.r(0x7956, 'get all account reg2', + fixed=[ + at(0, u16, 'packet id'), + at(2, account_id, 'account id'), + ], + fixed_size=6, + pre=[ADMIN], + post=[0x7957], + desc=''' + Request all login-stored ##registers of an account. + ''', + ) + login_admin.s(0x7957, 'get all account reg2 result', + head=[ + at(0, u16, 'packet id'), + at(2, u16, 'packet length'), + at(4, account_id, 'account id'), + ], + head_size=8, + repeat=[ + at(0, var_name, 'name'), + at(32, u32, 'value'), + ], + repeat_size=36, + pre=[0x7956], + post=[IDLE], + desc=''' + Recive all login-stored ##registers of an account. + ''', + ) + login_admin.r(0x7958, 'get account reg2', + fixed=[ + at(0, u16, 'packet id'), + at(2, account_id, 'account id'), + at(6, var_name, 'name'), + ], + fixed_size=38, + pre=[ADMIN], + post=[0x7959], + desc=''' + Request a login-stored ##register of an account. + ''', + ) + login_admin.s(0x7959, 'get account reg2 result', + fixed=[ + at(0, u16, 'packet id'), + at(2, account_id, 'account id'), + at(6, var_name, 'name'), + at(38, u32, 'value'), + ], + fixed_size=42, + pre=[0x7958], + post=[IDLE], + desc=''' + Recive a login-stored ##register of an account. + ''', + ) + login_admin.r(0x795a, 'set account reg2', + fixed=[ + at(0, u16, 'packet id'), + at(2, account_id, 'account id'), + at(6, var_name, 'name'), + at(38, u32, 'value'), + ], + fixed_size=42, + pre=[ADMIN], + post=[0x795b], + desc=''' + Modify a login-stored ##register of an account. + ''', + ) + login_admin.s(0x795b, 'set/del account reg2 result', + fixed=[ + at(0, u16, 'packet id'), + at(2, account_id, 'account id'), + at(6, u8, 'operation'), + at(7, u8, 'result'), + ], + fixed_size=8, + pre=[0x795a, 0x795c], + post=[IDLE], + desc=''' + Modify/Delete login-stored ##register of an account result. + operation: 0=set 1=del + result: 0=success 1=(set) new var created/(del) err var to delete not found 2=(set) err max vars reached + ''', + ) + login_admin.r(0x795c, 'del account reg2', + fixed=[ + at(0, u16, 'packet id'), + at(2, account_id, 'account id'), + at(6, var_name, 'name'), + ], + fixed_size=38, + pre=[ADMIN], + post=[0x795b], + desc=''' + delete a login-stored ##register of an account. + ''', + ) + # TOC_NEW ## new-style packets # notify packets, standalone, can occur at any time; always 'payload' -- cgit v1.2.3-60-g2f50