[Bots]: Cleanup (#934)
This commit is contained in:
parent
e05fa7f6a0
commit
6fb59fff1f
@ -415,6 +415,15 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bots::CleanBotArray()
|
||||||
|
{
|
||||||
|
ZeroMemory(&g_botai, sizeof(g_botai));
|
||||||
|
for (std::size_t i = 0; i < std::extent_v<decltype(g_botai)>; ++i)
|
||||||
|
{
|
||||||
|
g_botai[i].weapon = 1; // Prevent the bots from defaulting to the 'none' weapon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bots::Bots()
|
Bots::Bots()
|
||||||
{
|
{
|
||||||
AssertOffset(Game::client_t, bIsTestClient, 0x41AF0);
|
AssertOffset(Game::client_t, bIsTestClient, 0x41AF0);
|
||||||
@ -443,12 +452,7 @@ namespace Components
|
|||||||
g_botai[clientNum].active = false;
|
g_botai[clientNum].active = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Zero the bot command array
|
CleanBotArray();
|
||||||
for (std::size_t i = 0; i < std::extent_v<decltype(g_botai)>; ++i)
|
|
||||||
{
|
|
||||||
ZeroMemory(&g_botai[i], sizeof(BotMovementInfo));
|
|
||||||
g_botai[i].weapon = 1; // Prevent the bots from defaulting to the 'none' weapon
|
|
||||||
}
|
|
||||||
|
|
||||||
Command::Add("spawnBot", [](Command::Params* params)
|
Command::Add("spawnBot", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
@ -497,12 +501,6 @@ namespace Components
|
|||||||
AddScriptMethods();
|
AddScriptMethods();
|
||||||
|
|
||||||
// In case a loaded mod didn't call "BotStop" before the VM shutdown
|
// In case a loaded mod didn't call "BotStop" before the VM shutdown
|
||||||
Events::OnVMShutdown([]
|
Events::OnVMShutdown(CleanBotArray);
|
||||||
{
|
|
||||||
for (std::size_t i = 0; i < std::extent_v<decltype(g_botai)>; ++i)
|
|
||||||
{
|
|
||||||
g_botai[i].active = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,5 +35,7 @@ namespace Components
|
|||||||
static int SV_GetClientPing_Hk(int clientNum);
|
static int SV_GetClientPing_Hk(int clientNum);
|
||||||
|
|
||||||
static bool IsFull();
|
static bool IsFull();
|
||||||
|
|
||||||
|
static void CleanBotArray();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user