Fixes to new message dispatcher.

This commit is contained in:
joint 2019-08-12 16:58:00 +03:00 committed by jeefo
commit ac733404e1
2 changed files with 10 additions and 2 deletions

View file

@ -142,6 +142,13 @@ public:
int32 id (NetMsg msg) const { int32 id (NetMsg msg) const {
return m_maps[msg]; return m_maps[msg];
} }
private:
void reset () {
m_current = NetMsg::None;
m_bot = nullptr;
m_broadcast = false;
}
}; };
static auto &msgs = MessageDispatcher::get (); static auto &msgs = MessageDispatcher::get ();

View file

@ -377,6 +377,7 @@ MessageDispatcher::MessageDispatcher () {
m_wanted[name] = id; m_wanted[name] = id;
m_handlers[id] = handler; m_handlers[id] = handler;
}; };
reset ();
// we want to handle next messages // we want to handle next messages
pushWanted ("TextMsg", NetMsg::TextMsg, &MessageDispatcher::netMsgTextMsg); pushWanted ("TextMsg", NetMsg::TextMsg, &MessageDispatcher::netMsgTextMsg);
@ -454,7 +455,7 @@ void MessageDispatcher::registerMessage (const String &name, int32 id) {
} }
void MessageDispatcher::start (edict_t *ent, int32 dest, int32 type) { void MessageDispatcher::start (edict_t *ent, int32 dest, int32 type) {
m_current = NetMsg::None; reset ();
// search if we need to handle this message // search if we need to handle this message
for (const auto &msg : m_maps) { for (const auto &msg : m_maps) {
@ -475,7 +476,7 @@ void MessageDispatcher::start (edict_t *ent, int32 dest, int32 type) {
} }
// message for bot bot? // message for bot bot?
if (ent && (ent->v.flags & FL_FAKECLIENT)) { if (ent && (ent->v.flags & FL_FAKECLIENT) && !(ent->v.flags & FL_DORMANT)) {
m_bot = bots[ent]; m_bot = bots[ent];
if (!m_bot) { if (!m_bot) {