mirror of https://github.com/OpenTTD/OpenTTD.git
Fix: Industry layouts with zero regular tiles should be invalid
This commit is contained in:
parent
578bb6638f
commit
5587e439a9
|
@ -27,6 +27,7 @@
|
|||
#include "newgrf_sound.h"
|
||||
#include "newgrf_station.h"
|
||||
#include "industrytype.h"
|
||||
#include "industry_map.h"
|
||||
#include "newgrf_canal.h"
|
||||
#include "newgrf_townname.h"
|
||||
#include "newgrf_industries.h"
|
||||
|
@ -3374,15 +3375,22 @@ static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader *buf)
|
|||
static bool ValidateIndustryLayout(const IndustryTileLayout &layout)
|
||||
{
|
||||
const size_t size = layout.size();
|
||||
if (size == 0) return false;
|
||||
|
||||
size_t valid_regular_tiles = 0;
|
||||
|
||||
for (size_t i = 0; i < size - 1; i++) {
|
||||
for (size_t j = i + 1; j < size; j++) {
|
||||
if (layout[i].ti.x == layout[j].ti.x &&
|
||||
layout[i].ti.y == layout[j].ti.y) {
|
||||
return false;
|
||||
}
|
||||
if (layout[i].gfx != GFX_WATERTILE_SPECIALCHECK) {
|
||||
++valid_regular_tiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return valid_regular_tiles > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3533,7 +3541,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
|
|||
/* Declared as been valid, can be used */
|
||||
it.gfx = tempid;
|
||||
}
|
||||
} else if (it.gfx == 0xFF) {
|
||||
} else if (it.gfx == GFX_WATERTILE_SPECIALCHECK) {
|
||||
it.ti.x = (int8)GB(it.ti.x, 0, 8);
|
||||
it.ti.y = (int8)GB(it.ti.y, 0, 8);
|
||||
|
||||
|
|
Loading…
Reference in New Issue