summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-06-26 11:22:50 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-06-26 15:04:16 -0700
commit296629e067563e82b4a08b2a785d1c2f13b5a285 (patch)
treecee6131956069aeb6f5430b06a57b1f00750f857 /src
parent34807ca9fccc7425573256645024722571ef4442 (diff)
downloadtmwa-296629e067563e82b4a08b2a785d1c2f13b5a285.tar.gz
tmwa-296629e067563e82b4a08b2a785d1c2f13b5a285.tar.bz2
tmwa-296629e067563e82b4a08b2a785d1c2f13b5a285.tar.xz
tmwa-296629e067563e82b4a08b2a785d1c2f13b5a285.zip
Add null pointer checks for disconnected internals
Diffstat (limited to 'src')
-rw-r--r--src/admin/ladmin.cpp1
-rw-r--r--src/char/char.cpp21
-rw-r--r--src/map/chrif.cpp18
-rw-r--r--src/map/intif.cpp48
4 files changed, 73 insertions, 15 deletions
diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp
index ba55d73..69fc074 100644
--- a/src/admin/ladmin.cpp
+++ b/src/admin/ladmin.cpp
@@ -295,6 +295,7 @@ void ladmin_log(XString line)
static __attribute__((noreturn))
void delete_fromlogin(Session *)
{
+ login_session = nullptr;
{
PRINTF("Impossible to have a connection with the login-server [%s:%d] !\n"_fmt,
login_ip, login_port);
diff --git a/src/char/char.cpp b/src/char/char.cpp
index c26fa64..a0a92f1 100644
--- a/src/char/char.cpp
+++ b/src/char/char.cpp
@@ -2045,7 +2045,7 @@ void parse_frommap(Session *ms)
Packet_Head<0x2720> head_20;
head_20.account_id = account_id;
AString& repeat_20 = repeat;
- send_vpacket<0x2720, 8, 1>(ms, head_20, repeat_20);
+ send_vpacket<0x2720, 8, 1>(login_session, head_20, repeat_20);
}
else
{
@@ -2414,13 +2414,11 @@ void parse_char(Session *s)
{
IP4Address ip = s->client_ip;
+ assert (s != login_session);
+
if (!login_session)
{
s->set_eof();
-
- // I sure *hope* this doesn't happen ...
- if (s == login_session)
- login_session = nullptr;
return;
}
@@ -2499,8 +2497,8 @@ void parse_char(Session *s)
if (max_connect_user == 0
|| count_users() < max_connect_user)
{
- if (login_session)
- { // don't send request if no login-server
+ {
+ // there is always a login server
// request to login-server to obtain e-mail/time limit
Packet_Fixed<0x2716> fixed_16;
fixed_16.account_id = sd->account_id;
@@ -2524,9 +2522,8 @@ void parse_char(Session *s)
}
// authentification not found
{
- if (login_session)
{
- // don't send request if no login-server
+ // there is always a login-server
Packet_Fixed<0x2712> fixed_12;
fixed_12.account_id = sd->account_id;
fixed_12.login_id1 = sd->login_id1;
@@ -2535,12 +2532,6 @@ void parse_char(Session *s)
fixed_12.ip = s->client_ip;
send_fpacket<0x2712, 19>(login_session, fixed_12);
}
- else
- { // if no login-server, we must refuse connection
- Packet_Fixed<0x006c> fixed_6c;
- fixed_6c.code = 0;
- send_fpacket<0x006c, 3>(s, fixed_6c);
- }
}
}
x65_out:
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index ff0adbd..55e5810 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -214,6 +214,9 @@ int chrif_changemapserver(dumb_ptr<map_session_data> sd,
{
nullpo_retr(-1, sd);
+ if (!char_session)
+ return -1;
+
IP4Address s_ip;
for (io::FD i : iter_fds())
{
@@ -395,6 +398,9 @@ int chrif_charselectreq(dumb_ptr<map_session_data> sd)
*/
void chrif_changegm(AccountId id, ZString pass)
{
+ if (!char_session)
+ return;
+
if (battle_config.etc_log)
PRINTF("chrif_changegm: account: %d, password: '%s'.\n"_fmt, id, pass);
@@ -410,6 +416,9 @@ void chrif_changegm(AccountId id, ZString pass)
void chrif_changeemail(AccountId id, AccountEmail actual_email,
AccountEmail new_email)
{
+ if (!char_session)
+ return;
+
if (battle_config.etc_log)
PRINTF("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n"_fmt,
id, actual_email, new_email);
@@ -435,6 +444,9 @@ void chrif_changeemail(AccountId id, AccountEmail actual_email,
void chrif_char_ask_name(AccountId id, CharName character_name, short operation_type,
HumanTimeDiff modif)
{
+ if (!char_session)
+ return;
+
Packet_Fixed<0x2b0e> fixed_0e;
fixed_0e.account_id = id; // who ask, or nobody
fixed_0e.char_name = character_name;
@@ -673,6 +685,9 @@ int chrif_saveaccountreg2(dumb_ptr<map_session_data> sd)
{
nullpo_retr(-1, sd);
+ if (!char_session)
+ return -1;
+
std::vector<Packet_Repeat<0x2b10>> repeat_10;
for (size_t j = 0; j < sd->status.account_reg2_num; j++)
{
@@ -905,6 +920,9 @@ int chrif_recvgmaccounts(Session *s, const std::vector<Packet_Repeat<0x2b15>>& r
*/
int chrif_reloadGMdb(void)
{
+ if (!char_session)
+ return -1;
+
Packet_Fixed<0x2af7> fixed_f7;
send_fpacket<0x2af7, 2>(char_session, fixed_f7);
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index 3ca2130..543ec0b 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -53,6 +53,9 @@
// Message for all GMs on all map servers
void intif_GMmessage(XString mes)
{
+ if (!char_session)
+ return;
+
send_packet_repeatonly<0x3000, 4, 1>(char_session, mes);
}
@@ -61,6 +64,9 @@ void intif_wis_message(dumb_ptr<map_session_data> sd, CharName nick, ZString mes
{
nullpo_retv(sd);
+ if (!char_session)
+ return;
+
Packet_Head<0x3001> head_01;
head_01.from_char_name = sd->status_key.name;
head_01.to_char_name = nick;
@@ -75,6 +81,9 @@ void intif_wis_message(dumb_ptr<map_session_data> sd, CharName nick, ZString mes
static
void intif_wis_replay(CharId id, int flag)
{
+ if (!char_session)
+ return;
+
Packet_Fixed<0x3002> fixed_02;
fixed_02.char_id = id;
fixed_02.flag = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
@@ -87,6 +96,9 @@ void intif_wis_replay(CharId id, int flag)
// The transmission of GM only Wisp/Page from server to inter-server
void intif_wis_message_to_gm(CharName Wisp_name, GmLevel min_gm_level, ZString mes)
{
+ if (!char_session)
+ return;
+
Packet_Head<0x3003> head_03;
head_03.char_name = Wisp_name;
head_03.min_gm_level = min_gm_level;
@@ -101,6 +113,9 @@ void intif_wis_message_to_gm(CharName Wisp_name, GmLevel min_gm_level, ZString m
void intif_saveaccountreg(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
+ if (!char_session)
+ return;
+
assert (sd->status.account_reg_num < ACCOUNT_REG_NUM);
Packet_Head<0x3004> head_04;
@@ -119,6 +134,9 @@ void intif_request_accountreg(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
+ if (!char_session)
+ return;
+
Packet_Fixed<0x3005> fixed_05;
fixed_05.account_id = block_to_account(sd->bl_id);
send_fpacket<0x3005, 6>(char_session, fixed_05);
@@ -127,6 +145,9 @@ void intif_request_accountreg(dumb_ptr<map_session_data> sd)
// 倉庫データ要求
void intif_request_storage(AccountId account_id)
{
+ if (!char_session)
+ return;
+
Packet_Fixed<0x3010> fixed_10;
fixed_10.account_id = account_id;
send_fpacket<0x3010, 6>(char_session, fixed_10);
@@ -136,6 +157,9 @@ void intif_request_storage(AccountId account_id)
void intif_send_storage(Storage *stor)
{
nullpo_retv(stor);
+ if (!char_session)
+ return;
+
Packet_Payload<0x3011> payload_11;
payload_11.account_id = stor->account_id;
payload_11.storage = *stor;
@@ -147,6 +171,9 @@ void intif_create_party(dumb_ptr<map_session_data> sd, PartyName name)
{
nullpo_retv(sd);
+ if (!char_session)
+ return;
+
Packet_Fixed<0x3020> fixed_20;
fixed_20.account_id = sd->status_key.account_id;
fixed_20.party_name = name;
@@ -159,6 +186,9 @@ void intif_create_party(dumb_ptr<map_session_data> sd, PartyName name)
// パーティ情報要求
void intif_request_partyinfo(PartyId party_id)
{
+ if (!char_session)
+ return;
+
Packet_Fixed<0x3021> fixed_21;
fixed_21.party_id = party_id;
send_fpacket<0x3021, 6>(char_session, fixed_21);
@@ -167,6 +197,9 @@ void intif_request_partyinfo(PartyId party_id)
// パーティ追加要求
void intif_party_addmember(PartyId party_id, AccountId account_id)
{
+ if (!char_session)
+ return;
+
dumb_ptr<map_session_data> sd;
sd = map_id2sd(account_to_block(account_id));
if (sd != NULL)
@@ -184,6 +217,9 @@ void intif_party_addmember(PartyId party_id, AccountId account_id)
// パーティ設定変更
void intif_party_changeoption(PartyId party_id, AccountId account_id, int exp, int item)
{
+ if (!char_session)
+ return;
+
Packet_Fixed<0x3023> fixed_23;
fixed_23.party_id = party_id;
fixed_23.account_id = account_id;
@@ -195,6 +231,9 @@ void intif_party_changeoption(PartyId party_id, AccountId account_id, int exp, i
// パーティ脱退要求
void intif_party_leave(PartyId party_id, AccountId account_id)
{
+ if (!char_session)
+ return;
+
Packet_Fixed<0x3024> fixed_24;
fixed_24.party_id = party_id;
fixed_24.account_id = account_id;
@@ -204,6 +243,9 @@ void intif_party_leave(PartyId party_id, AccountId account_id)
// パーティ移動要求
void intif_party_changemap(dumb_ptr<map_session_data> sd, int online)
{
+ if (!char_session)
+ return;
+
if (sd != NULL)
{
Packet_Fixed<0x3025> fixed_25;
@@ -219,6 +261,9 @@ void intif_party_changemap(dumb_ptr<map_session_data> sd, int online)
// パーティ会話送信
void intif_party_message(PartyId party_id, AccountId account_id, XString mes)
{
+ if (!char_session)
+ return;
+
Packet_Head<0x3027> head_27;
head_27.party_id = party_id;
head_27.account_id = account_id;
@@ -228,6 +273,9 @@ void intif_party_message(PartyId party_id, AccountId account_id, XString mes)
// パーティ競合チェック要求
void intif_party_checkconflict(PartyId party_id, AccountId account_id, CharName nick)
{
+ if (!char_session)
+ return;
+
Packet_Fixed<0x3028> fixed_28;
fixed_28.party_id = party_id;
fixed_28.account_id = account_id;