Use range-based for loops in libopenrct2

This commit is contained in:
Hielke Morsink 2017-12-20 02:50:18 +01:00 committed by Michael Steenbeek
parent 3c2aaefc85
commit 628039dd8a
23 changed files with 194 additions and 209 deletions

View File

@ -377,9 +377,9 @@ static void cheat_remove_all_guests()
ride->last_peep_in_queue[stationIndex] = SPRITE_INDEX_NULL; ride->last_peep_in_queue[stationIndex] = SPRITE_INDEX_NULL;
} }
for (size_t trainIndex = 0; trainIndex < 32; trainIndex++) for (auto trainIndex : ride->vehicles)
{ {
spriteIndex = ride->vehicles[trainIndex]; spriteIndex = trainIndex;
while (spriteIndex != SPRITE_INDEX_NULL) while (spriteIndex != SPRITE_INDEX_NULL)
{ {
vehicle = GET_VEHICLE(spriteIndex); vehicle = GET_VEHICLE(spriteIndex);
@ -387,9 +387,9 @@ static void cheat_remove_all_guests()
vehicle->num_peeps = 0; vehicle->num_peeps = 0;
vehicle->next_free_seat = 0; vehicle->next_free_seat = 0;
for (size_t peepInTrainIndex = 0; peepInTrainIndex < 32; peepInTrainIndex++) for (auto &peepInTrainIndex : vehicle->peep)
{ {
vehicle->peep[peepInTrainIndex] = SPRITE_INDEX_NULL; peepInTrainIndex = SPRITE_INDEX_NULL;
} }
spriteIndex = vehicle->next_vehicle_on_train; spriteIndex = vehicle->next_vehicle_on_train;
@ -460,9 +460,9 @@ static void cheat_own_all_land()
} }
// Completely unown peep spawn points // Completely unown peep spawn points
for (sint32 i = 0; i < MAX_PEEP_SPAWNS; i++) { for (const auto &spawn : gPeepSpawns) {
sint32 x = gPeepSpawns[i].x; sint32 x = spawn.x;
sint32 y = gPeepSpawns[i].y; sint32 y = spawn.y;
if (x != PEEP_SPAWN_UNDEFINED) { if (x != PEEP_SPAWN_UNDEFINED) {
rct_tile_element * surfaceElement = map_get_surface_element_at(x >> 5, y >> 5); rct_tile_element * surfaceElement = map_get_surface_element_at(x >> 5, y >> 5);
surfaceElement->properties.surface.ownership = OWNERSHIP_UNOWNED; surfaceElement->properties.surface.ownership = OWNERSHIP_UNOWNED;

View File

@ -297,11 +297,11 @@ namespace Editor
map_remove_all_rides(); map_remove_all_rides();
// //
for (sint32 i = 0; i < MAX_BANNERS; i++) for (auto &banner : gBanners)
{ {
if (gBanners[i].type == 255) if (banner.type == 255)
{ {
gBanners[i].flags &= ~BANNER_FLAG_LINKED_TO_RIDE; banner.flags &= ~BANNER_FLAG_LINKED_TO_RIDE;
} }
} }
@ -551,17 +551,17 @@ namespace Editor
} }
} }
for (sint32 i = 0; i < MAX_PARK_ENTRANCES; i++) for (const auto &parkEntrance : gParkEntrances)
{ {
if (gParkEntrances[i].x == LOCATION_NULL) if (parkEntrance.x == LOCATION_NULL)
{ {
continue; continue;
} }
sint32 x = gParkEntrances[i].x; sint32 x = parkEntrance.x;
sint32 y = gParkEntrances[i].y; sint32 y = parkEntrance.y;
sint32 z = gParkEntrances[i].z / 8; sint32 z = parkEntrance.z / 8;
sint32 direction = gParkEntrances[i].direction ^2; sint32 direction = parkEntrance.direction ^ 2;
switch (footpath_is_connected_to_map_edge(x, y, z, direction, 0)) switch (footpath_is_connected_to_map_edge(x, y, z, direction, 0))
{ {

View File

@ -48,16 +48,19 @@ static void setup_track_manager_objects()
{ {
sint32 numObjects = (sint32)object_repository_get_items_count(); sint32 numObjects = (sint32)object_repository_get_items_count();
const ObjectRepositoryItem * items = object_repository_get_items(); const ObjectRepositoryItem * items = object_repository_get_items();
for (sint32 i = 0; i < numObjects; i++) { for (sint32 i = 0; i < numObjects; i++)
{
uint8 * selectionFlags = &_objectSelectionFlags[i]; uint8 * selectionFlags = &_objectSelectionFlags[i];
const ObjectRepositoryItem * item = &items[i]; const ObjectRepositoryItem * item = &items[i];
uint8 object_type = item->ObjectEntry.flags & 0xF; uint8 object_type = item->ObjectEntry.flags & 0xF;
if (object_type == OBJECT_TYPE_RIDE) { if (object_type == OBJECT_TYPE_RIDE)
{
*selectionFlags |= OBJECT_SELECTION_FLAG_6; *selectionFlags |= OBJECT_SELECTION_FLAG_6;
for (uint8 j = 0; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY; j++) { for (auto rideType : item->RideType)
uint8 rideType = item->RideType[j]; {
if (rideType != RIDE_TYPE_NULL && ride_type_has_flag(rideType, RIDE_TYPE_FLAG_HAS_TRACK)) { if (rideType != RIDE_TYPE_NULL && ride_type_has_flag(rideType, RIDE_TYPE_FLAG_HAS_TRACK))
{
*selectionFlags &= ~OBJECT_SELECTION_FLAG_6; *selectionFlags &= ~OBJECT_SELECTION_FLAG_6;
break; break;
} }
@ -74,17 +77,21 @@ static void setup_track_designer_objects()
{ {
sint32 numObjects = (sint32)object_repository_get_items_count(); sint32 numObjects = (sint32)object_repository_get_items_count();
const ObjectRepositoryItem * items = object_repository_get_items(); const ObjectRepositoryItem * items = object_repository_get_items();
for (sint32 i = 0; i < numObjects; i++) { for (sint32 i = 0; i < numObjects; i++)
{
uint8 * selectionFlags = &_objectSelectionFlags[i]; uint8 * selectionFlags = &_objectSelectionFlags[i];
const ObjectRepositoryItem * item = &items[i]; const ObjectRepositoryItem * item = &items[i];
uint8 objectType = item->ObjectEntry.flags & 0xF; uint8 objectType = item->ObjectEntry.flags & 0xF;
if (objectType == OBJECT_TYPE_RIDE){ if (objectType == OBJECT_TYPE_RIDE)
{
*selectionFlags |= OBJECT_SELECTION_FLAG_6; *selectionFlags |= OBJECT_SELECTION_FLAG_6;
for (uint8 j = 0; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY; j++) { for (uint8 rideType : item->RideType)
uint8 rideType = item->RideType[j]; {
if (rideType != RIDE_TYPE_NULL) { if (rideType != RIDE_TYPE_NULL)
if (RideData4[rideType].flags & RIDE_TYPE_FLAG4_SHOW_IN_TRACK_DESIGNER) { {
if (RideData4[rideType].flags & RIDE_TYPE_FLAG4_SHOW_IN_TRACK_DESIGNER)
{
*selectionFlags &= ~OBJECT_SELECTION_FLAG_6; *selectionFlags &= ~OBJECT_SELECTION_FLAG_6;
break; break;
} }
@ -268,8 +275,9 @@ static void remove_selected_objects_from_research(const rct_object_entry* instal
if (entry_type == OBJECT_TYPE_RIDE){ if (entry_type == OBJECT_TYPE_RIDE){
rct_ride_entry* rideEntry = (rct_ride_entry*)object_entry_groups[entry_type].chunks[entry_index]; rct_ride_entry* rideEntry = (rct_ride_entry*)object_entry_groups[entry_type].chunks[entry_index];
for (uint8 j = 0; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY; j++) { for (auto rideType : rideEntry->ride_type)
research_remove(entry_index | rideEntry->ride_type[j] << 8 | 0x10000); {
research_remove(entry_index | rideType << 8 | 0x10000);
} }
} }
else if (entry_type == OBJECT_TYPE_SCENERY_GROUP){ else if (entry_type == OBJECT_TYPE_SCENERY_GROUP){
@ -308,9 +316,11 @@ void unload_unselected_objects()
*/ */
static void window_editor_object_selection_select_default_objects() static void window_editor_object_selection_select_default_objects()
{ {
if (_numSelectedObjectsForType[0] == 0) { if (_numSelectedObjectsForType[0] == 0)
for (sint32 i = 0; i < (sint32)Util::CountOf(DefaultSelectedObjects); i++) { {
window_editor_object_selection_select_object(0, 7, &DefaultSelectedObjects[i]); for (const auto &defaultSelectedObject : DefaultSelectedObjects)
{
window_editor_object_selection_select_object(0, 7, &defaultSelectedObject);
} }
} }
} }
@ -333,8 +343,9 @@ static void window_editor_object_selection_select_required_objects()
*/ */
void reset_selected_object_count_and_size() void reset_selected_object_count_and_size()
{ {
for (uint8 objectType = 0; objectType < 11; objectType++) { for (auto &objectType : _numSelectedObjectsForType)
_numSelectedObjectsForType[objectType] = 0; {
objectType = 0;
} }
sint32 numObjects = (sint32)object_repository_get_items_count(); sint32 numObjects = (sint32)object_repository_get_items_count();

View File

@ -1134,14 +1134,12 @@ void game_convert_strings_to_utf8()
rct2_to_utf8_self(gScenarioDetails, 256); rct2_to_utf8_self(gScenarioDetails, 256);
// User strings // User strings
for (sint32 i = 0; i < MAX_USER_STRINGS; i++) for (auto * string : gUserStrings)
{ {
utf8 * userString = gUserStrings[i]; if (!str_is_null_or_empty(string))
if (!str_is_null_or_empty(userString))
{ {
rct2_to_utf8_self(userString, RCT12_USER_STRING_MAX_LENGTH); rct2_to_utf8_self(string, RCT12_USER_STRING_MAX_LENGTH);
utf8_remove_formatting(userString, true); utf8_remove_formatting(string, true);
} }
} }
@ -1174,10 +1172,8 @@ void game_convert_strings_to_rct2(rct_s6_data * s6)
utf8_to_rct2_self(s6->scenario_description, sizeof(s6->scenario_description)); utf8_to_rct2_self(s6->scenario_description, sizeof(s6->scenario_description));
// User strings // User strings
for (sint32 i = 0; i < MAX_USER_STRINGS; i++) for (auto * userString : s6->custom_strings)
{ {
char * userString = s6->custom_strings[i];
if (!str_is_null_or_empty(userString)) if (!str_is_null_or_empty(userString))
{ {
utf8_to_rct2_self(userString, RCT12_USER_STRING_MAX_LENGTH); utf8_to_rct2_self(userString, RCT12_USER_STRING_MAX_LENGTH);
@ -1185,13 +1181,11 @@ void game_convert_strings_to_rct2(rct_s6_data * s6)
} }
// News items // News items
for (sint32 i = 0; i < MAX_NEWS_ITEMS; i++) for (auto &newsItem : s6->news_items)
{ {
rct12_news_item * newsItem = &s6->news_items[i]; if (!str_is_null_or_empty(newsItem.Text))
if (!str_is_null_or_empty(newsItem->Text))
{ {
utf8_to_rct2_self(newsItem->Text, sizeof(newsItem->Text)); utf8_to_rct2_self(newsItem.Text, sizeof(newsItem.Text));
} }
} }
} }

View File

@ -148,8 +148,8 @@ sint32 find_object_in_entry_group(const rct_object_entry* entry, uint8* entry_ty
void get_type_entry_index(size_t index, uint8 * outObjectType, uint8 * outEntryIndex) void get_type_entry_index(size_t index, uint8 * outObjectType, uint8 * outEntryIndex)
{ {
uint8 objectType = OBJECT_TYPE_RIDE; uint8 objectType = OBJECT_TYPE_RIDE;
for (size_t i = 0; i < OBJECT_TYPE_COUNT; i++) { for (auto groupCount : object_entry_group_counts)
size_t groupCount = object_entry_group_counts[i]; {
if (index >= groupCount) { if (index >= groupCount) {
index -= groupCount; index -= groupCount;
objectType++; objectType++;

View File

@ -153,9 +153,9 @@ public:
ride->queue_time[i] = 0; ride->queue_time[i] = 0;
} }
for (size_t i = 0; i < MAX_VEHICLES_PER_RIDE; i++) for (auto &vehicle : ride->vehicles)
{ {
ride->vehicles[i] = SPRITE_INDEX_NULL; vehicle = SPRITE_INDEX_NULL;
} }
ride->status = RIDE_STATUS_CLOSED; ride->status = RIDE_STATUS_CLOSED;

View File

@ -87,15 +87,14 @@ public:
sub_6CB945(_rideIndex); sub_6CB945(_rideIndex);
news_item_disable_news(NEWS_ITEM_RIDE, _rideIndex); news_item_disable_news(NEWS_ITEM_RIDE, _rideIndex);
for (sint32 i = 0; i < MAX_BANNERS; i++) for (auto &banner : gBanners)
{ {
rct_banner *banner = &gBanners[i]; if (banner.type != BANNER_NULL &&
if (banner->type != BANNER_NULL && banner.flags & BANNER_FLAG_LINKED_TO_RIDE &&
banner->flags & BANNER_FLAG_LINKED_TO_RIDE && banner.colour == _rideIndex)
banner->colour == _rideIndex)
{ {
banner->flags &= 0xFB; banner.flags &= 0xFB;
banner->string_idx = STR_DEFAULT_SIGN; banner.string_idx = STR_DEFAULT_SIGN;
} }
} }

View File

@ -306,15 +306,14 @@ void audio_start_title_music()
void audio_stop_ride_music() void audio_stop_ride_music()
{ {
for (sint32 i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) for (auto &rideMusic : gRideMusicList)
{ {
rct_ride_music * rideMusic = &gRideMusicList[i]; if (rideMusic.ride_id != RIDE_ID_NULL)
if (rideMusic->ride_id != RIDE_ID_NULL)
{ {
rideMusic->ride_id = RIDE_ID_NULL; rideMusic.ride_id = RIDE_ID_NULL;
if (rideMusic->sound_channel != nullptr) if (rideMusic.sound_channel != nullptr)
{ {
Mixer_Stop_Channel(rideMusic->sound_channel); Mixer_Stop_Channel(rideMusic.sound_channel);
} }
} }
} }
@ -352,9 +351,8 @@ void audio_init_ride_sounds_and_info()
sint32 deviceNum = 0; sint32 deviceNum = 0;
audio_init_ride_sounds(deviceNum); audio_init_ride_sounds(deviceNum);
for (size_t m = 0; m < Util::CountOf(gRideMusicInfoList); m++) for (auto * rideMusicInfo : gRideMusicInfoList)
{ {
rct_ride_music_info * rideMusicInfo = gRideMusicInfoList[m];
const utf8 * path = context_get_path_legacy(rideMusicInfo->path_id); const utf8 * path = context_get_path_legacy(rideMusicInfo->path_id);
if (File::Exists(path)) if (File::Exists(path))
{ {
@ -382,18 +380,16 @@ void audio_init_ride_sounds_and_info()
void audio_init_ride_sounds(sint32 device) void audio_init_ride_sounds(sint32 device)
{ {
audio_close(); audio_close();
for (sint32 i = 0; i < AUDIO_MAX_VEHICLE_SOUNDS; i++) for (auto &vehicleSound : gVehicleSoundList)
{ {
rct_vehicle_sound * vehicleSound = &gVehicleSoundList[i]; vehicleSound.id = SOUND_ID_NULL;
vehicleSound->id = SOUND_ID_NULL;
} }
gAudioCurrentDevice = device; gAudioCurrentDevice = device;
config_save_default(); config_save_default();
for (sint32 i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) for (auto &rideMusic : gRideMusicList)
{ {
rct_ride_music * rideMusic = &gRideMusicList[i]; rideMusic.ride_id = RIDE_ID_NULL;
rideMusic->ride_id = RIDE_ID_NULL;
} }
} }
@ -441,19 +437,18 @@ void audio_stop_vehicle_sounds()
return; return;
} }
for (size_t i = 0; i < Util::CountOf(gVehicleSoundList); i++) for (auto &vehicleSound : gVehicleSoundList)
{ {
rct_vehicle_sound * vehicleSound = &gVehicleSoundList[i]; if (vehicleSound.id != SOUND_ID_NULL)
if (vehicleSound->id != SOUND_ID_NULL)
{ {
vehicleSound->id = SOUND_ID_NULL; vehicleSound.id = SOUND_ID_NULL;
if (vehicleSound->sound1_id != SOUND_ID_NULL) if (vehicleSound.sound1_id != SOUND_ID_NULL)
{ {
Mixer_Stop_Channel(vehicleSound->sound1_channel); Mixer_Stop_Channel(vehicleSound.sound1_channel);
} }
if (vehicleSound->sound2_id != SOUND_ID_NULL) if (vehicleSound.sound2_id != SOUND_ID_NULL)
{ {
Mixer_Stop_Channel(vehicleSound->sound2_channel); Mixer_Stop_Channel(vehicleSound.sound2_channel);
} }
} }
} }

View File

@ -234,12 +234,11 @@ static const PredefinedTheme PredefinedThemes[] = {
static const WindowThemeDesc * GetWindowThemeDescriptor(rct_windowclass windowClass) static const WindowThemeDesc * GetWindowThemeDescriptor(rct_windowclass windowClass)
{ {
for (size_t i = 0; i < Util::CountOf(WindowThemeDescriptors); i++) for (const auto &desc : WindowThemeDescriptors)
{ {
const WindowThemeDesc * desc = &WindowThemeDescriptors[i]; if (desc.WindowClass == windowClass)
if (desc->WindowClass == windowClass)
{ {
return desc; return &desc;
} }
} }
return nullptr; return nullptr;
@ -247,12 +246,11 @@ static const WindowThemeDesc * GetWindowThemeDescriptor(rct_windowclass windowCl
static const WindowThemeDesc * GetWindowThemeDescriptor(const utf8 * windowClassSZ) static const WindowThemeDesc * GetWindowThemeDescriptor(const utf8 * windowClassSZ)
{ {
for (size_t i = 0; i < Util::CountOf(WindowThemeDescriptors); i++) for (const auto &desc : WindowThemeDescriptors)
{ {
const WindowThemeDesc * desc = &WindowThemeDescriptors[i]; if (String::Equals(desc.WindowClassSZ, windowClassSZ))
if (String::Equals(desc->WindowClassSZ, windowClassSZ))
{ {
return desc; return &desc;
} }
} }
return nullptr; return nullptr;

View File

@ -573,9 +573,9 @@ static bool award_is_deserved_most_dazzling_ride_colours(sint32 awardType, sint3
countedRides++; countedRides++;
mainTrackColour = ride->track_colour_main[0]; mainTrackColour = ride->track_colour_main[0];
for (uint32 j = 0; j < Util::CountOf(dazzling_ride_colours); j++) for (auto dazzling_ride_colour : dazzling_ride_colours)
{ {
if (mainTrackColour == dazzling_ride_colours[j]) if (mainTrackColour == dazzling_ride_colour)
{ {
colourfulRides++; colourfulRides++;
break; break;
@ -672,10 +672,10 @@ static bool award_is_deserved(sint32 awardType, sint32 activeAwardTypes)
void award_reset() void award_reset()
{ {
for (sint32 i = 0; i < MAX_AWARDS; i++) for (auto &award : gCurrentAwards)
{ {
gCurrentAwards[i].Time = 0; award.Time = 0;
gCurrentAwards[i].Type = 0; award.Type = 0;
} }
} }
@ -726,10 +726,10 @@ void award_update_all()
} }
// Decrease award times // Decrease award times
for (sint32 i = 0; i < MAX_AWARDS; i++) for (auto &award : gCurrentAwards)
{ {
if (gCurrentAwards[i].Time != 0) if (award.Time != 0)
if (--gCurrentAwards[i].Time == 0) if (--award.Time == 0)
window_invalidate_by_class(WC_PARK_INFORMATION); window_invalidate_by_class(WC_PARK_INFORMATION);
} }
} }

View File

@ -90,9 +90,9 @@ void news_item_init_queue()
news_item_get(11)->Type = NEWS_ITEM_NULL; news_item_get(11)->Type = NEWS_ITEM_NULL;
// Throttles for warning types (PEEP_*_WARNING) // Throttles for warning types (PEEP_*_WARNING)
for (uint32 i = 0; i < Util::CountOf(gPeepWarningThrottle); i++) for (auto &warningThrottle : gPeepWarningThrottle)
{ {
gPeepWarningThrottle[i] = 0; warningThrottle = 0;
} }
auto intent = Intent(INTENT_ACTION_INVALIDATE_TICKER_NEWS); auto intent = Intent(INTENT_ACTION_INVALIDATE_TICKER_NEWS);

View File

@ -242,9 +242,9 @@ void research_finish_item(uint32 entryIndex)
continue; continue;
} }
for (uint8 j = 0; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY; j++) for (auto rideType : rideEntry2->ride_type)
{ {
if (rideEntry2->ride_type[j] == base_ride_type) if (rideType == base_ride_type)
{ {
ride_entry_set_invented(i); ride_entry_set_invented(i);
break; break;
@ -413,19 +413,19 @@ void research_reset_current_item()
ebp->category = cat; ebp->category = cat;
} }
for (sint32 i = 0; i < MAX_RESEARCHED_RIDE_TYPES; ++i) for (auto &researchedRideType : gResearchedRideTypes)
{ {
gResearchedRideTypes[i] = 0; researchedRideType = 0;
} }
for (sint32 i = 0; i < MAX_RESEARCHED_RIDE_ENTRIES; ++i) for (auto &researchedRideEntry : gResearchedRideEntries)
{ {
gResearchedRideEntries[i] = 0; researchedRideEntry = 0;
} }
for (sint32 i = 0; i < MAX_RESEARCHED_SCENERY_ITEMS; i++) for (auto &researchedSceneryItem : gResearchedSceneryItems)
{ {
gResearchedSceneryItems[i] = 0xFFFFFFFF; researchedSceneryItem = 0xFFFFFFFF;
} }
for (sint32 i = 0; i < MAX_SCENERY_GROUP_OBJECTS; ++i) for (sint32 i = 0; i < MAX_SCENERY_GROUP_OBJECTS; ++i)
@ -634,9 +634,8 @@ void research_populate_list_random()
} }
sint32 researched = (scenario_rand() & 0xFF) > 128; sint32 researched = (scenario_rand() & 0xFF) > 128;
for (sint32 j = 0; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY; j++) for (auto rideType : rideEntry->ride_type)
{ {
sint32 rideType = rideEntry->ride_type[j];
if (rideType != RIDE_TYPE_NULL) if (rideType != RIDE_TYPE_NULL)
{ {
research_insert(researched, RESEARCH_ENTRY_RIDE_MASK | (rideType << 8) | i, rideEntry->category[0]); research_insert(researched, RESEARCH_ENTRY_RIDE_MASK | (rideType << 8) | i, rideEntry->category[0]);
@ -669,9 +668,8 @@ void research_populate_list_researched()
continue; continue;
} }
for (sint32 j = 0; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY; j++) for (auto rideType : rideEntry->ride_type)
{ {
sint32 rideType = rideEntry->ride_type[j];
if (rideType != RIDE_TYPE_NULL) if (rideType != RIDE_TYPE_NULL)
{ {
research_insert(true, RESEARCH_ENTRY_RIDE_MASK | (rideType << 8) | i, rideEntry->category[0]); research_insert(true, RESEARCH_ENTRY_RIDE_MASK | (rideType << 8) | i, rideEntry->category[0]);
@ -742,9 +740,8 @@ void research_insert_ride_entry(uint8 entryIndex, bool researched)
{ {
rct_ride_entry * rideEntry = get_ride_entry(entryIndex); rct_ride_entry * rideEntry = get_ride_entry(entryIndex);
uint8 category = rideEntry->category[0]; uint8 category = rideEntry->category[0];
for (sint32 i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++) for (auto rideType : rideEntry->ride_type)
{ {
uint8 rideType = rideEntry->ride_type[i];
if (rideType != RIDE_TYPE_NULL) if (rideType != RIDE_TYPE_NULL)
{ {
research_insert(researched, RESEARCH_ENTRY_RIDE_MASK | (rideType << 8) | entryIndex, category); research_insert(researched, RESEARCH_ENTRY_RIDE_MASK | (rideType << 8) | entryIndex, category);
@ -828,23 +825,23 @@ bool scenery_group_is_invented(sint32 sgIndex)
void reset_researched_scenery_items() void reset_researched_scenery_items()
{ {
for (sint32 i = 0; i < MAX_RESEARCHED_SCENERY_ITEMS; i++) for (auto &researchedSceneryItem : gResearchedSceneryItems)
{ {
gResearchedSceneryItems[i] = 0xFFFFFFFF; researchedSceneryItem = 0xFFFFFFFF;
} }
} }
void reset_researched_ride_types_and_entries() void reset_researched_ride_types_and_entries()
{ {
// Iteration endpoint used to be 4 for unknown reasons, likely a mistake // Iteration endpoint used to be 4 for unknown reasons, likely a mistake
for (sint32 i = 0; i < MAX_RESEARCHED_RIDE_TYPES; i++) for (auto &researchedRideType : gResearchedRideTypes)
{ {
gResearchedRideTypes[i] = 0xFFFFFFFF; researchedRideType = 0xFFFFFFFF;
} }
for (sint32 i = 0; i < MAX_RESEARCHED_RIDE_ENTRIES; i++) for (auto &researchedRideEntry : gResearchedRideEntries)
{ {
gResearchedRideEntries[i] = 0xFFFFFFFF; researchedRideEntry = 0xFFFFFFFF;
} }
} }

View File

@ -55,9 +55,9 @@ struct ObjectEntryHash
size_t operator()(const rct_object_entry &entry) const size_t operator()(const rct_object_entry &entry) const
{ {
uint32 hash = 5381; uint32 hash = 5381;
for (sint32 i = 0; i < 8; i++) for (auto i : entry.name)
{ {
hash = ((hash << 5) + hash) + entry.name[i]; hash = ((hash << 5) + hash) + i;
} }
return hash; return hash;
} }

View File

@ -30,9 +30,9 @@
RideObject::~RideObject() RideObject::~RideObject()
{ {
for (sint32 i = 0; i < 4; i++) for (auto &peepLoadingPosition : _peepLoadingPositions)
{ {
Memory::Free(_peepLoadingPositions[i]); Memory::Free(peepLoadingPosition);
} }
} }
@ -40,9 +40,9 @@ void RideObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
{ {
stream->Seek(8, STREAM_SEEK_CURRENT); stream->Seek(8, STREAM_SEEK_CURRENT);
_legacyType.flags = stream->ReadValue<uint32>(); _legacyType.flags = stream->ReadValue<uint32>();
for (sint32 i = 0; i < RCT2_MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++) for (auto &rideType : _legacyType.ride_type)
{ {
_legacyType.ride_type[i] = stream->ReadValue<uint8>(); rideType = stream->ReadValue<uint8>();
} }
_legacyType.min_cars_in_train = stream->ReadValue<uint8>(); _legacyType.min_cars_in_train = stream->ReadValue<uint8>();
_legacyType.max_cars_in_train = stream->ReadValue<uint8>(); _legacyType.max_cars_in_train = stream->ReadValue<uint8>();
@ -55,10 +55,9 @@ void RideObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
_legacyType.rear_vehicle = stream->ReadValue<uint8>(); _legacyType.rear_vehicle = stream->ReadValue<uint8>();
_legacyType.third_vehicle = stream->ReadValue<uint8>(); _legacyType.third_vehicle = stream->ReadValue<uint8>();
_legacyType.pad_019 = stream->ReadValue<uint8>(); _legacyType.pad_019 = stream->ReadValue<uint8>();
for (sint32 i = 0; i < RCT2_MAX_VEHICLES_PER_RIDE_ENTRY; i++) for (auto &vehicleEntry : _legacyType.vehicles)
{ {
rct_ride_entry_vehicle * entry = &_legacyType.vehicles[i]; ReadLegacyVehicle(context, stream, &vehicleEntry);
ReadLegacyVehicle(context, stream, entry);
} }
stream->Seek(4, STREAM_SEEK_CURRENT); stream->Seek(4, STREAM_SEEK_CURRENT);
_legacyType.excitement_multiplier = stream->ReadValue<sint8>(); _legacyType.excitement_multiplier = stream->ReadValue<sint8>();
@ -317,9 +316,9 @@ void RideObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 heigh
{ {
uint32 imageId = _legacyType.images_offset; uint32 imageId = _legacyType.images_offset;
for (size_t i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++) for (auto rideType : _legacyType.ride_type)
{ {
if (_legacyType.ride_type[i] != RIDE_TYPE_NULL) if (rideType != RIDE_TYPE_NULL)
break; break;
else else
imageId++; imageId++;
@ -442,9 +441,9 @@ void RideObject::PerformFixes()
std::string identifier = GetIdentifier(); std::string identifier = GetIdentifier();
// Add boosters if the track type is eligible // Add boosters if the track type is eligible
for (sint32 i = 0; i < RCT2_MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++) for (auto rideType : _legacyType.ride_type)
{ {
if (ride_type_supports_boosters(_legacyType.ride_type[i])) if (ride_type_supports_boosters(rideType))
{ {
_legacyType.enabledTrackPieces |= (1ULL << TRACK_BOOSTER); _legacyType.enabledTrackPieces |= (1ULL << TRACK_BOOSTER);
} }

View File

@ -64,9 +64,9 @@ static void paint_session_init(paint_session * session, rct_drawpixelinfo * dpi)
session->NextFreePaintStruct = session->PaintStructs; session->NextFreePaintStruct = session->PaintStructs;
session->UnkF1AD28 = nullptr; session->UnkF1AD28 = nullptr;
session->UnkF1AD2C = nullptr; session->UnkF1AD2C = nullptr;
for (sint32 i = 0; i < MAX_PAINT_QUADRANTS; i++) for (auto &quadrant : session->Quadrants)
{ {
session->Quadrants[i] = nullptr; quadrant = nullptr;
} }
session->QuadrantBackIndex = -1; session->QuadrantBackIndex = -1;
session->QuadrantFrontIndex = 0; session->QuadrantFrontIndex = 0;

View File

@ -1105,17 +1105,15 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
gCurrentViewportFlags & VIEWPORT_FLAG_LAND_OWNERSHIP) gCurrentViewportFlags & VIEWPORT_FLAG_LAND_OWNERSHIP)
{ {
const LocationXY16& pos = session->MapPosition; const LocationXY16& pos = session->MapPosition;
for (sint32 i = 0; i < MAX_PEEP_SPAWNS; ++i) for (auto &spawn : gPeepSpawns)
{ {
const rct2_peep_spawn * spawn = &gPeepSpawns[i]; if ((spawn.x & 0xFFE0) == pos.x && (spawn.y & 0xFFE0) == pos.y)
if ((spawn->x & 0xFFE0) == pos.x && (spawn->y & 0xFFE0) == pos.y)
{ {
sub_98196C(session, SPR_TERRAIN_SELECTION_SQUARE_SIMPLE, 0, 0, 32, 32, 16, spawn->z * 16, rotation); sub_98196C(session, SPR_TERRAIN_SELECTION_SQUARE_SIMPLE, 0, 0, 32, 32, 16, spawn.z * 16, rotation);
const sint32 offset = ((spawn->direction ^ 2) + rotation) & 3; const sint32 offset = ((spawn.direction ^ 2) + rotation) & 3;
const uint32 image_id = (PEEP_SPAWN_ARROW_0 + offset) | 0x20380000; const uint32 image_id = (PEEP_SPAWN_ARROW_0 + offset) | 0x20380000;
sub_98196C(session, image_id, 0, 0, 32, 32, 19, spawn->z * 16, rotation); sub_98196C(session, image_id, 0, 0, 32, 32, 19, spawn.z * 16, rotation);
} }
} }
} }
@ -1362,7 +1360,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
uint8 al = regs.al | regs.ah; uint8 al = regs.al | regs.ah;
for (sint32 i = 0; i < 4; i++) for (const auto& fenceData : _tileSurfaceBoundaries)
{ {
const sint32 bit = al & 1; const sint32 bit = al & 1;
al >>= 1; al >>= 1;
@ -1370,8 +1368,6 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
if (bit == 0) if (bit == 0)
continue; continue;
const tile_surface_boundary_data& fenceData = _tileSurfaceBoundaries[i];
sint32 local_height = height; sint32 local_height = height;
sint32 image_id = 0; sint32 image_id = 0;

View File

@ -10361,12 +10361,12 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep
bool pathLoop = false; bool pathLoop = false;
/* Check the peep->pathfind_history to see if this junction has /* Check the peep->pathfind_history to see if this junction has
* already been visited by the peep while heading for this goal. */ * already been visited by the peep while heading for this goal. */
for (sint32 i = 0; i < 4; ++i) for (auto &pathfindHistory : peep->pathfind_history)
{ {
if (peep->pathfind_history[i].x == x >> 5 && peep->pathfind_history[i].y == y >> 5 && if (pathfindHistory.x == x >> 5 && pathfindHistory.y == y >> 5 &&
peep->pathfind_history[i].z == z) pathfindHistory.z == z)
{ {
if (peep->pathfind_history[i].direction == 0) if (pathfindHistory.direction == 0)
{ {
/* If all directions have already been tried while /* If all directions have already been tried while
* heading to this goal, this is a loop. */ * heading to this goal, this is a loop. */
@ -10377,7 +10377,7 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep
/* The peep remembers walking through this junction /* The peep remembers walking through this junction
* before, but has not yet tried all directions. * before, but has not yet tried all directions.
* Limit the edges to search to those not yet tried. */ * Limit the edges to search to those not yet tried. */
edges &= peep->pathfind_history[i].direction; edges &= pathfindHistory.direction;
} }
break; break;
} }
@ -10633,10 +10633,10 @@ sint32 peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep * pe
/* If the peep remembers walking through this junction /* If the peep remembers walking through this junction
* previously while heading for its goal, retrieve the * previously while heading for its goal, retrieve the
* directions it has not yet tried. */ * directions it has not yet tried. */
for (sint32 i = 0; i < 4; ++i) for (auto &pathfindHistory : peep->pathfind_history)
{ {
if (peep->pathfind_history[i].x == x / 32 && peep->pathfind_history[i].y == y / 32 && if (pathfindHistory.x == x / 32 && pathfindHistory.y == y / 32 &&
peep->pathfind_history[i].z == z) pathfindHistory.z == z)
{ {
/* Fix broken pathfind_history[i].direction /* Fix broken pathfind_history[i].direction
@ -10645,9 +10645,9 @@ sint32 peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep * pe
* changes or in earlier code .directions was * changes or in earlier code .directions was
* initialised to 0xF rather than the permitted * initialised to 0xF rather than the permitted
* edges. */ * edges. */
peep->pathfind_history[i].direction &= permitted_edges; pathfindHistory.direction &= permitted_edges;
edges = peep->pathfind_history[i].direction; edges = pathfindHistory.direction;
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
if (gPathFindDebug) if (gPathFindDebug)
@ -10668,8 +10668,8 @@ sint32 peep_pathfind_choose_direction(sint16 x, sint16 y, uint8 z, rct_peep * pe
* the paths or the pathfinding itself * the paths or the pathfinding itself
* has changed (been fixed) since * has changed (been fixed) since
* the game was saved. */ * the game was saved. */
peep->pathfind_history[i].direction = permitted_edges; pathfindHistory.direction = permitted_edges;
edges = peep->pathfind_history[i].direction; edges = pathfindHistory.direction;
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
if (gPathFindDebug) if (gPathFindDebug)
@ -13491,9 +13491,9 @@ static void peep_pick_ride_to_go_on(rct_peep * peep)
if (peep->x == LOCATION_NULL) if (peep->x == LOCATION_NULL)
return; return;
for (uint32 i = 0; i < Util::CountOf(_peepRideConsideration); i++) for (auto &rideConsideration : _peepRideConsideration)
{ {
_peepRideConsideration[i] = 0; rideConsideration = 0;
} }
// FIX Originally checked for a toy, likely a mistake and should be a map, // FIX Originally checked for a toy, likely a mistake and should be a map,
@ -13632,9 +13632,9 @@ static void peep_head_for_nearest_ride_type(rct_peep * peep, sint32 rideType)
} }
} }
for (uint32 i = 0; i < Util::CountOf(_peepRideConsideration); i++) for (auto &rideConsideration : _peepRideConsideration)
{ {
_peepRideConsideration[i] = 0; rideConsideration = 0;
} }
// FIX Originally checked for a toy,.likely a mistake and should be a map // FIX Originally checked for a toy,.likely a mistake and should be a map
@ -13764,9 +13764,9 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep * peep, sint32 rideTy
return; return;
} }
for (uint32 i = 0; i < Util::CountOf(_peepRideConsideration); i++) for (auto &rideConsideration : _peepRideConsideration)
{ {
_peepRideConsideration[i] = 0; rideConsideration = 0;
} }
// FIX Originally checked for a toy,.likely a mistake and should be a map // FIX Originally checked for a toy,.likely a mistake and should be a map

View File

@ -1260,9 +1260,9 @@ private:
void FixVehiclePeepLinks(rct_vehicle * vehicle, const uint16 * spriteIndexMap) void FixVehiclePeepLinks(rct_vehicle * vehicle, const uint16 * spriteIndexMap)
{ {
for (int i = 0; i < 32; i++) for (auto &peep : vehicle->peep)
{ {
vehicle->peep[i] = MapSpriteIndex(vehicle->peep[i], spriteIndexMap); peep = MapSpriteIndex(peep, spriteIndexMap);
} }
} }
@ -1506,9 +1506,9 @@ private:
void FixRidePeepLinks(Ride * ride, const uint16 * spriteIndexMap) void FixRidePeepLinks(Ride * ride, const uint16 * spriteIndexMap)
{ {
for (sint32 i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++) for (auto &peep : ride->last_peep_in_queue)
{ {
ride->last_peep_in_queue[i] = MapSpriteIndex(ride->last_peep_in_queue[i], spriteIndexMap); peep = MapSpriteIndex(peep, spriteIndexMap);
} }
ride->mechanic = MapSpriteIndex(ride->mechanic, spriteIndexMap); ride->mechanic = MapSpriteIndex(ride->mechanic, spriteIndexMap);
if (ride->type == RIDE_TYPE_SPIRAL_SLIDE) if (ride->type == RIDE_TYPE_SPIRAL_SLIDE)
@ -1565,12 +1565,11 @@ private:
void ImportLitter() void ImportLitter()
{ {
for (auto &sprite : _s4.sprites)
for (size_t i = 0; i < RCT1_MAX_SPRITES; i++)
{ {
if (_s4.sprites[i].unknown.sprite_identifier == SPRITE_IDENTIFIER_LITTER) if (sprite.unknown.sprite_identifier == SPRITE_IDENTIFIER_LITTER)
{ {
rct_litter * srcLitter = &_s4.sprites[i].litter; rct_litter * srcLitter = &sprite.litter;
rct_litter * litter = (rct_litter *) create_sprite(SPRITE_IDENTIFIER_LITTER); rct_litter * litter = (rct_litter *) create_sprite(SPRITE_IDENTIFIER_LITTER);
move_sprite_to_list((rct_sprite *) litter, SPRITE_LIST_LITTER * 2); move_sprite_to_list((rct_sprite *) litter, SPRITE_LIST_LITTER * 2);
@ -1594,11 +1593,11 @@ private:
void ImportMiscSprites() void ImportMiscSprites()
{ {
for (size_t i = 0; i < RCT1_MAX_SPRITES; i++) for (auto &sprite : _s4.sprites)
{ {
if (_s4.sprites[i].unknown.sprite_identifier == SPRITE_IDENTIFIER_MISC) if (sprite.unknown.sprite_identifier == SPRITE_IDENTIFIER_MISC)
{ {
rct1_unk_sprite * src = &_s4.sprites[i].unknown; rct1_unk_sprite * src = &sprite.unknown;
rct_unk_sprite * dst = (rct_unk_sprite *) create_sprite(SPRITE_IDENTIFIER_MISC); rct_unk_sprite * dst = (rct_unk_sprite *) create_sprite(SPRITE_IDENTIFIER_MISC);
move_sprite_to_list((rct_sprite *) dst, SPRITE_LIST_MISC * 2); move_sprite_to_list((rct_sprite *) dst, SPRITE_LIST_MISC * 2);

View File

@ -77,9 +77,9 @@ rct_vehicle * cable_lift_segment_create(sint32 rideIndex,
current->scream_sound_id = 0xFF; current->scream_sound_id = 0xFF;
current->vehicle_sprite_type = 0; current->vehicle_sprite_type = 0;
current->bank_rotation = 0; current->bank_rotation = 0;
for (sint32 j = 0; j < 32; j++) for (auto &peep : current->peep)
{ {
current->peep[j] = SPRITE_INDEX_NULL; peep = SPRITE_INDEX_NULL;
} }
current->var_CD = 0; current->var_CD = 0;
current->sprite_direction = direction << 3; current->sprite_direction = direction << 3;

View File

@ -1028,28 +1028,27 @@ void vehicle_sounds_update()
{ {
vehicle_update_sound_params(&get_sprite(i)->vehicle); vehicle_update_sound_params(&get_sprite(i)->vehicle);
} }
for (uint32 i = 0; i < Util::CountOf(gVehicleSoundList); i++) for (auto &vehicle_sound : gVehicleSoundList)
{ {
rct_vehicle_sound * vehicle_sound = &gVehicleSoundList[i]; if (vehicle_sound.id != SOUND_ID_NULL)
if (vehicle_sound->id != SOUND_ID_NULL)
{ {
for (rct_vehicle_sound_params * vehicle_sound_params = &gVehicleSoundParamsList[0]; for (rct_vehicle_sound_params * vehicle_sound_params = &gVehicleSoundParamsList[0];
vehicle_sound_params != gVehicleSoundParamsListEnd; vehicle_sound_params++) vehicle_sound_params != gVehicleSoundParamsListEnd; vehicle_sound_params++)
{ {
if (vehicle_sound->id == vehicle_sound_params->id) if (vehicle_sound.id == vehicle_sound_params->id)
{ {
goto label26; goto label26;
} }
} }
if (vehicle_sound->sound1_id != SOUND_ID_NULL) if (vehicle_sound.sound1_id != SOUND_ID_NULL)
{ {
Mixer_Stop_Channel(vehicle_sound->sound1_channel); Mixer_Stop_Channel(vehicle_sound.sound1_channel);
} }
if (vehicle_sound->sound2_id != SOUND_ID_NULL) if (vehicle_sound.sound2_id != SOUND_ID_NULL)
{ {
Mixer_Stop_Channel(vehicle_sound->sound2_channel); Mixer_Stop_Channel(vehicle_sound.sound2_channel);
} }
vehicle_sound->id = SOUND_ID_NULL; vehicle_sound.id = SOUND_ID_NULL;
} }
label26:; label26:;
} }
@ -2310,10 +2309,8 @@ static void vehicle_update_waiting_for_passengers(rct_vehicle * vehicle)
if (ride->depart_flags & RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES) if (ride->depart_flags & RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES)
{ {
for (auto train_id : ride->vehicles)
for (sint32 i = 0; i < MAX_VEHICLES_PER_RIDE; ++i)
{ {
uint16 train_id = ride->vehicles[i];
if (train_id == SPRITE_INDEX_NULL) if (train_id == SPRITE_INDEX_NULL)
continue; continue;
@ -4625,15 +4622,15 @@ static void vehicle_update_boat_location(rct_vehicle * vehicle)
} }
static const sint8 rotations[] = { 0, 1, -1, 2 }; static const sint8 rotations[] = { 0, 1, -1, 2 };
for (sint32 i = 0; i < 4; i++) for (auto rotation : rotations)
{ {
if (randDirection + rotations[i] == curDirection) if (randDirection + rotation == curDirection)
{ {
continue; continue;
} }
sint16 x = vehicle->track_x + TileDirectionDelta[(randDirection + rotations[i]) & 3].x; sint16 x = vehicle->track_x + TileDirectionDelta[(randDirection + rotation) & 3].x;
sint16 y = vehicle->track_y + TileDirectionDelta[(randDirection + rotations[i]) & 3].y; sint16 y = vehicle->track_y + TileDirectionDelta[(randDirection + rotation) & 3].y;
if (vehicle_is_boat_on_water(vehicle, x, y)) if (vehicle_is_boat_on_water(vehicle, x, y))
{ {
@ -6454,10 +6451,10 @@ bool vehicle_update_dodgems_collision(rct_vehicle * vehicle, sint16 x, sint16 y,
LocationXY8 location = { static_cast<uint8>(x / 32), static_cast<uint8>(y / 32) }; LocationXY8 location = { static_cast<uint8>(x / 32), static_cast<uint8>(y / 32) };
uint8 rideIndex = vehicle->ride; uint8 rideIndex = vehicle->ride;
for (uint32 i = 0; i < Util::CountOf(Unk9A37C4); i++) for (auto xy_offset : Unk9A37C4)
{ {
location.x += Unk9A37C4[i].x; location.x += xy_offset.x;
location.y += Unk9A37C4[i].y; location.y += xy_offset.y;
uint16 spriteIdx = sprite_get_first_in_quadrant(location.x * 32, location.y * 32); uint16 spriteIdx = sprite_get_first_in_quadrant(location.x * 32, location.y * 32);
while (spriteIdx != SPRITE_INDEX_NULL) while (spriteIdx != SPRITE_INDEX_NULL)
@ -7657,10 +7654,10 @@ static bool vehicle_update_motion_collision_detection(rct_vehicle * vehicle, sin
bool mayCollide = false; bool mayCollide = false;
uint16 collideId = SPRITE_INDEX_NULL; uint16 collideId = SPRITE_INDEX_NULL;
rct_vehicle * collideVehicle = NULL; rct_vehicle * collideVehicle = NULL;
for (uint32 i = 0; i < Util::CountOf(Unk9A37C4); i++) for (auto xy_offset : Unk9A37C4)
{ {
location.x += Unk9A37C4[i].x; location.x += xy_offset.x;
location.y += Unk9A37C4[i].y; location.y += xy_offset.y;
collideId = sprite_get_first_in_quadrant(location.x * 32, location.y * 32); collideId = sprite_get_first_in_quadrant(location.x * 32, location.y * 32);
for (; collideId != SPRITE_INDEX_NULL; collideId = collideVehicle->next_in_quadrant) for (; collideId != SPRITE_INDEX_NULL; collideId = collideVehicle->next_in_quadrant)

View File

@ -214,12 +214,12 @@ void vehicle_visual_virginia_reel(paint_session * session, sint32 x, sint32 imag
riding_peep_sprites[((ecx / 8) + i) & 3] = vehicle->peep_tshirt_colours[i]; riding_peep_sprites[((ecx / 8) + i) & 3] = vehicle->peep_tshirt_colours[i];
} }
sint32 draw_order[4] = { 0, 1, 3, 2 }; sint32 draw_order[4] = { 0, 1, 3, 2 };
for (uint32 i = 0; i < Util::CountOf(draw_order); i++) for (auto i : draw_order)
{ {
if (riding_peep_sprites[draw_order[i]] != 0xFF) if (riding_peep_sprites[i] != 0xFF)
{ {
image_id = (baseImage_id + ((draw_order[i] + 1) * 72)) | image_id = (baseImage_id + ((i + 1) * 72)) |
SPRITE_ID_PALETTE_COLOUR_1(riding_peep_sprites[draw_order[i]]); SPRITE_ID_PALETTE_COLOUR_1(riding_peep_sprites[i]);
sub_98199C(session, image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, sub_98199C(session, image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y,
bb->offset_z + z, rotation); bb->offset_z + z, rotation);
} }

View File

@ -687,17 +687,17 @@ extern "C"
void fix_park_entrance_locations(void) void fix_park_entrance_locations(void)
{ {
// Fix gParkEntrance locations for which the tile_element no longer exists // Fix gParkEntrance locations for which the tile_element no longer exists
for (uint8 entranceNum = 0; entranceNum < MAX_PARK_ENTRANCES; ++entranceNum) for (auto &entrance : gParkEntrances)
{ {
if (gParkEntrances[entranceNum].x == LOCATION_NULL) if (entrance.x == LOCATION_NULL)
continue; continue;
if (map_get_park_entrance_element_at( if (map_get_park_entrance_element_at(
gParkEntrances[entranceNum].x, entrance.x,
gParkEntrances[entranceNum].y, entrance.y,
gParkEntrances[entranceNum].z >> 3, false) == NULL) entrance.z >> 3, false) == NULL)
{ {
gParkEntrances[entranceNum].x = LOCATION_NULL; entrance.x = LOCATION_NULL;
} }
} }
} }

View File

@ -498,9 +498,9 @@ static uint8 perm[512];
static void noise_rand() static void noise_rand()
{ {
for (uint32 i = 0; i < Util::CountOf(perm); i++) for (auto &i : perm)
{ {
perm[i] = util_rand() & 0xFF; i = util_rand() & 0xFF;
} }
} }