summaryrefslogtreecommitdiff
path: root/src/map/chrif.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/chrif.cpp')
-rw-r--r--src/map/chrif.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 04e82ca..64fd547 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -1035,6 +1035,15 @@ void ladmin_itemfrob(Session *s)
}
}
+static
+void chrif_delete(Session *s)
+{
+ assert (s == char_session);
+ PRINTF("Map-server can't connect to char-server (connection #%d).\n"_fmt,
+ s);
+ char_session = nullptr;
+}
+
/*==========================================
*
*------------------------------------------
@@ -1046,15 +1055,9 @@ void chrif_parse(Session *s)
// only char-server can have an access to here.
// so, if it isn't the char-server, we disconnect the session (fd != char_fd).
- if (s != char_session || s->eof)
+ if (s != char_session)
{
- if (s == char_session)
- {
- PRINTF("Map-server can't connect to char-server (connection #%d).\n"_fmt,
- s);
- char_session = nullptr;
- }
- delete_session(s);
+ s->set_eof();
return;
}
@@ -1075,7 +1078,7 @@ void chrif_parse(Session *s)
if (r == 2)
return; // intifで処理したが、データが足りない
- s->eof = 1;
+ s->set_eof();
return;
}
packet_len = packet_len_table[cmd - 0x2af8];
@@ -1158,7 +1161,7 @@ void chrif_parse(Session *s)
if (battle_config.error_log)
PRINTF("chrif_parse : unknown packet %d %d\n"_fmt, s,
RFIFOW(s, 0));
- s->eof = 1;
+ s->set_eof();
return;
}
RFIFOSKIP(s, packet_len);
@@ -1211,10 +1214,10 @@ void check_connect_char_server(TimerData *, tick_t)
{
PRINTF("Attempt to connect to char-server...\n"_fmt);
chrif_state = 0;
- char_session = make_connection(char_ip, char_port);
+ char_session = make_connection(char_ip, char_port,
+ SessionParsers{func_parse: chrif_parse, func_delete: chrif_delete});
if (!char_session)
return;
- char_session->func_parse = chrif_parse;
realloc_fifo(char_session, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
chrif_connect(char_session);