fix: adding/removing bots during round restart causes "SZ_GetSpace: tried to write to an uninitialized sizebuf_t: ???"
This commit is contained in:
parent
dc8ded3cf7
commit
1cad8919b4
3 changed files with 23 additions and 7 deletions
|
|
@ -822,6 +822,7 @@ private:
|
||||||
bool updateLiftStates ();
|
bool updateLiftStates ();
|
||||||
bool canRunHeavyWeight ();
|
bool canRunHeavyWeight ();
|
||||||
|
|
||||||
|
void markStale ();
|
||||||
void instantChatter (int type);
|
void instantChatter (int type);
|
||||||
void update ();
|
void update ();
|
||||||
void runMovement ();
|
void runMovement ();
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,13 @@ namespace variadic {
|
||||||
// sometimes actually by their side, that's why we strongly recommend to check it here too. In
|
// sometimes actually by their side, that's why we strongly recommend to check it here too. In
|
||||||
// case it's a bot asking for a client command, we handle it like we do for bot commands
|
// case it's a bot asking for a client command, we handle it like we do for bot commands
|
||||||
|
|
||||||
|
if (game.isNullEntity (ent)) {
|
||||||
|
if (game.is (GameFlags::Metamod)) {
|
||||||
|
RETURN_META (MRES_SUPERCEDE);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
auto buffer = strings.chars ();
|
auto buffer = strings.chars ();
|
||||||
|
|
||||||
|
|
@ -62,7 +69,7 @@ namespace variadic {
|
||||||
vsnprintf (buffer, StringBuffer::StaticBufferSize, format, ap);
|
vsnprintf (buffer, StringBuffer::StaticBufferSize, format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
if (util.isFakeClient (ent)) {
|
if (util.isFakeClient (ent) || (ent->v.flags & FL_DORMANT)) {
|
||||||
auto bot = bots[ent];
|
auto bot = bots[ent];
|
||||||
|
|
||||||
if (bot) {
|
if (bot) {
|
||||||
|
|
@ -227,9 +234,6 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
|
||||||
|
|
||||||
for (auto &bot : bots) {
|
for (auto &bot : bots) {
|
||||||
if (bot->pev == &ent->v) {
|
if (bot->pev == &ent->v) {
|
||||||
bot->showChaterIcon (false);
|
|
||||||
|
|
||||||
conf.clearUsedName (bot.get ()); // clear the bot name
|
|
||||||
bots.erase (bot.get ()); // remove the bot from bots array
|
bots.erase (bot.get ()); // remove the bot from bots array
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1112,6 +1112,11 @@ bool BotManager::isTeamStacked (int team) {
|
||||||
void BotManager::erase (Bot *bot) {
|
void BotManager::erase (Bot *bot) {
|
||||||
for (auto &e : m_bots) {
|
for (auto &e : m_bots) {
|
||||||
if (e.get () == bot) {
|
if (e.get () == bot) {
|
||||||
|
bot->showChaterIcon (false);
|
||||||
|
bot->markStale ();
|
||||||
|
|
||||||
|
conf.clearUsedName (bot); // clear the bot name
|
||||||
|
|
||||||
e.reset ();
|
e.reset ();
|
||||||
m_bots.remove (e); // remove from bots array
|
m_bots.remove (e); // remove from bots array
|
||||||
|
|
||||||
|
|
@ -1418,14 +1423,20 @@ void Bot::kick () {
|
||||||
if (!(pev->flags & FL_CLIENT) || strings.isEmpty (username)) {
|
if (!(pev->flags & FL_CLIENT) || strings.isEmpty (username)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
markStale ();
|
||||||
// clear fakeclient bit
|
|
||||||
pev->flags &= ~FL_FAKECLIENT;
|
|
||||||
|
|
||||||
game.serverCommand ("kick \"%s\"", username);
|
game.serverCommand ("kick \"%s\"", username);
|
||||||
ctrl.msg ("Bot '%s' kicked.", username);
|
ctrl.msg ("Bot '%s' kicked.", username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bot::markStale () {
|
||||||
|
// clear fakeclient bit
|
||||||
|
pev->flags &= ~FL_FAKECLIENT;
|
||||||
|
|
||||||
|
// make as not receiveing any messages
|
||||||
|
pev->flags |= FL_DORMANT;
|
||||||
|
}
|
||||||
|
|
||||||
void Bot::updateTeamJoin () {
|
void Bot::updateTeamJoin () {
|
||||||
// this function handles the selection of teams & class
|
// this function handles the selection of teams & class
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue