mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-24 18:17:21 +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;
|
ActionMap action_map;
|
||||||
action_map.set_size(size);
|
action_map.set_size(size);
|
||||||
|
action_map.zero();
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
action_map.map[0].write[i] = 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 i = 0; i < ids.height; i++) {
|
||||||
for (int j = 0; j < ids.width; j++) {
|
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 y = 0; y < size; y++) {
|
||||||
for (int x = 0; x < size; x++) {
|
for (int x = 0; x < size; x++) {
|
||||||
|
@ -15,6 +15,12 @@ struct Tile {
|
|||||||
map[i].resize(size);
|
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];
|
static const uint8_t rotation_map[6][9];
|
||||||
|
Loading…
Reference in New Issue
Block a user