mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Update botvars rubberband and controller in P_PlayerAfterThink instead of K_BuildBotTiccmd
These vars directly affect gamestate but K_BuildBotTiccmd only runs for the server.
This commit is contained in:
parent
8e7c5b2712
commit
b0e079bdf0
3 changed files with 45 additions and 14 deletions
37
src/k_bot.c
37
src/k_bot.c
|
|
@ -921,7 +921,7 @@ static void K_DrawPredictionDebug(botprediction_t *predict, player_t *player)
|
|||
Return:-
|
||||
None
|
||||
--------------------------------------------------*/
|
||||
static void K_BotTrick(player_t *player, ticcmd_t *cmd, line_t *botController)
|
||||
static void K_BotTrick(player_t *player, ticcmd_t *cmd, const line_t *botController)
|
||||
{
|
||||
// Trick panel state -- do nothing until a controller line is found, in which case do a trick.
|
||||
if (botController == NULL)
|
||||
|
|
@ -1259,7 +1259,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
|||
angle_t destangle = 0;
|
||||
UINT8 spindash = 0;
|
||||
INT32 turnamt = 0;
|
||||
line_t *botController = NULL;
|
||||
const line_t *botController = player->botvars.controller != UINT16_MAX ? &lines[player->botvars.controller] : NULL;
|
||||
|
||||
// Remove any existing controls
|
||||
memset(cmd, 0, sizeof(ticcmd_t));
|
||||
|
|
@ -1292,18 +1292,6 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
|||
return;
|
||||
}
|
||||
|
||||
botController = K_FindBotController(player->mo);
|
||||
if (botController == NULL)
|
||||
{
|
||||
player->botvars.controller = UINT16_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->botvars.controller = botController - lines;
|
||||
}
|
||||
|
||||
player->botvars.rubberband = K_UpdateRubberband(player);
|
||||
|
||||
if (player->trickpanel != 0)
|
||||
{
|
||||
K_BotTrick(player, cmd, botController);
|
||||
|
|
@ -1531,3 +1519,24 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
|||
Z_Free(predict);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void K_UpdateBotGameplayVars(player_t *player);
|
||||
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
void K_UpdateBotGameplayVars(player_t *player)
|
||||
{
|
||||
const line_t *botController;
|
||||
|
||||
if (gamestate != GS_LEVEL || !player->mo)
|
||||
{
|
||||
// Not in the level.
|
||||
return;
|
||||
}
|
||||
|
||||
botController = K_FindBotController(player->mo);
|
||||
|
||||
player->botvars.controller = botController ? (botController - lines) : UINT16_MAX;
|
||||
player->botvars.rubberband = K_UpdateRubberband(player);
|
||||
}
|
||||
|
|
|
|||
16
src/k_bot.h
16
src/k_bot.h
|
|
@ -238,6 +238,22 @@ INT32 K_PositionBully(player_t *player);
|
|||
void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void K_UpdateBotGameplayVars(player_t *player);
|
||||
|
||||
Updates gamestate affecting botvars. This must be
|
||||
called for both client and server.
|
||||
|
||||
Input Arguments:-
|
||||
player - Player to whom to update the botvars.
|
||||
|
||||
Return:-
|
||||
None
|
||||
--------------------------------------------------*/
|
||||
|
||||
void K_UpdateBotGameplayVars(player_t *player);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt);
|
||||
|
||||
|
|
|
|||
|
|
@ -4301,6 +4301,12 @@ void P_PlayerAfterThink(player_t *player)
|
|||
// Run followers in AfterThink, after the players have moved,
|
||||
// so a lag value of 1 is exactly attached to the player.
|
||||
K_HandleFollower(player);
|
||||
|
||||
|
||||
if (K_PlayerUsesBotMovement(player))
|
||||
{
|
||||
K_UpdateBotGameplayVars(player);
|
||||
}
|
||||
}
|
||||
|
||||
void P_SetPlayerAngle(player_t *player, angle_t angle)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue