diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.cpp | 34 | ||||
-rw-r--r-- | src/map/chrif.cpp | 5 | ||||
-rw-r--r-- | src/map/clif.cpp | 6 | ||||
-rw-r--r-- | src/map/pc.cpp | 35 |
4 files changed, 58 insertions, 22 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 123a723..f50cddf 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -2348,12 +2348,36 @@ ATCE atcommand_char_change_sex(Session *s, dumb_ptr<map_session_data> sd, ZString message) { CharName character; + VString<1> gender; + int operation; - if (!asplit(message, &character)) + if (!extract(message, record<' ', 1>(&character, &gender))) + { + clif_displaymessage(s, + "Please, enter a char name (usage: @charchangesex <char name> [Gender])."_s); return ATCE::USAGE; - + } + else { - chrif_char_ask_name(sd->status_key.account_id, character, 5, HumanTimeDiff()); + if (sex_from_char(gender.front()) == SEX::FEMALE) + { + operation = 5; + } + else if (sex_from_char(gender.front()) == SEX::MALE) + { + operation = 6; + } + else if (sex_from_char(gender.front()) == SEX::NEUTRAL) + { + operation = 7; + } + else + { + clif_displaymessage(s, + "Please, enter a char name (usage: @charchangesex <char name> [Gender])."_s); + return ATCE::USAGE; + } + chrif_char_ask_name(sd->status_key.account_id, character, operation, HumanTimeDiff()); // type: 5 - changesex clif_displaymessage(s, "Character name sends to char-server to ask it."_s); } @@ -5215,9 +5239,9 @@ Map<XString, AtCommandInfo> atcommand_info = {"allstats"_s, {"[value]"_s, 60, atcommand_all_stats, "Adjust all stats by value (or maximum)"_s}}, - {"charchangesex"_s, {"<charname>"_s, + {"charchangesex"_s, {"<charname> <sex>"_s, 60, atcommand_char_change_sex, - "Flip a characters sex and disconnect them"_s}}, + "Change a characters sex and disconnect them"_s}}, {"block"_s, {"<charname>"_s, 60, atcommand_char_block, "Permanently block a player's account from the server"_s}}, diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index ce5669e..7421344 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -554,10 +554,7 @@ void chrif_changedsex(Session *, const Packet_Fixed<0x2b0d>& fixed) { if (sd != nullptr && sd->status.sex != sex) { - if (sd->status.sex == SEX::MALE) - sd->sex = sd->status.sex = SEX::FEMALE; - else if (sd->status.sex == SEX::FEMALE) - sd->sex = sd->status.sex = SEX::MALE; + sd->sex = sd->status.sex = sex; // to avoid any problem with equipment and invalid sex, equipment is unequiped. for (IOff0 i : IOff0::iter()) { diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 64e9939..9743e49 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -659,7 +659,7 @@ void clif_set0078_main_1d8(dumb_ptr<map_session_data> sd, Buffer& buf) fixed_1d8.manner = sd->status.manner; fixed_1d8.opt3 = sd->opt3; fixed_1d8.karma = sd->status.karma; - fixed_1d8.sex = sd->sex; + fixed_1d8.sex = sd->status.sex; fixed_1d8.pos.x = sd->bl_x; fixed_1d8.pos.y = sd->bl_y; fixed_1d8.pos.dir = sd->dir; @@ -713,7 +713,7 @@ void clif_set0078_alt_1d9(dumb_ptr<map_session_data> sd, Buffer& buf) fixed_1d8.manner = sd->status.manner; fixed_1d8.opt3 = sd->opt3; fixed_1d8.karma = sd->status.karma; - fixed_1d8.sex = sd->sex; + fixed_1d8.sex = sd->status.sex; fixed_1d8.pos.x = sd->bl_x; fixed_1d8.pos.y = sd->bl_y; fixed_1d8.pos.dir = sd->dir; @@ -766,7 +766,7 @@ void clif_set007b(dumb_ptr<map_session_data> sd, Buffer& buf) fixed_1da.manner = sd->status.manner; fixed_1da.opt3 = sd->opt3; fixed_1da.karma = sd->status.karma; - fixed_1da.sex = sd->sex; + fixed_1da.sex = sd->status.sex; fixed_1da.pos2.x0 = sd->bl_x; fixed_1da.pos2.y0 = sd->bl_y; fixed_1da.pos2.x1 = sd->to_x; diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 254ecb5..cb115c3 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -627,7 +627,7 @@ int pc_isequip(dumb_ptr<map_session_data> sd, IOff0 n) return 1; P<struct item_data> item = TRY_UNWRAP(sd->inventory_data[n], return 0); - if (item->sex != SEX::NEUTRAL && sd->status.sex != item->sex) + if (item->sex != SEX::UNSPECIFIED && sd->status.sex != item->sex) return 0; if (item->elv > 0 && sd->status.base_level < item->elv) return 0; @@ -657,12 +657,6 @@ int pc_authok(AccountId id, int login_id2, sd->status_key = *st_key; sd->status = *st_data; - if (sd->status.sex != sd->sex) - { - clif_authfail_fd(sd->sess, 0); - return 1; - } - MAP_LOG_STATS(sd, "LOGIN"_fmt); MAP_LOG_XP(sd, "LOGIN"_fmt); MAP_LOG_MAGIC(sd, "LOGIN"_fmt); @@ -2129,7 +2123,7 @@ int pc_isUseitem(dumb_ptr<map_session_data> sd, IOff0 n) if (itemdb_type(nameid) != ItemType::USE) return 0; - if (item->sex != SEX::NEUTRAL && sd->status.sex != item->sex) + if (item->sex != SEX::UNSPECIFIED && sd->status.sex != item->sex) return 0; if (item->elv > 0 && sd->status.base_level < item->elv) return 0; @@ -3361,7 +3355,7 @@ int pc_readparam(dumb_ptr<map_session_data> sd, SP type) val = unwrap<Species>(sd->status.species); break; case SP::SEX: - val = static_cast<uint8_t>(sd->sex); + val = static_cast<uint8_t>(sd->status.sex); break; case SP::WEIGHT: val = sd->weight; @@ -3493,7 +3487,28 @@ int pc_setparam(dumb_ptr<map_session_data> sd, SP type, int val) } break; case SP::SEX: - chrif_char_ask_name(AccountId(), sd->status_key.name, 5, HumanTimeDiff()); + switch (val) + { + case 0: + sd->sex = sd->status.sex = SEX::FEMALE; + break; + case 1: + sd->sex = sd->status.sex = SEX::MALE; + break; + default: + sd->sex = sd->status.sex = SEX::NEUTRAL; + break; + } + for (IOff0 j : IOff0::iter()) + { + if (sd->status.inventory[j].nameid + && bool(sd->status.inventory[j].equip) + && !pc_isequip(sd, j)) + pc_unequipitem(sd, j, CalcStatus::LATER); + } + pc_calcstatus(sd, 0); + chrif_save(sd); + clif_fixpcpos(sd); break; case SP::WEIGHT: sd->weight = val; |