mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-21 22:13:07 +01:00
Fix winning scenarios
This commit is contained in:
@@ -1037,7 +1037,7 @@ static void window_loadsave_select(rct_window* w, const char* path)
|
||||
|
||||
case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE):
|
||||
save_path(&gConfigGeneral.last_save_landscape_directory, pathBuffer);
|
||||
safe_strcpy(gScenarioFileName, pathBuffer, sizeof(gScenarioFileName));
|
||||
gScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
|
||||
if (scenario_save(pathBuffer, gConfigGeneral.save_plugin_data ? 3 : 2))
|
||||
{
|
||||
gCurrentLoadedPath = pathBuffer;
|
||||
@@ -1058,7 +1058,7 @@ static void window_loadsave_select(rct_window* w, const char* path)
|
||||
int32_t parkFlagsBackup = gParkFlags;
|
||||
gParkFlags &= ~PARK_FLAGS_SPRITES_INITIALISED;
|
||||
gEditorStep = EditorStep::Invalid;
|
||||
safe_strcpy(gScenarioFileName, pathBuffer, sizeof(gScenarioFileName));
|
||||
gScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
|
||||
int32_t success = scenario_save(pathBuffer, gConfigGeneral.save_plugin_data ? 3 : 2);
|
||||
gParkFlags = parkFlagsBackup;
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace OpenRCT2
|
||||
|
||||
void ReadWriteScenarioChunk(OrcaStream& os)
|
||||
{
|
||||
os.ReadWriteChunk(ParkFileChunkType::SCENARIO, [](OrcaStream::ChunkStream& cs) {
|
||||
os.ReadWriteChunk(ParkFileChunkType::SCENARIO, [&os](OrcaStream::ChunkStream& cs) {
|
||||
cs.ReadWrite(gScenarioCategory);
|
||||
ReadWriteStringTable(cs, gScenarioName, "en-GB");
|
||||
|
||||
@@ -343,6 +343,11 @@ namespace OpenRCT2
|
||||
{
|
||||
cs.Write(AllowEarlyCompletion());
|
||||
}
|
||||
|
||||
if (os.GetHeader().TargetVersion >= 1)
|
||||
{
|
||||
cs.ReadWrite(gScenarioFileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ private:
|
||||
|
||||
uint16_t mapSize = _s4.map_size == 0 ? RCT1_MAX_MAP_SIZE : _s4.map_size;
|
||||
|
||||
String::Set(gScenarioFileName, sizeof(gScenarioFileName), GetRCT1ScenarioName().c_str());
|
||||
gScenarioFileName = GetRCT1ScenarioName();
|
||||
|
||||
// Do map initialisation, same kind of stuff done when loading scenario editor
|
||||
auto context = OpenRCT2::GetContext();
|
||||
|
||||
@@ -380,12 +380,12 @@ public:
|
||||
if (_s6.header.type == S6_TYPE_SCENARIO)
|
||||
{
|
||||
// _s6.scenario_filename is wrong for some RCT2 expansion scenarios, so we use the real filename
|
||||
String::Set(gScenarioFileName, sizeof(gScenarioFileName), Path::GetFileName(_s6Path));
|
||||
gScenarioFileName = String::ToStd(Path::GetFileName(_s6Path));
|
||||
}
|
||||
else
|
||||
{
|
||||
// For savegames the filename can be arbitrary, so we have no choice but to rely on the name provided
|
||||
String::Set(gScenarioFileName, sizeof(gScenarioFileName), _s6.scenario_filename);
|
||||
gScenarioFileName = std::string(String::ToStringView(_s6.scenario_filename, std::size(_s6.scenario_filename)));
|
||||
}
|
||||
gCurrentRealTimeTicks = 0;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ uint16_t gScenarioParkRatingWarningDays;
|
||||
money64 gScenarioCompletedCompanyValue;
|
||||
money64 gScenarioCompanyValueRecord;
|
||||
|
||||
char gScenarioFileName[MAX_PATH];
|
||||
std::string gScenarioFileName;
|
||||
|
||||
static void scenario_objective_check();
|
||||
|
||||
@@ -206,7 +206,7 @@ void scenario_success()
|
||||
gScenarioCompletedCompanyValue = companyValue;
|
||||
peep_applause();
|
||||
|
||||
if (scenario_repository_try_record_highscore(gScenarioFileName, companyValue, nullptr))
|
||||
if (scenario_repository_try_record_highscore(gScenarioFileName.c_str(), companyValue, nullptr))
|
||||
{
|
||||
// Allow name entry
|
||||
gParkFlags |= PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
@@ -221,7 +221,7 @@ void scenario_success()
|
||||
*/
|
||||
void scenario_success_submit_name(const char* name)
|
||||
{
|
||||
if (scenario_repository_try_record_highscore(gScenarioFileName, gScenarioCompanyValueRecord, name))
|
||||
if (scenario_repository_try_record_highscore(gScenarioFileName.c_str(), gScenarioCompanyValueRecord, name))
|
||||
{
|
||||
gScenarioCompletedBy = name;
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ extern bool gFirstTimeSaving;
|
||||
extern uint16_t gSavedAge;
|
||||
extern uint32_t gLastAutoSaveUpdate;
|
||||
|
||||
extern char gScenarioFileName[260];
|
||||
extern std::string gScenarioFileName;
|
||||
|
||||
void load_from_sc6(const char* path);
|
||||
void scenario_begin();
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace OpenRCT2::Scripting
|
||||
void filename_set(const std::string& value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
String::Set(gScenarioFileName, std::size(gScenarioFileName), value.c_str());
|
||||
gScenarioFileName = value;
|
||||
}
|
||||
|
||||
std::shared_ptr<ScScenarioObjective> objective_get() const
|
||||
|
||||
Reference in New Issue
Block a user