[General]: Use some static assert (#909)
This commit is contained in:
parent
44ca51e11b
commit
64ed0ba7fb
@ -278,10 +278,8 @@ namespace Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto entnum = cl->gentity->s.number;
|
|
||||||
|
|
||||||
// Keep test client functionality
|
// Keep test client functionality
|
||||||
if (!g_botai[entnum].active)
|
if (!g_botai[cl - Game::svs_clients].active)
|
||||||
{
|
{
|
||||||
Game::SV_BotUserMove(cl);
|
Game::SV_BotUserMove(cl);
|
||||||
return;
|
return;
|
||||||
@ -292,10 +290,10 @@ namespace Components
|
|||||||
|
|
||||||
userCmd.serverTime = *Game::svs_time;
|
userCmd.serverTime = *Game::svs_time;
|
||||||
|
|
||||||
userCmd.buttons = g_botai[entnum].buttons;
|
userCmd.buttons = g_botai[cl - Game::svs_clients].buttons;
|
||||||
userCmd.forwardmove = g_botai[entnum].forward;
|
userCmd.forwardmove = g_botai[cl - Game::svs_clients].forward;
|
||||||
userCmd.rightmove = g_botai[entnum].right;
|
userCmd.rightmove = g_botai[cl - Game::svs_clients].right;
|
||||||
userCmd.weapon = g_botai[entnum].weapon;
|
userCmd.weapon = g_botai[cl - Game::svs_clients].weapon;
|
||||||
|
|
||||||
userCmd.angles[0] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[0] - cl->gentity->client->ps.delta_angles[0]));
|
userCmd.angles[0] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[0] - cl->gentity->client->ps.delta_angles[0]));
|
||||||
userCmd.angles[1] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[1] - cl->gentity->client->ps.delta_angles[1]));
|
userCmd.angles[1] = ANGLE2SHORT((cl->gentity->client->ps.viewangles[1] - cl->gentity->client->ps.delta_angles[1]));
|
||||||
@ -349,10 +347,23 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Bots::SV_GetClientPing_Hk(const int clientNum)
|
||||||
|
{
|
||||||
|
AssertIn(clientNum, Game::MAX_CLIENTS);
|
||||||
|
|
||||||
|
if (Game::SV_IsTestClient(clientNum))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Game::svs_clients[clientNum].ping;
|
||||||
|
}
|
||||||
|
|
||||||
Bots::Bots()
|
Bots::Bots()
|
||||||
{
|
{
|
||||||
AssertOffset(Game::client_t, bIsTestClient, 0x41AF0);
|
AssertOffset(Game::client_t, bIsTestClient, 0x41AF0);
|
||||||
AssertOffset(Game::client_t, ping, 0x212C8);
|
AssertOffset(Game::client_t, ping, 0x212C8);
|
||||||
|
AssertOffset(Game::client_t, gentity, 0x212A0);
|
||||||
|
|
||||||
// Replace connect string
|
// Replace connect string
|
||||||
Utils::Hook::Set<const char*>(0x48ADA6, "connect bot%d \"\\cg_predictItems\\1\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\%s\\clanAbbrev\\%s\\protocol\\%d\\checksum\\%d\\statver\\%d %u\\qport\\%d\"");
|
Utils::Hook::Set<const char*>(0x48ADA6, "connect bot%d \"\\cg_predictItems\\1\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\%s\\clanAbbrev\\%s\\protocol\\%d\\checksum\\%d\\statver\\%d %u\\qport\\%d\"");
|
||||||
@ -365,10 +376,12 @@ namespace Components
|
|||||||
|
|
||||||
Utils::Hook(0x441B80, G_SelectWeaponIndex_Hk, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x441B80, G_SelectWeaponIndex_Hk, HOOK_JUMP).install()->quick();
|
||||||
|
|
||||||
|
Utils::Hook(0x459654, SV_GetClientPing_Hk, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
SVRandomBotNames = Dvar::Register<bool>("sv_RandomBotNames", false, Game::DVAR_NONE, "Randomize the bots' names");
|
SVRandomBotNames = Dvar::Register<bool>("sv_RandomBotNames", false, Game::DVAR_NONE, "Randomize the bots' names");
|
||||||
|
|
||||||
// Reset BotMovementInfo.active when client is dropped
|
// Reset BotMovementInfo.active when client is dropped
|
||||||
Events::OnClientDisconnect([](const int clientNum)
|
Events::OnClientDisconnect([](const int clientNum) -> void
|
||||||
{
|
{
|
||||||
g_botai[clientNum].active = false;
|
g_botai[clientNum].active = false;
|
||||||
});
|
});
|
||||||
|
@ -27,5 +27,7 @@ namespace Components
|
|||||||
|
|
||||||
static void G_SelectWeaponIndex(int clientNum, int iWeaponIndex);
|
static void G_SelectWeaponIndex(int clientNum, int iWeaponIndex);
|
||||||
static void G_SelectWeaponIndex_Hk();
|
static void G_SelectWeaponIndex_Hk();
|
||||||
|
|
||||||
|
static int SV_GetClientPing_Hk(int clientNum);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user