mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Merge pull request #730 from duncanspumpkin/fix_728
Fix scenery rating crash
This commit is contained in:
@@ -733,8 +733,8 @@ static int ride_ratings_get_scenery_score(rct_ride *ride)
|
||||
|
||||
// Count surrounding scenery items
|
||||
numSceneryItems = 0;
|
||||
for (yy = y - 5; yy <= y + 5; yy++) {
|
||||
for (xx = x - 5; xx <= x + 5; xx++) {
|
||||
for (yy = max(y - 5, 0); yy <= y + 5; yy++) {
|
||||
for (xx = max(x - 5, 0); xx <= x + 5; xx++) {
|
||||
// Count scenery items on this tile
|
||||
mapElement = map_get_first_element_at(xx, yy);
|
||||
do {
|
||||
|
||||
@@ -88,6 +88,11 @@ void map_element_iterator_restart_for_tile(map_element_iterator *it)
|
||||
|
||||
rct_map_element *map_get_first_element_at(int x, int y)
|
||||
{
|
||||
if (x < 0 || y < 0 || x > 255 || y > 255)
|
||||
{
|
||||
log_error("Trying to access element outside of range");
|
||||
return NULL;
|
||||
}
|
||||
return TILE_MAP_ELEMENT_POINTER(x + y * 256);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user