diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-04 14:35:36 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-04 14:35:36 +1100 |
commit | 6c896c2ef79c1740d7dea6fae95518c768de8931 (patch) | |
tree | fce5fcd1bb6b9743cee93371b7f7d7b586a455b1 /source/game/StarNetPackets.cpp | |
parent | be676518f4639250376842db7e48e5aaeaad9424 (diff) |
Make ping updates more accurate
Diffstat (limited to 'source/game/StarNetPackets.cpp')
-rw-r--r-- | source/game/StarNetPackets.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/source/game/StarNetPackets.cpp b/source/game/StarNetPackets.cpp index fd127a2..3cbb3ad 100644 --- a/source/game/StarNetPackets.cpp +++ b/source/game/StarNetPackets.cpp @@ -924,15 +924,26 @@ void WorldStartAcknowledgePacket::write(DataStream& ds) const { } PingPacket::PingPacket() {} +PingPacket::PingPacket(int64_t time) : time(time) {} -void PingPacket::read(DataStream& ds) { +void PingPacket::readLegacy(DataStream& ds) { // Packets can't be empty, read the trash data ds.read<bool>(); + time = 0; } -void PingPacket::write(DataStream& ds) const { +void PingPacket::read(DataStream& ds) { + ds.readVlqI(time); +} + + +void PingPacket::writeLegacy(DataStream& ds) const { // Packets can't be empty, write some trash data - ds.write(false); + ds.write<bool>(false); +} + +void PingPacket::write(DataStream& ds) const { + ds.writeVlqI(time); } EntityCreatePacket::EntityCreatePacket(EntityType entityType, ByteArray storeData, ByteArray firstNetState, EntityId entityId) @@ -1234,17 +1245,27 @@ void FindUniqueEntityResponsePacket::write(DataStream& ds) const { } PongPacket::PongPacket() {} +PongPacket::PongPacket(int64_t time) : time(time) {} -void PongPacket::read(DataStream& ds) { +void PongPacket::readLegacy(DataStream& ds) { // Packets can't be empty, read the trash data ds.read<bool>(); + time = 0; } -void PongPacket::write(DataStream& ds) const { +void PongPacket::read(DataStream& ds) { + ds.readVlqI(time); +} + +void PongPacket::writeLegacy(DataStream& ds) const { // Packets can't be empty, write some trash data ds.write<bool>(false); } +void PongPacket::write(DataStream& ds) const { + ds.writeVlqI(time); +} + StepUpdatePacket::StepUpdatePacket() : remoteTime(0.0) {} StepUpdatePacket::StepUpdatePacket(double remoteTime) : remoteTime(remoteTime) {} |