move bot ticcmd to SV_Maketic

This commit is contained in:
Sally Coolatta 2020-06-07 03:41:56 -04:00
parent 58dbdc2378
commit 559b879a28
3 changed files with 39 additions and 8 deletions

View file

@ -5274,20 +5274,29 @@ static void Local_Maketic(INT32 realtics)
// game responder calls HU_Responder, AM_Responder, F_Responder, // game responder calls HU_Responder, AM_Responder, F_Responder,
// and G_MapEventsToControls // and G_MapEventsToControls
if (!dedicated) rendergametic = gametic; if (!dedicated) rendergametic = gametic;
// translate inputs (keyboard/mouse/joystick) into game controls // translate inputs (keyboard/mouse/joystick) into game controls
G_BuildTiccmd(&localcmds, realtics, 1); G_BuildTiccmd(&localcmds, realtics, 1);
localcmds.angleturn |= TICCMD_RECEIVED;
if (splitscreen) if (splitscreen)
{ {
G_BuildTiccmd(&localcmds2, realtics, 2); G_BuildTiccmd(&localcmds2, realtics, 2);
localcmds2.angleturn |= TICCMD_RECEIVED;
if (splitscreen > 1) if (splitscreen > 1)
{ {
G_BuildTiccmd(&localcmds3, realtics, 3); G_BuildTiccmd(&localcmds3, realtics, 3);
localcmds3.angleturn |= TICCMD_RECEIVED;
if (splitscreen > 2) if (splitscreen > 2)
{
G_BuildTiccmd(&localcmds4, realtics, 4); G_BuildTiccmd(&localcmds4, realtics, 4);
localcmds4.angleturn |= TICCMD_RECEIVED;
}
} }
} }
localcmds.angleturn |= TICCMD_RECEIVED;
} }
void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle) void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle)
@ -5324,11 +5333,30 @@ void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle)
static void SV_Maketic(void) static void SV_Maketic(void)
{ {
INT32 j; INT32 j;
boolean b[MAXPLAYERS];
memset(b, false, sizeof (b));
for (j = 0; j < MAXPLAYERS; j++)
{
if (K_PlayerUsesBotMovement(&players[j]))
{
b[j] = true;
K_BuildBotTiccmd(&players[j], &netcmds[maketic%TICQUEUE][j]);
}
}
for (j = 0; j < MAXNETNODES; j++) for (j = 0; j < MAXNETNODES; j++)
{
if (playerpernode[j]) if (playerpernode[j])
{ {
INT32 player = nodetoplayer[j]; INT32 player = nodetoplayer[j];
if (b[player])
{
continue;
}
if ((netcmds[maketic%TICQUEUE][player].angleturn & TICCMD_RECEIVED) == 0) if ((netcmds[maketic%TICQUEUE][player].angleturn & TICCMD_RECEIVED) == 0)
{ // we didn't receive this tic { // we didn't receive this tic
INT32 i; INT32 i;
@ -5349,6 +5377,7 @@ static void SV_Maketic(void)
} }
} }
} }
}
// all tic are now proceed make the next // all tic are now proceed make the next
maketic++; maketic++;

View file

@ -2401,16 +2401,18 @@ void G_Ticker(boolean run)
if (playeringame[i]) if (playeringame[i])
{ {
if (K_PlayerUsesBotMovement(&players[i])) G_CopyTiccmd(cmd, &netcmds[buf][i], 1);
// Use the leveltime sent in the player's ticcmd to determine control lag
if (modeattacking || K_PlayerUsesBotMovement(&players[i]))
{ {
K_BuildBotTiccmd(&players[i], cmd); // Never has lag
cmd->latency = 0; cmd->latency = 0;
} }
else else
{ {
G_CopyTiccmd(cmd, &netcmds[buf][i], 1); //@TODO add a cvar to allow setting this max
// Use the leveltime sent in the player's ticcmd to determine control lag cmd->latency = min(((leveltime & 0xFF) - cmd->latency) & 0xFF, MAXPREDICTTICS-1);
cmd->latency = modeattacking ? 0 : min(((leveltime & 0xFF) - cmd->latency) & 0xFF, MAXPREDICTTICS-1); //@TODO add a cvar to allow setting this max
} }
} }
} }

View file

@ -675,7 +675,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
// Remove any existing controls // Remove any existing controls
memset(cmd, 0, sizeof(ticcmd_t)); memset(cmd, 0, sizeof(ticcmd_t));
cmd->angleturn = (player->mo->angle >> 16) | TICCMD_RECEIVED; cmd->angleturn = (player->mo->angle >> 16);
if (gamestate != GS_LEVEL) if (gamestate != GS_LEVEL)
{ {