From f593049cd8286f48497782d8bc0afe787724ad5d Mon Sep 17 00:00:00 2001 From: wushin Date: Mon, 9 Nov 2015 13:46:56 -0600 Subject: Add third gender to account Add Gender to char Make gear work proper with new gender Enable legacy clients to use account gender --- src/login/login.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/login/login.cpp') diff --git a/src/login/login.cpp b/src/login/login.cpp index 9310ad3..4ab0773 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -441,8 +441,6 @@ bool impl_extract(XString line, AuthData *ad) if (sex.size() != 1) return false; ad->sex = sex_from_char(sex.front()); - if (ad->sex == SEX::NEUTRAL) - return false; if (!e_mail_check(ad->email)) ad->email = DEFAULT_EMAIL; @@ -1181,7 +1179,7 @@ void parse_fromchar(Session *s) case 0x2727: // Change of sex (sex is reversed) { Packet_Fixed<0x2727> fixed; - rv = recv_fpacket<0x2727, 6>(s, fixed); + rv = recv_fpacket<0x2727, 7>(s, fixed); if (rv != RecvResult::Complete) break; @@ -1192,11 +1190,7 @@ void parse_fromchar(Session *s) if (ad.account_id == acc) { { - SEX sex; - if (ad.sex == SEX::FEMALE) - sex = SEX::MALE; - else - sex = SEX::FEMALE; + SEX sex = fixed.sex; LOGIN_LOG("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n"_fmt, server[id].name, acc, sex_to_char(sex), @@ -1504,7 +1498,7 @@ void parse_admin(Session *s) LOGIN_LOG("'ladmin': Attempt to create an invalid account (account or pass is too short, ip: %s)\n"_fmt, ip); } - else if (ma.sex != SEX::FEMALE && ma.sex != SEX::MALE) + else if (ma.sex != SEX::FEMALE && ma.sex != SEX::MALE && ma.sex != SEX::NEUTRAL) { LOGIN_LOG("'ladmin': Attempt to create an invalid account (account: %s, invalid sex, ip: %s)\n"_fmt, ma.userid, ip); @@ -1765,7 +1759,7 @@ void parse_admin(Session *s) { SEX sex = fixed.sex; - if (sex != SEX::FEMALE && sex != SEX::MALE) + if (sex != SEX::FEMALE && sex != SEX::MALE && sex != SEX::NEUTRAL) { LOGIN_LOG("'ladmin': Attempt to give an invalid sex (account: %s, received sex: %c, ip: %s)\n"_fmt, account_name, sex_to_char(sex), ip); -- cgit v1.2.3-70-g09d2 From 8f33fc6192655ab7a4453a54616c911b19a8ded3 Mon Sep 17 00:00:00 2001 From: wushin Date: Sun, 31 Jan 2016 21:27:30 -0600 Subject: Don't override char gender sd->sex is fluid, only trust sd->status.sex to be static --- src/char/char.cpp | 1 - src/login/login.cpp | 1 - src/map/pc.cpp | 6 ------ 3 files changed, 8 deletions(-) (limited to 'src/login/login.cpp') diff --git a/src/char/char.cpp b/src/char/char.cpp index bc759d0..5effd32 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -1689,7 +1689,6 @@ void parse_frommap(Session *ms) Packet_Payload<0x2afd> payload_fd; // not file descriptor payload_fd.account_id = account_id; payload_fd.login_id2 = afi.login_id2; - cd->sex = afi.sex; payload_fd.packet_client_version = afi.packet_client_version; FPRINTF(stderr, "From queue index %zd: recalling packet version %d\n"_fmt, diff --git a/src/login/login.cpp b/src/login/login.cpp index 4ab0773..a1c6650 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -879,7 +879,6 @@ void parse_fromchar(Session *s) if (auth_fifo[i].account_id == acc && auth_fifo[i].login_id1 == fixed.login_id1 && auth_fifo[i].login_id2 == fixed.login_id2 && // relate to the versions higher than 18 - auth_fifo[i].sex == fixed.sex && auth_fifo[i].ip == fixed.ip && !auth_fifo[i].delflag) { diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 59fbba6..389f6b5 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -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); -- cgit v1.2.3-70-g09d2 From f889e025cc403ceb6f6276d66fdc367f544a0e82 Mon Sep 17 00:00:00 2001 From: mekolat Date: Sun, 31 Jan 2016 23:39:10 -0500 Subject: do not force logout after sex change remove sex change roundtrip only unequip on gender incompatibility --- src/char/char.cpp | 32 -------------------------------- src/login/login.cpp | 46 ---------------------------------------------- src/map/pc.cpp | 9 ++------- 3 files changed, 2 insertions(+), 85 deletions(-) (limited to 'src/login/login.cpp') diff --git a/src/char/char.cpp b/src/char/char.cpp index 5effd32..1dc0e90 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -1977,38 +1977,6 @@ void parse_frommap(Session *ms) fixed_0f.error = 2; break; } - case 5: // changesex - case 6: // changesex - case 7: // changesex - { - if (!acc - || isGM(acc).overwhelms(isGM(ck->account_id))) - { - if (login_session) - { // don't send request if no login-server - Packet_Fixed<0x2727> fixed_27; - fixed_27.account_id = ck->account_id; - switch (operation) - { - case 5: - fixed_27.sex = SEX::FEMALE; - break; - case 6: - fixed_27.sex = SEX::MALE; - break; - case 7: - fixed_27.sex = SEX::NEUTRAL; - break; - } - send_fpacket<0x2727, 7>(login_session, fixed_27); - } - else - fixed_0f.error = 3; - } - else - fixed_0f.error = 2; - break; - } } } else diff --git a/src/login/login.cpp b/src/login/login.cpp index a1c6650..c071429 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -1175,52 +1175,6 @@ void parse_fromchar(Session *s) break; } - case 0x2727: // Change of sex (sex is reversed) - { - Packet_Fixed<0x2727> fixed; - rv = recv_fpacket<0x2727, 7>(s, fixed); - if (rv != RecvResult::Complete) - break; - - { - AccountId acc = fixed.account_id; - for (AuthData& ad : auth_data) - { - if (ad.account_id == acc) - { - { - SEX sex = fixed.sex; - LOGIN_LOG("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n"_fmt, - server[id].name, acc, - sex_to_char(sex), - ip); - for (int j = 0; j < AUTH_FIFO_SIZE; j++) - { - if (auth_fifo[j].account_id == acc) - auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification) - } - ad.sex = sex; - - Packet_Fixed<0x2723> fixed_23; - fixed_23.account_id = acc; - fixed_23.sex = sex; - - for (Session *ss : iter_char_sessions()) - { - send_fpacket<0x2723, 7>(ss, fixed_23); - } - } - goto x2727_out; - } - } - LOGIN_LOG("Char-server '%s': Error of sex change (account: %d not found, sex would be reversed, ip: %s).\n"_fmt, - server[id].name, acc, ip); - x2727_out: - ; - } - break; - } - case 0x2728: // We receive account_reg2 from a char-server, and we send them to other char-servers. { Packet_Head<0x2728> head; diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 389f6b5..cb115c3 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -3487,33 +3487,28 @@ int pc_setparam(dumb_ptr sd, SP type, int val) } break; case SP::SEX: - 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)) + && bool(sd->status.inventory[j].equip) + && !pc_isequip(sd, j)) 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; -- cgit v1.2.3-70-g09d2