mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 20:13:07 +01:00
Move gScenarioFileName to GameState
This commit is contained in:
@@ -326,7 +326,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE):
|
||||
SetAndSaveConfigPath(Config::Get().general.LastSaveLandscapeDirectory, pathBuffer);
|
||||
gScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
|
||||
gameState.ScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
|
||||
if (ScenarioSave(gameState, pathBuffer, Config::Get().general.SavePluginData ? 3 : 2))
|
||||
{
|
||||
gCurrentLoadedPath = pathBuffer;
|
||||
@@ -347,7 +347,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
int32_t parkFlagsBackup = gameState.Park.Flags;
|
||||
gameState.Park.Flags &= ~PARK_FLAGS_SPRITES_INITIALISED;
|
||||
gameState.EditorStep = EditorStep::Invalid;
|
||||
gScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
|
||||
gameState.ScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
|
||||
int32_t success = ScenarioSave(gameState, pathBuffer, Config::Get().general.SavePluginData ? 3 : 2);
|
||||
gameState.Park.Flags = parkFlagsBackup;
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ namespace OpenRCT2
|
||||
std::string ScenarioName;
|
||||
std::string ScenarioDetails;
|
||||
std::string ScenarioCompletedBy;
|
||||
std::string ScenarioFileName;
|
||||
|
||||
std::vector<Banner> Banners;
|
||||
Entity_t Entities[MAX_ENTITIES]{};
|
||||
|
||||
@@ -457,7 +457,7 @@ namespace OpenRCT2
|
||||
|
||||
if (os.GetHeader().TargetVersion >= 1)
|
||||
{
|
||||
cs.ReadWrite(gScenarioFileName);
|
||||
cs.ReadWrite(gameState.ScenarioFileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ namespace OpenRCT2::RCT1
|
||||
|
||||
uint16_t mapSize = _s4.MapSize == 0 ? Limits::kMaxMapSize : _s4.MapSize;
|
||||
|
||||
gScenarioFileName = GetRCT1ScenarioName();
|
||||
gameState.ScenarioFileName = GetRCT1ScenarioName();
|
||||
|
||||
// Do map initialisation, same kind of stuff done when loading scenario editor
|
||||
gameStateInitAll(gameState, { mapSize, mapSize });
|
||||
|
||||
@@ -501,12 +501,13 @@ namespace OpenRCT2::RCT2
|
||||
if (_s6.Header.Type == S6_TYPE_SCENARIO)
|
||||
{
|
||||
// _s6.ScenarioFilename is wrong for some RCT2 expansion scenarios, so we use the real filename
|
||||
gScenarioFileName = Path::GetFileName(_s6Path);
|
||||
gameState.ScenarioFileName = Path::GetFileName(_s6Path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For savegames the filename can be arbitrary, so we have no choice but to rely on the name provided
|
||||
gScenarioFileName = std::string(String::ToStringView(_s6.ScenarioFilename, std::size(_s6.ScenarioFilename)));
|
||||
gameState.ScenarioFileName = std::string(
|
||||
String::ToStringView(_s6.ScenarioFilename, std::size(_s6.ScenarioFilename)));
|
||||
}
|
||||
gCurrentRealTimeTicks = 0;
|
||||
|
||||
|
||||
@@ -70,8 +70,6 @@ uint32_t gLastAutoSaveUpdate = 0;
|
||||
|
||||
bool gAllowEarlyCompletionInNetworkPlay;
|
||||
|
||||
std::string gScenarioFileName;
|
||||
|
||||
static void ScenarioCheckObjective(GameState_t& gameState);
|
||||
|
||||
using namespace OpenRCT2;
|
||||
@@ -205,7 +203,7 @@ void ScenarioSuccess(GameState_t& gameState)
|
||||
gameState.ScenarioCompletedCompanyValue = companyValue;
|
||||
PeepApplause();
|
||||
|
||||
if (ScenarioRepositoryTryRecordHighscore(gScenarioFileName.c_str(), companyValue, nullptr))
|
||||
if (ScenarioRepositoryTryRecordHighscore(gameState.ScenarioFileName.c_str(), companyValue, nullptr))
|
||||
{
|
||||
// Allow name entry
|
||||
gameState.Park.Flags |= PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
@@ -220,7 +218,7 @@ void ScenarioSuccess(GameState_t& gameState)
|
||||
*/
|
||||
void ScenarioSuccessSubmitName(GameState_t& gameState, const char* name)
|
||||
{
|
||||
if (ScenarioRepositoryTryRecordHighscore(gScenarioFileName.c_str(), gameState.ScenarioCompanyValueRecord, name))
|
||||
if (ScenarioRepositoryTryRecordHighscore(gameState.ScenarioFileName.c_str(), gameState.ScenarioCompanyValueRecord, name))
|
||||
{
|
||||
gameState.ScenarioCompletedBy = name;
|
||||
}
|
||||
|
||||
@@ -160,8 +160,6 @@ extern std::string gScenarioSavePath;
|
||||
extern bool gFirstTimeSaving;
|
||||
extern uint32_t gLastAutoSaveUpdate;
|
||||
|
||||
extern std::string gScenarioFileName;
|
||||
|
||||
void ScenarioBegin(OpenRCT2::GameState_t& gameState);
|
||||
void ScenarioReset(OpenRCT2::GameState_t& gameState);
|
||||
void ScenarioUpdate(OpenRCT2::GameState_t& gameState);
|
||||
|
||||
@@ -362,7 +362,8 @@ public:
|
||||
// Get scenario using RCTC style name of RCT2 scenario
|
||||
scenario = GetByFilename((scenarioBaseName + ".sea").c_str());
|
||||
}
|
||||
// gScenarioFileName .Park scenarios is the full file path instead of just <scenarioName.park>, so need to convert
|
||||
// GameState_t::ScenarioFileName .Park scenarios is the full file path instead of just <scenarioName.park>, so need
|
||||
// to convert
|
||||
else if (String::IEquals(scenarioExtension, ".park"))
|
||||
{
|
||||
scenario = GetByFilename((scenarioBaseName + ".park").c_str());
|
||||
|
||||
@@ -231,13 +231,13 @@ namespace OpenRCT2::Scripting
|
||||
|
||||
std::string filename_get()
|
||||
{
|
||||
return gScenarioFileName;
|
||||
return GetGameState().ScenarioFileName;
|
||||
}
|
||||
|
||||
void filename_set(const std::string& value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
gScenarioFileName = value;
|
||||
GetGameState().ScenarioFileName = value;
|
||||
}
|
||||
|
||||
std::shared_ptr<ScScenarioObjective> objective_get() const
|
||||
|
||||
Reference in New Issue
Block a user