1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

Fix #5325: Crash from invalid ride type in research_finish_item

This commit is contained in:
Michał Janiszewski
2017-04-02 15:35:27 +02:00
committed by Michael Steenbeek
parent 10d1e8a538
commit cf87760b60

View File

@@ -15,6 +15,7 @@
#pragma endregion
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../game.h"
#include "../interface/window.h"
#include "../localisation/date.h"
@@ -183,9 +184,10 @@ void research_finish_item(sint32 entryIndex)
sint32 base_ride_type = (entryIndex >> 8) & 0xFF;
sint32 rideEntryIndex = entryIndex & 0xFF;
rct_ride_entry *rideEntry = get_ride_entry(rideEntryIndex);
if (rideEntry != NULL && rideEntry != (rct_ride_entry *)-1)
if (rideEntry != NULL && rideEntry != (rct_ride_entry *)-1 && base_ride_type != RIDE_TYPE_NULL)
{
ride_type_set_invented(base_ride_type);
openrct2_assert(base_ride_type < countof(RideTypePossibleTrackConfigurations), "Invalid base_ride_type = %d", base_ride_type);
gResearchedTrackTypesA[base_ride_type] = (RideTypePossibleTrackConfigurations[base_ride_type]) & 0xFFFFFFFFULL;
gResearchedTrackTypesB[base_ride_type] = (RideTypePossibleTrackConfigurations[base_ride_type] >> 32ULL) & 0xFFFFFFFFULL;