mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-08 20:09:36 +01:00
Don't crash in TilingWFC due to the result containing bad indices. This will help with debugging.
This commit is contained in:
parent
c930e8b754
commit
89d7829c1e
@ -36,6 +36,7 @@ Tile::ActionMap Tile::generate_action_map(const WaveFormCollapse::Symmetry symme
|
||||
|
||||
ActionMap action_map;
|
||||
action_map.set_size(size);
|
||||
action_map.zero();
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
action_map.map[0].write[i] = i;
|
||||
@ -499,7 +500,15 @@ Array2D<int> TilingWaveFormCollapse::id_to_tiling(Array2D<int> ids) {
|
||||
|
||||
for (int i = 0; i < ids.height; i++) {
|
||||
for (int j = 0; j < ids.width; j++) {
|
||||
IdToTilePair oriented_tile = id_to_oriented_tile[ids.get(i, j)];
|
||||
int id = ids.get(i, j);
|
||||
|
||||
if (id < 0 || id >= id_to_oriented_tile.size()) {
|
||||
id = 0;
|
||||
|
||||
ERR_PRINT("id < 0 || id >= id_to_oriented_tile.size()");
|
||||
}
|
||||
|
||||
IdToTilePair oriented_tile = id_to_oriented_tile[id];
|
||||
|
||||
for (int y = 0; y < size; y++) {
|
||||
for (int x = 0; x < size; x++) {
|
||||
|
@ -15,6 +15,12 @@ struct Tile {
|
||||
map[i].resize(size);
|
||||
}
|
||||
}
|
||||
|
||||
void zero() {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
map[i].fill(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static const uint8_t rotation_map[6][9];
|
||||
@ -163,4 +169,4 @@ private:
|
||||
Vector<Vector<int>> oriented_tile_ids;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user