From df1108923a13b6b10c121a4f972bee1747438b7a Mon Sep 17 00:00:00 2001 From: Matej Pristak Date: Tue, 22 Mar 2016 20:55:34 +0100 Subject: [PATCH] Fixing venders being stuck when map->char connection gets reset. --- src/map/chrif.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/map/chrif.c b/src/map/chrif.c index 8e728fa7e9..077629f1d2 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -30,6 +30,7 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_ static struct eri *auth_db_ers; //For reutilizing player login structures. static DBMap* auth_db; // int id -> struct auth_node* +static bool char_init_done = false; //server already initialized? Used for InterInitOnce and vending loadings static const int packet_len_table[0x3d] = { // U - used, F - free 60, 3,-1,-1,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff @@ -484,8 +485,6 @@ int chrif_changemapserverack(uint32 account_id, int login_id1, int login_id2, ui * 0x2af9 B */ int chrif_connectack(int fd) { - static bool char_init_done = false; - if (RFIFOB(fd,2)) { ShowFatalError("Connection to char-server failed %d, please check conf/import/map_conf userid and passwd.\n", RFIFOB(fd,2)); exit(EXIT_FAILURE); @@ -499,7 +498,6 @@ int chrif_connectack(int fd) { ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit")); if( !char_init_done ) { - char_init_done = true; ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInitOnce")); guild_castle_map_init(); } @@ -564,8 +562,12 @@ void chrif_on_ready(void) { guild_castle_reconnect(-1, 0, 0); // Charserver is ready for loading autotrader - do_init_buyingstore_autotrade(); - do_init_vending_autotrade(); + if (!char_init_done) + { + do_init_buyingstore_autotrade(); + do_init_vending_autotrade(); + char_init_done = true; + } }