diff --git a/src/bnetd/connection.cpp b/src/bnetd/connection.cpp index f8e65e7..62f2329 100644 --- a/src/bnetd/connection.cpp +++ b/src/bnetd/connection.cpp @@ -550,6 +550,15 @@ namespace pvpgn return; } + +#ifdef WITH_LUA + if (c->protocol.account) + { + lua_handle_user(c, NULL, NULL, luaevent_user_disconnect); + } +#endif + + classstr = conn_class_get_str(c->protocol.cclass); if (list_remove_data(conn_head, c, (conn_or_dead_list) ? &curr : elem) < 0) @@ -693,10 +702,6 @@ namespace pvpgn eventlog(eventlog_level_error, __FUNCTION__, "cannot sync account (sync_on_logoff)"); } -#ifdef WITH_LUA - lua_handle_user(c, NULL, NULL, luaevent_user_disconnect); -#endif - if (account_get_conn(c->protocol.account) == c) /* make sure you don't set this when already on new conn (relogin with same account) */ account_set_conn(c->protocol.account, NULL); c->protocol.account = NULL; /* the account code will free the memory later */