diff options
author | wushin <pasekei@gmail.com> | 2015-11-09 13:46:56 -0600 |
---|---|---|
committer | wushin <pasekei@gmail.com> | 2016-02-08 18:53:15 -0600 |
commit | f593049cd8286f48497782d8bc0afe787724ad5d (patch) | |
tree | 371402a86444ce9104227d638192fa4a305dd48f /src/map | |
parent | f81bcc78fb1aa5475bbe54907ff82199fc031521 (diff) | |
download | tmwa-f593049cd8286f48497782d8bc0afe787724ad5d.tar.gz tmwa-f593049cd8286f48497782d8bc0afe787724ad5d.tar.bz2 tmwa-f593049cd8286f48497782d8bc0afe787724ad5d.tar.xz tmwa-f593049cd8286f48497782d8bc0afe787724ad5d.zip |
Add third gender to account
Add Gender to char
Make gear work proper with new gender
Enable legacy clients to use account gender
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/pc.cpp | 32 |
3 files changed, 59 insertions, 12 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 4dd80bb..11ca1a3 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/pc.cpp b/src/map/pc.cpp index 254ecb5..8a5127d 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; @@ -2129,7 +2129,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; @@ -3493,7 +3493,33 @@ 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()); + int operation; + switch (val) + { + case 0: + sd->sex = sd->status.sex = SEX::FEMALE; + operation = 5; + break; + case 1: + sd->sex = sd->status.sex = SEX::MALE; + operation = 6; + break; + default: + sd->sex = sd->status.sex = SEX::NEUTRAL; + operation = 7; + break; + } + for (IOff0 j : IOff0::iter()) + { + if (sd->status.inventory[j].nameid + && bool(sd->status.inventory[j].equip)) + pc_unequipitem(sd, j, CalcStatus::LATER); + } + pc_calcstatus(sd, 0); + chrif_save(sd); + sd->login_id1++; + clif_fixpcpos(sd); + chrif_char_ask_name(AccountId(), sd->status_key.name, operation, HumanTimeDiff()); break; case SP::WEIGHT: sd->weight = val; |