Protect against unknown ride types

This commit is contained in:
Ted John 2018-03-30 16:58:12 +01:00
parent 375deb0c9f
commit 63e9275b60
3 changed files with 6 additions and 5 deletions

View File

@ -21,6 +21,7 @@
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/Context.h>
#include <openrct2/core/String.hpp>
#include <openrct2/Editor.h>
#include <openrct2/EditorObjectSelectionSession.h>
#include <openrct2/Game.h>
@ -304,7 +305,7 @@ static bool visible_list_sort_ride_type(const list_item &a, const list_item &b)
{
auto rideTypeA = language_get_string(get_ride_type_string_id(a.repositoryItem));
auto rideTypeB = language_get_string(get_ride_type_string_id(b.repositoryItem));
sint32 result = strcmp(rideTypeA, rideTypeB);
sint32 result = String::Compare(rideTypeA, rideTypeB);
return result != 0 ?
result < 0 :
visible_list_sort_ride_name(a, b);

View File

@ -80,9 +80,9 @@ namespace String
sint32 Compare(const utf8 * a, const utf8 * b, bool ignoreCase)
{
if (a == b) return true;
if (a == nullptr || b == nullptr) return false;
if (a == b) return 0;
if (a == nullptr) a = "";
if (b == nullptr) b = "";
if (ignoreCase)
{
return _stricmp(a, b);

View File

@ -488,7 +488,7 @@ void RideObject::ReadJson(IReadObjectContext * context, const json_t * root)
rideType = ParseRideType(rideTypes[i]);
if (rideType == RIDE_TYPE_NULL)
{
context->LogWarning(OBJECT_ERROR_INVALID_PROPERTY, "Unknown ride type");
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Unknown ride type");
}
}