mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r15685) -Fix [FS#2720]: do not crash when someone substitutes the "map generation" sprites with garbage.
This commit is contained in:
parent
cef662825b
commit
3d780608a2
@ -352,7 +352,7 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
|
|||||||
* This function takes care of the fact that land in OpenTTD can never differ
|
* This function takes care of the fact that land in OpenTTD can never differ
|
||||||
* more than 1 in height
|
* more than 1 in height
|
||||||
*/
|
*/
|
||||||
static void FixSlopes()
|
void FixSlopes()
|
||||||
{
|
{
|
||||||
uint width, height;
|
uint width, height;
|
||||||
int row, col;
|
int row, col;
|
||||||
|
@ -37,4 +37,10 @@ void LoadHeightmap(char *filename);
|
|||||||
*/
|
*/
|
||||||
void FlatEmptyWorld(byte tile_height);
|
void FlatEmptyWorld(byte tile_height);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function takes care of the fact that land in OpenTTD can never differ
|
||||||
|
* more than 1 in height
|
||||||
|
*/
|
||||||
|
void FixSlopes();
|
||||||
|
|
||||||
#endif /* HEIGHTMAP_H */
|
#endif /* HEIGHTMAP_H */
|
||||||
|
@ -766,7 +766,7 @@ static void GenerateTerrain(int type, uint flag)
|
|||||||
Tile *tile_cur = tile;
|
Tile *tile_cur = tile;
|
||||||
|
|
||||||
for (uint w_cur = w; w_cur != 0; --w_cur) {
|
for (uint w_cur = w; w_cur != 0; --w_cur) {
|
||||||
if (*p >= tile_cur->type_height) tile_cur->type_height = *p;
|
if (GB(*p, 0, 4) >= tile_cur->type_height) tile_cur->type_height = GB(*p, 0, 4);
|
||||||
p++;
|
p++;
|
||||||
tile_cur++;
|
tile_cur++;
|
||||||
}
|
}
|
||||||
@ -779,7 +779,7 @@ static void GenerateTerrain(int type, uint flag)
|
|||||||
Tile *tile_cur = tile;
|
Tile *tile_cur = tile;
|
||||||
|
|
||||||
for (uint h_cur = h; h_cur != 0; --h_cur) {
|
for (uint h_cur = h; h_cur != 0; --h_cur) {
|
||||||
if (*p >= tile_cur->type_height) tile_cur->type_height = *p;
|
if (GB(*p, 0, 4) >= tile_cur->type_height) tile_cur->type_height = GB(*p, 0, 4);
|
||||||
p++;
|
p++;
|
||||||
tile_cur += TileDiffXY(0, 1);
|
tile_cur += TileDiffXY(0, 1);
|
||||||
}
|
}
|
||||||
@ -793,7 +793,7 @@ static void GenerateTerrain(int type, uint flag)
|
|||||||
Tile *tile_cur = tile;
|
Tile *tile_cur = tile;
|
||||||
|
|
||||||
for (uint w_cur = w; w_cur != 0; --w_cur) {
|
for (uint w_cur = w; w_cur != 0; --w_cur) {
|
||||||
if (*p >= tile_cur->type_height) tile_cur->type_height = *p;
|
if (GB(*p, 0, 4) >= tile_cur->type_height) tile_cur->type_height = GB(*p, 0, 4);
|
||||||
p++;
|
p++;
|
||||||
tile_cur--;
|
tile_cur--;
|
||||||
}
|
}
|
||||||
@ -807,7 +807,7 @@ static void GenerateTerrain(int type, uint flag)
|
|||||||
Tile *tile_cur = tile;
|
Tile *tile_cur = tile;
|
||||||
|
|
||||||
for (uint h_cur = h; h_cur != 0; --h_cur) {
|
for (uint h_cur = h; h_cur != 0; --h_cur) {
|
||||||
if (*p >= tile_cur->type_height) tile_cur->type_height = *p;
|
if (GB(*p, 0, 4) >= tile_cur->type_height) tile_cur->type_height = GB(*p, 0, 4);
|
||||||
p++;
|
p++;
|
||||||
tile_cur -= TileDiffXY(0, 1);
|
tile_cur -= TileDiffXY(0, 1);
|
||||||
}
|
}
|
||||||
@ -815,6 +815,8 @@ static void GenerateTerrain(int type, uint flag)
|
|||||||
} while (--w != 0);
|
} while (--w != 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FixSlopes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user