Call lua_handle_user() earlier within conn_destroy() to ensure none of the t_connection struct variables have been freed yet.

This commit is contained in:
relesgoe 2021-01-31 11:46:19 -08:00
parent 5f764c59ea
commit ac0cacfbd6

View file

@ -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 */