diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-10-05 22:15:20 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-10-10 14:37:49 -0700 |
commit | a44741c83773989430f5e3ac4a8a83c93b1341ff (patch) | |
tree | f235bfd95ae17d597fda2fedc1ea561358edf23a /src/map | |
parent | e591d5b6d891516476aaf12808f4d3b3506e5f92 (diff) | |
download | tmwa-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 ...
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/chrif.cpp | 11 | ||||
-rw-r--r-- | src/map/clif.cpp | 10 | ||||
-rw-r--r-- | src/map/itemdb.cpp | 2 | ||||
-rw-r--r-- | src/map/itemdb.hpp | 2 | ||||
-rw-r--r-- | src/map/map.hpp | 3 | ||||
-rw-r--r-- | src/map/mob.cpp | 6 | ||||
-rw-r--r-- | src/map/mob.hpp | 2 | ||||
-rw-r--r-- | src/map/pc.cpp | 11 | ||||
-rw-r--r-- | src/map/pc.hpp | 2 | ||||
-rw-r--r-- | src/map/script.cpp | 12 |
10 files changed, 29 insertions, 32 deletions
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); |