Skip to content

Commit

Permalink
Fix loading bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
heimskr committed May 5, 2023
1 parent 8bcd377 commit d849d3b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 0 additions & 2 deletions include/util/GL.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ namespace GL {
throw std::runtime_error("Couldn't generate buffer object");
glBindBuffer(target, bo); CHECKGL
glBufferData(target, count * sizeof(T), data, usage); CHECKGL
if (bo == 3800)
raise(SIGTRAP);
return bo;
}

Expand Down
6 changes: 3 additions & 3 deletions src/game/TileProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ namespace Game3 {
}

for (const auto &item: json.at(2)) {
const auto [x, y] = item.at(1).get<std::pair<int32_t, int32_t>>();
const auto [x, y] = item.at(0).get<std::pair<int32_t, int32_t>>();
const auto compressed = item.at(1).get<std::vector<uint8_t>>();
provider.biomeMap[ChunkPosition{x, y}] = decompress32(std::span(compressed.data(), compressed.size()));
}

for (const auto &item: json.at(2)) {
const auto [x, y] = item.at(1).get<std::pair<int32_t, int32_t>>();
for (const auto &item: json.at(3)) {
const auto [x, y] = item.at(0).get<std::pair<int32_t, int32_t>>();
const auto compressed = item.at(1).get<std::vector<uint8_t>>();
provider.pathMap[ChunkPosition{x, y}] = decompress8(std::span(compressed.data(), compressed.size()));
}
Expand Down
8 changes: 4 additions & 4 deletions src/util/Zstd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ namespace Game3 {
out.reserve(decompressed.size() / 2);

if constexpr (std::endian::native == std::endian::little) {
for (size_t i = 0, max = decompressed.size() / 2; i < max; i += 2)
for (size_t i = 0, max = decompressed.size(); i < max; i += 2)
out.emplace_back(*reinterpret_cast<const uint16_t *>(&decompressed[i]));
} else {
for (size_t i = 0, max = decompressed.size() / 2; i < max; i += 2)
for (size_t i = 0, max = decompressed.size(); i < max; i += 2)
out.emplace_back(decompressed[i] | (static_cast<uint16_t>(decompressed[i + 1]) << 8));
}

Expand All @@ -57,10 +57,10 @@ namespace Game3 {
out.reserve(decompressed.size() / 2);

if constexpr (std::endian::native == std::endian::little) {
for (size_t i = 0, max = decompressed.size() / 2; i < max; i += 2)
for (size_t i = 0, max = decompressed.size(); i < max; i += 4)
out.emplace_back(*reinterpret_cast<const uint32_t *>(&decompressed[i]));
} else {
for (size_t i = 0, max = decompressed.size() / 2; i < max; i += 2)
for (size_t i = 0, max = decompressed.size(); i < max; i += 4)
out.emplace_back(decompressed[i] | (static_cast<uint32_t>(decompressed[i + 1]) << 8)
| (static_cast<uint32_t>(decompressed[i + 2]) << 16)
| (static_cast<uint32_t>(decompressed[i + 3]) << 24));
Expand Down

0 comments on commit d849d3b

Please sign in to comment.