fix: crash with menus and commands (resolves #292)

This commit is contained in:
jeefo 2023-02-02 16:52:28 +03:00
commit 84c2794aed
No known key found for this signature in database
GPG key ID: D85B0637366787C3
2 changed files with 13 additions and 0 deletions

View file

@ -220,6 +220,10 @@ public:
} }
} }
edict_t *getIssuer() {
return m_ent;
}
// global heloer for sending message to correct channel // global heloer for sending message to correct channel
template <typename ...Args> void msg (const char *fmt, Args &&...args); template <typename ...Args> void msg (const char *fmt, Args &&...args);

View file

@ -244,6 +244,11 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
graph.setEditor (nullptr); graph.setEditor (nullptr);
} }
// clear issuer for the menus and commands
if (ent == ctrl.getIssuer ()) {
ctrl.setIssuer (nullptr);
}
if (game.is (GameFlags::Metamod)) { if (game.is (GameFlags::Metamod)) {
RETURN_META (MRES_IGNORED); RETURN_META (MRES_IGNORED);
} }
@ -344,6 +349,10 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
// send message on new map // send message on new map
util.setNeedForWelcome (false); util.setNeedForWelcome (false);
// clear local entity
game.setLocalEntity (nullptr);
// reset graph state
graph.reset (); graph.reset ();
// clear all the bots // clear all the bots