Review changes

This commit is contained in:
Axel1092 2020-06-30 14:26:53 +02:00 committed by Axel1092
parent a4b92a02d9
commit 273a181f8f
3 changed files with 11 additions and 22 deletions

View File

@ -46,20 +46,16 @@ void CarlaRecorderLightScenes::Write(std::ofstream &OutFile)
std::streampos PosStart = OutFile.tellp();
// write a dummy packet size
uint32_t Total = 0;
uint32_t Total = 2 + Lights.size() * sizeof(CarlaRecorderLightScene);
WriteValue<uint32_t>(OutFile, Total);
// write total records
Total = Lights.size();
WriteValue<uint16_t>(OutFile, Total);
for (uint16_t i=0; i<Total; ++i)
Lights[i].Write(OutFile);
for (auto& Light : Lights)
{
Light.Write(OutFile);
}
// write the real packet size
std::streampos PosEnd = OutFile.tellp();
Total = PosEnd - PosStart - sizeof(uint32_t);
OutFile.seekp(PosStart, std::ios::beg);
WriteValue<uint32_t>(OutFile, Total);
OutFile.seekp(PosEnd, std::ios::beg);
}

View File

@ -39,23 +39,16 @@ void CarlaRecorderLightVehicles::Write(std::ofstream &OutFile)
// write the packet id
WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::VehicleLight));
std::streampos PosStart = OutFile.tellp();
// write a dummy packet size
uint32_t Total = 0;
uint32_t Total = 2 + Vehicles.size() * sizeof(CarlaRecorderLightVehicle);
WriteValue<uint32_t>(OutFile, Total);
// write total records
Total = Vehicles.size();
WriteValue<uint16_t>(OutFile, Total);
for (uint16_t i=0; i<Total; ++i)
Vehicles[i].Write(OutFile);
// write the real packet size
std::streampos PosEnd = OutFile.tellp();
Total = PosEnd - PosStart - sizeof(uint32_t);
OutFile.seekp(PosStart, std::ios::beg);
WriteValue<uint32_t>(OutFile, Total);
OutFile.seekp(PosEnd, std::ios::beg);
for (auto& Vehicle : Vehicles)
{
Vehicle.Write(OutFile);
}
}

View File

@ -555,7 +555,7 @@ void CarlaReplayer::ProcessLightScene(void)
uint16_t Total;
CarlaRecorderLightScene LightScene;
// read Total walkers
// read Total light events
ReadValue<uint16_t>(File, Total);
for (uint16_t i = 0; i < Total; ++i)
{