mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Better handling of disconnects, code cleanup
This commit is contained in:
@@ -17,7 +17,7 @@ int CMemorySerializer::read(std::byte * data, unsigned size)
|
||||
if(buffer.size() < readPos + size)
|
||||
throw std::runtime_error(boost::str(boost::format("Cannot read past the buffer (accessing index %d, while size is %d)!") % (readPos + size - 1) % buffer.size()));
|
||||
|
||||
std::memcpy(data, buffer.data() + readPos, size);
|
||||
std::copy_n(buffer.data() + readPos, size, data);
|
||||
readPos += size;
|
||||
return size;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ int CMemorySerializer::write(const std::byte * data, unsigned size)
|
||||
{
|
||||
auto oldSize = buffer.size(); //and the pos to write from
|
||||
buffer.resize(oldSize + size);
|
||||
std::memcpy(buffer.data() + oldSize, data, size);
|
||||
std::copy_n(data, size, buffer.data() + oldSize);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user