mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 10:21:57 -05:00
#8376: Added static function show_error in S6Importer.cpp
This commit is contained in:
parent
495a756e66
commit
9708e3a043
5 changed files with 16 additions and 30 deletions
|
@ -132,6 +132,7 @@ The following people are not part of the development team, but have been contrib
|
|||
* Steve Xu (stevexu-umich)
|
||||
* (aw20368)
|
||||
* Jim Armstrong (41northstudios)
|
||||
* Kenny Castro-Monroy (kennycastro007)
|
||||
|
||||
## Toolchain
|
||||
* (Balletie) - macOS
|
||||
|
|
|
@ -83,8 +83,6 @@ uint32_t gCurrentRealTimeTicks;
|
|||
|
||||
rct_string_id gGameCommandErrorTitle;
|
||||
rct_string_id gGameCommandErrorText;
|
||||
uint8_t gErrorType;
|
||||
rct_string_id gErrorStringId;
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
|
|
|
@ -133,8 +133,6 @@ using GAME_COMMAND_POINTER = void(
|
|||
|
||||
extern rct_string_id gGameCommandErrorTitle;
|
||||
extern rct_string_id gGameCommandErrorText;
|
||||
extern uint8_t gErrorType;
|
||||
extern rct_string_id gErrorStringId;
|
||||
|
||||
extern GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT];
|
||||
|
||||
|
|
|
@ -292,20 +292,6 @@ void GameState::UpdateLogic()
|
|||
// Update windows
|
||||
// window_dispatch_update_all();
|
||||
|
||||
if (gErrorType != ERROR_TYPE_NONE)
|
||||
{
|
||||
rct_string_id title_text = STR_UNABLE_TO_LOAD_FILE;
|
||||
rct_string_id body_text = gErrorStringId;
|
||||
if (gErrorType == ERROR_TYPE_GENERIC)
|
||||
{
|
||||
title_text = gErrorStringId;
|
||||
body_text = 0xFFFF;
|
||||
}
|
||||
gErrorType = ERROR_TYPE_NONE;
|
||||
|
||||
context_show_error(title_text, body_text);
|
||||
}
|
||||
|
||||
// Start autosave timer after update
|
||||
if (gLastAutoSaveUpdate == AUTOSAVE_PAUSE)
|
||||
{
|
||||
|
|
|
@ -1528,6 +1528,15 @@ std::unique_ptr<IParkImporter> ParkImporter::CreateS6(IObjectRepository& objectR
|
|||
return std::make_unique<S6Importer>(objectRepository);
|
||||
}
|
||||
|
||||
static void show_error(uint8_t errorType, rct_string_id errorStringId)
|
||||
{
|
||||
if (errorType == ERROR_TYPE_GENERIC)
|
||||
{
|
||||
context_show_error(errorStringId, 0xFFFF);
|
||||
}
|
||||
context_show_error(STR_UNABLE_TO_LOAD_FILE, errorStringId);
|
||||
}
|
||||
|
||||
void load_from_sv6(const char* path)
|
||||
{
|
||||
auto context = OpenRCT2::GetContext();
|
||||
|
@ -1546,19 +1555,16 @@ void load_from_sv6(const char* path)
|
|||
}
|
||||
catch (const ObjectLoadException&)
|
||||
{
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_INVALID_DATA);
|
||||
}
|
||||
catch (const IOException& loadError)
|
||||
{
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_GAME_SAVE_FAILED;
|
||||
log_error("Error loading: %s", loadError.what());
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_GAME_SAVE_FAILED);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_INVALID_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1584,20 +1590,17 @@ void load_from_sc6(const char* path)
|
|||
}
|
||||
catch (const ObjectLoadException& loadError)
|
||||
{
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_GAME_SAVE_FAILED;
|
||||
log_error("Error loading: %s", loadError.what());
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_GAME_SAVE_FAILED);
|
||||
}
|
||||
catch (const IOException& loadError)
|
||||
{
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_GAME_SAVE_FAILED;
|
||||
log_error("Error loading: %s", loadError.what());
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_GAME_SAVE_FAILED);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
gErrorType = ERROR_TYPE_FILE_LOAD;
|
||||
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_INVALID_DATA);
|
||||
}
|
||||
gScreenAge = 0;
|
||||
gLastAutoSaveUpdate = AUTOSAVE_PAUSE;
|
||||
|
|
Loading…
Reference in a new issue