summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-10-05 22:15:20 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-10-10 14:37:49 -0700
commita44741c83773989430f5e3ac4a8a83c93b1341ff (patch)
treef235bfd95ae17d597fda2fedc1ea561358edf23a
parente591d5b6d891516476aaf12808f4d3b3506e5f92 (diff)
downloadtmwa-a44741c83773989430f5e3ac4a8a83c93b1341ff.tar.gz
tmwa-a44741c83773989430f5e3ac4a8a83c93b1341ff.tar.bz2
tmwa-a44741c83773989430f5e3ac4a8a83c93b1341ff.tar.xz
tmwa-a44741c83773989430f5e3ac4a8a83c93b1341ff.zip
Enumify sex
It's amazing some of this code ever worked ...
-rw-r--r--src/char/char.cpp15
-rw-r--r--src/common/mmo.hpp33
-rw-r--r--src/login/login.cpp89
-rw-r--r--src/map/chrif.cpp11
-rw-r--r--src/map/clif.cpp10
-rw-r--r--src/map/itemdb.cpp2
-rw-r--r--src/map/itemdb.hpp2
-rw-r--r--src/map/map.hpp3
-rw-r--r--src/map/mob.cpp6
-rw-r--r--src/map/mob.hpp2
-rw-r--r--src/map/pc.cpp11
-rw-r--r--src/map/pc.hpp2
-rw-r--r--src/map/script.cpp12
13 files changed, 109 insertions, 89 deletions
diff --git a/src/char/char.cpp b/src/char/char.cpp
index c0dea4a..170e91a 100644
--- a/src/char/char.cpp
+++ b/src/char/char.cpp
@@ -90,7 +90,8 @@ std::bitset<256> char_name_letters; // list of letters/symbols authorised (or n
struct char_session_data : SessionData
{
- int account_id, login_id1, login_id2, sex;
+ int account_id, login_id1, login_id2;
+ SEX sex;
unsigned short packet_tmw_version;
AccountEmail email;
TimeT connect_until_time;
@@ -108,7 +109,7 @@ struct AuthFifoEntry
int login_id1, login_id2;
IP4Address ip;
int delflag;
- int sex;
+ SEX sex;
unsigned short packet_tmw_version;
TimeT connect_until_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
};
@@ -1210,7 +1211,7 @@ void parse_tologin(int fd)
{
unsigned char buf[7];
int acc = RFIFOL(fd, 2);
- int sex = RFIFOB(fd, 6);
+ SEX sex = static_cast<SEX>(RFIFOB(fd, 6));
RFIFOSKIP(fd, 7);
if (acc > 0)
{
@@ -1239,7 +1240,7 @@ void parse_tologin(int fd)
}
WBUFW(buf, 0) = 0x2b0d;
WBUFL(buf, 2) = acc;
- WBUFB(buf, 6) = sex;
+ WBUFB(buf, 6) = static_cast<uint8_t>(sex);
mapif_sendall(buf, 7);
}
break;
@@ -1759,7 +1760,7 @@ void parse_frommap(int fd)
auth_fifo_iter->login_id1 = RFIFOL(fd, 6);
auth_fifo_iter->login_id2 = RFIFOL(fd, 10);
auth_fifo_iter->delflag = 0;
- auth_fifo_iter->sex = RFIFOB(fd, 44);
+ auth_fifo_iter->sex = static_cast<SEX>(RFIFOB(fd, 44));
auth_fifo_iter->connect_until_time = TimeT(); // unlimited/unknown time by default (not display in map-server)
auth_fifo_iter->ip = RFIFOIP(fd, 45);
@@ -2173,7 +2174,7 @@ void parse_char(int fd)
sd->login_id1 = RFIFOL(fd, 6);
sd->login_id2 = RFIFOL(fd, 10);
sd->packet_tmw_version = RFIFOW(fd, 14);
- sd->sex = RFIFOB(fd, 16);
+ sd->sex = static_cast<SEX>(RFIFOB(fd, 16));
// send back account_id
WFIFOL(fd, 0) = account_id;
WFIFOSET(fd, 4);
@@ -2223,7 +2224,7 @@ void parse_char(int fd)
WFIFOL(login_fd, 2) = sd->account_id;
WFIFOL(login_fd, 6) = sd->login_id1;
WFIFOL(login_fd, 10) = sd->login_id2; // relate to the versions higher than 18
- WFIFOB(login_fd, 14) = sd->sex;
+ WFIFOB(login_fd, 14) = static_cast<uint8_t>(sd->sex);
WFIFOIP(login_fd, 15) = session[fd]->client_ip;
WFIFOSET(login_fd, 19);
}
diff --git a/src/common/mmo.hpp b/src/common/mmo.hpp
index 0e1a7d0..6dff03a 100644
--- a/src/common/mmo.hpp
+++ b/src/common/mmo.hpp
@@ -267,6 +267,36 @@ enum class ItemLook : uint16_t
DUAL_26 = 0x16,
};
+enum class SEX : uint8_t
+{
+ FEMALE = 0,
+ MALE = 1,
+ SERVER = 2,
+ ERROR,
+};
+inline
+char sex_to_char(SEX sex)
+{
+ switch (sex)
+ {
+ case SEX::FEMALE: return 'F';
+ case SEX::MALE: return 'M';
+ case SEX::SERVER: return 'S';
+ default: return '\0';
+ }
+}
+inline
+SEX sex_from_char(char c)
+{
+ switch (c)
+ {
+ case 'F': return SEX::FEMALE;
+ case 'M': return SEX::MALE;
+ case 'S': return SEX::SERVER;
+ default: return SEX::ERROR;
+ }
+}
+
struct mmo_charstatus
{
int char_id;
@@ -290,7 +320,8 @@ struct mmo_charstatus
CharName name;
unsigned char base_level, job_level;
earray<short, ATTR, ATTR::COUNT> attrs;
- unsigned char char_num, sex;
+ unsigned char char_num;
+ SEX sex;
unsigned long mapip;
unsigned int mapport;
diff --git a/src/login/login.cpp b/src/login/login.cpp
index c70c8d3..3a76c00 100644
--- a/src/login/login.cpp
+++ b/src/login/login.cpp
@@ -57,7 +57,7 @@ struct mmo_account
long login_id2;
long char_id;
timestamp_milliseconds_buffer lastlogin;
- int sex;
+ SEX sex;
};
struct mmo_char_server
@@ -156,14 +156,16 @@ struct
{
int account_id, login_id1, login_id2;
IP4Address ip;
- int sex, delflag;
+ SEX sex;
+ int delflag;
} auth_fifo[AUTH_FIFO_SIZE];
static
int auth_fifo_pos = 0;
struct AuthData
{
- int account_id, sex;
+ int account_id;
+ SEX sex;
AccountName userid;
AccountCrypt pass;
timestamp_milliseconds_buffer lastlogin;
@@ -432,7 +434,7 @@ FString mmo_auth_tostr(const AuthData *p)
p->userid,
p->pass,
p->lastlogin,
- (p->sex == 2) ? 'S' : (p->sex ? 'M' : 'F'),
+ sex_to_char(p->sex),
p->logincount,
p->state,
p->email,
@@ -504,13 +506,9 @@ bool extract(XString line, AuthData *ad)
if (sex.size() != 1)
return false;
- switch (sex.front())
- {
- case 'S': case 's': ad->sex = 2; break;
- case 'M': case 'm': ad->sex = 1; break;
- case 'F': case 'f': ad->sex = 0; break;
- default: return false;
- }
+ ad->sex = sex_from_char(sex.front());
+ if (ad->sex == SEX::ERROR)
+ return false;
if (!e_mail_check(ad->email))
ad->email = DEFAULT_EMAIL;
@@ -571,7 +569,7 @@ int mmo_auth_init(void)
if (isGM(ad.account_id) > 0)
GM_count++;
- if (ad.sex == 2)
+ if (ad.sex == SEX::SERVER)
server_count++;
if (ad.account_id >= account_id_count)
@@ -733,7 +731,7 @@ void check_GM_file(TimerData *, tick_t)
// Account creation (with e-mail check)
//-------------------------------------
static
-int mmo_auth_new(struct mmo_account *account, char sex, AccountEmail email)
+int mmo_auth_new(struct mmo_account *account, SEX sex, AccountEmail email)
{
while (isGM(account_id_count) > 0)
account_id_count++;
@@ -744,7 +742,7 @@ int mmo_auth_new(struct mmo_account *account, char sex, AccountEmail email)
ad.userid = account->userid;
ad.pass = MD5_saltcrypt(account->passwd, make_salt());
ad.lastlogin = stringish<timestamp_milliseconds_buffer>("-");
- ad.sex = (sex == 'M');
+ ad.sex = sex;
ad.logincount = 0;
ad.state = 0;
@@ -881,7 +879,7 @@ int mmo_auth(struct mmo_account *account, int fd)
}
else
{
- int new_id = mmo_auth_new(account, new_account_sex, DEFAULT_EMAIL);
+ int new_id = mmo_auth_new(account, sex_from_char(new_account_sex), DEFAULT_EMAIL);
LOGIN_LOG("Account creation and authentification accepted (account %s (id: %d), sex: %c, connection with _F/_M, ip: %s)\n",
account->userid, new_id,
new_account_sex, ip);
@@ -985,7 +983,7 @@ void parse_fromchar(int fd)
if (auth_fifo[i].account_id == acc &&
auth_fifo[i].login_id1 == RFIFOL(fd, 6) &&
auth_fifo[i].login_id2 == RFIFOL(fd, 10) && // relate to the versions higher than 18
- auth_fifo[i].sex == RFIFOB(fd, 14) &&
+ auth_fifo[i].sex == static_cast<SEX>(RFIFOB(fd, 14)) &&
(!check_ip_flag
|| auth_fifo[i].ip == RFIFOIP(fd, 15))
&& !auth_fifo[i].delflag)
@@ -1364,26 +1362,27 @@ void parse_fromchar(int fd)
if (RFIFOREST(fd) < 6)
return;
{
- int acc, sex;
+ int acc;
acc = RFIFOL(fd, 2);
for (AuthData& ad : auth_data)
{
if (ad.account_id == acc)
{
- if (ad.sex == 2)
+ if (ad.sex == SEX::SERVER)
LOGIN_LOG("Char-server '%s': Error of sex change - Server account (suggested account: %d, actual sex %d (Server), ip: %s).\n",
server[id].name, acc,
ad.sex, ip);
else
{
unsigned char buf[16];
- if (ad.sex == 0)
- sex = 1;
+ SEX sex;
+ if (ad.sex == SEX::FEMALE)
+ sex = SEX::MALE;
else
- sex = 0;
+ sex = SEX::FEMALE;
LOGIN_LOG("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n",
server[id].name, acc,
- (sex == 2) ? 'S' : (sex ? 'M' : 'F'),
+ sex_to_char(sex),
ip);
for (int j = 0; j < AUTH_FIFO_SIZE; j++)
if (auth_fifo[j].account_id == acc)
@@ -1391,7 +1390,7 @@ void parse_fromchar(int fd)
ad.sex = sex;
WBUFW(buf, 0) = 0x2723;
WBUFL(buf, 2) = acc;
- WBUFB(buf, 6) = sex;
+ WBUFB(buf, 6) = static_cast<uint8_t>(sex);
charif_sendallwos(-1, buf, 7);
}
goto x2727_out;
@@ -1646,7 +1645,7 @@ void parse_admin(int fd)
WFIFOL(fd, len) = account_id;
WFIFOB(fd, len + 4) = isGM(account_id);
WFIFO_STRING(fd, len + 5, ad.userid, 24);
- WFIFOB(fd, len + 29) = ad.sex;
+ WFIFOB(fd, len + 29) = static_cast<uint8_t>(ad.sex);
WFIFOL(fd, len + 30) = ad.logincount;
if (ad.state == 0 && ad.ban_until_time) // if no state and banished
WFIFOL(fd, len + 34) = 7; // 6 = Your are Prohibited to log in until %s
@@ -1682,7 +1681,7 @@ void parse_admin(int fd)
ma.userid = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
ma.passwd = stringish<AccountPass>(RFIFO_STRING<24>(fd, 26).to_print());
ma.lastlogin = stringish<timestamp_milliseconds_buffer>("-");
- ma.sex = RFIFOB(fd, 50);
+ ma.sex = sex_from_char(RFIFOB(fd, 50));
WFIFOW(fd, 0) = 0x7931;
WFIFOL(fd, 2) = -1;
WFIFO_STRING(fd, 6, ma.userid, 24);
@@ -1691,7 +1690,7 @@ void parse_admin(int fd)
LOGIN_LOG("'ladmin': Attempt to create an invalid account (account or pass is too short, ip: %s)\n",
ip);
}
- else if (ma.sex != 'F' && ma.sex != 'M')
+ else if (ma.sex != SEX::FEMALE && ma.sex != SEX::MALE)
{
LOGIN_LOG("'ladmin': Attempt to create an invalid account (account: %s, invalid sex, ip: %s)\n",
ma.userid, ip);
@@ -1924,16 +1923,11 @@ void parse_admin(int fd)
AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
WFIFO_STRING(fd, 6, account_name, 24);
{
- char sex;
- sex = RFIFOB(fd, 26);
- if (sex != 'F' && sex != 'M')
+ SEX sex = sex_from_char(RFIFOB(fd, 26));
+ if (sex != SEX::FEMALE && sex != SEX::MALE)
{
- if (sex > 31)
- LOGIN_LOG("'ladmin': Attempt to give an invalid sex (account: %s, received sex: %c, ip: %s)\n",
- account_name, sex, ip);
- else
- LOGIN_LOG("'ladmin': Attempt to give an invalid sex (account: %s, received sex: 'control char', ip: %s)\n",
- account_name, ip);
+ LOGIN_LOG("'ladmin': Attempt to give an invalid sex (account: %s, received sex: %c, ip: %s)\n",
+ account_name, sex_to_char(sex), ip);
}
else
{
@@ -1941,9 +1935,7 @@ void parse_admin(int fd)
if (ad)
{
WFIFO_STRING(fd, 6, ad->userid, 24);
- if (ad->sex !=
- ((sex == 'S' || sex == 's') ? 2
- : (sex == 'M' || sex == 'm')))
+ if (ad->sex != sex)
{
unsigned char buf[16];
WFIFOL(fd, 2) = ad->account_id;
@@ -1951,26 +1943,25 @@ void parse_admin(int fd)
if (auth_fifo[j].account_id ==
ad->account_id)
auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification)
- ad->sex = (sex == 'S' || sex == 's') ? 2
- : (sex == 'M' || sex == 'm');
+ ad->sex = sex;
LOGIN_LOG("'ladmin': Modification of a sex (account: %s, new sex: %c, ip: %s)\n",
- ad->userid, sex, ip);
+ ad->userid, sex_to_char(sex), ip);
// send to all char-server the change
WBUFW(buf, 0) = 0x2723;
WBUFL(buf, 2) = ad->account_id;
- WBUFB(buf, 6) = ad->sex;
+ WBUFB(buf, 6) = static_cast<uint8_t>(ad->sex);
charif_sendallwos(-1, buf, 7);
}
else
{
LOGIN_LOG("'ladmin': Modification of a sex, but the sex is already the good sex (account: %s, sex: %c, ip: %s)\n",
- ad->userid, sex, ip);
+ ad->userid, sex_to_char(sex), ip);
}
}
else
{
LOGIN_LOG("'ladmin': Attempt to modify the sex of an unknown account (account: %s, received sex: %c, ip: %s)\n",
- account_name, sex, ip);
+ account_name, sex_to_char(sex), ip);
}
}
}
@@ -2575,7 +2566,7 @@ void parse_admin(int fd)
WFIFOL(fd, 2) = ad->account_id;
WFIFOB(fd, 6) = isGM(ad->account_id);
WFIFO_STRING(fd, 7, ad->userid, 24);
- WFIFOB(fd, 31) = ad->sex;
+ WFIFOB(fd, 31) = static_cast<uint8_t>(ad->sex);
WFIFOL(fd, 32) = ad->logincount;
WFIFOL(fd, 36) = ad->state;
WFIFO_STRING(fd, 40, ad->error_message, 20);
@@ -2620,7 +2611,7 @@ void parse_admin(int fd)
ad.userid, RFIFOL(fd, 2), ip);
WFIFOB(fd, 6) = isGM(ad.account_id);
WFIFO_STRING(fd, 7, ad.userid, 24);
- WFIFOB(fd, 31) = ad.sex;
+ WFIFOB(fd, 31) = static_cast<uint8_t>(ad.sex);
WFIFOL(fd, 32) = ad.logincount;
WFIFOL(fd, 36) = ad.state;
WFIFO_STRING(fd, 40, ad.error_message, 20);
@@ -2897,7 +2888,7 @@ void parse_login(int fd)
WFIFOL(fd, 12) = account.login_id2;
WFIFOL(fd, 16) = 0; // in old version, that was for ip (not more used)
WFIFO_STRING(fd, 20, account.lastlogin, 24); // in old version, that was for name (not more used)
- WFIFOB(fd, 46) = account.sex;
+ WFIFOB(fd, 46) = static_cast<uint8_t>(account.sex);
WFIFOSET(fd, 47 + 32 * server_num);
if (auth_fifo_pos >= AUTH_FIFO_SIZE)
auth_fifo_pos = 0;
@@ -2966,7 +2957,7 @@ void parse_login(int fd)
server_name, RFIFOIP(fd, 54), RFIFOW(fd, 58), ip);
result = mmo_auth(&account, fd);
- if (result == -1 && account.sex == 2)
+ if (result == -1 && account.sex == SEX::SERVER)
{
// If this is the main server, and we don't already have a main server
if (server_fd[0] <= 0
@@ -2988,7 +2979,7 @@ void parse_login(int fd)
}
}
- if (result == -1 && account.sex == 2
+ if (result == -1 && account.sex == SEX::SERVER
&& account.account_id < MAX_SERVERS
&& server_fd[account.account_id] == -1)
{
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 1f7d1cc..43608d3 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -219,7 +219,7 @@ int chrif_changemapserver(dumb_ptr<map_session_data> sd,
WFIFOW(char_fd, 36) = y;
WFIFOIP(char_fd, 38) = ip;
WFIFOL(char_fd, 42) = port;
- WFIFOB(char_fd, 44) = sd->status.sex;
+ WFIFOB(char_fd, 44) = static_cast<uint8_t>(sd->status.sex);
WFIFOIP(char_fd, 45) = s_ip;
WFIFOSET(char_fd, 49);
@@ -604,11 +604,11 @@ void chrif_changedgm(int fd)
static
void chrif_changedsex(int fd)
{
- int acc, sex, i;
+ int acc, i;
dumb_ptr<map_session_data> sd;
acc = RFIFOL(fd, 2);
- sex = RFIFOL(fd, 6);
+ SEX sex = static_cast<SEX>(RFIFOB(fd, 6));
if (battle_config.etc_log)
PRINTF("chrif_changedsex %d.\n", acc);
sd = map_id2sd(acc);
@@ -616,7 +616,10 @@ void chrif_changedsex(int fd)
{
if (sd != NULL && sd->status.sex != sex)
{
- sd->sex = sd->status.sex = !sd->status.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;
// to avoid any problem with equipment and invalid sex, equipment is unequiped.
for (i = 0; i < MAX_INVENTORY; i++)
{
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 45c9c13..c0d4681 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -694,9 +694,9 @@ int clif_set0078(dumb_ptr<map_session_data> sd, unsigned char *buf)
WBUFL(buf, 34) = 0 /*guild_id*/;
WBUFW(buf, 38) = 0 /*guild_emblem_id*/;
WBUFW(buf, 40) = sd->status.manner;
- WBUFW(buf, 42) = uint16_t(sd->opt3);
+ WBUFW(buf, 42) = static_cast<uint16_t>(sd->opt3);
WBUFB(buf, 44) = sd->status.karma;
- WBUFB(buf, 45) = sd->sex;
+ WBUFB(buf, 45) = static_cast<uint8_t>(sd->sex);
WBUFPOS(buf, 46, sd->bl_x, sd->bl_y);
// work around ICE in gcc 4.6
uint8_t dir = static_cast<uint8_t>(sd->dir);
@@ -750,9 +750,9 @@ int clif_set007b(dumb_ptr<map_session_data> sd, unsigned char *buf)
WBUFL(buf, 38) = 0/*guild_id*/;
WBUFW(buf, 42) = 0/*guild_emblem_id*/;
WBUFW(buf, 44) = sd->status.manner;
- WBUFW(buf, 46) = uint16_t(sd->opt3);
+ WBUFW(buf, 46) = static_cast<uint16_t>(sd->opt3);
WBUFB(buf, 48) = sd->status.karma;
- WBUFB(buf, 49) = sd->sex;
+ WBUFB(buf, 49) = static_cast<uint8_t>(sd->sex);
WBUFPOS2(buf, 50, sd->bl_x, sd->bl_y, sd->to_x, sd->to_y);
WBUFW(buf, 55) = pc_isGM(sd) == 60 ? 0x80 : 0;
WBUFB(buf, 57) = 5;
@@ -3484,7 +3484,7 @@ void clif_parse_WantToConnection(int fd, dumb_ptr<map_session_data> sd)
pc_setnewpc(sd, account_id, RFIFOL(fd, 6), RFIFOL(fd, 10),
tick_t(static_cast<interval_t>(RFIFOL(fd, 14))),
- RFIFOB(fd, 18));
+ static_cast<SEX>(RFIFOB(fd, 18)));
map_addiddb(sd);
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp
index 588acd9..c0d54c9 100644
--- a/src/map/itemdb.cpp
+++ b/src/map/itemdb.cpp
@@ -84,7 +84,7 @@ struct item_data *itemdb_search(int nameid)
id->value_buy = 10;
id->value_sell = id->value_buy / 2;
id->weight = 10;
- id->sex = 2;
+ id->sex = SEX::SERVER;
id->elv = 0;
if (nameid > 500 && nameid < 600)
diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp
index 7e5aa34..a08777e 100644
--- a/src/map/itemdb.hpp
+++ b/src/map/itemdb.hpp
@@ -13,7 +13,7 @@ struct item_data
int value_buy;
int value_sell;
ItemType type;
- int sex;
+ SEX sex;
EPOS equip;
int weight;
int atk;
diff --git a/src/map/map.hpp b/src/map/map.hpp
index b0e6f18..356e077 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -160,7 +160,8 @@ struct map_session_data : block_list, SessionData
unsigned unbreakable_armor:1;
unsigned deaf:1;
} special_state;
- int char_id, login_id1, login_id2, sex;
+ int char_id, login_id1, login_id2;
+ SEX sex;
unsigned char tmw_version; // tmw client version
struct mmo_charstatus status;
struct item_data *inventory_data[MAX_INVENTORY];
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index ee74b08..09107ed 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -477,11 +477,6 @@ int mob_once_spawn_area(dumb_ptr<map_session_data> sd,
}
// TODO: deprecate these
-int mob_get_sex(int mob_class)
-{
- return mob_db[mob_class].sex;
-}
-
short mob_get_hair(int mob_class)
{
return mob_db[mob_class].hair;
@@ -3545,7 +3540,6 @@ int mob_readdb(void)
mob_db[mob_class].skills.clear();
- mob_db[mob_class].sex = 0;
mob_db[mob_class].hair = 0;
mob_db[mob_class].hair_color = 0;
mob_db[mob_class].weapon = 0;
diff --git a/src/map/mob.hpp b/src/map/mob.hpp
index bf53798..2ed4018 100644
--- a/src/map/mob.hpp
+++ b/src/map/mob.hpp
@@ -52,7 +52,6 @@ struct mob_db_
int nameid;
random_::Fixed<int, 10000> p;
} dropitem[8];
- int sex;
short hair, hair_color, weapon, shield, head_top, head_mid, head_buttom, option, clothes_color; // [Valaris]
int equip; // [Valaris]
std::vector<struct mob_skill> skills;
@@ -76,7 +75,6 @@ int mob_stopattack(dumb_ptr<mob_data>);
int mob_spawn(int);
int mob_damage(dumb_ptr<block_list>, dumb_ptr<mob_data>, int, int);
int mob_heal(dumb_ptr<mob_data>, int);
-int mob_get_sex(int);
short mob_get_hair(int);
short mob_get_hair_color(int);
short mob_get_weapon(int);
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index b622cc0..cf953aa 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -437,7 +437,7 @@ void pc_makesavestatus(dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
int pc_setnewpc(dumb_ptr<map_session_data> sd, int account_id, int char_id,
- int login_id1, tick_t client_tick, int sex)
+ int login_id1, tick_t client_tick, SEX sex)
{
nullpo_ret(sd);
@@ -592,7 +592,7 @@ int pc_isequip(dumb_ptr<map_session_data> sd, int n)
if (item == NULL)
return 0;
- if (item->sex != 2 && sd->status.sex != item->sex)
+ if (item->sex != SEX::SERVER && sd->status.sex != item->sex)
return 0;
if (item->elv > 0 && sd->status.base_level < item->elv)
return 0;
@@ -2228,7 +2228,7 @@ int pc_isUseitem(dumb_ptr<map_session_data> sd, int n)
if (itemdb_type(nameid) != ItemType::USE)
return 0;
- if (item->sex != 2 && sd->status.sex != item->sex)
+ if (item->sex != SEX::SERVER && sd->status.sex != item->sex)
return 0;
if (item->elv > 0 && sd->status.base_level < item->elv)
return 0;
@@ -3615,7 +3615,7 @@ int pc_readparam(dumb_ptr<map_session_data> sd, SP type)
val = sd->status.species;
break;
case SP::SEX:
- val = sd->sex;
+ val = static_cast<uint8_t>(sd->sex);
break;
case SP::WEIGHT:
val = sd->weight;
@@ -3743,7 +3743,8 @@ int pc_setparam(dumb_ptr<map_session_data> sd, SP type, int val)
}
break;
case SP::SEX:
- sd->sex = val;
+ // this is a really bad idea
+ sd->sex = static_cast<SEX>(val);
break;
case SP::WEIGHT:
sd->weight = val;
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index 77d1288..a2b4aa4 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -52,7 +52,7 @@ int pc_counttargeted(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> src,
ATK target_lv);
int pc_setrestartvalue(dumb_ptr<map_session_data> sd, int type);
void pc_makesavestatus(dumb_ptr<map_session_data>);
-int pc_setnewpc(dumb_ptr<map_session_data>, int, int, int, tick_t, int);
+int pc_setnewpc(dumb_ptr<map_session_data>, int, int, int, tick_t, SEX);
int pc_authok(int, int, TimeT, short tmw_version, const struct mmo_charstatus *);
int pc_authfail(int);
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 2f4d1cb..55e6b53 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -3093,15 +3093,15 @@ void builtin_changesex(ScriptState *st)
dumb_ptr<map_session_data> sd = NULL;
sd = script_rid2sd(st);
- if (sd->status.sex == 0)
+ if (sd->status.sex == SEX::FEMALE)
{
- sd->status.sex = 1;
- sd->sex = 1;
+ sd->status.sex = SEX::MALE;
+ sd->sex = SEX::MALE;
}
- else if (sd->status.sex == 1)
+ else if (sd->status.sex == SEX::MALE)
{
- sd->status.sex = 0;
- sd->sex = 0;
+ sd->status.sex = SEX::FEMALE;
+ sd->sex = SEX::FEMALE;
}
chrif_char_ask_name(-1, sd->status.name, 5, HumanTimeDiff()); // type: 5 - changesex
chrif_save(sd);