Skip to content

Commit c14797f

Browse files
committed
fix: correct execution order to fix tas playback
tools have to be updated before player info is fetched, as it requires most recent tools state
1 parent 4158b55 commit c14797f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/Features/Tas/TasPlayer.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ static bool IsTaunting(ClientEnt *player) {
601601
}
602602

603603
TasFramebulk TasPlayer::SamplePreProcessedFramebulk(int slot, int tasTick, void *player, CUserCmd *cmd) {
604-
605-
auto pInfo = GetPlayerInfo(slot, server->GetPlayer(slot + 1), cmd);
606604
TasFramebulk& fb = RequestProcessedFramebulkAt(slot, tasTick);
607605

608606
auto fbTick = fb.tick;
@@ -636,6 +634,8 @@ TasFramebulk TasPlayer::SamplePreProcessedFramebulk(int slot, int tasTick, void
636634
}
637635

638636
if (IsUsingTools()) {
637+
UpdateTools(slot, fb, PRE_PROCESSING);
638+
auto pInfo = GetPlayerInfo(slot, server->GetPlayer(slot + 1), cmd);
639639
ApplyTools(fb, pInfo, PRE_PROCESSING);
640640

641641
if (sar_tas_debug.GetInt() > 0) {
@@ -660,6 +660,7 @@ void TasPlayer::PostProcess(int slot, void *player, CUserCmd *cmd) {
660660

661661
TasFramebulk& fb = RequestProcessedFramebulkAt(slot, tasTick);
662662

663+
UpdateTools(slot, fb, POST_PROCESSING);
663664
auto playerInfo = GetPlayerInfo(slot, player, cmd);
664665

665666
float orig_forward = cmd->forwardmove;
@@ -782,14 +783,16 @@ void TasPlayer::ApplyMoveAnalog(Vector moveAnalog, CUserCmd *cmd) {
782783
}
783784
}
784785

785-
void TasPlayer::ApplyTools(TasFramebulk &fb, const TasPlayerInfo &pInfo, TasToolProcessingType processType) {
786-
int slot = pInfo.slot;
787-
786+
void TasPlayer::UpdateTools(int slot, const TasFramebulk &fb, TasToolProcessingType processType) {
788787
for (TasToolCommand cmd : fb.toolCmds) {
789788
auto tool = TasTool::GetInstanceByName(slot, cmd.tool->GetName());
790789
if (!CanProcessTool(tool, processType)) continue;
791790
tool->SetParams(cmd.params);
792791
}
792+
}
793+
794+
void TasPlayer::ApplyTools(TasFramebulk &fb, const TasPlayerInfo &pInfo, TasToolProcessingType processType) {
795+
int slot = pInfo.slot;
793796

794797
FOR_TAS_SCRIPT_VERSIONS_UNTIL(2) {
795798
// use old "earliest first" ordering system (partially also present in TasTool::SetParams)

src/Features/Tas/TasPlayer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class TasPlayer : public Feature {
123123
TasFramebulk SamplePreProcessedFramebulk(int slot, int tasTick, void *player, CUserCmd *cmd);
124124
void PostProcess(int slot, void *player, CUserCmd *cmd);
125125
void ApplyMoveAnalog(Vector moveAnalog, CUserCmd *cmd);
126+
void UpdateTools(int slot, const TasFramebulk &fb, TasToolProcessingType processType);
126127
void ApplyTools(TasFramebulk &fb, const TasPlayerInfo &pInfo, TasToolProcessingType processType);
127128
bool CanProcessTool(TasTool *tool, TasToolProcessingType processType);
128129
void DumpUsercmd(int slot, const CUserCmd *cmd, int tick, const char *source);

0 commit comments

Comments
 (0)