summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-02-04 23:18:54 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-02-06 11:18:37 -0800
commit9215c35975be745628e8188473154c7e476add55 (patch)
tree14d4f5d51381f8a59803233c24dfafc846ddf583 /src/map
parent9544985ccbb20d7f8377c63a4e59d1ff97b844ac (diff)
downloadtmwa-9215c35975be745628e8188473154c7e476add55.tar.gz
tmwa-9215c35975be745628e8188473154c7e476add55.tar.bz2
tmwa-9215c35975be745628e8188473154c7e476add55.tar.xz
tmwa-9215c35975be745628e8188473154c7e476add55.zip
Wrap remaining FDs in a class
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.cpp82
-rw-r--r--src/map/chrif.cpp25
-rw-r--r--src/map/clif.cpp33
-rw-r--r--src/map/intif.cpp4
-rw-r--r--src/map/map.cpp43
-rw-r--r--src/map/mob.cpp7
-rw-r--r--src/map/party.cpp14
-rw-r--r--src/map/pc.cpp4
-rw-r--r--src/map/script.cpp14
9 files changed, 118 insertions, 108 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 931a4d0..f5deab8 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -715,9 +715,9 @@ ATCE atcommand_who(Session *s, dumb_ptr<map_session_data> sd,
count = 0;
GM_level = pc_isGM(sd);
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -778,9 +778,9 @@ ATCE atcommand_whogroup(Session *s, dumb_ptr<map_session_data> sd,
count = 0;
GM_level = pc_isGM(sd);
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -842,9 +842,9 @@ ATCE atcommand_whomap(Session *s, dumb_ptr<map_session_data> sd,
count = 0;
GM_level = pc_isGM(sd);
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -903,9 +903,9 @@ ATCE atcommand_whomapgroup(Session *s, dumb_ptr<map_session_data> sd,
count = 0;
GM_level = pc_isGM(sd);
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -963,9 +963,9 @@ ATCE atcommand_whogm(Session *s, dumb_ptr<map_session_data> sd,
count = 0;
GM_level = pc_isGM(sd);
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -1522,9 +1522,9 @@ ATCE atcommand_pvpoff(Session *s, dumb_ptr<map_session_data> sd,
if (sd->bl_m->flag.pvp)
{
sd->bl_m->flag.pvp = 0;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -1561,9 +1561,9 @@ ATCE atcommand_pvpon(Session *s, dumb_ptr<map_session_data> sd,
if (!sd->bl_m->flag.pvp && !sd->bl_m->flag.nopvp)
{
sd->bl_m->flag.pvp = 1;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -2155,9 +2155,9 @@ ATCE atcommand_character_stats_all(Session *s, dumb_ptr<map_session_data>,
int count;
count = 0;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -2395,9 +2395,9 @@ static
ATCE atcommand_doom(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -2419,9 +2419,9 @@ static
ATCE atcommand_doommap(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -2458,9 +2458,9 @@ static
ATCE atcommand_raise(Session *s, dumb_ptr<map_session_data>,
ZString)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -2475,9 +2475,9 @@ static
ATCE atcommand_raisemap(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -2687,9 +2687,9 @@ static
ATCE atcommand_kickall(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -2905,9 +2905,9 @@ static
ATCE atcommand_mapexit(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -3318,9 +3318,9 @@ ATCE atcommand_recallall(Session *s, dumb_ptr<map_session_data> sd,
}
count = 0;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -3374,9 +3374,9 @@ ATCE atcommand_partyrecall(Session *s, dumb_ptr<map_session_data> sd,
(p = party_search(atoi(message.c_str()))) != NULL)
{
count = 0;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -3475,9 +3475,9 @@ ATCE atcommand_mapinfo(Session *s, dumb_ptr<map_session_data> sd,
break;
case 1:
clif_displaymessage(s, "----- Players in Map -----");
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -3486,7 +3486,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, i, pl_sd->bl_x, pl_sd->bl_y);
+ pl_sd->status.name, s2, pl_sd->bl_x, pl_sd->bl_y);
clif_displaymessage(s, output);
}
}
@@ -3797,9 +3797,9 @@ ATCE atcommand_effect(Session *s, dumb_ptr<map_session_data> sd,
}
else
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -5031,9 +5031,9 @@ ATCE atcommand_ipcheck(Session *s, dumb_ptr<map_session_data>,
// We now have the IP address of a character.
// Loop over all logged in sessions looking for matches.
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
@@ -5059,9 +5059,9 @@ static
ATCE atcommand_doomspot(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 959186c..ab67b5c 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -202,15 +202,15 @@ int chrif_changemapserver(dumb_ptr<map_session_data> sd,
nullpo_retr(-1, sd);
IP4Address s_ip;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s = session[i].get();
+ Session *s = get_session(i);
if (!s)
continue;
if (dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get())) == sd)
{
assert (s == sd->sess);
- s_ip = session[i]->client_ip;
+ s_ip = s->client_ip;
break;
}
}
@@ -321,12 +321,12 @@ int chrif_authreq(dumb_ptr<map_session_data> sd)
if (!sd || !char_session || !sd->bl_id || !sd->login_id1)
return -1;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s = session[i].get();
+ Session *s = get_session(i);
if (!s)
continue;
- if (dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get())) == sd)
+ if (dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get())) == sd)
{
assert (s == sd->sess);
WFIFOW(char_session, 0) = 0x2afc;
@@ -334,7 +334,7 @@ int chrif_authreq(dumb_ptr<map_session_data> sd)
WFIFOL(char_session, 6) = sd->char_id;
WFIFOL(char_session, 10) = sd->login_id1;
WFIFOL(char_session, 14) = sd->login_id2;
- WFIFOIP(char_session, 18) = session[i]->client_ip;
+ WFIFOIP(char_session, 18) = s->client_ip;
WFIFOSET(char_session, 22);
break;
}
@@ -355,9 +355,9 @@ int chrif_charselectreq(dumb_ptr<map_session_data> sd)
return -1;
IP4Address s_ip;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s = session[i].get();
+ Session *s = get_session(i);
if (!s)
continue;
if (dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get())) == sd)
@@ -1157,11 +1157,12 @@ void send_users_tochar(TimerData *, tick_t)
return;
WFIFOW(char_session, 0) = 0x2aff;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (sd && sd->state.auth &&
!((battle_config.hide_GM_session
|| sd->state.shroud_active
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 0429600..61c47d9 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -165,11 +165,12 @@ int clif_countusers(void)
{
int users = 0;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (sd && sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd)))
users++;
}
@@ -182,11 +183,12 @@ int clif_countusers(void)
*/
int clif_foreachclient(std::function<void (dumb_ptr<map_session_data>)> func)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (sd && sd->state.auth)
func(sd);
}
@@ -302,9 +304,9 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
switch (type)
{
case SendWho::ALL_CLIENT: // 全クライアントに送信
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s = session[i].get();
+ Session *s = get_session(i);
if (!s)
continue;
dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
@@ -320,9 +322,9 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
}
break;
case SendWho::ALL_SAMEMAP: // 同じマップの全クライアントに送信
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s = session[i].get();
+ Session *s = get_session(i);
if (!s)
continue;
dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
@@ -402,9 +404,9 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
}
}
}
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s = session[i].get();
+ Session *s = get_session(i);
if (!s)
continue;
dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
@@ -3379,11 +3381,12 @@ int clif_specialeffect(dumb_ptr<block_list> bl, int type, int flag)
if (flag == 2)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (sd && sd->state.auth && sd->bl_m == bl->bl_m)
clif_specialeffect(sd, type, 1);
}
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index 006be1c..7d699dd 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -315,9 +315,9 @@ void mapif_parse_WisToGM(Session *s)
CharName Wisp_name = stringish<CharName>(RFIFO_STRING<24>(s, 4));
FString message = RFIFO_STRING(s, 30, len);
// information is sended to all online GM
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- Session *s2 = session[i].get();
+ Session *s2 = get_session(i);
if (!s2)
continue;
dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 3817422..2600412 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -871,13 +871,14 @@ dumb_ptr<map_session_data> map_id2sd(int id)
return (struct map_session_data*)bl;
return NULL;
*/
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- if (session[i]->session_data)
+ if (s->session_data)
{
- map_session_data *sd = static_cast<map_session_data *>(session[i]->session_data.get());
+ map_session_data *sd = static_cast<map_session_data *>(s->session_data.get());
if (sd->bl_id == id)
return dumb_ptr<map_session_data>(sd);
}
@@ -905,13 +906,13 @@ CharName map_charid2nick(int id)
/* [Fate] Operations to iterate over active map sessions */
static
-dumb_ptr<map_session_data> map_get_session(int i)
+dumb_ptr<map_session_data> map_get_session(io::FD i)
{
- if (i >= 0 && i < fd_max)
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
return nullptr;
- map_session_data *d = static_cast<map_session_data *>(session[i]->session_data.get());
+ map_session_data *d = static_cast<map_session_data *>(s->session_data.get());
if (d && d->state.auth)
return dumb_ptr<map_session_data>(d);
}
@@ -922,9 +923,9 @@ dumb_ptr<map_session_data> map_get_session(int i)
static
dumb_ptr<map_session_data> map_get_session_forward(int start)
{
- for (int i = start; i < fd_max; i++)
+ for (int i = start; i < get_fd_max(); i++)
{
- dumb_ptr<map_session_data> d = map_get_session(i);
+ dumb_ptr<map_session_data> d = map_get_session(io::FD::cast_dammit(i));
if (d)
return d;
}
@@ -935,10 +936,9 @@ dumb_ptr<map_session_data> map_get_session_forward(int start)
static
dumb_ptr<map_session_data> map_get_session_backward(int start)
{
- int i;
- for (i = start; i >= 0; i--)
+ for (int i = start; i >= 0; i--)
{
- dumb_ptr<map_session_data> d = map_get_session(i);
+ dumb_ptr<map_session_data> d = map_get_session(io::FD::cast_dammit(i));
if (d)
return d;
}
@@ -953,17 +953,17 @@ dumb_ptr<map_session_data> map_get_first_session(void)
dumb_ptr<map_session_data> map_get_next_session(dumb_ptr<map_session_data> d)
{
- return map_get_session_forward(d->sess->fd + 1);
+ return map_get_session_forward(d->sess->fd.uncast_dammit() + 1);
}
dumb_ptr<map_session_data> map_get_last_session(void)
{
- return map_get_session_backward(fd_max);
+ return map_get_session_backward(get_fd_max());
}
dumb_ptr<map_session_data> map_get_prev_session(dumb_ptr<map_session_data> d)
{
- return map_get_session_backward(d->sess->fd - 1);
+ return map_get_session_backward(d->sess->fd.uncast_dammit() - 1);
}
/*==========================================
@@ -974,11 +974,12 @@ dumb_ptr<map_session_data> map_get_prev_session(dumb_ptr<map_session_data> d)
*/
dumb_ptr<map_session_data> map_nick2sd(CharName nick)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- map_session_data *pl_sd = static_cast<map_session_data *>(session[i]->session_data.get());
+ map_session_data *pl_sd = static_cast<map_session_data *>(s->session_data.get());
if (pl_sd && pl_sd->state.auth)
{
{
@@ -1611,8 +1612,8 @@ void term_func(void)
BL::NUL);
}
- for (int i = 0; i < fd_max; i++)
- delete_session(session[i].get());
+ for (io::FD i : iter_fds())
+ delete_session(get_session(i));
map_removenpc();
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index d68c580..7a73df5 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -2652,11 +2652,12 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> md, int damage,
sd = mvp_sd;
else
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- dumb_ptr<map_session_data> tmp_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> tmp_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (tmp_sd && tmp_sd->state.auth)
{
if (md->bl_m == tmp_sd->bl_m)
diff --git a/src/map/party.cpp b/src/map/party.cpp
index 09f103e..b2ce340 100644
--- a/src/map/party.cpp
+++ b/src/map/party.cpp
@@ -126,11 +126,12 @@ int party_check_member(struct party *p)
{
nullpo_ret(p);
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- map_session_data *sd = static_cast<map_session_data *>(session[i]->session_data.get());
+ map_session_data *sd = static_cast<map_session_data *>(s->session_data.get());
if (sd && sd->state.auth)
{
if (sd->status.party_id == p->party_id)
@@ -165,11 +166,12 @@ int party_check_member(struct party *p)
// 情報所得失敗(そのIDのキャラを全部未所属にする)
int party_recv_noinfo(int party_id)
{
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- map_session_data *sd = static_cast<map_session_data *>(session[i]->session_data.get());
+ map_session_data *sd = static_cast<map_session_data *>(s->session_data.get());
if (sd && sd->state.auth)
{
if (sd->status.party_id == party_id)
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 168d124..8d242ae 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -5201,13 +5201,13 @@ void pc_autosave_sub(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- if (save_flag == 0 && sd->sess->fd > last_save_fd)
+ if (save_flag == 0 && sd->sess->fd.uncast_dammit() > last_save_fd)
{
pc_makesavestatus(sd);
chrif_save(sd);
save_flag = 1;
- last_save_fd = sd->sess->fd;
+ last_save_fd = sd->sess->fd.uncast_dammit();
}
}
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 6bd4543..c154182 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -3367,11 +3367,12 @@ void builtin_pvpon(ScriptState *st)
if (battle_config.pk_mode) // disable ranking functions if pk_mode is on [Valaris]
return;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- map_session_data *pl_sd = static_cast<map_session_data *>(session[i]->session_data.get());
+ map_session_data *pl_sd = static_cast<map_session_data *>(s->session_data.get());
if (pl_sd && pl_sd->state.auth)
{
if (m == pl_sd->bl_m && !pl_sd->pvp_timer)
@@ -3401,11 +3402,12 @@ void builtin_pvpoff(ScriptState *st)
if (battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris]
return;
- for (int i = 0; i < fd_max; i++)
+ for (io::FD i : iter_fds())
{
- if (!session[i])
+ Session *s = get_session(i);
+ if (!s)
continue;
- map_session_data *pl_sd = static_cast<map_session_data *>(session[i]->session_data.get());
+ map_session_data *pl_sd = static_cast<map_session_data *>(s->session_data.get());
if (pl_sd && pl_sd->state.auth)
{
if (m == pl_sd->bl_m)