Add player.oldcmd -- ticcmd from previous tic

This commit is contained in:
James R 2022-09-22 08:43:40 -07:00
parent c792818887
commit 7251ed5d9e
3 changed files with 10 additions and 0 deletions

View file

@ -333,6 +333,7 @@ typedef struct player_s
// Caveat: ticcmd_t is ATTRPACK! Be careful what precedes it.
ticcmd_t cmd;
ticcmd_t oldcmd; // from the previous tic
playerstate_t playerstate;

View file

@ -192,6 +192,8 @@ static int player_get(lua_State *L)
LUA_PushUserdata(L, plr->mo, META_MOBJ);
else if (fastcmp(field,"cmd"))
LUA_PushUserdata(L, &plr->cmd, META_TICCMD);
else if (fastcmp(field,"oldcmd"))
LUA_PushUserdata(L, &plr->oldcmd, META_TICCMD);
else if (fastcmp(field,"respawn"))
LUA_PushUserdata(L, &plr->respawn, META_RESPAWN);
else if (fastcmp(field,"playerstate"))
@ -526,6 +528,8 @@ static int player_set(lua_State *L)
}
else if (fastcmp(field,"cmd"))
return NOSET;
else if (fastcmp(field,"oldcmd"))
return NOSET;
else if (fastcmp(field,"respawn"))
return NOSET;
else if (fastcmp(field,"playerstate"))

View file

@ -768,6 +768,11 @@ void P_Ticker(boolean run)
K_TimerInit();
}
for (i = 0; i < MAXPLAYERS; i++)
{
G_CopyTiccmd(&players[i].oldcmd, &players[i].cmd, 1);
}
// Z_CheckMemCleanup();
}