Skip to content

Commit 3e639ce

Browse files
committed
attempt to process playbacks better
1 parent f24e5c4 commit 3e639ce

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

Server/Components/NPCs/NPC/npc.cpp

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,9 @@ void NPC::tick(Microseconds elapsed, TimePoint now)
25512551
{
25522552
if (playback_ && playback_->isValid())
25532553
{
2554-
processPlayback(now);
2554+
// Used to process playback here, but I've moved it out put generate update rate to down below
2555+
// Keeping this here as a reminder that playbacks already have their own timestamps so they're not
2556+
// Oversent or overprocessed
25552557
}
25562558
else
25572559
{
@@ -2822,39 +2824,46 @@ void NPC::tick(Microseconds elapsed, TimePoint now)
28222824
}
28232825
}
28242826

2825-
if (duration_cast<Milliseconds>(now - lastFootSyncUpdate_).count() > npcComponent_->getFootSyncRate())
2827+
if (playback_ && playback_->isValid())
28262828
{
2827-
if (!vehicle_ || vehicleSeat_ == SEAT_NONE)
2828-
{
2829-
sendFootSync();
2830-
}
2831-
2832-
lastFootSyncUpdate_ = now;
2829+
processPlayback(now);
28332830
}
2834-
2835-
if (duration_cast<Milliseconds>(now - lastVehicleSyncUpdate_).count() > npcComponent_->getVehicleSyncRate())
2831+
else
28362832
{
2837-
if (vehicle_ && vehicleSeat_ != SEAT_NONE)
2833+
if (duration_cast<Milliseconds>(now - lastFootSyncUpdate_).count() > npcComponent_->getFootSyncRate())
28382834
{
2839-
if (vehicleSeat_ == 0) // driver
2835+
if (!vehicle_ || vehicleSeat_ == SEAT_NONE)
28402836
{
2841-
sendDriverSync();
2837+
sendFootSync();
28422838
}
2843-
else
2839+
2840+
lastFootSyncUpdate_ = now;
2841+
}
2842+
2843+
if (duration_cast<Milliseconds>(now - lastVehicleSyncUpdate_).count() > npcComponent_->getVehicleSyncRate())
2844+
{
2845+
if (vehicle_ && vehicleSeat_ != SEAT_NONE)
28442846
{
2845-
sendPassengerSync();
2847+
if (vehicleSeat_ == 0) // driver
2848+
{
2849+
sendDriverSync();
2850+
}
2851+
else
2852+
{
2853+
sendPassengerSync();
2854+
}
28462855
}
2847-
}
28482856

2849-
lastVehicleSyncUpdate_ = now;
2850-
}
2857+
lastVehicleSyncUpdate_ = now;
2858+
}
28512859

2852-
if (duration_cast<Milliseconds>(now - lastAimSyncUpdate_).count() > npcComponent_->getAimSyncRate())
2853-
{
2854-
sendAimSync();
2855-
updateAim();
2860+
if (duration_cast<Milliseconds>(now - lastAimSyncUpdate_).count() > npcComponent_->getAimSyncRate())
2861+
{
2862+
sendAimSync();
2863+
updateAim();
28562864

2857-
lastAimSyncUpdate_ = now;
2865+
lastAimSyncUpdate_ = now;
2866+
}
28582867
}
28592868
}
28602869
}

Server/Components/NPCs/Playback/playback.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ bool NPCPlayback::process(NPC& npc, TimePoint now)
141141
{
142142
npc.setVehicleTrainSpeed(syncData.TrainSpeed);
143143
}
144+
145+
npc.sendDriverSync();
144146
}
145147
}
146148
}
@@ -165,6 +167,8 @@ bool NPCPlayback::process(NPC& npc, TimePoint now)
165167
(syncData.AnimationFlags >> 10 & 0x1) != 0,
166168
(syncData.AnimationFlags >> 11 & 0x1) != 0,
167169
(syncData.AnimationFlags >> 12 & 0xF) != 0);
170+
171+
npc.sendFootSync();
168172
}
169173
}
170174

0 commit comments

Comments
 (0)