summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.cpp342
-rw-r--r--src/char/char.hpp6
-rw-r--r--src/char/int_party.cpp4
-rw-r--r--src/char/inter.cpp12
-rw-r--r--src/common/mmo.hpp22
-rw-r--r--src/map/atcommand.cpp80
-rw-r--r--src/map/battle.cpp8
-rw-r--r--src/map/chrif.cpp25
-rw-r--r--src/map/clif.cpp36
-rw-r--r--src/map/intif.cpp18
-rw-r--r--src/map/magic-expr.cpp2
-rw-r--r--src/map/magic-stmt.cpp4
-rw-r--r--src/map/map.cpp8
-rw-r--r--src/map/map.hpp5
-rw-r--r--src/map/party.cpp36
-rw-r--r--src/map/pc.cpp29
-rw-r--r--src/map/pc.hpp2
-rw-r--r--src/map/script.cpp8
-rw-r--r--src/map/storage.cpp14
-rw-r--r--src/map/tmw.cpp6
-rw-r--r--src/map/trade.cpp8
21 files changed, 361 insertions, 314 deletions
diff --git a/src/char/char.cpp b/src/char/char.cpp
index 04e540b..81afeed 100644
--- a/src/char/char.cpp
+++ b/src/char/char.cpp
@@ -127,7 +127,7 @@ int check_ip_flag = 1; // It's to check IP of a player between char-serv
static
int char_id_count = 150000;
static
-std::vector<mmo_charstatus> char_data;
+std::vector<CharPair> char_keys;
static
int max_connect_user = 0;
static
@@ -153,7 +153,7 @@ static
int online_gm_display_min_level = 20; // minimum GM level to display 'GM' when we want to display it
static
-std::vector<Session *> online_chars; // same size of char_data, and id value of current server (or -1)
+std::vector<Session *> online_chars; // same size of char_keys, and id value of current server (or -1)
static
TimeT update_online; // to update online files when we receiving information from a server (not less than 8 seconds)
@@ -192,13 +192,13 @@ int isGM(int account_id)
// and returns index if only 1 character is found
// and similar to the searched name.
//----------------------------------------------
-const mmo_charstatus *search_character(CharName character_name)
+const CharPair *search_character(CharName character_name)
{
- for (const mmo_charstatus& cd : char_data)
+ for (const CharPair& cd : char_keys)
{
{
// Strict comparison (if found, we finish the function immediatly with correct value)
- if (cd.name == character_name)
+ if (cd.key.name == character_name)
return &cd;
}
}
@@ -207,35 +207,38 @@ const mmo_charstatus *search_character(CharName character_name)
return nullptr;
}
-const mmo_charstatus *search_character_id(int char_id)
+const CharPair *search_character_id(int char_id)
{
- for (const mmo_charstatus& cd : char_data)
+ for (const CharPair& cd : char_keys)
{
- if (cd.char_id == char_id)
+ if (cd.key.char_id == char_id)
return &cd;
}
return nullptr;
}
-Session *server_for(const mmo_charstatus *mcs)
+// TODO make these DIE already
+Session *server_for(const CharPair *mcs)
{
if (!mcs)
return nullptr;
- return online_chars[mcs - &char_data.front()];
+ return online_chars[mcs - &char_keys.front()];
}
static
-Session *& server_for_m(const mmo_charstatus *mcs)
+Session *& server_for_m(const CharPair *mcs)
{
- return online_chars[mcs - &char_data.front()];
+ return online_chars[mcs - &char_keys.front()];
}
//-------------------------------------------------
// Function to create the character line (for save)
//-------------------------------------------------
static
-AString mmo_char_tostr(struct mmo_charstatus *p)
+AString mmo_char_tostr(struct CharPair *cp)
{
+ CharKey *k = &cp->key;
+ CharData *p = cp->data.get();
// on multi-map server, sometimes it's posssible that last_point become void. (reason???) We check that to not lost character at restart.
if (!p->last_point.map_)
{
@@ -258,9 +261,9 @@ AString mmo_char_tostr(struct mmo_charstatus *p)
"%d,%d,%d,%d,%d\t"
"%s,%d,%d\t"
"%s,%d,%d,%d\t",
- p->char_id,
- p->account_id, p->char_num,
- p->name,
+ k->char_id,
+ k->account_id, k->char_num,
+ k->name,
p->species, p->base_level, p->job_level,
p->base_exp, p->job_exp, p->zeny,
p->hp, p->max_hp, p->sp, p->max_sp,
@@ -367,10 +370,10 @@ bool extract(XString str, struct skill_loader *s)
// Function to set the character from the line (at read of characters file)
//-------------------------------------------------------------------------
static
-bool extract(XString str, struct mmo_charstatus *p)
+bool extract(XString str, CharPair *cp)
{
- // initilialise character
- *p = mmo_charstatus{};
+ CharKey *k = &cp->key;
+ CharData *p = cp->data.get();
uint32_t unused_guild_id, unused_pet_id;
std::vector<struct point> memos;
@@ -379,9 +382,9 @@ bool extract(XString str, struct mmo_charstatus *p)
std::vector<struct global_reg> vars;
if (!extract(str,
record<'\t'>(
- &p->char_id,
- record<','>(&p->account_id, &p->char_num),
- &p->name,
+ &k->char_id,
+ record<','>(&k->account_id, &k->char_num),
+ &k->name,
record<','>(&p->species, &p->base_level, &p->job_level),
record<','>(&p->base_exp, &p->job_exp, &p->zeny),
record<','>(&p->hp, &p->max_hp, &p->sp, &p->max_sp),
@@ -403,7 +406,7 @@ bool extract(XString str, struct mmo_charstatus *p)
vrec<' '>(&vars))))
return false;
- if (wisp_server_name == p->name)
+ if (wisp_server_name == k->name)
return false;
// TODO replace *every* lookup with a map lookup
@@ -411,10 +414,10 @@ bool extract(XString str, struct mmo_charstatus *p)
static std::set<CharName> seen_names;
// we don't have to worry about deleted characters,
// this is only called during startup
- auto _seen_id = seen_ids.insert(p->char_id);
+ auto _seen_id = seen_ids.insert(k->char_id);
if (!_seen_id.second)
return false;
- auto _seen_name = seen_names.insert(p->name);
+ auto _seen_name = seen_names.insert(k->name);
if (!_seen_name.second)
{
seen_ids.erase(_seen_id.first);
@@ -458,7 +461,7 @@ bool extract(XString str, struct mmo_charstatus *p)
static
int mmo_char_init(void)
{
- char_data.clear();
+ char_keys.clear();
online_chars.clear();
io::ReadFile in(char_txt);
@@ -490,22 +493,22 @@ int mmo_char_init(void)
}
}
- mmo_charstatus cd {};
+ CharPair cd;
if (!extract(line, &cd))
{
CHAR_LOG("Char skipped\n%s", line);
continue;
}
- if (cd.char_id >= char_id_count)
- char_id_count = cd.char_id + 1;
- char_data.push_back(std::move(cd));
+ if (cd.key.char_id >= char_id_count)
+ char_id_count = cd.key.char_id + 1;
+ char_keys.push_back(std::move(cd));
online_chars.push_back(nullptr);
}
PRINTF("mmo_char_init: %zu characters read in %s.\n",
- char_data.size(), char_txt);
+ char_keys.size(), char_txt);
CHAR_LOG("mmo_char_init: %zu characters read in %s.\n",
- char_data.size(), char_txt);
+ char_keys.size(), char_txt);
CHAR_LOG("Id for the next created character: %d.\n",
char_id_count);
@@ -528,7 +531,7 @@ void mmo_char_sync(void)
}
{
// yes, we need a mutable reference to do the saves ...
- for (mmo_charstatus& cd : char_data)
+ for (CharPair& cd : char_keys)
{
AString line = mmo_char_tostr(&cd);
fp.put_line(line);
@@ -577,7 +580,7 @@ void mmo_char_sync_timer(TimerData *, tick_t)
// Function to create a new character
//-----------------------------------
static
-mmo_charstatus *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], uint8_t slot, uint16_t hair_color, uint16_t hair_style)
+CharPair *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], uint8_t slot, uint16_t hair_color, uint16_t hair_style)
{
// ugh
char_session_data *sd = static_cast<char_session_data *>(s->session_data.get());
@@ -658,22 +661,22 @@ mmo_charstatus *make_new_char(Session *s, CharName name, const uint8_t (&stats)[
}
}
- for (const mmo_charstatus& cd : char_data)
+ for (const CharPair& cd : char_keys)
{
- if (cd.name == name)
+ if (cd.key.name == name)
{
CHAR_LOG("Make new char error (name already exists): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n",
- s, sd->account_id, slot, name, cd.name,
+ s, sd->account_id, slot, name, cd.key.name,
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color);
return nullptr;
}
- if (cd.account_id == sd->account_id
- && cd.char_num == slot)
+ if (cd.key.account_id == sd->account_id
+ && cd.key.char_num == slot)
{
CHAR_LOG("Make new char error (slot already used): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n",
- s, sd->account_id, slot, name, cd.name,
+ s, sd->account_id, slot, name, cd.key.name,
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color);
@@ -699,12 +702,14 @@ mmo_charstatus *make_new_char(Session *s, CharName name, const uint8_t (&stats)[
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color, ip);
- mmo_charstatus cd {};
+ CharPair cp;
+ CharKey& ck = cp.key;
+ CharData& cd = *cp.data;
- cd.char_id = char_id_count++;
- cd.account_id = sd->account_id;
- cd.char_num = slot;
- cd.name = name;
+ ck.char_id = char_id_count++;
+ ck.account_id = sd->account_id;
+ ck.char_num = slot;
+ ck.name = name;
cd.species = 0;
cd.base_level = 1;
cd.job_level = 1;
@@ -739,10 +744,10 @@ mmo_charstatus *make_new_char(Session *s, CharName name, const uint8_t (&stats)[
cd.head_bottom = 0;
cd.last_point = start_point;
cd.save_point = start_point;
- char_data.push_back(std::move(cd));
+ char_keys.push_back(std::move(cp));
online_chars.push_back(nullptr);
- return &char_data.back();
+ return &char_keys.back();
}
//-------------------------------------------------------------
@@ -796,7 +801,7 @@ void create_online_files(void)
FPRINTF(fp, "\n");
// display each player.
- for (struct mmo_charstatus& cd : char_data)
+ for (CharPair& cd : char_keys)
{
if (!server_for(&cd))
continue;
@@ -805,18 +810,18 @@ void create_online_files(void)
// displaying the character name
{
// without/with 'GM' display
- int gml = isGM(cd.account_id);
+ int gml = isGM(cd.key.account_id);
{
if (gml >= online_gm_display_min_level)
- FPRINTF(fp, "%-24s (GM) ", cd.name);
+ FPRINTF(fp, "%-24s (GM) ", cd.key.name);
else
- FPRINTF(fp, "%-24s ", cd.name);
+ FPRINTF(fp, "%-24s ", cd.key.name);
}
// name of the character in the html (no < >, because that create problem in html code)
FPRINTF(fp2, " <td>");
if (gml >= online_gm_display_min_level)
FPRINTF(fp2, "<b>");
- for (char c : cd.name.to__actual())
+ for (char c : cd.key.name.to__actual())
{
switch (c)
{
@@ -888,8 +893,9 @@ int count_users(void)
// [Fate] Find inventory item based on equipment mask, return view. ID must match view ID (!).
//----------------------------------------
static
-int find_equip_view(const mmo_charstatus *p, EPOS equipmask)
+int find_equip_view(const CharPair *cp, EPOS equipmask)
{
+ CharData *p = cp->data.get();
for (int i = 0; i < MAX_INVENTORY; i++)
if (p->inventory[i].nameid && p->inventory[i].amount
&& bool(p->inventory[i].equip & equipmask))
@@ -904,10 +910,10 @@ static
int mmo_char_send006b(Session *s, struct char_session_data *sd)
{
int found_num = 0;
- std::array<const mmo_charstatus *, 9> found_char;
- for (const mmo_charstatus& cd : char_data)
+ std::array<const CharPair *, 9> found_char;
+ for (const CharPair& cd : char_keys)
{
- if (cd.account_id == sd->account_id)
+ if (cd.key.account_id == sd->account_id)
{
found_char[found_num] = &cd;
found_num++;
@@ -923,19 +929,22 @@ int mmo_char_send006b(Session *s, struct char_session_data *sd)
for (int i = 0; i < found_num; i++)
{
- const mmo_charstatus *p = found_char[i];
+ const CharPair *cp = found_char[i];
int j = offset + (i * 106);
- WFIFOL(s, j) = p->char_id;
+ const CharKey *k = &cp->key;
+ const CharData *p = cp->data.get();
+
+ WFIFOL(s, j) = k->char_id;
WFIFOL(s, j + 4) = p->base_exp;
WFIFOL(s, j + 8) = p->zeny;
WFIFOL(s, j + 12) = p->job_exp;
WFIFOL(s, j + 16) = p->job_level;
- WFIFOW(s, j + 20) = find_equip_view(p, EPOS::SHOES);
- WFIFOW(s, j + 22) = find_equip_view(p, EPOS::GLOVES);
- WFIFOW(s, j + 24) = find_equip_view(p, EPOS::CAPE);
- WFIFOW(s, j + 26) = find_equip_view(p, EPOS::MISC1);
+ WFIFOW(s, j + 20) = find_equip_view(cp, EPOS::SHOES);
+ WFIFOW(s, j + 22) = find_equip_view(cp, EPOS::GLOVES);
+ WFIFOW(s, j + 24) = find_equip_view(cp, EPOS::CAPE);
+ WFIFOW(s, j + 26) = find_equip_view(cp, EPOS::MISC1);
WFIFOL(s, j + 28) = static_cast<uint16_t>(p->option);
WFIFOL(s, j + 32) = p->karma;
@@ -958,10 +967,10 @@ int mmo_char_send006b(Session *s, struct char_session_data *sd)
WFIFOW(s, j + 66) = p->head_top;
WFIFOW(s, j + 68) = p->head_mid;
WFIFOW(s, j + 70) = p->hair_color;
- WFIFOW(s, j + 72) = find_equip_view(p, EPOS::MISC2);
+ WFIFOW(s, j + 72) = find_equip_view(cp, EPOS::MISC2);
// WFIFOW(s,j+72) = p->clothes_color;
- WFIFO_STRING(s, j + 74, p->name.to__actual(), 24);
+ WFIFO_STRING(s, j + 74, k->name.to__actual(), 24);
WFIFOB(s, j + 98) = min(p->attrs[ATTR::STR], 255);
WFIFOB(s, j + 99) = min(p->attrs[ATTR::AGI], 255);
@@ -969,7 +978,7 @@ int mmo_char_send006b(Session *s, struct char_session_data *sd)
WFIFOB(s, j + 101) = min(p->attrs[ATTR::INT], 255);
WFIFOB(s, j + 102) = min(p->attrs[ATTR::DEX], 255);
WFIFOB(s, j + 103) = min(p->attrs[ATTR::LUK], 255);
- WFIFOB(s, j + 104) = p->char_num;
+ WFIFOB(s, j + 104) = k->char_num;
}
WFIFOSET(s, WFIFOW(s, 2));
@@ -981,15 +990,15 @@ static
int set_account_reg2(int acc, int num, struct global_reg *reg)
{
int c = 0;
- for (mmo_charstatus& cd : char_data)
+ for (CharPair& cd : char_keys)
{
- if (cd.account_id == acc)
+ if (cd.key.account_id == acc)
{
for (int i = 0; i < num; ++i)
- cd.account_reg2[i] = reg[i];
- cd.account_reg2_num = num;
+ cd.data->account_reg2[i] = reg[i];
+ cd.data->account_reg2_num = num;
for (int i = num; i < ACCOUNT_REG2_NUM; ++i)
- cd.account_reg2[i] = global_reg{};
+ cd.data->account_reg2[i] = global_reg{};
c++;
}
}
@@ -998,39 +1007,42 @@ int set_account_reg2(int acc, int num, struct global_reg *reg)
// Divorce a character from it's partner and let the map server know
static
-int char_divorce(struct mmo_charstatus *cs)
+int char_divorce(CharPair *cp)
{
uint8_t buf[10];
- if (cs == NULL)
+ if (cp == NULL)
return 0;
+ CharKey *ck = &cp->key;
+ CharData *cs = cp->data.get();
+
if (cs->partner_id <= 0)
{
WBUFW(buf, 0) = 0x2b12;
- WBUFL(buf, 2) = cs->char_id;
+ WBUFL(buf, 2) = ck->char_id;
WBUFL(buf, 6) = 0; // partner id 0 means failure
mapif_sendall(buf, 10);
return 0;
}
WBUFW(buf, 0) = 0x2b12;
- WBUFL(buf, 2) = cs->char_id;
+ WBUFL(buf, 2) = ck->char_id;
- for (mmo_charstatus& cd : char_data)
+ for (CharPair& cd : char_keys)
{
- if (cd.char_id == cs->partner_id
- && cd.partner_id == cs->char_id)
+ if (cd.key.char_id == cs->partner_id
+ && cd.data->partner_id == ck->char_id)
{
WBUFL(buf, 6) = cs->partner_id;
mapif_sendall(buf, 10);
cs->partner_id = 0;
- cd.partner_id = 0;
+ cd.data->partner_id = 0;
return 0;
}
// The other char doesn't have us as their partner, so just clear our partner
// Don't worry about this, as the map server should verify itself that the other doesn't have us as a partner, and so won't mess with their marriage
- else if (cd.char_id == cs->partner_id)
+ else if (cd.key.char_id == cs->partner_id)
{
WBUFL(buf, 6) = cs->partner_id;
mapif_sendall(buf, 10);
@@ -1074,20 +1086,23 @@ int disconnect_player(int accound_id)
// キャラ削除に伴うデータ削除
static
-int char_delete(struct mmo_charstatus *cs)
+int char_delete(CharPair *cp)
{
+ CharKey *ck = &cp->key;
+ CharData *cs = cp->data.get();
+
// パーティー脱退
if (cs->party_id)
- inter_party_leave(cs->party_id, cs->account_id);
+ inter_party_leave(cs->party_id, ck->account_id);
// 離婚
if (cs->partner_id)
- char_divorce(cs);
+ char_divorce(cp);
// Force the character (and all on the same account) to leave all map servers
{
unsigned char buf[6];
WBUFW(buf, 0) = 0x2afe;
- WBUFL(buf, 2) = cs->account_id;
+ WBUFL(buf, 2) = ck->account_id;
mapif_sendall(buf, 6);
}
@@ -1241,9 +1256,11 @@ void parse_tologin(Session *ls)
RFIFOSKIP(ls, 7);
if (acc > 0)
{
- for (struct mmo_charstatus& cd : char_data)
+ for (CharPair& cp : char_keys)
{
- if (cd.account_id == acc)
+ CharKey& ck = cp.key;
+ CharData& cd = *cp.data;
+ if (ck.account_id == acc)
{
cd.sex = sex;
// auth_fifo[i].sex = sex;
@@ -1350,10 +1367,12 @@ void parse_tologin(Session *ls)
WBUFL(buf, 6) = dest_id;
mapif_sendall(buf, 10); // forward package to map servers
- for (struct mmo_charstatus& cd : char_data)
+ for (CharPair& cp : char_keys)
{
- struct mmo_charstatus *c = &cd;
- struct storage *s = account2storage(c->account_id);
+ CharKey *k = &cp.key;
+ CharData& cd = *cp.data.get();
+ CharData *c = &cd;
+ struct storage *s = account2storage(k->account_id);
int changes = 0;
int j;
#define FIX(v) if (v == source_id) {v = dest_id; ++changes; }
@@ -1373,8 +1392,8 @@ void parse_tologin(Session *ls)
#undef FIX
if (changes)
CHAR_LOG("itemfrob(%d -> %d): `%s'(%d, account %d): changed %d times\n",
- source_id, dest_id, c->name, c->char_id,
- c->account_id, changes);
+ source_id, dest_id, k->name, k->char_id,
+ k->account_id, changes);
}
@@ -1391,23 +1410,26 @@ void parse_tologin(Session *ls)
// Deletion of all characters of the account
//#warning "This comment is a lie, but it's still true."
// needs to use index because they may move during resize
- for (int idx = 0; idx < char_data.size(); idx++)
+ for (int idx = 0; idx < char_keys.size(); idx++)
{
- mmo_charstatus& cd = char_data[idx];
- if (cd.account_id == RFIFOL(ls, 2))
+ CharPair& cp = char_keys[idx];
+ CharKey& ck = cp.key;
+ if (ck.account_id == RFIFOL(ls, 2))
{
- char_delete(&cd);
- if (&cd != &char_data.back())
+ char_delete(&cp);
+ if (&cp != &char_keys.back())
{
- std::swap(cd, char_data.back());
+ std::swap(cp, char_keys.back());
// if moved character owns to deleted account, check again it's character
- if (cd.account_id == RFIFOL(ls, 2))
+ // YES this is the newly swapped one
+ // we could avoid this by working backwards
+ if (ck.account_id == RFIFOL(ls, 2))
{
idx--;
// Correct moved character reference in the character's owner by [Yor]
}
}
- char_data.pop_back();
+ char_keys.pop_back();
}
}
// Deletion of the storage
@@ -1659,19 +1681,23 @@ void parse_frommap(Session *ms)
(!check_ip_flag || afi.ip == ip)
&& !afi.delflag)
{
- mmo_charstatus *cd = nullptr;
- for (mmo_charstatus& cdi : char_data)
+ CharPair *cp = nullptr;
+ for (CharPair& cdi : char_keys)
{
- if (cdi.char_id == afi.char_id)
+ if (cdi.key.char_id == afi.char_id)
{
- cd = &cdi;
+ cp = &cdi;
break;
}
}
- assert (cd && "uh-oh - deleted while in queue?");
+ assert (cp && "uh-oh - deleted while in queue?");
+
+ CharKey *ck = &cp->key;
+ CharData *cd = cp->data.get();
+
afi.delflag = 1;
WFIFOW(ms, 0) = 0x2afd;
- WFIFOW(ms, 2) = 18 + sizeof(*cd);
+ WFIFOW(ms, 2) = 18 + sizeof(*ck) + sizeof(*cd);
WFIFOL(ms, 4) = account_id;
WFIFOL(ms, 8) = afi.login_id2;
WFIFOL(ms, 12) = static_cast<time_t>(afi.connect_until_time);
@@ -1680,7 +1706,8 @@ void parse_frommap(Session *ms)
FPRINTF(stderr,
"From queue index %zd: recalling packet version %d\n",
(&afi - &auth_fifo.front()), afi.packet_tmw_version);
- WFIFO_STRUCT(ms, 18, *cd);
+ WFIFO_STRUCT(ms, 18, *ck);
+ WFIFO_STRUCT(ms, 18 + sizeof(*ck), *cd);
WFIFOSET(ms, WFIFOW(ms, 2));
//PRINTF("auth_fifo search success (auth #%d, account %d, character: %d).\n", i, RFIFOL(fd,2), RFIFOL(fd,6));
goto x2afc_out;
@@ -1716,9 +1743,9 @@ void parse_frommap(Session *ms)
for (int i = 0; i < server[id].users; i++)
{
int char_id = RFIFOL(ms, 6 + i * 4);
- for (const mmo_charstatus& cd : char_data)
+ for (const CharPair& cd : char_keys)
{
- if (cd.char_id == char_id)
+ if (cd.key.char_id == char_id)
{
server_for_m(&cd) = ms;
break;
@@ -1740,12 +1767,13 @@ void parse_frommap(Session *ms)
case 0x2b01:
if (RFIFOREST(ms) < 4 || RFIFOREST(ms) < RFIFOW(ms, 2))
return;
- for (mmo_charstatus& cd : char_data)
+ for (CharPair& cd : char_keys)
{
- if (cd.account_id == RFIFOL(ms, 4) &&
- cd.char_id == RFIFOL(ms, 8))
+ if (cd.key.account_id == RFIFOL(ms, 4) &&
+ cd.key.char_id == RFIFOL(ms, 8))
{
- RFIFO_STRUCT(ms, 12, cd);
+ RFIFO_STRUCT(ms, 12, cd.key);
+ RFIFO_STRUCT(ms, 12 + sizeof(cd.key), *cd.data);
break;
}
}
@@ -1797,9 +1825,9 @@ void parse_frommap(Session *ms)
// default, if not found in the loop
WFIFOW(ms, 6) = 1;
- for (const mmo_charstatus& cd : char_data)
- if (cd.account_id == RFIFOL(ms, 2) &&
- cd.char_id == RFIFOL(ms, 14))
+ for (const CharPair& cd : char_keys)
+ if (cd.key.account_id == RFIFOL(ms, 2) &&
+ cd.key.char_id == RFIFOL(ms, 14))
{
auth_fifo_iter++;
WFIFOL(ms, 6) = 0;
@@ -1859,24 +1887,24 @@ void parse_frommap(Session *ms)
WFIFOL(ms, 2) = acc; // who want do operation
WFIFOW(ms, 30) = operation; // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5-changesex
// search character
- const mmo_charstatus *cd = search_character(character_name);
+ const CharPair *cd = search_character(character_name);
if (cd)
{
- WFIFO_STRING(ms, 6, cd->name.to__actual(), 24); // put correct name if found
+ const CharKey *ck = &cd->key;
+ WFIFO_STRING(ms, 6, ck->name.to__actual(), 24); // put correct name if found
WFIFOW(ms, 32) = 0; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
switch (RFIFOW(ms, 30))
{
case 1: // block
if (acc == -1
- || isGM(acc) >= isGM(cd->account_id))
+ || isGM(acc) >= isGM(ck->account_id))
{
if (login_session)
{ // don't send request if no login-server
WFIFOW(login_session, 0) = 0x2724;
- WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOL(login_session, 2) = ck->account_id; // account value
WFIFOL(login_session, 6) = 5; // status of the account
WFIFOSET(login_session, 10);
-// PRINTF("char : status -> login: account %d, status: %d \n", char_data[i].account_id, 5);
}
else
WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -1886,18 +1914,16 @@ void parse_frommap(Session *ms)
break;
case 2: // ban
if (acc == -1
- || isGM(acc) >= isGM(cd->account_id))
+ || isGM(acc) >= isGM(ck->account_id))
{
if (login_session)
{ // don't send request if no login-server
WFIFOW(login_session, 0) = 0x2725;
- WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOL(login_session, 2) = ck->account_id; // account value
HumanTimeDiff ban_change;
RFIFO_STRUCT(ms, 32, ban_change);
WFIFO_STRUCT(login_session, 6, ban_change);
WFIFOSET(login_session, 18);
-// PRINTF("char : status -> login: account %d, ban: %dy %dm %dd %dh %dmn %ds\n",
-// char_data[i].account_id, (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), (short)RFIFOW(fd,38), (short)RFIFOW(fd,40), (short)RFIFOW(fd,42));
}
else
WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -1907,15 +1933,14 @@ void parse_frommap(Session *ms)
break;
case 3: // unblock
if (acc == -1
- || isGM(acc) >= isGM(cd->account_id))
+ || isGM(acc) >= isGM(ck->account_id))
{
if (login_session)
{ // don't send request if no login-server
WFIFOW(login_session, 0) = 0x2724;
- WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOL(login_session, 2) = ck->account_id; // account value
WFIFOL(login_session, 6) = 0; // status of the account
WFIFOSET(login_session, 10);
-// PRINTF("char : status -> login: account %d, status: %d \n", char_data[i].account_id, 0);
}
else
WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -1925,14 +1950,13 @@ void parse_frommap(Session *ms)
break;
case 4: // unban
if (acc == -1
- || isGM(acc) >= isGM(cd->account_id))
+ || isGM(acc) >= isGM(ck->account_id))
{
if (login_session)
{ // don't send request if no login-server
WFIFOW(login_session, 0) = 0x272a;
- WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOL(login_session, 2) = ck->account_id; // account value
WFIFOSET(login_session, 6);
-// PRINTF("char : status -> login: account %d, unban request\n", char_data[i].account_id);
}
else
WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -1942,14 +1966,13 @@ void parse_frommap(Session *ms)
break;
case 5: // changesex
if (acc == -1
- || isGM(acc) >= isGM(cd->account_id))
+ || isGM(acc) >= isGM(ck->account_id))
{
if (login_session)
{ // don't send request if no login-server
WFIFOW(login_session, 0) = 0x2727;
- WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOL(login_session, 2) = ck->account_id; // account value
WFIFOSET(login_session, 6);
-// PRINTF("char : status -> login: account %d, change sex request\n", char_data[i].account_id);
}
else
WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -2009,8 +2032,8 @@ void parse_frommap(Session *ms)
if (RFIFOREST(ms) < 4)
return;
{
- for (mmo_charstatus& cd : char_data)
- if (cd.char_id == RFIFOL(ms, 2))
+ for (CharPair& cd : char_keys)
+ if (cd.key.char_id == RFIFOL(ms, 2))
{
char_divorce(&cd);
break;
@@ -2074,20 +2097,23 @@ static
void handle_x0066(Session *s, struct char_session_data *sd, uint8_t rfifob_2, IP4Address ip)
{
{
- mmo_charstatus *cd = nullptr;
- for (mmo_charstatus& cdi : char_data)
+ CharPair *cp = nullptr;
+ for (CharPair& cdi : char_keys)
{
- if (cdi.account_id == sd->account_id && cdi.char_num == rfifob_2)
+ if (cdi.key.account_id == sd->account_id && cdi.key.char_num == rfifob_2)
{
- cd = &cdi;
+ cp = &cdi;
break;
}
}
- if (cd)
+ if (cp)
{
+ CharKey *ck = &cp->key;
+ CharData *cd = cp->data.get();
+
CHAR_LOG("Character Selected, Account ID: %d, Character Slot: %d, Character Name: %s [%s]\n",
sd->account_id, rfifob_2,
- cd->name, ip);
+ ck->name, ip);
// searching map server
int i = search_mapserver(cd->last_point.map_);
// if map is not found, we check major cities
@@ -2117,11 +2143,11 @@ void handle_x0066(Session *s, struct char_session_data *sd, uint8_t rfifob_2, IP
}
}
WFIFOW(s, 0) = 0x71;
- WFIFOL(s, 2) = cd->char_id;
+ WFIFOL(s, 2) = ck->char_id;
WFIFO_STRING(s, 6, cd->last_point.map_, 16);
PRINTF("Character selection '%s' (account: %d, slot: %d) [%s]\n",
- cd->name,
- sd->account_id, cd->char_num, ip);
+ ck->name,
+ sd->account_id, ck->char_num, ip);
PRINTF("--Send IP of map-server. ");
if (lan_ip_check(ip))
WFIFOIP(s, 22) = lan_map_ip;
@@ -2132,7 +2158,7 @@ void handle_x0066(Session *s, struct char_session_data *sd, uint8_t rfifob_2, IP
if (auth_fifo_iter == auth_fifo.end())
auth_fifo_iter = auth_fifo.begin();
auth_fifo_iter->account_id = sd->account_id;
- auth_fifo_iter->char_id = cd->char_id;
+ auth_fifo_iter->char_id = ck->char_id;
auth_fifo_iter->login_id1 = sd->login_id1;
auth_fifo_iter->login_id2 = sd->login_id2;
auth_fifo_iter->delflag = 0;
@@ -2295,8 +2321,8 @@ void parse_char(Session *s)
uint8_t slot = RFIFOB(s, 32);
uint16_t hair_color = RFIFOW(s, 33);
uint16_t hair_style = RFIFOW(s, 35);
- const struct mmo_charstatus *cd = make_new_char(s, name, stats, slot, hair_color, hair_style);
- if (!cd)
+ const CharPair *cp = make_new_char(s, name, stats, slot, hair_color, hair_style);
+ if (!cp)
{
WFIFOW(s, 0) = 0x6e;
WFIFOB(s, 2) = 0x00;
@@ -2304,11 +2330,13 @@ void parse_char(Session *s)
RFIFOSKIP(s, 37);
break;
}
+ const CharKey *ck = &cp->key;
+ const CharData *cd = cp->data.get();
WFIFOW(s, 0) = 0x6d;
WFIFO_ZERO(s, 2, 106);
- WFIFOL(s, 2) = cd->char_id;
+ WFIFOL(s, 2) = ck->char_id;
WFIFOL(s, 2 + 4) = cd->base_exp;
WFIFOL(s, 2 + 8) = cd->zeny;
WFIFOL(s, 2 + 12) = cd->job_exp;
@@ -2322,7 +2350,7 @@ void parse_char(Session *s)
WFIFOW(s, 2 + 44) = min(cd->max_hp, 0x7fff);
WFIFOW(s, 2 + 46) = min(cd->sp, 0x7fff);
WFIFOW(s, 2 + 48) = min(cd->max_sp, 0x7fff);
- WFIFOW(s, 2 + 50) = static_cast<uint16_t>(DEFAULT_WALK_SPEED.count()); // char_data[i].speed;
+ WFIFOW(s, 2 + 50) = static_cast<uint16_t>(DEFAULT_WALK_SPEED.count()); // cd->speed;
WFIFOW(s, 2 + 52) = cd->species;
WFIFOW(s, 2 + 54) = cd->hair;
@@ -2334,7 +2362,7 @@ void parse_char(Session *s)
WFIFOW(s, 2 + 68) = cd->head_mid;
WFIFOW(s, 2 + 70) = cd->hair_color;
- WFIFO_STRING(s, 2 + 74, cd->name.to__actual(), 24);
+ WFIFO_STRING(s, 2 + 74, ck->name.to__actual(), 24);
WFIFOB(s, 2 + 98) = min(cd->attrs[ATTR::STR], 255);
WFIFOB(s, 2 + 99) = min(cd->attrs[ATTR::AGI], 255);
@@ -2342,7 +2370,7 @@ void parse_char(Session *s)
WFIFOB(s, 2 + 101) = min(cd->attrs[ATTR::INT], 255);
WFIFOB(s, 2 + 102) = min(cd->attrs[ATTR::DEX], 255);
WFIFOB(s, 2 + 103) = min(cd->attrs[ATTR::LUK], 255);
- WFIFOB(s, 2 + 104) = cd->char_num;
+ WFIFOB(s, 2 + 104) = ck->char_num;
WFIFOSET(s, 108);
}
@@ -2359,10 +2387,10 @@ void parse_char(Session *s)
{
{
- struct mmo_charstatus *cs = nullptr;
- for (mmo_charstatus& cd : char_data)
+ CharPair *cs = nullptr;
+ for (CharPair& cd : char_keys)
{
- if (cd.char_id == RFIFOL(s, 2))
+ if (cd.key.char_id == RFIFOL(s, 2))
{
cs = &cd;
break;
@@ -2373,12 +2401,12 @@ void parse_char(Session *s)
{
char_delete(cs); // deletion process
- if (cs != &char_data.back())
+ if (cs != &char_keys.back())
{
- std::swap(*cs, char_data.back());
+ std::swap(*cs, char_keys.back());
}
- char_data.pop_back();
+ char_keys.pop_back();
WFIFOW(s, 0) = 0x6f;
WFIFOSET(s, 2);
goto x68_out;
@@ -2808,7 +2836,7 @@ void term_func(void)
gm_accounts.clear();
- char_data.clear();
+ char_keys.clear();
delete_session(login_session);
delete_session(char_session);
diff --git a/src/char/char.hpp b/src/char/char.hpp
index cac060f..57cacee 100644
--- a/src/char/char.hpp
+++ b/src/char/char.hpp
@@ -19,9 +19,9 @@ struct mmo_map_server
MapName maps[MAX_MAP_PER_SERVER];
};
-const mmo_charstatus *search_character(CharName character_name);
-const mmo_charstatus *search_character_id(int char_id);
-Session *server_for(const mmo_charstatus *mcs);
+const CharPair *search_character(CharName character_name);
+const CharPair *search_character_id(int char_id);
+Session *server_for(const CharPair *mcs);
int mapif_sendall(const uint8_t *buf, unsigned int len);
int mapif_sendallwos(Session *s, const uint8_t *buf, unsigned int len);
diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp
index cf9b3e5..85af96c 100644
--- a/src/char/int_party.cpp
+++ b/src/char/int_party.cpp
@@ -108,8 +108,8 @@ void party_check_deleted_init(struct party *p)
{
if (!p->member[i].account_id)
continue;
- const struct mmo_charstatus *c = search_character(p->member[i].name);
- if (!c || c->account_id != p->member[i].account_id)
+ const CharPair *c = search_character(p->member[i].name);
+ if (!c || c->key.account_id != p->member[i].account_id)
{
CHAR_LOG("WARNING: deleting obsolete party member %d %s of %d %s\n",
p->member[i].account_id, p->member[i].name,
diff --git a/src/char/inter.cpp b/src/char/inter.cpp
index 192ffd5..4fea6be 100644
--- a/src/char/inter.cpp
+++ b/src/char/inter.cpp
@@ -210,7 +210,7 @@ void mapif_GMmessage(XString mes)
static
void mapif_wis_message(Session *tms, CharName src, CharName dst, XString msg)
{
- const mmo_charstatus *mcs = search_character(src);
+ const CharPair *mcs = search_character(src);
assert (mcs);
size_t str_size = msg.size() + 1;
@@ -218,7 +218,7 @@ void mapif_wis_message(Session *tms, CharName src, CharName dst, XString msg)
WBUFW(buf, 0) = 0x3801;
WBUFW(buf, 2) = 56 + str_size;
- WBUFL(buf, 4) = mcs->char_id; // formerly, whisper ID
+ WBUFL(buf, 4) = mcs->key.char_id; // formerly, whisper ID
WBUF_STRING(buf, 8, src.to__actual(), 24);
WBUF_STRING(buf, 32, dst.to__actual(), 24);
WBUF_STRING(buf, 56, msg, str_size);
@@ -301,7 +301,7 @@ void mapif_parse_WisRequest(Session *sms)
CharName to = stringish<CharName>(RFIFO_STRING<24>(sms, 28));
// search if character exists before to ask all map-servers
- const mmo_charstatus *mcs = search_character(to);
+ const CharPair *mcs = search_character(to);
if (!mcs)
{
uint8_t buf[27];
@@ -314,7 +314,7 @@ void mapif_parse_WisRequest(Session *sms)
else
{
// to be sure of the correct name, rewrite it
- to = mcs->name;
+ to = mcs->key.name;
// if source is destination, don't ask other servers.
if (from == to)
{
@@ -347,8 +347,8 @@ int mapif_parse_WisReply(Session *tms)
{
int id = RFIFOL(tms, 2), flag = RFIFOB(tms, 6);
- const mmo_charstatus *smcs = search_character_id(id);
- CharName from = smcs->name;
+ const CharPair *smcs = search_character_id(id);
+ CharName from = smcs->key.name;
Session *sms = server_for(smcs);
{
mapif_wis_end(sms, from, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
diff --git a/src/common/mmo.hpp b/src/common/mmo.hpp
index b2f36b6..67123d9 100644
--- a/src/common/mmo.hpp
+++ b/src/common/mmo.hpp
@@ -294,10 +294,16 @@ SEX sex_from_char(char c)
}
}
-struct mmo_charstatus
+struct CharKey
{
- int char_id;
+ CharName name;
int account_id;
+ int char_id;
+ unsigned char char_num;
+};
+
+struct CharData
+{
int partner_id;
int base_exp, job_exp, zeny;
@@ -314,10 +320,8 @@ struct mmo_charstatus
short shield;
short head_top, head_mid, head_bottom;
- CharName name;
unsigned char base_level, job_level;
earray<short, ATTR, ATTR::COUNT> attrs;
- unsigned char char_num;
SEX sex;
unsigned long mapip;
@@ -334,6 +338,16 @@ struct mmo_charstatus
struct global_reg account_reg2[ACCOUNT_REG2_NUM];
};
+struct CharPair
+{
+ CharKey key;
+ std::unique_ptr<CharData> data;
+
+ CharPair()
+ : key{}, data(make_unique<CharData>())
+ {}
+};
+
struct storage
{
int dirty;
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 6cb1425..5e46775 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -178,7 +178,7 @@ void log_atcommand(dumb_ptr<map_session_data> sd, ZString cmd)
FPRINTF(*fp, "[%s] %s(%d,%d) %s(%d) : %s\n",
tmpstr,
map, sd->bl_x, sd->bl_y,
- sd->status.name, sd->status.account_id,
+ sd->status_key.name, sd->status_key.account_id,
cmd);
}
@@ -607,7 +607,7 @@ ATCE atcommand_where(Session *s, dumb_ptr<map_session_data> sd,
{
// you can look only lower or same level
AString output = STRPRINTF("%s: %s (%d,%d)",
- pl_sd->status.name,
+ pl_sd->status_key.name,
pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y);
clif_displaymessage(s, output);
}
@@ -730,7 +730,7 @@ ATCE atcommand_who(Session *s, dumb_ptr<map_session_data> sd,
&& (pl_GM_level > GM_level)))
{
// you can look only lower or same level
- VString<23> player_name = pl_sd->status.name.to__lower();
+ VString<23> player_name = pl_sd->status_key.name.to__lower();
if (player_name.contains_seq(match_text))
{
// search with no case sensitive
@@ -738,12 +738,12 @@ ATCE atcommand_who(Session *s, dumb_ptr<map_session_data> sd,
if (pl_GM_level > 0)
output = STRPRINTF(
"Name: %s (GM:%d) | Location: %s %d %d",
- pl_sd->status.name, pl_GM_level,
+ pl_sd->status_key.name, pl_GM_level,
pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y);
else
output = STRPRINTF(
"Name: %s | Location: %s %d %d",
- pl_sd->status.name, pl_sd->mapname_,
+ pl_sd->status_key.name, pl_sd->mapname_,
pl_sd->bl_x, pl_sd->bl_y);
clif_displaymessage(s, output);
count++;
@@ -793,7 +793,7 @@ ATCE atcommand_whogroup(Session *s, dumb_ptr<map_session_data> sd,
&& (pl_GM_level > GM_level)))
{
// you can look only lower or same level
- VString<23> player_name = pl_sd->status.name.to__lower();
+ VString<23> player_name = pl_sd->status_key.name.to__lower();
if (player_name.contains_seq(match_text))
{
// search with no case sensitive
@@ -803,7 +803,7 @@ ATCE atcommand_whogroup(Session *s, dumb_ptr<map_session_data> sd,
if (pl_GM_level > 0)
output = STRPRINTF(
"Name: %s (GM:%d) | Party: '%s'",
- pl_sd->status.name, pl_GM_level, temp0);
+ pl_sd->status_key.name, pl_GM_level, temp0);
clif_displaymessage(s, output);
count++;
}
@@ -863,12 +863,12 @@ ATCE atcommand_whomap(Session *s, dumb_ptr<map_session_data> sd,
if (pl_GM_level > 0)
output = STRPRINTF(
"Name: %s (GM:%d) | Location: %s %d %d",
- pl_sd->status.name, pl_GM_level,
+ pl_sd->status_key.name, pl_GM_level,
pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y);
else
output = STRPRINTF(
"Name: %s | Location: %s %d %d",
- pl_sd->status.name, pl_sd->mapname_,
+ pl_sd->status_key.name, pl_sd->mapname_,
pl_sd->bl_x, pl_sd->bl_y);
clif_displaymessage(s, output);
count++;
@@ -925,10 +925,10 @@ ATCE atcommand_whomapgroup(Session *s, dumb_ptr<map_session_data> sd,
AString output;
if (pl_GM_level > 0)
output = STRPRINTF("Name: %s (GM:%d) | Party: '%s'",
- pl_sd->status.name, pl_GM_level, temp0);
+ pl_sd->status_key.name, pl_GM_level, temp0);
else
output = STRPRINTF("Name: %s | Party: '%s'",
- pl_sd->status.name, temp0);
+ pl_sd->status_key.name, temp0);
clif_displaymessage(s, output);
count++;
}
@@ -980,14 +980,14 @@ ATCE atcommand_whogm(Session *s, dumb_ptr<map_session_data> sd,
&& (pl_GM_level > GM_level)))
{
// you can look only lower or same level
- VString<23> player_name = pl_sd->status.name.to__lower();
+ VString<23> player_name = pl_sd->status_key.name.to__lower();
if (player_name.contains_seq(match_text))
{
// search with no case sensitive
AString output;
output = STRPRINTF(
"Name: %s (GM:%d) | Location: %s %d %d",
- pl_sd->status.name, pl_GM_level,
+ pl_sd->status_key.name, pl_GM_level,
pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y);
clif_displaymessage(s, output);
output = STRPRINTF(
@@ -1109,7 +1109,7 @@ ATCE atcommand_storage(Session *s, dumb_ptr<map_session_data> sd,
return ATCE::EXIST;
}
- if ((stor = account2storage2(sd->status.account_id)) != NULL
+ if ((stor = account2storage2(sd->status_key.account_id)) != NULL
&& stor->storage_status == 1)
{
clif_displaymessage(s, "msg_table[250]");
@@ -1503,7 +1503,7 @@ ATCE atcommand_gm(Session *s, dumb_ptr<map_session_data> sd,
return ATCE::PERM;
}
else
- chrif_changegm(sd->status.account_id, message);
+ chrif_changegm(sd->status_key.account_id, message);
return ATCE::OKAY;
}
@@ -1796,7 +1796,7 @@ void atlist_nearby_sub(dumb_ptr<block_list> bl, Session *s)
nullpo_retv(bl);
AString buf = STRPRINTF(" - \"%s\"",
- bl->is_player()->status.name);
+ bl->is_player()->status_key.name);
clif_displaymessage(s, buf);
}
@@ -2110,7 +2110,7 @@ ATCE atcommand_character_stats(Session *s, dumb_ptr<map_session_data>,
if (pl_sd != NULL)
{
AString output;
- output = STRPRINTF("'%s' stats:", pl_sd->status.name);
+ output = STRPRINTF("'%s' stats:", pl_sd->status_key.name);
clif_displaymessage(s, output);
output = STRPRINTF("Base Level - %d", pl_sd->status.base_level),
clif_displaymessage(s, output);
@@ -2172,7 +2172,7 @@ ATCE atcommand_character_stats_all(Session *s, dumb_ptr<map_session_data>,
AString output;
output = STRPRINTF(
"Name: %s | BLvl: %d | Job: Novice/Human (Lvl: %d) | HP: %d/%d | SP: %d/%d",
- pl_sd->status.name, pl_sd->status.base_level,
+ pl_sd->status_key.name, pl_sd->status.base_level,
pl_sd->status.job_level,
pl_sd->status.hp, pl_sd->status.max_hp,
pl_sd->status.sp, pl_sd->status.max_sp);
@@ -2255,7 +2255,7 @@ ATCE atcommand_char_change_sex(Session *s, dumb_ptr<map_session_data> sd,
return ATCE::USAGE;
{
- chrif_char_ask_name(sd->status.account_id, character, 5, HumanTimeDiff());
+ chrif_char_ask_name(sd->status_key.account_id, character, 5, HumanTimeDiff());
// type: 5 - changesex
clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
@@ -2273,7 +2273,7 @@ ATCE atcommand_char_block(Session *s, dumb_ptr<map_session_data> sd,
return ATCE::USAGE;
{
- chrif_char_ask_name(sd->status.account_id, character, 1, HumanTimeDiff());
+ chrif_char_ask_name(sd->status_key.account_id, character, 1, HumanTimeDiff());
// type: 1 - block
clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
@@ -2293,7 +2293,7 @@ ATCE atcommand_char_ban(Session *s, dumb_ptr<map_session_data> sd,
return ATCE::USAGE;
{
- chrif_char_ask_name(sd->status.account_id, character, 2, modif);
+ chrif_char_ask_name(sd->status_key.account_id, character, 2, modif);
// type: 2 - ban
clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
@@ -2312,7 +2312,7 @@ ATCE atcommand_char_unblock(Session *s, dumb_ptr<map_session_data> sd,
{
// send answer to login server via char-server
- chrif_char_ask_name(sd->status.account_id, character, 3, HumanTimeDiff());
+ chrif_char_ask_name(sd->status_key.account_id, character, 3, HumanTimeDiff());
// type: 3 - unblock
clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
@@ -2331,7 +2331,7 @@ ATCE atcommand_char_unban(Session *s, dumb_ptr<map_session_data> sd,
{
// send answer to login server via char-server
- chrif_char_ask_name(sd->status.account_id, character, 4, HumanTimeDiff());
+ chrif_char_ask_name(sd->status_key.account_id, character, 4, HumanTimeDiff());
// type: 4 - unban
clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
@@ -2697,7 +2697,7 @@ ATCE atcommand_kickall(Session *s, dumb_ptr<map_session_data> sd,
&& pl_sd->state.auth && pc_isGM(sd) >= pc_isGM(pl_sd))
{
// you can kick only lower or same gm level
- if (sd->status.account_id != pl_sd->status.account_id)
+ if (sd->status_key.account_id != pl_sd->status_key.account_id)
clif_GM_kick(sd, pl_sd, 0);
}
}
@@ -2913,7 +2913,7 @@ ATCE atcommand_mapexit(Session *, dumb_ptr<map_session_data> sd,
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
- if (sd->status.account_id != pl_sd->status.account_id)
+ if (sd->status_key.account_id != pl_sd->status_key.account_id)
clif_GM_kick(sd, pl_sd, 0);
}
}
@@ -3326,7 +3326,7 @@ ATCE atcommand_recallall(Session *s, dumb_ptr<map_session_data> sd,
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd
&& pl_sd->state.auth
- && sd->status.account_id != pl_sd->status.account_id
+ && sd->status_key.account_id != pl_sd->status_key.account_id
&& pc_isGM(sd) >= pc_isGM(pl_sd))
{
// you can recall only lower or same level
@@ -3381,7 +3381,7 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr<map_session_data> sd,
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth
- && sd->status.account_id != pl_sd->status.account_id
+ && sd->status_key.account_id != pl_sd->status_key.account_id
&& pl_sd->status.party_id == p->party_id)
{
if (pl_sd->bl_m && pl_sd->bl_m->flag.get(MapFlag::NOWARP)
@@ -3477,7 +3477,7 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr<map_session_data> sd,
{
output = STRPRINTF(
"Player '%s' (session #%d) | Location: %d,%d",
- pl_sd->status.name, s2, pl_sd->bl_x, pl_sd->bl_y);
+ pl_sd->status_key.name, s2, pl_sd->bl_x, pl_sd->bl_y);
clif_displaymessage(s, output);
}
}
@@ -3714,7 +3714,7 @@ ATCE atcommand_broadcast(Session *, dumb_ptr<map_session_data> sd,
if (!message)
return ATCE::USAGE;
- AString output = STRPRINTF("%s : %s", sd->status.name, message);
+ AString output = STRPRINTF("%s : %s", sd->status_key.name, message);
intif_GMmessage(output);
return ATCE::OKAY;
@@ -3727,7 +3727,7 @@ ATCE atcommand_localbroadcast(Session *, dumb_ptr<map_session_data> sd,
if (!message)
return ATCE::USAGE;
- AString output = STRPRINTF("%s : %s", sd->status.name, message);
+ AString output = STRPRINTF("%s : %s", sd->status_key.name, message);
clif_GMmessage(sd, output, 1);
@@ -3766,7 +3766,7 @@ ATCE atcommand_email(Session *s, dumb_ptr<map_session_data> sd,
}
else
{
- chrif_changeemail(sd->status.account_id, actual_email, new_email);
+ chrif_changeemail(sd->status_key.account_id, actual_email, new_email);
clif_displaymessage(s, "Information sended to login-server via char-server.");
}
@@ -3837,7 +3837,7 @@ ATCE atcommand_character_item_list(Session *s, dumb_ptr<map_session_data> sd,
{
AString output = STRPRINTF(
"------ Items list of '%s' ------",
- pl_sd->status.name);
+ pl_sd->status_key.name);
clif_displaymessage(s, output);
}
EPOS equip = pl_sd->status.inventory[i].equip;
@@ -3976,7 +3976,7 @@ ATCE atcommand_character_storage_list(Session *s, dumb_ptr<map_session_data> sd,
if (pc_isGM(sd) >= pc_isGM(pl_sd))
{
// you can look items only lower or same level
- if ((stor = account2storage2(pl_sd->status.account_id)) != NULL)
+ if ((stor = account2storage2(pl_sd->status_key.account_id)) != NULL)
{
counter = 0;
count = 0;
@@ -3992,7 +3992,7 @@ ATCE atcommand_character_storage_list(Session *s, dumb_ptr<map_session_data> sd,
{
AString output = STRPRINTF(
"------ Storage items list of '%s' ------",
- pl_sd->status.name);
+ pl_sd->status_key.name);
clif_displaymessage(s, output);
}
AString output;
@@ -4110,7 +4110,7 @@ ATCE atcommand_character_cart_list(Session *s, dumb_ptr<map_session_data> sd,
{
AString output = STRPRINTF(
"------ Cart items list of '%s' ------",
- pl_sd->status.name);
+ pl_sd->status_key.name);
clif_displaymessage(s, output);
}
@@ -4618,7 +4618,7 @@ ATCE atcommand_adjgmlvl(Session *s, dumb_ptr<map_session_data>,
if (pl_sd == NULL)
return ATCE::EXIST;
- pc_set_gm_level(pl_sd->status.account_id, newlev);
+ pc_set_gm_level(pl_sd->status_key.account_id, newlev);
return ATCE::OKAY;
}
@@ -4776,7 +4776,7 @@ ATCE atcommand_tee(Session *, dumb_ptr<map_session_data> sd,
ZString message)
{
MString data;
- data += sd->status.name.to__actual();
+ data += sd->status_key.name.to__actual();
data += " : ";
data += message;
clif_message(sd, AString(data));
@@ -4836,7 +4836,7 @@ ATCE atcommand_jump_iterate(Session *s, dumb_ptr<map_session_data> sd,
return ATCE::PERM;
}
pc_setpos(sd, pl_sd->bl_m->name_, pl_sd->bl_x, pl_sd->bl_y, BeingRemoveWhy::WARPED);
- AString output = STRPRINTF("Jump to %s", pl_sd->status.name);
+ AString output = STRPRINTF("Jump to %s", pl_sd->status_key.name);
clif_displaymessage(s, output);
sd->followtarget = pl_sd->bl_id;
@@ -4863,7 +4863,7 @@ ATCE atcommand_wgm(Session *s, dumb_ptr<map_session_data> sd,
if (tmw_CheckChatSpam(sd, message))
return ATCE::OKAY;
- tmw_GmHackMsg(STRPRINTF("[GM] %s: %s", sd->status.name, message));
+ tmw_GmHackMsg(STRPRINTF("[GM] %s: %s", sd->status_key.name, message));
if (!pc_isGM(sd))
clif_displaymessage(s, "Message sent.");
@@ -5035,7 +5035,7 @@ ATCE atcommand_ipcheck(Session *s, dumb_ptr<map_session_data>,
{
AString output = STRPRINTF(
"Name: %s | Location: %s %d %d",
- pl_sd->status.name, pl_sd->mapname_,
+ pl_sd->status_key.name, pl_sd->mapname_,
pl_sd->bl_x, pl_sd->bl_y);
clif_displaymessage(s, output);
}
diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index 3830c0f..4d76dbd 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -2050,10 +2050,10 @@ ATK battle_weapon_attack(dumb_ptr<block_list> src, dumb_ptr<block_list> target,
weapon = sd->inventory_data[weapon_index]->nameid;
MAP_LOG("PC%d %s:%d,%d WPNDMG %s%d %d FOR %d WPN %d",
- sd->status.char_id, src->bl_m->name_, src->bl_x, src->bl_y,
+ sd->status_key.char_id, src->bl_m->name_, src->bl_x, src->bl_y,
(target->bl_type == BL::PC) ? "PC" : "MOB",
(target->bl_type == BL::PC)
- ? target->is_player()-> status.char_id
+ ? target->is_player()-> status_key.char_id
: target->bl_id,
battle_get_class(target),
wd.damage + wd.damage2, weapon);
@@ -2063,10 +2063,10 @@ ATK battle_weapon_attack(dumb_ptr<block_list> src, dumb_ptr<block_list> target,
{
dumb_ptr<map_session_data> sd2 = target->is_player();
MAP_LOG("PC%d %s:%d,%d WPNINJURY %s%d %d FOR %d",
- sd2->status.char_id, target->bl_m->name_, target->bl_x, target->bl_y,
+ sd2->status_key.char_id, target->bl_m->name_, target->bl_x, target->bl_y,
(src->bl_type == BL::PC) ? "PC" : "MOB",
(src->bl_type == BL::PC)
- ? src->is_player()->status.char_id
+ ? src->is_player()->status_key.char_id
: src->bl_id,
battle_get_class(src),
wd.damage + wd.damage2);
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index c49a101..a74e870 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -111,15 +111,16 @@ int chrif_save(dumb_ptr<map_session_data> sd)
pc_makesavestatus(sd);
WFIFOW(char_session, 0) = 0x2b01;
- WFIFOW(char_session, 2) = sizeof(sd->status) + 12;
+ WFIFOW(char_session, 2) = sizeof(sd->status_key) + sizeof(sd->status) + 12;
WFIFOL(char_session, 4) = sd->bl_id;
WFIFOL(char_session, 8) = sd->char_id;
- WFIFO_STRUCT(char_session, 12, sd->status);
+ WFIFO_STRUCT(char_session, 12, sd->status_key);
+ WFIFO_STRUCT(char_session, 12 + sizeof(sd->status_key), sd->status);
WFIFOSET(char_session, WFIFOW(char_session, 2));
//For data sync
if (sd->state.storage_open)
- storage_storage_save(sd->status.account_id, 0);
+ storage_storage_save(sd->status_key.account_id, 0);
return 0;
}
@@ -219,7 +220,7 @@ int chrif_changemapserver(dumb_ptr<map_session_data> sd,
WFIFOL(char_session, 2) = sd->bl_id;
WFIFOL(char_session, 6) = sd->login_id1;
WFIFOL(char_session, 10) = sd->login_id2;
- WFIFOL(char_session, 14) = sd->status.char_id;
+ WFIFOL(char_session, 14) = sd->status_key.char_id;
WFIFO_STRING(char_session, 18, name, 16);
WFIFOW(char_session, 34) = x;
WFIFOW(char_session, 36) = y;
@@ -241,14 +242,14 @@ int chrif_changemapserverack(Session *s)
{
dumb_ptr<map_session_data> sd = map_id2sd(RFIFOL(s, 2));
- if (sd == NULL || sd->status.char_id != RFIFOL(s, 14))
+ if (sd == NULL || sd->status_key.char_id != RFIFOL(s, 14))
return -1;
if (RFIFOL(s, 6) == 1)
{
if (battle_config.error_log)
PRINTF("map server change failed.\n");
- pc_authfail(sd->status.account_id);
+ pc_authfail(sd->status_key.account_id);
return 0;
}
MapName mapname = RFIFO_STRING<16>(s, 18);
@@ -939,7 +940,7 @@ void ladmin_itemfrob_c2(dumb_ptr<block_list> bl, int source_id, int dest_id)
case BL::PC:
{
dumb_ptr<map_session_data> pc = bl->is_player();
- struct storage *stor = account2storage2(pc->status.account_id);
+ struct storage *stor = account2storage2(pc->status_key.account_id);
int j;
for (j = 0; j < MAX_INVENTORY; j++)
@@ -1085,11 +1086,13 @@ void chrif_parse(Session *s)
int login_id2 = RFIFOL(s, 8);
TimeT connect_until_time = static_cast<time_t>(RFIFOL(s, 12));
short tmw_version = RFIFOW(s, 16);
- struct mmo_charstatus st {};
- RFIFO_STRUCT(s, 18, st);
+ CharKey st_key;
+ CharData st_data;
+ RFIFO_STRUCT(s, 18, st_key);
+ RFIFO_STRUCT(s, 18 + sizeof(st_key), st_data);
pc_authok(id, login_id2,
connect_until_time, tmw_version,
- &st);
+ &st_key, &st_data);
}
break;
case 0x2afe:
@@ -1168,7 +1171,7 @@ void send_users_tochar(TimerData *, tick_t)
|| sd->state.shroud_active
|| bool(sd->status.option & Option::HIDE)) && pc_isGM(sd)))
{
- WFIFOL(char_session, 6 + 4 * users) = sd->status.char_id;
+ WFIFOL(char_session, 6 + 4 * users) = sd->status_key.char_id;
users++;
}
}
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 5355192..70e9e1d 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -3069,7 +3069,7 @@ void clif_party_invite(dumb_ptr<map_session_data> sd,
return;
WFIFOW(s, 0) = 0xfe;
- WFIFOL(s, 2) = sd->status.account_id;
+ WFIFOL(s, 2) = sd->status_key.account_id;
WFIFO_STRING(s, 6, p->name, 24);
WFIFOSET(s, clif_parse_func_table[0xfe].len);
}
@@ -3212,12 +3212,12 @@ int clif_party_xy(struct party *, dumb_ptr<map_session_data> sd)
nullpo_ret(sd);
WBUFW(buf, 0) = 0x107;
- WBUFL(buf, 2) = sd->status.account_id;
+ WBUFL(buf, 2) = sd->status_key.account_id;
WBUFW(buf, 6) = sd->bl_x;
WBUFW(buf, 8) = sd->bl_y;
clif_send(buf, clif_parse_func_table[0x107].len, sd, SendWho::PARTY_SAMEMAP_WOS);
// if(battle_config.etc_log)
-// PRINTF("clif_party_xy %d\n",sd->status.account_id);
+// PRINTF("clif_party_xy %d\n",sd->status_key.account_id);
return 0;
}
@@ -3232,13 +3232,13 @@ int clif_party_hp(struct party *, dumb_ptr<map_session_data> sd)
nullpo_ret(sd);
WBUFW(buf, 0) = 0x106;
- WBUFL(buf, 2) = sd->status.account_id;
+ WBUFL(buf, 2) = sd->status_key.account_id;
WBUFW(buf, 6) = (sd->status.hp > 0x7fff) ? 0x7fff : sd->status.hp;
WBUFW(buf, 8) =
(sd->status.max_hp > 0x7fff) ? 0x7fff : sd->status.max_hp;
clif_send(buf, clif_parse_func_table[0x106].len, sd, SendWho::PARTY_AREA_WOS);
// if(battle_config.etc_log)
-// PRINTF("clif_party_hp %d\n",sd->status.account_id);
+// PRINTF("clif_party_hp %d\n",sd->status_key.account_id);
return 0;
}
@@ -3358,7 +3358,7 @@ int clif_GM_kick(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd,
nullpo_ret(tsd);
if (type)
- clif_GM_kickack(sd, tsd->status.account_id);
+ clif_GM_kickack(sd, tsd->status_key.account_id);
tsd->opt1 = Opt1::ZERO;
tsd->opt2 = Opt2::ZERO;
clif_parse_QuitGame(tsd->sess, tsd);
@@ -3679,7 +3679,7 @@ void clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> sd)
if (ssd->state.shroud_active)
WFIFO_STRING(s, 6, "", 24);
else
- WFIFO_STRING(s, 6, ssd->status.name.to__actual(), 24);
+ WFIFO_STRING(s, 6, ssd->status_key.name.to__actual(), 24);
WFIFOSET(s, clif_parse_func_table[0x95].len);
struct party *p = NULL;
@@ -4044,7 +4044,7 @@ void clif_parse_Wis(Session *s, dumb_ptr<map_session_data> sd)
*/
CharName tname = stringish<CharName>(RFIFO_STRING<24>(s, 4));
if (!(dstsd = map_nick2sd(tname))
- || dstsd->status.name != tname)
+ || dstsd->status_key.name != tname)
intif_wis_message(sd, tname, mbuf);
else
{
@@ -4059,7 +4059,7 @@ void clif_parse_Wis(Session *s, dumb_ptr<map_session_data> sd)
{
/* The player is not being ignored. */
{
- clif_wis_message(dstsd->sess, sd->status.name, mbuf);
+ clif_wis_message(dstsd->sess, sd->status_key.name, mbuf);
/* The whisper was sent successfully. */
clif_wis_end(s, 0);
}
@@ -5261,7 +5261,7 @@ int clif_check_packet_flood(Session *s, int cmd)
if (sd->packet_flood_in >= battle_config.packet_spam_flood)
{
- PRINTF("packet flood detected from %s [0x%x]\n", sd->status.name, cmd);
+ PRINTF("packet flood detected from %s [0x%x]\n", sd->status_key.name, cmd);
if (battle_config.packet_spam_kick)
{
s->eof = 1; // Kick
@@ -5281,7 +5281,7 @@ inline
void WARN_MALFORMED_MSG(dumb_ptr<map_session_data> sd, const char *msg)
{
PRINTF("clif_validate_chat(): %s (ID %d) sent a malformed message: %s.\n",
- sd->status.name, sd->status.account_id, msg);
+ sd->status_key.name, sd->status_key.account_id, msg);
}
/**
* Validate message integrity (inspired by upstream source (eAthena)).
@@ -5306,7 +5306,7 @@ AString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type)
Session *s = sd->sess;
size_t msg_len = RFIFOW(s, 2) - 4;
- size_t name_len = sd->status.name.to__actual().size();
+ size_t name_len = sd->status_key.name.to__actual().size();
/*
* At least one character is required in all instances.
* Notes for length checks:
@@ -5370,7 +5370,7 @@ AString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type)
if (type == ChatType::Global)
{
XString p = pbuf;
- if (!(p.startswith(sd->status.name.to__actual()) && p.xslice_t(name_len).startswith(" : ")))
+ if (!(p.startswith(sd->status_key.name.to__actual()) && p.xslice_t(name_len).startswith(" : ")))
{
/* Disallow malformed/spoofed messages. */
clif_setwaitclose(s);
@@ -5416,7 +5416,7 @@ void clif_parse(Session *s)
pc_logout(sd);
clif_quitsave(s, sd);
- PRINTF("Player [%s] has logged off your server.\n", sd->status.name); // Player logout display [Valaris]
+ PRINTF("Player [%s] has logged off your server.\n", sd->status_key.name); // Player logout display [Valaris]
}
else if (sd)
{ // not authentified! (refused by char-server or disconnect before to be authentified)
@@ -5511,8 +5511,8 @@ void clif_parse(Session *s)
if (sd && sd->state.auth)
{
PRINTF("\nAccount ID %d, character ID %d, player name %s.\n",
- sd->status.account_id, sd->status.char_id,
- sd->status.name);
+ sd->status_key.account_id, sd->status_key.char_id,
+ sd->status_key.name);
}
else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
PRINTF("\nAccount ID %d.\n", sd->bl_id);
@@ -5533,8 +5533,8 @@ void clif_parse(Session *s)
FPRINTF(fp,
"%s\nPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
now,
- sd->status.account_id,
- sd->status.char_id, sd->status.name);
+ sd->status_key.account_id,
+ sd->status_key.char_id, sd->status_key.name);
}
else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
FPRINTF(fp,
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index e994bdb..5c6c46a 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -58,14 +58,14 @@ void intif_wis_message(dumb_ptr<map_session_data> sd, CharName nick, ZString mes
size_t mes_len = mes.size() + 1;
WFIFOW(char_session, 0) = 0x3001;
WFIFOW(char_session, 2) = mes_len + 52;
- WFIFO_STRING(char_session, 4, sd->status.name.to__actual(), 24);
+ WFIFO_STRING(char_session, 4, sd->status_key.name.to__actual(), 24);
WFIFO_STRING(char_session, 28, nick.to__actual(), 24);
WFIFO_STRING(char_session, 52, mes, mes_len);
WFIFOSET(char_session, WFIFOW(char_session, 2));
if (battle_config.etc_log)
PRINTF("intif_wis_message from %s to %s)\n",
- sd->status.name, nick);
+ sd->status_key.name, nick);
}
// The reply of Wisp/page
@@ -150,9 +150,9 @@ void intif_create_party(dumb_ptr<map_session_data> sd, PartyName name)
nullpo_retv(sd);
WFIFOW(char_session, 0) = 0x3020;
- WFIFOL(char_session, 2) = sd->status.account_id;
+ WFIFOL(char_session, 2) = sd->status_key.account_id;
WFIFO_STRING(char_session, 6, name, 24);
- WFIFO_STRING(char_session, 30, sd->status.name.to__actual(), 24);
+ WFIFO_STRING(char_session, 30, sd->status_key.name.to__actual(), 24);
WFIFO_STRING(char_session, 54, sd->bl_m->name_, 16);
WFIFOW(char_session, 70) = sd->status.base_level;
WFIFOSET(char_session, 72);
@@ -176,7 +176,7 @@ void intif_party_addmember(int party_id, int account_id)
WFIFOW(char_session, 0) = 0x3022;
WFIFOL(char_session, 2) = party_id;
WFIFOL(char_session, 6) = account_id;
- WFIFO_STRING(char_session, 10, sd->status.name.to__actual(), 24);
+ WFIFO_STRING(char_session, 10, sd->status_key.name.to__actual(), 24);
WFIFO_STRING(char_session, 34, sd->bl_m->name_, 16);
WFIFOW(char_session, 50) = sd->status.base_level;
WFIFOSET(char_session, 52);
@@ -210,7 +210,7 @@ void intif_party_changemap(dumb_ptr<map_session_data> sd, int online)
{
WFIFOW(char_session, 0) = 0x3025;
WFIFOL(char_session, 2) = sd->status.party_id;
- WFIFOL(char_session, 6) = sd->status.account_id;
+ WFIFOL(char_session, 6) = sd->status_key.account_id;
WFIFO_STRING(char_session, 10, sd->bl_m->name_, 16);
WFIFOB(char_session, 26) = online;
WFIFOW(char_session, 27) = sd->status.base_level;
@@ -264,7 +264,7 @@ int intif_parse_WisMessage(Session *s)
to);
}
sd = map_nick2sd(to); // Searching destination player
- if (sd != NULL && sd->status.name == to)
+ if (sd != NULL && sd->status_key.name == to)
{
// exactly same name (inter-server have checked the name before)
{
@@ -369,14 +369,14 @@ int intif_parse_LoadStorage(Session *s)
{ // Already open.. lets ignore this update
if (battle_config.error_log)
PRINTF("intif_parse_LoadStorage: storage received for a client already open (User %d:%d)\n",
- sd->status.account_id, sd->status.char_id);
+ sd->status_key.account_id, sd->status_key.char_id);
return 1;
}
if (stor->dirty)
{ // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex]
if (battle_config.error_log)
PRINTF("intif_parse_LoadStorage: received storage for an already modified non-saved storage! (User %d:%d)\n",
- sd->status.account_id, sd->status.char_id);
+ sd->status_key.account_id, sd->status_key.char_id);
return 1;
}
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index 1628395..65cd35b 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -98,7 +98,7 @@ AString show_entity(dumb_ptr<block_list> entity)
switch (entity->bl_type)
{
case BL::PC:
- return entity->is_player()->status.name.to__actual();
+ return entity->is_player()->status_key.name.to__actual();
case BL::NPC:
return entity->is_npc()->name;
case BL::MOB:
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index 7ca718b..a71f43c 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -328,7 +328,7 @@ int op_instaheal(dumb_ptr<env_t> env, const_array<val_t> args)
dumb_ptr<map_session_data> caster_pc = caster->is_player();
dumb_ptr<map_session_data> subject_pc = subject->is_player();
MAP_LOG_PC(caster_pc, "SPELLHEAL-INSTA PC%d FOR %d",
- subject_pc->status.char_id, ARGINT(1));
+ subject_pc->status_key.char_id, ARGINT(1));
}
battle_heal(caster, subject, ARGINT(1), ARGINT(2), 0);
@@ -1438,7 +1438,7 @@ interval_t spell_run(dumb_ptr<invocation> invocation_, int allow_delete)
if (caster)
{
dumb_ptr<env_t> env = invocation_->env;
- ZString caster_name = (caster ? caster->status.name : CharName()).to__actual();
+ ZString caster_name = (caster ? caster->status_key.name : CharName()).to__actual();
argrec_t arg[3] =
{
{"@target", env->VAR(VAR_TARGET).ty == TYPE::ENTITY ? 0 : env->VAR(VAR_TARGET).v.v_int},
diff --git a/src/map/map.cpp b/src/map/map.cpp
index a063d2b..4fa511a 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -795,7 +795,7 @@ void map_addnickdb(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- nick_db.put(sd->status.name, sd);
+ nick_db.put(sd->status_key.name, sd);
}
/*==========================================
@@ -846,8 +846,8 @@ void map_quit(dumb_ptr<map_session_data> sd)
map_delblock(sd);
id_db.put(sd->bl_id, nullptr);
- nick_db.put(sd->status.name, nullptr);
- charid_db.erase(sd->status.char_id);
+ nick_db.put(sd->status_key.name, nullptr);
+ charid_db.erase(sd->status_key.char_id);
}
/*==========================================
@@ -984,7 +984,7 @@ dumb_ptr<map_session_data> map_nick2sd(CharName nick)
if (pl_sd && pl_sd->state.auth)
{
{
- if (pl_sd->status.name == nick)
+ if (pl_sd->status_key.name == nick)
return dumb_ptr<map_session_data>(pl_sd);
}
}
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 685feed..ad5adcf 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -170,7 +170,8 @@ struct map_session_data : block_list, SessionData
int char_id, login_id1, login_id2;
SEX sex;
unsigned char tmw_version; // tmw client version
- struct mmo_charstatus status;
+ CharKey status_key;
+ CharData status;
struct item_data *inventory_data[MAX_INVENTORY];
earray<short, EQUIP, EQUIP::COUNT> equip_index;
int weight, max_weight;
@@ -605,7 +606,7 @@ void map_log(XString line);
# define MAP_LOG_PC(sd, fmt, ...) \
MAP_LOG("PC%d %s:%d,%d " fmt, \
- sd->status.char_id, (sd->bl_m ? sd->bl_m->name_ : stringish<MapName>("undefined.gat")), sd->bl_x, sd->bl_y, ## __VA_ARGS__)
+ sd->status_key.char_id, (sd->bl_m ? sd->bl_m->name_ : stringish<MapName>("undefined.gat")), sd->bl_x, sd->bl_y, ## __VA_ARGS__)
// 床アイテム関連
void map_clearflooritem_timer(TimerData *, tick_t, int);
diff --git a/src/map/party.cpp b/src/map/party.cpp
index b2ce340..f7b8396 100644
--- a/src/map/party.cpp
+++ b/src/map/party.cpp
@@ -139,9 +139,9 @@ int party_check_member(struct party *p)
int j, f = 1;
for (j = 0; j < MAX_PARTY; j++)
{ // パーティにデータがあるか確認
- if (p->member[j].account_id == sd->status.account_id)
+ if (p->member[j].account_id == sd->status_key.account_id)
{
- if (p->member[j].name == sd->status.name)
+ if (p->member[j].name == sd->status_key.name)
f = 0; // データがある
else
{
@@ -155,7 +155,7 @@ int party_check_member(struct party *p)
sd->status.party_id = 0;
if (battle_config.error_log)
PRINTF("party: check_member %d[%s] is not member\n",
- sd->status.account_id, sd->status.name);
+ sd->status_key.account_id, sd->status_key.name);
}
}
}
@@ -242,7 +242,7 @@ int party_invite(dumb_ptr<map_session_data> sd, int account_id)
if (tsd->trade_partner || tsd->npc_id
|| tsd->npc_shopid || pc_checkskill(tsd, SkillID::NV_PARTY) < 1)
{
- clif_party_inviteack(sd, tsd->status.name, 1);
+ clif_party_inviteack(sd, tsd->status_key.name, 1);
return 0;
}
}
@@ -250,7 +250,7 @@ int party_invite(dumb_ptr<map_session_data> sd, int account_id)
/* The target player is already in a party, or has a pending invitation. */
if (tsd->status.party_id > 0 || tsd->party_invite > 0)
{
- clif_party_inviteack(sd, tsd->status.name, 0);
+ clif_party_inviteack(sd, tsd->status_key.name, 0);
return 0;
}
@@ -264,7 +264,7 @@ int party_invite(dumb_ptr<map_session_data> sd, int account_id)
*/
if (p->member[i].account_id == account_id)
{
- clif_party_inviteack(sd, tsd->status.name, 1);
+ clif_party_inviteack(sd, tsd->status_key.name, 1);
return 0;
}
@@ -275,13 +275,13 @@ int party_invite(dumb_ptr<map_session_data> sd, int account_id)
/* There isn't enough room for a new member. */
if (full)
{
- clif_party_inviteack(sd, tsd->status.name, 3);
+ clif_party_inviteack(sd, tsd->status_key.name, 3);
return 0;
}
/* Otherwise, relay the invitation to the target player. */
tsd->party_invite = sd->status.party_id;
- tsd->party_invite_account = sd->status.account_id;
+ tsd->party_invite_account = sd->status_key.account_id;
clif_party_invite(sd, tsd);
return 0;
@@ -305,7 +305,7 @@ int party_reply_invite(dumb_ptr<map_session_data> sd, int account_id, int flag)
/* The invitation was accepted. */
if (flag == 1)
- intif_party_addmember(sd->party_invite, sd->status.account_id);
+ intif_party_addmember(sd->party_invite, sd->status_key.account_id);
/* The invitation was rejected. */
else
{
@@ -316,7 +316,7 @@ int party_reply_invite(dumb_ptr<map_session_data> sd, int account_id, int flag)
sd->party_invite_account = 0;
if ((tsd = map_id2sd(account_id)))
- clif_party_inviteack(tsd, sd->status.name, 1);
+ clif_party_inviteack(tsd, sd->status_key.name, 1);
}
return 0;
}
@@ -352,7 +352,7 @@ int party_member_added(int party_id, int account_id, int flag)
if (flag == 1)
{ // 失敗
if (sd2 != NULL)
- clif_party_inviteack(sd2, sd->status.name, 0);
+ clif_party_inviteack(sd2, sd->status_key.name, 0);
return 0;
}
@@ -361,7 +361,7 @@ int party_member_added(int party_id, int account_id, int flag)
sd->status.party_id = party_id;
if (sd2 != NULL)
- clif_party_inviteack(sd2, sd->status.name, 2);
+ clif_party_inviteack(sd2, sd->status_key.name, 2);
// いちおう競合確認
party_check_conflict(sd);
@@ -384,7 +384,7 @@ int party_removemember(dumb_ptr<map_session_data> sd, int account_id)
for (i = 0; i < MAX_PARTY; i++)
{ // リーダーかどうかチェック
- if (p->member[i].account_id == sd->status.account_id)
+ if (p->member[i].account_id == sd->status_key.account_id)
if (p->member[i].leader == 0)
return 0;
}
@@ -413,9 +413,9 @@ int party_leave(dumb_ptr<map_session_data> sd)
for (i = 0; i < MAX_PARTY; i++)
{ // 所属しているか
- if (p->member[i].account_id == sd->status.account_id)
+ if (p->member[i].account_id == sd->status_key.account_id)
{
- intif_party_leave(p->party_id, sd->status.account_id);
+ intif_party_leave(p->party_id, sd->status_key.account_id);
return 0;
}
}
@@ -479,7 +479,7 @@ int party_changeoption(dumb_ptr<map_session_data> sd, int exp, int item)
if (sd->status.party_id == 0
|| (p = party_search(sd->status.party_id)) == NULL)
return 0;
- intif_party_changeoption(sd->status.party_id, sd->status.account_id, exp,
+ intif_party_changeoption(sd->status.party_id, sd->status_key.account_id, exp,
item);
return 0;
}
@@ -604,7 +604,7 @@ void party_send_message(dumb_ptr<map_session_data> sd, XString mes)
{
if (sd->status.party_id == 0)
return;
- intif_party_message(sd->status.party_id, sd->status.account_id, mes);
+ intif_party_message(sd->status.party_id, sd->status_key.account_id, mes);
}
// パーティメッセージ受信
@@ -622,7 +622,7 @@ void party_check_conflict(dumb_ptr<map_session_data> sd)
nullpo_retv(sd);
intif_party_checkconflict(sd->status.party_id,
- sd->status.account_id, sd->status.name);
+ sd->status_key.account_id, sd->status_key.name);
}
// 位置やHP通知用
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index f8f9dc8..8ff5a01 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -243,7 +243,7 @@ uint8_t pc_isGM(dumb_ptr<map_session_data> sd)
{
nullpo_ret(sd);
- auto it = gm_accountm.find(sd->status.account_id);
+ auto it = gm_accountm.find(sd->status_key.account_id);
if (it != gm_accountm.end())
return it->second;
return 0;
@@ -606,7 +606,7 @@ int pc_isequip(dumb_ptr<map_session_data> sd, int n)
*------------------------------------------
*/
int pc_authok(int id, int login_id2, TimeT connect_until_time,
- short tmw_version, const struct mmo_charstatus *st)
+ short tmw_version, const CharKey *st_key, const CharData *st_data)
{
dumb_ptr<map_session_data> sd = NULL;
@@ -620,7 +620,8 @@ int pc_authok(int id, int login_id2, TimeT connect_until_time,
sd->login_id2 = login_id2;
sd->tmw_version = tmw_version;
- sd->status = *st;
+ sd->status_key = *st_key;
+ sd->status = *st_data;
if (sd->status.sex != sd->sex)
{
@@ -727,8 +728,8 @@ int pc_authok(int id, int login_id2, TimeT connect_until_time,
clif_authok(sd);
map_addnickdb(sd);
- if (!map_charid2nick(sd->status.char_id).to__actual())
- map_addchariddb(sd->status.char_id, sd->status.name);
+ if (!map_charid2nick(sd->status_key.char_id).to__actual())
+ map_addchariddb(sd->status_key.char_id, sd->status_key.name);
//スパノビ用死にカウンターのスクリプト変数からの読み出しとsdへのセット
sd->die_counter = pc_readglobalreg(sd, stringish<VarName>("PC_DIE_COUNTER"));
@@ -739,12 +740,12 @@ int pc_authok(int id, int login_id2, TimeT connect_until_time,
if (pc_isGM(sd))
{
PRINTF("Connection accepted: character '%s' (account: %d; GM level %d).\n",
- sd->status.name, sd->status.account_id, pc_isGM(sd));
+ sd->status_key.name, sd->status_key.account_id, pc_isGM(sd));
clif_updatestatus(sd, SP::GM);
}
else
PRINTF("Connection accepted: Character '%s' (account: %d).\n",
- sd->status.name, sd->status.account_id);
+ sd->status_key.name, sd->status_key.account_id);
sd->auto_ban_info.in_progress = 0;
@@ -2148,7 +2149,7 @@ int can_pick_item_up_from(dumb_ptr<map_session_data> self, int other_id)
return 1;
/* From our partner? */
- if (self->status.partner_id == other->status.char_id)
+ if (self->status.partner_id == other->status_key.char_id)
return 1;
/* From a party member? */
@@ -3442,7 +3443,7 @@ int pc_damage(dumb_ptr<block_list> src, dumb_ptr<map_session_data> sd,
if (src->bl_type == BL::PC)
{
MAP_LOG_PC(sd, "INJURED-BY PC%d FOR %d",
- src->is_player()->status.char_id,
+ src->is_player()->status_key.char_id,
damage);
}
else
@@ -4837,8 +4838,8 @@ int pc_marriage(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> dstsd)
if (sd == NULL || dstsd == NULL || sd->status.partner_id > 0
|| dstsd->status.partner_id > 0)
return -1;
- sd->status.partner_id = dstsd->status.char_id;
- dstsd->status.partner_id = sd->status.char_id;
+ sd->status.partner_id = dstsd->status_key.char_id;
+ dstsd->status.partner_id = sd->status_key.char_id;
return 0;
}
@@ -4856,8 +4857,8 @@ int pc_divorce(dumb_ptr<map_session_data> sd)
if ((p_sd =
map_nick2sd(map_charid2nick(sd->status.partner_id))) != NULL)
{
- if (p_sd->status.partner_id != sd->status.char_id
- || sd->status.partner_id != p_sd->status.char_id)
+ if (p_sd->status.partner_id != sd->status_key.char_id
+ || sd->status.partner_id != p_sd->status_key.char_id)
{
PRINTF("pc_divorce: Illegal partner_id sd=%d p_sd=%d\n",
sd->status.partner_id, p_sd->status.partner_id);
@@ -4873,7 +4874,7 @@ int pc_divorce(dumb_ptr<map_session_data> sd)
}
}
else
- chrif_send_divorce(sd->status.char_id);
+ chrif_send_divorce(sd->status_key.char_id);
return 0;
}
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index be66cc4..df612d8 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -53,7 +53,7 @@ int pc_counttargeted(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> src,
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, SEX);
-int pc_authok(int, int, TimeT, short tmw_version, const struct mmo_charstatus *);
+int pc_authok(int, int, TimeT, short tmw_version, const CharKey *, const CharData *);
int pc_authfail(int accid);
EPOS pc_equippoint(dumb_ptr<map_session_data> sd, int n);
diff --git a/src/map/script.cpp b/src/map/script.cpp
index d13bb05..6fe965c 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -2112,13 +2112,13 @@ void builtin_getcharid(ScriptState *st)
return;
}
if (num == 0)
- push_int(st->stack, ByteCode::INT, sd->status.char_id);
+ push_int(st->stack, ByteCode::INT, sd->status_key.char_id);
if (num == 1)
push_int(st->stack, ByteCode::INT, sd->status.party_id);
if (num == 2)
push_int(st->stack, ByteCode::INT, 0/*guild_id*/);
if (num == 3)
- push_int(st->stack, ByteCode::INT, sd->status.account_id);
+ push_int(st->stack, ByteCode::INT, sd->status_key.account_id);
}
/*==========================================
@@ -2150,7 +2150,7 @@ void builtin_strcharinfo(ScriptState *st)
num = conv_num(st, &AARGO2(2));
if (num == 0)
{
- dumb_string buf = dumb_string::copys(sd->status.name.to__actual());
+ dumb_string buf = dumb_string::copys(sd->status_key.name.to__actual());
push_str(st->stack, ByteCode::STR, buf);
}
if (num == 1)
@@ -3105,7 +3105,7 @@ void builtin_changesex(ScriptState *st)
dumb_ptr<map_session_data> sd = NULL;
sd = script_rid2sd(st);
- chrif_char_ask_name(-1, sd->status.name, 5, HumanTimeDiff()); // type: 5 - changesex
+ chrif_char_ask_name(-1, sd->status_key.name, 5, HumanTimeDiff()); // type: 5 - changesex
chrif_save(sd);
}
diff --git a/src/map/storage.cpp b/src/map/storage.cpp
index d6832c8..b753c0d 100644
--- a/src/map/storage.cpp
+++ b/src/map/storage.cpp
@@ -60,10 +60,10 @@ int storage_storageopen(dumb_ptr<map_session_data> sd)
if (sd->state.storage_open)
return 1; //Already open?
- struct storage *stor = storage_db.search(sd->status.account_id);
+ struct storage *stor = storage_db.search(sd->status_key.account_id);
if (stor == NULL)
{ //Request storage.
- intif_request_storage(sd->status.account_id);
+ intif_request_storage(sd->status_key.account_id);
return 1;
}
@@ -158,7 +158,7 @@ int storage_storageadd(dumb_ptr<map_session_data> sd, int index, int amount)
struct storage *stor;
nullpo_ret(sd);
- stor = account2storage2(sd->status.account_id);
+ stor = account2storage2(sd->status_key.account_id);
nullpo_ret(stor);
if ((stor->storage_amount > MAX_STORAGE) || !stor->storage_status)
@@ -194,7 +194,7 @@ int storage_storageget(dumb_ptr<map_session_data> sd, int index, int amount)
PickupFail flag;
nullpo_ret(sd);
- stor = account2storage2(sd->status.account_id);
+ stor = account2storage2(sd->status_key.account_id);
nullpo_ret(stor);
if (index < 0 || index >= MAX_STORAGE)
@@ -223,7 +223,7 @@ int storage_storageclose(dumb_ptr<map_session_data> sd)
struct storage *stor;
nullpo_ret(sd);
- stor = account2storage2(sd->status.account_id);
+ stor = account2storage2(sd->status_key.account_id);
nullpo_ret(stor);
clif_storageclose(sd);
@@ -232,7 +232,7 @@ int storage_storageclose(dumb_ptr<map_session_data> sd)
if (save_settings & 4)
chrif_save(sd); //Invokes the storage saving as well.
else
- storage_storage_save(sd->status.account_id, 0);
+ storage_storage_save(sd->status_key.account_id, 0);
}
stor->storage_status = 0;
sd->state.storage_open = 0;
@@ -256,7 +256,7 @@ int storage_storage_quit(dumb_ptr<map_session_data> sd)
nullpo_ret(sd);
- stor = account2storage2(sd->status.account_id);
+ stor = account2storage2(sd->status_key.account_id);
if (stor)
{
chrif_save(sd); //Invokes the storage saving as well.
diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp
index 72cfa2b..16276fa 100644
--- a/src/map/tmw.cpp
+++ b/src/map/tmw.cpp
@@ -96,12 +96,12 @@ void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length)
sd->auto_ban_info.in_progress = 1;
AString hack_msg = STRPRINTF("[GM] %s has been autobanned for %s spam",
- sd->status.name,
+ sd->status_key.name,
reason);
tmw_GmHackMsg(hack_msg);
AString fake_command = STRPRINTF("@autoban %s %dh (%s spam)",
- sd->status.name, length, reason);
+ sd->status_key.name, length, reason);
log_atcommand(sd, fake_command);
AString anotherbuf = STRPRINTF("You have been banned for %s spamming. Please do not spam.",
@@ -111,7 +111,7 @@ void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length)
/* type: 2 - ban(year, month, day, hour, minute, second) */
HumanTimeDiff ban_len {};
ban_len.hour = length;
- chrif_char_ask_name(-1, sd->status.name, 2, ban_len);
+ chrif_char_ask_name(-1, sd->status_key.name, 2, ban_len);
clif_setwaitclose(sd->sess);
}
diff --git a/src/map/trade.cpp b/src/map/trade.cpp
index 7fc01ae..9626191 100644
--- a/src/map/trade.cpp
+++ b/src/map/trade.cpp
@@ -56,9 +56,9 @@ void trade_traderequest(dumb_ptr<map_session_data> sd, int target_id)
}
else if (sd != target_sd)
{
- target_sd->trade_partner = sd->status.account_id;
- sd->trade_partner = target_sd->status.account_id;
- clif_traderequest(target_sd, sd->status.name);
+ target_sd->trade_partner = sd->status_key.account_id;
+ sd->trade_partner = target_sd->status_key.account_id;
+ clif_traderequest(target_sd, sd->status_key.name);
}
}
}
@@ -326,7 +326,7 @@ void trade_tradecommit(dumb_ptr<map_session_data> sd)
if ((target_sd = map_id2sd(sd->trade_partner)) != NULL)
{
MAP_LOG_PC(sd, " TRADECOMMIT WITH %d GIVE %d GET %d",
- target_sd->status.char_id, sd->deal_zeny,
+ target_sd->status_key.char_id, sd->deal_zeny,
target_sd->deal_zeny);
if ((sd->deal_locked >= 1) && (target_sd->deal_locked >= 1))
{ // both have pressed 'ok'