MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / readPacket

Method readPacket

source/network/ODPacket.cpp:255–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255int32_t ODPacket::readPacket(std::ifstream& is)
256{
257 int32_t timestamp;
258 int32_t packetSize;
259
260 is.read(reinterpret_cast<char*>(&timestamp), sizeof(int32_t));
261 if(is.eof())
262 return -1;
263
264 is.read(reinterpret_cast<char*>(&packetSize), sizeof(int32_t));
265 if(is.eof())
266 return -1;
267
268 mPacket.clear();
269 char buffer[BUFFER_SIZE];
270 while(packetSize > 0)
271 {
272 int32_t sizeToRead = std::min(packetSize, BUFFER_SIZE);
273 is.read(buffer, sizeToRead);
274 mPacket.append(buffer, sizeToRead);
275 packetSize -= sizeToRead;
276 }
277
278 return timestamp;
279}

Callers 2

isDataAvailableMethod · 0.80
checkReplayValidMethod · 0.80

Calls 1

clearMethod · 0.80

Tested by

no test coverage detected