Copy trailing bits to output after each packet for file hash matching
This commit is contained in:
parent
361119f19f
commit
91e63d3f39
@ -13,7 +13,7 @@ public:
|
||||
virtual void EndWriting() override final;
|
||||
|
||||
virtual void StartCommandPacket(CommandPacket& packet) override final;
|
||||
virtual void EndCommandPacket() override final;
|
||||
virtual void EndCommandPacket(const PacketTrailingBits& trailingBits) override final;
|
||||
|
||||
virtual void WriteNetPacket(NetPacket& packet, SourceGameContext& context) override final;
|
||||
|
||||
@ -51,7 +51,7 @@ void ConLogWriter::StartCommandPacket(CommandPacket& packet)
|
||||
{
|
||||
}
|
||||
|
||||
void ConLogWriter::EndCommandPacket()
|
||||
void ConLogWriter::EndCommandPacket(const PacketTrailingBits& trailingBits)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
virtual void EndWriting() override final;
|
||||
|
||||
virtual void StartCommandPacket(CommandPacket& packet) override final;
|
||||
virtual void EndCommandPacket() override final;
|
||||
virtual void EndCommandPacket(const PacketTrailingBits& trailingBits) override final;
|
||||
|
||||
virtual void WriteNetPacket(NetPacket& packet, SourceGameContext& context) override final;
|
||||
|
||||
@ -56,8 +56,12 @@ void DemoWriter::StartCommandPacket(CommandPacket& packet)
|
||||
m_cmdPacketBuf.Reset();
|
||||
}
|
||||
|
||||
void DemoWriter::EndCommandPacket()
|
||||
void DemoWriter::EndCommandPacket(const PacketTrailingBits& trailingBits)
|
||||
{
|
||||
if (trailingBits.numTrailingBits > 0)
|
||||
{
|
||||
m_cmdPacketBuf.WriteUBitLong(trailingBits.value, trailingBits.numTrailingBits);
|
||||
}
|
||||
if (m_cmdPacketBuf.GetNumBytesWritten() > 0)
|
||||
{
|
||||
m_writer.WriteRawData(m_cmdPacketBuf.GetBasePointer(), m_cmdPacketBuf.GetNumBytesWritten());
|
||||
|
@ -111,7 +111,7 @@ static void DestroyDemMsgStructs(void* demDataStructs[9])
|
||||
delete reinterpret_cast<DemMsg::Dem_StringTables*>(demDataStructs[8]);
|
||||
}
|
||||
|
||||
void ParsePacket(uint8_t* packet, size_t length,
|
||||
PacketTrailingBits ParsePacket(uint8_t* packet, size_t length,
|
||||
SourceGameContext& context, IDemoWriter* writer,
|
||||
void* netDataStructs[32])
|
||||
{
|
||||
@ -125,6 +125,18 @@ void ParsePacket(uint8_t* packet, size_t length,
|
||||
NetHandlers::NetMsg_BitRead(netPacket.type, bitbuf, context, netPacket.data);
|
||||
writer->WriteNetPacket(netPacket, context);
|
||||
}
|
||||
|
||||
PacketTrailingBits trailingBits;
|
||||
trailingBits.numTrailingBits = bitbuf.GetNumBitsLeft();
|
||||
if (trailingBits.numTrailingBits)
|
||||
{
|
||||
trailingBits.value = bitbuf.ReadUBitLong(trailingBits.numTrailingBits);
|
||||
}
|
||||
else
|
||||
{
|
||||
trailingBits.value = 0;
|
||||
}
|
||||
return trailingBits;
|
||||
}
|
||||
|
||||
void DemoReader::ProcessDem(void* inputFp, IDemoWriter* writer)
|
||||
@ -151,13 +163,14 @@ void DemoReader::ProcessDem(void* inputFp, IDemoWriter* writer)
|
||||
packet.data = demDataStructs[packet.cmd];
|
||||
DemHandlers::DemMsg_FileRead(packet.cmd, reader, packet.data);
|
||||
|
||||
PacketTrailingBits trailingBits = PacketTrailingBits();
|
||||
writer->StartCommandPacket(packet);
|
||||
if (packet.cmd == dem_packet || packet.cmd == dem_signon)
|
||||
{
|
||||
Array<uint8_t> buffer = reader.ReadRawData(NET_MAX_PAYLOAD);
|
||||
ParsePacket(buffer.begin(), buffer.length(), context, writer, netDataStructs);
|
||||
trailingBits = ParsePacket(buffer.begin(), buffer.length(), context, writer, netDataStructs);
|
||||
}
|
||||
writer->EndCommandPacket();
|
||||
writer->EndCommandPacket(trailingBits);
|
||||
} while (packet.cmd != dem_stop);
|
||||
writer->EndWriting();
|
||||
|
||||
|
@ -23,6 +23,12 @@ struct NetPacket
|
||||
void* data;
|
||||
};
|
||||
|
||||
struct PacketTrailingBits
|
||||
{
|
||||
uint32_t numTrailingBits;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
class IDemoWriter
|
||||
{
|
||||
public:
|
||||
@ -32,7 +38,7 @@ public:
|
||||
virtual void EndWriting() = 0;
|
||||
|
||||
virtual void StartCommandPacket(CommandPacket& packet) = 0;
|
||||
virtual void EndCommandPacket() = 0;
|
||||
virtual void EndCommandPacket(const PacketTrailingBits& trailingBits) = 0;
|
||||
|
||||
virtual void WriteNetPacket(NetPacket& packet, SourceGameContext& context) = 0;
|
||||
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
virtual void EndWriting() override final;
|
||||
|
||||
virtual void StartCommandPacket(CommandPacket& packet) override final;
|
||||
virtual void EndCommandPacket() override final;
|
||||
virtual void EndCommandPacket(const PacketTrailingBits& trailingBits) override final;
|
||||
|
||||
virtual void WriteNetPacket(NetPacket& packet, SourceGameContext& context) override final;
|
||||
};
|
||||
@ -37,7 +37,7 @@ void JsonWriter::StartCommandPacket(CommandPacket& packet)
|
||||
{
|
||||
}
|
||||
|
||||
void JsonWriter::EndCommandPacket()
|
||||
void JsonWriter::EndCommandPacket(const PacketTrailingBits& trailingBits)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user