fix CBufferedStream::ensureSize growth & read semantics (compat for 'A War' map)

This commit is contained in:
Michał Zaremba committed 2025-10-11 09:38:06 +02:00
1 parent ace5425433
commit d2ac0fd4ff
2 files changed
+7 -5

No files matched your search

+2 -2
View File
@@ -65,10 +65,10 @@ void CBufferedStream::ensureSize(si64 size)
while(static_cast<si64>(buffer.size()) < size && !endOfFileReached)
{
si64 initialSize = buffer.size();
si64 currentStep = std::min<si64>(size, buffer.size());
si64 need = size - buffer.size();
// to avoid large number of calls at start
// this is often used to load h3m map headers, most of which are ~300 bytes in size
vstd::amax(currentStep, 512);
si64 currentStep = std::min<si64>(need, std::max<si64>(initialSize, si64{512}));
buffer.resize(initialSize + currentStep);
+5 -3
View File
@@ -199,9 +199,11 @@ RoadId MapReaderH3M::readRoad()
RiverId MapReaderH3M::readRiver()
{
RiverId result(readInt8());
assert(result.getNum() <= features.riversCount);
return result;
const uint8_t raw = readInt8();
// Keep low 3 bits as river type (0..4); discard high-bit flags set by some editors (HotA ?)
const uint8_t type = raw & 0x07;
assert(type <= features.riversCount);
return RiverId(type);
}
PrimarySkill MapReaderH3M::readPrimary()