forked from rosebudai/OpenRCT2-Web
Move most gScenario* globals to GameState_t
This commit is contained in:
1 parent
d4b0c2e115
commit
115e7389a9
23 files changed
+308
-278
No files matched your search
@@ -439,7 +439,7 @@ static void ShortcutQuickSaveGame()
|
||||
{
|
||||
auto intent = Intent(WindowClass::Loadsave);
|
||||
intent.PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE);
|
||||
intent.PutExtra(INTENT_EXTRA_PATH, gScenarioName);
|
||||
intent.PutExtra(INTENT_EXTRA_PATH, GetGameState().ScenarioName);
|
||||
ContextOpenIntent(&intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace OpenRCT2::Scripting
|
||||
}
|
||||
|
||||
if (isScenario)
|
||||
ScenarioBegin();
|
||||
ScenarioBegin(gameState);
|
||||
else
|
||||
GameLoadInit();
|
||||
gLoadKeepWindowsOpen = old;
|
||||
|
||||
@@ -254,7 +254,8 @@ private:
|
||||
|
||||
void JumpForwardToSaveScenario() const
|
||||
{
|
||||
const auto savePrepareResult = ScenarioPrepareForSave();
|
||||
auto& gameState = GetGameState();
|
||||
const auto savePrepareResult = ScenarioPrepareForSave(gameState);
|
||||
if (!savePrepareResult.Successful)
|
||||
{
|
||||
ContextShowError(STR_UNABLE_TO_SAVE_SCENARIO_FILE, savePrepareResult.Message, {});
|
||||
@@ -265,7 +266,7 @@ private:
|
||||
WindowCloseAll();
|
||||
auto intent = Intent(WindowClass::Loadsave);
|
||||
intent.PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO);
|
||||
intent.PutExtra(INTENT_EXTRA_PATH, gScenarioName);
|
||||
intent.PutExtra(INTENT_EXTRA_PATH, gameState.ScenarioName);
|
||||
ContextOpenIntent(&intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -390,7 +390,8 @@ private:
|
||||
*/
|
||||
void SetObjective(int32_t objective)
|
||||
{
|
||||
gScenarioObjective.Type = objective;
|
||||
auto& gameState = GetGameState();
|
||||
gameState.ScenarioObjective.Type = objective;
|
||||
Invalidate();
|
||||
|
||||
// Set default objective arguments
|
||||
@@ -402,36 +403,37 @@ private:
|
||||
case OBJECTIVE_10_ROLLERCOASTERS:
|
||||
break;
|
||||
case OBJECTIVE_GUESTS_BY:
|
||||
gScenarioObjective.Year = 3;
|
||||
gScenarioObjective.NumGuests = 1500;
|
||||
gameState.ScenarioObjective.Year = 3;
|
||||
gameState.ScenarioObjective.NumGuests = 1500;
|
||||
break;
|
||||
case OBJECTIVE_PARK_VALUE_BY:
|
||||
gScenarioObjective.Year = 3;
|
||||
gScenarioObjective.Currency = 50000.00_GBP;
|
||||
gameState.ScenarioObjective.Year = 3;
|
||||
gameState.ScenarioObjective.Currency = 50000.00_GBP;
|
||||
break;
|
||||
case OBJECTIVE_GUESTS_AND_RATING:
|
||||
gScenarioObjective.NumGuests = 2000;
|
||||
gameState.ScenarioObjective.NumGuests = 2000;
|
||||
break;
|
||||
case OBJECTIVE_MONTHLY_RIDE_INCOME:
|
||||
gScenarioObjective.Currency = 10000.00_GBP;
|
||||
gameState.ScenarioObjective.Currency = 10000.00_GBP;
|
||||
break;
|
||||
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
|
||||
gScenarioObjective.MinimumLength = 1200;
|
||||
gameState.ScenarioObjective.MinimumLength = 1200;
|
||||
break;
|
||||
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
|
||||
gScenarioObjective.MinimumExcitement = FIXED_2DP(6, 70);
|
||||
gameState.ScenarioObjective.MinimumExcitement = FIXED_2DP(6, 70);
|
||||
break;
|
||||
case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE:
|
||||
gScenarioObjective.Currency = 50000.00_GBP;
|
||||
gameState.ScenarioObjective.Currency = 50000.00_GBP;
|
||||
break;
|
||||
case OBJECTIVE_MONTHLY_FOOD_INCOME:
|
||||
gScenarioObjective.Currency = 1000.00_GBP;
|
||||
gameState.ScenarioObjective.Currency = 1000.00_GBP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ShowObjectiveDropdown()
|
||||
{
|
||||
const auto& gameState = GetGameState();
|
||||
int32_t numItems = 0, objectiveType;
|
||||
Widget* dropdownWidget;
|
||||
|
||||
@@ -458,7 +460,7 @@ private:
|
||||
{ windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1, colours[1],
|
||||
0, Dropdown::Flag::StayOpen, numItems, dropdownWidget->width() - 3);
|
||||
|
||||
objectiveType = gScenarioObjective.Type;
|
||||
objectiveType = gameState.ScenarioObjective.Type;
|
||||
for (int32_t j = 0; j < numItems; j++)
|
||||
{
|
||||
if (gDropdownItems[j].Args - STR_OBJECTIVE_DROPDOWN_NONE == objectiveType)
|
||||
@@ -484,67 +486,68 @@ private:
|
||||
WindowDropdownShowTextCustomWidth(
|
||||
{ windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1, colours[1],
|
||||
0, Dropdown::Flag::StayOpen, 5, dropdownWidget->width() - 3);
|
||||
Dropdown::SetChecked(gScenarioCategory, true);
|
||||
Dropdown::SetChecked(GetGameState().ScenarioCategory, true);
|
||||
}
|
||||
|
||||
void Arg1Increase()
|
||||
{
|
||||
switch (gScenarioObjective.Type)
|
||||
auto& gameState = GetGameState();
|
||||
switch (gameState.ScenarioObjective.Type)
|
||||
{
|
||||
case OBJECTIVE_PARK_VALUE_BY:
|
||||
case OBJECTIVE_MONTHLY_RIDE_INCOME:
|
||||
case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE:
|
||||
if (gScenarioObjective.Currency >= ObjectiveCurrencyLoanAndValueMax)
|
||||
if (gameState.ScenarioObjective.Currency >= ObjectiveCurrencyLoanAndValueMax)
|
||||
{
|
||||
ContextShowError(STR_CANT_INCREASE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.Currency += ObjectiveCurrencyLoanAndValueAdjustment;
|
||||
gameState.ScenarioObjective.Currency += ObjectiveCurrencyLoanAndValueAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case OBJECTIVE_MONTHLY_FOOD_INCOME:
|
||||
if (gScenarioObjective.Currency >= ObjectiveCurrencyFoodMax)
|
||||
if (gameState.ScenarioObjective.Currency >= ObjectiveCurrencyFoodMax)
|
||||
{
|
||||
ContextShowError(STR_CANT_INCREASE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.Currency += ObjectiveCurrencyFoodAdjustment;
|
||||
gameState.ScenarioObjective.Currency += ObjectiveCurrencyFoodAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
|
||||
if (gScenarioObjective.MinimumLength >= ObjectiveLengthMax)
|
||||
if (gameState.ScenarioObjective.MinimumLength >= ObjectiveLengthMax)
|
||||
{
|
||||
ContextShowError(STR_CANT_INCREASE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.MinimumLength += ObjectiveLengthAdjustment;
|
||||
gameState.ScenarioObjective.MinimumLength += ObjectiveLengthAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
|
||||
if (gScenarioObjective.MinimumExcitement >= ObjectiveExcitementMax)
|
||||
if (gameState.ScenarioObjective.MinimumExcitement >= ObjectiveExcitementMax)
|
||||
{
|
||||
ContextShowError(STR_CANT_INCREASE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.MinimumExcitement += ObjectiveExcitementAdjustment;
|
||||
gameState.ScenarioObjective.MinimumExcitement += ObjectiveExcitementAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (gScenarioObjective.NumGuests >= ObjectiveGuestsMax)
|
||||
if (gameState.ScenarioObjective.NumGuests >= ObjectiveGuestsMax)
|
||||
{
|
||||
ContextShowError(STR_CANT_INCREASE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.NumGuests += ObjectiveGuestsAdjustment;
|
||||
gameState.ScenarioObjective.NumGuests += ObjectiveGuestsAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
@@ -553,62 +556,63 @@ private:
|
||||
|
||||
void Arg1Decrease()
|
||||
{
|
||||
switch (gScenarioObjective.Type)
|
||||
auto& gameState = GetGameState();
|
||||
switch (gameState.ScenarioObjective.Type)
|
||||
{
|
||||
case OBJECTIVE_PARK_VALUE_BY:
|
||||
case OBJECTIVE_MONTHLY_RIDE_INCOME:
|
||||
case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE:
|
||||
if (gScenarioObjective.Currency <= ObjectiveCurrencyLoanAndValueMin)
|
||||
if (gameState.ScenarioObjective.Currency <= ObjectiveCurrencyLoanAndValueMin)
|
||||
{
|
||||
ContextShowError(STR_CANT_REDUCE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.Currency -= ObjectiveCurrencyLoanAndValueAdjustment;
|
||||
gameState.ScenarioObjective.Currency -= ObjectiveCurrencyLoanAndValueAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case OBJECTIVE_MONTHLY_FOOD_INCOME:
|
||||
if (gScenarioObjective.Currency <= ObjectiveCurrencyFoodMin)
|
||||
if (gameState.ScenarioObjective.Currency <= ObjectiveCurrencyFoodMin)
|
||||
{
|
||||
ContextShowError(STR_CANT_REDUCE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.Currency -= ObjectiveCurrencyFoodAdjustment;
|
||||
gameState.ScenarioObjective.Currency -= ObjectiveCurrencyFoodAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
|
||||
if (gScenarioObjective.MinimumLength <= ObjectiveLengthMin)
|
||||
if (gameState.ScenarioObjective.MinimumLength <= ObjectiveLengthMin)
|
||||
{
|
||||
ContextShowError(STR_CANT_REDUCE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.MinimumLength -= ObjectiveLengthAdjustment;
|
||||
gameState.ScenarioObjective.MinimumLength -= ObjectiveLengthAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
|
||||
if (gScenarioObjective.MinimumExcitement <= ObjectiveExcitementMin)
|
||||
if (gameState.ScenarioObjective.MinimumExcitement <= ObjectiveExcitementMin)
|
||||
{
|
||||
ContextShowError(STR_CANT_REDUCE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.MinimumExcitement -= ObjectiveExcitementAdjustment;
|
||||
gameState.ScenarioObjective.MinimumExcitement -= ObjectiveExcitementAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (gScenarioObjective.NumGuests <= ObjectiveGuestsMin)
|
||||
if (gameState.ScenarioObjective.NumGuests <= ObjectiveGuestsMin)
|
||||
{
|
||||
ContextShowError(STR_CANT_REDUCE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.NumGuests -= ObjectiveGuestsAdjustment;
|
||||
gameState.ScenarioObjective.NumGuests -= ObjectiveGuestsAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
@@ -617,26 +621,28 @@ private:
|
||||
|
||||
void Arg2Increase()
|
||||
{
|
||||
if (gScenarioObjective.Year >= ObjectiveYearMax)
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Year >= ObjectiveYearMax)
|
||||
{
|
||||
ContextShowError(STR_CANT_INCREASE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.Year += ObjectiveYearAdjustment;
|
||||
gameState.ScenarioObjective.Year += ObjectiveYearAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void Arg2Decrease()
|
||||
{
|
||||
if (gScenarioObjective.Year <= ObjectiveYearMin)
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Year <= ObjectiveYearMin)
|
||||
{
|
||||
ContextShowError(STR_CANT_REDUCE_FURTHER, STR_NONE, {});
|
||||
}
|
||||
else
|
||||
{
|
||||
gScenarioObjective.Year -= ObjectiveYearAdjustment;
|
||||
gameState.ScenarioObjective.Year -= ObjectiveYearAdjustment;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@@ -649,6 +655,7 @@ private:
|
||||
*/
|
||||
void OnMouseUpMain(WidgetIndex widgetIndex)
|
||||
{
|
||||
const auto& gameState = GetGameState();
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_PARK_NAME:
|
||||
@@ -660,13 +667,13 @@ private:
|
||||
}
|
||||
case WIDX_SCENARIO_NAME:
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_SCENARIO_NAME, STR_SCENARIO_NAME, STR_ENTER_SCENARIO_NAME, {}, gScenarioName.c_str(),
|
||||
this, WIDX_SCENARIO_NAME, STR_SCENARIO_NAME, STR_ENTER_SCENARIO_NAME, {}, gameState.ScenarioName.c_str(),
|
||||
ScenarioNameMaxLength);
|
||||
break;
|
||||
case WIDX_DETAILS:
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_DETAILS, STR_PARK_SCENARIO_DETAILS, STR_ENTER_SCENARIO_DESCRIPTION, {}, gScenarioDetails.c_str(),
|
||||
ScenarioDetailsNameMaxLength);
|
||||
this, WIDX_DETAILS, STR_PARK_SCENARIO_DETAILS, STR_ENTER_SCENARIO_DESCRIPTION, {},
|
||||
gameState.ScenarioDetails.c_str(), ScenarioDetailsNameMaxLength);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -715,6 +722,7 @@ private:
|
||||
*/
|
||||
void OnDropdownMain(WidgetIndex widgetIndex, int32_t dropdownIndex)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
uint8_t newObjectiveType;
|
||||
|
||||
if (dropdownIndex == -1)
|
||||
@@ -725,13 +733,13 @@ private:
|
||||
case WIDX_OBJECTIVE_DROPDOWN:
|
||||
// TODO: Don't rely on string ID order
|
||||
newObjectiveType = static_cast<uint8_t>(gDropdownItems[dropdownIndex].Args - STR_OBJECTIVE_DROPDOWN_NONE);
|
||||
if (gScenarioObjective.Type != newObjectiveType)
|
||||
if (gameState.ScenarioObjective.Type != newObjectiveType)
|
||||
SetObjective(newObjectiveType);
|
||||
break;
|
||||
case WIDX_CATEGORY_DROPDOWN:
|
||||
if (gScenarioCategory != static_cast<uint8_t>(dropdownIndex))
|
||||
if (gameState.ScenarioCategory != static_cast<uint8_t>(dropdownIndex))
|
||||
{
|
||||
gScenarioCategory = static_cast<SCENARIO_CATEGORY>(dropdownIndex);
|
||||
gameState.ScenarioCategory = static_cast<SCENARIO_CATEGORY>(dropdownIndex);
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
@@ -750,7 +758,7 @@ private:
|
||||
OnPrepareDraw();
|
||||
InvalidateWidget(WIDX_TAB_1);
|
||||
|
||||
objectiveType = gScenarioObjective.Type;
|
||||
objectiveType = GetGameState().ScenarioObjective.Type;
|
||||
|
||||
// Check if objective is allowed by money and pay-per-ride settings.
|
||||
const bool objectiveAllowedByMoneyUsage = !(GetGameState().ParkFlags & PARK_FLAGS_NO_MONEY)
|
||||
@@ -774,6 +782,7 @@ private:
|
||||
if (text.empty())
|
||||
return;
|
||||
|
||||
auto& gameState = GetGameState();
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_PARK_NAME:
|
||||
@@ -781,19 +790,19 @@ private:
|
||||
auto action = ParkSetNameAction(std::string(text));
|
||||
GameActions::Execute(&action);
|
||||
|
||||
if (gScenarioName.empty())
|
||||
if (gameState.ScenarioName.empty())
|
||||
{
|
||||
auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark();
|
||||
gScenarioName = park.Name;
|
||||
gameState.ScenarioName = park.Name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WIDX_SCENARIO_NAME:
|
||||
gScenarioName = text;
|
||||
gameState.ScenarioName = text;
|
||||
Invalidate();
|
||||
break;
|
||||
case WIDX_DETAILS:
|
||||
gScenarioDetails = text;
|
||||
gameState.ScenarioDetails = text;
|
||||
Invalidate();
|
||||
break;
|
||||
}
|
||||
@@ -805,6 +814,7 @@ private:
|
||||
*/
|
||||
void OnPrepareDrawMain()
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
auto widgetsToSet = window_editor_objective_options_widgets[page];
|
||||
if (widgets != widgetsToSet)
|
||||
{
|
||||
@@ -814,7 +824,7 @@ private:
|
||||
|
||||
SetPressedTab();
|
||||
|
||||
switch (gScenarioObjective.Type)
|
||||
switch (gameState.ScenarioObjective.Type)
|
||||
{
|
||||
case OBJECTIVE_GUESTS_BY:
|
||||
case OBJECTIVE_PARK_VALUE_BY:
|
||||
@@ -861,6 +871,7 @@ private:
|
||||
*/
|
||||
void OnDrawMain(DrawPixelInfo& dpi)
|
||||
{
|
||||
const auto& gameState = GetGameState();
|
||||
int32_t widthToSet;
|
||||
StringId stringId;
|
||||
|
||||
@@ -874,14 +885,14 @@ private:
|
||||
// Objective value
|
||||
screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_OBJECTIVE].left + 1, widgets[WIDX_OBJECTIVE].top };
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(ObjectiveDropdownOptionNames[gScenarioObjective.Type]);
|
||||
ft.Add<StringId>(ObjectiveDropdownOptionNames[gameState.ScenarioObjective.Type]);
|
||||
DrawTextBasic(dpi, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft);
|
||||
|
||||
if (widgets[WIDX_OBJECTIVE_ARG_1].type != WindowWidgetType::Empty)
|
||||
{
|
||||
// Objective argument 1 label
|
||||
screenCoords = windowPos + ScreenCoordsXY{ 28, widgets[WIDX_OBJECTIVE_ARG_1].top };
|
||||
switch (gScenarioObjective.Type)
|
||||
switch (gameState.ScenarioObjective.Type)
|
||||
{
|
||||
case OBJECTIVE_GUESTS_BY:
|
||||
case OBJECTIVE_GUESTS_AND_RATING:
|
||||
@@ -910,31 +921,31 @@ private:
|
||||
screenCoords = windowPos
|
||||
+ ScreenCoordsXY{ widgets[WIDX_OBJECTIVE_ARG_1].left + 1, widgets[WIDX_OBJECTIVE_ARG_1].top };
|
||||
ft = Formatter();
|
||||
switch (gScenarioObjective.Type)
|
||||
switch (gameState.ScenarioObjective.Type)
|
||||
{
|
||||
case OBJECTIVE_GUESTS_BY:
|
||||
case OBJECTIVE_GUESTS_AND_RATING:
|
||||
stringId = STR_WINDOW_COLOUR_2_COMMA16;
|
||||
ft.Add<uint16_t>(gScenarioObjective.NumGuests);
|
||||
ft.Add<uint16_t>(gameState.ScenarioObjective.NumGuests);
|
||||
break;
|
||||
case OBJECTIVE_PARK_VALUE_BY:
|
||||
case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE:
|
||||
case OBJECTIVE_MONTHLY_RIDE_INCOME:
|
||||
case OBJECTIVE_MONTHLY_FOOD_INCOME:
|
||||
stringId = STR_CURRENCY_FORMAT_LABEL;
|
||||
ft.Add<money64>(gScenarioObjective.Currency);
|
||||
ft.Add<money64>(gameState.ScenarioObjective.Currency);
|
||||
break;
|
||||
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
|
||||
stringId = STR_WINDOW_COLOUR_2_LENGTH;
|
||||
ft.Add<uint16_t>(gScenarioObjective.MinimumLength);
|
||||
ft.Add<uint16_t>(gameState.ScenarioObjective.MinimumLength);
|
||||
break;
|
||||
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
|
||||
stringId = STR_WINDOW_COLOUR_2_COMMA2DP32;
|
||||
ft.Add<uint16_t>(gScenarioObjective.MinimumExcitement);
|
||||
ft.Add<uint16_t>(gameState.ScenarioObjective.MinimumExcitement);
|
||||
break;
|
||||
default:
|
||||
stringId = STR_WINDOW_COLOUR_2_COMMA2DP32;
|
||||
ft.Add<money64>(gScenarioObjective.Currency);
|
||||
ft.Add<money64>(gameState.ScenarioObjective.Currency);
|
||||
break;
|
||||
}
|
||||
DrawTextBasic(dpi, screenCoords, stringId, ft, COLOUR_BLACK);
|
||||
@@ -950,7 +961,7 @@ private:
|
||||
screenCoords = windowPos
|
||||
+ ScreenCoordsXY{ widgets[WIDX_OBJECTIVE_ARG_2].left + 1, widgets[WIDX_OBJECTIVE_ARG_2].top };
|
||||
ft = Formatter();
|
||||
ft.Add<uint16_t>((gScenarioObjective.Year * MONTH_COUNT) - 1);
|
||||
ft.Add<uint16_t>((gameState.ScenarioObjective.Year * MONTH_COUNT) - 1);
|
||||
DrawTextBasic(dpi, screenCoords, STR_WINDOW_OBJECTIVE_VALUE_DATE, ft);
|
||||
}
|
||||
|
||||
@@ -974,7 +985,7 @@ private:
|
||||
|
||||
ft = Formatter();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
ft.Add<const char*>(gScenarioName.c_str());
|
||||
ft.Add<const char*>(gameState.ScenarioName.c_str());
|
||||
DrawTextEllipsised(dpi, screenCoords, widthToSet, STR_WINDOW_SCENARIO_NAME, ft);
|
||||
|
||||
// Scenario details label
|
||||
@@ -987,7 +998,7 @@ private:
|
||||
|
||||
ft = Formatter();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
ft.Add<const char*>(gScenarioDetails.c_str());
|
||||
ft.Add<const char*>(gameState.ScenarioDetails.c_str());
|
||||
DrawTextWrapped(dpi, screenCoords, widthToSet, STR_BLACK_STRING, ft);
|
||||
|
||||
// Scenario category label
|
||||
@@ -997,7 +1008,7 @@ private:
|
||||
// Scenario category value
|
||||
screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_CATEGORY].left + 1, widgets[WIDX_CATEGORY].top };
|
||||
ft = Formatter();
|
||||
ft.Add<StringId>(ScenarioCategoryStringIds[gScenarioCategory]);
|
||||
ft.Add<StringId>(ScenarioCategoryStringIds[gameState.ScenarioCategory]);
|
||||
DrawTextBasic(dpi, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft);
|
||||
}
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@ public:
|
||||
DrawTextBasic(dpi, windowPos + ScreenCoordsXY{ 8, 294 }, stringId, ft);
|
||||
|
||||
// Objective related financial information
|
||||
if (gScenarioObjective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME)
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME)
|
||||
{
|
||||
auto lastMonthProfit = FinanceGetLastMonthShopProfit();
|
||||
ft = Formatter();
|
||||
|
||||
@@ -503,6 +503,7 @@ private:
|
||||
|
||||
void OnPrepareDrawEntrance()
|
||||
{
|
||||
const auto& gameState = GetGameState();
|
||||
widgets = _pagedWidgets[page];
|
||||
InitScrollWidgets();
|
||||
|
||||
@@ -524,7 +525,7 @@ private:
|
||||
widgets[WIDX_OPEN_LIGHT].image = ImageId(openLightImage);
|
||||
|
||||
// Only allow closing of park for guest / rating objective
|
||||
if (gScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
disabled_widgets |= (1uLL << WIDX_OPEN_OR_CLOSE) | (1uLL << WIDX_CLOSE_LIGHT) | (1uLL << WIDX_OPEN_LIGHT);
|
||||
else
|
||||
disabled_widgets &= ~((1uLL << WIDX_OPEN_OR_CLOSE) | (1uLL << WIDX_CLOSE_LIGHT) | (1uLL << WIDX_OPEN_LIGHT));
|
||||
@@ -549,7 +550,7 @@ private:
|
||||
if (ThemeGetFlags() & UITHEME_FLAG_USE_LIGHTS_PARK)
|
||||
{
|
||||
widgets[WIDX_OPEN_OR_CLOSE].type = WindowWidgetType::Empty;
|
||||
if (gScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
{
|
||||
widgets[WIDX_CLOSE_LIGHT].type = WindowWidgetType::FlatBtn;
|
||||
widgets[WIDX_OPEN_LIGHT].type = WindowWidgetType::FlatBtn;
|
||||
@@ -1038,7 +1039,7 @@ private:
|
||||
if (widgetIndex == WIDX_ENTER_NAME && !text.empty())
|
||||
{
|
||||
std::string strText(text);
|
||||
ScenarioSuccessSubmitName(strText.c_str());
|
||||
ScenarioSuccessSubmitName(GetGameState(), strText.c_str());
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@@ -1064,6 +1065,7 @@ private:
|
||||
|
||||
void OnDrawObjective(DrawPixelInfo& dpi)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
DrawWidgets(dpi);
|
||||
DrawTabImages(dpi);
|
||||
|
||||
@@ -1072,7 +1074,7 @@ private:
|
||||
+ ScreenCoordsXY{ widgets[WIDX_PAGE_BACKGROUND].left + 4, widgets[WIDX_PAGE_BACKGROUND].top + 7 };
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
ft.Add<const char*>(gScenarioDetails.c_str());
|
||||
ft.Add<const char*>(gameState.ScenarioDetails.c_str());
|
||||
screenCoords.y += DrawTextWrapped(dpi, screenCoords, 222, STR_BLACK_STRING, ft);
|
||||
screenCoords.y += 5;
|
||||
|
||||
@@ -1082,10 +1084,10 @@ private:
|
||||
|
||||
// Objective
|
||||
ft = Formatter();
|
||||
if (gScenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST)
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST)
|
||||
{
|
||||
StringId rideTypeString = STR_NONE;
|
||||
auto rideTypeId = gScenarioObjective.RideId;
|
||||
auto rideTypeId = gameState.ScenarioObjective.RideId;
|
||||
if (rideTypeId != RIDE_TYPE_NULL && rideTypeId < RIDE_TYPE_COUNT)
|
||||
{
|
||||
rideTypeString = GetRideTypeDescriptor(rideTypeId).Naming.Name;
|
||||
@@ -1094,21 +1096,21 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
ft.Add<uint16_t>(gScenarioObjective.NumGuests);
|
||||
ft.Add<int16_t>(DateGetTotalMonths(MONTH_OCTOBER, gScenarioObjective.Year));
|
||||
if (gScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
|
||||
ft.Add<uint16_t>(gScenarioObjective.MinimumExcitement);
|
||||
ft.Add<uint16_t>(gameState.ScenarioObjective.NumGuests);
|
||||
ft.Add<int16_t>(DateGetTotalMonths(MONTH_OCTOBER, gameState.ScenarioObjective.Year));
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
|
||||
ft.Add<uint16_t>(gameState.ScenarioObjective.MinimumExcitement);
|
||||
else
|
||||
ft.Add<money64>(gScenarioObjective.Currency);
|
||||
ft.Add<money64>(gameState.ScenarioObjective.Currency);
|
||||
}
|
||||
|
||||
screenCoords.y += DrawTextWrapped(dpi, screenCoords, 221, ObjectiveNames[gScenarioObjective.Type], ft);
|
||||
screenCoords.y += DrawTextWrapped(dpi, screenCoords, 221, ObjectiveNames[gameState.ScenarioObjective.Type], ft);
|
||||
screenCoords.y += 5;
|
||||
|
||||
// Objective outcome
|
||||
if (gScenarioCompletedCompanyValue != MONEY64_UNDEFINED)
|
||||
if (gameState.ScenarioCompletedCompanyValue != MONEY64_UNDEFINED)
|
||||
{
|
||||
if (gScenarioCompletedCompanyValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
if (gameState.ScenarioCompletedCompanyValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
{
|
||||
// Objective failed
|
||||
DrawTextWrapped(dpi, screenCoords, 222, STR_OBJECTIVE_FAILED);
|
||||
@@ -1117,7 +1119,7 @@ private:
|
||||
{
|
||||
// Objective completed
|
||||
ft = Formatter();
|
||||
ft.Add<money64>(gScenarioCompletedCompanyValue);
|
||||
ft.Add<money64>(gameState.ScenarioCompletedCompanyValue);
|
||||
DrawTextWrapped(dpi, screenCoords, 222, STR_OBJECTIVE_ACHIEVED, ft);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/audio/audio.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
@@ -20,6 +21,8 @@
|
||||
#include <openrct2/scenario/Scenario.h>
|
||||
#include <openrct2/windows/Intent.h>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
static constexpr int32_t WH_SAVE = 54;
|
||||
static constexpr int32_t WW_SAVE = 260;
|
||||
static constexpr int32_t WH_QUIT = 38;
|
||||
@@ -99,7 +102,7 @@ public:
|
||||
if (NetworkGetMode() == NETWORK_MODE_NONE)
|
||||
{
|
||||
gGamePaused |= GAME_PAUSED_MODAL;
|
||||
OpenRCT2::Audio::StopAll();
|
||||
Audio::StopAll();
|
||||
}
|
||||
|
||||
WindowInvalidateByClass(WindowClass::TopToolbar);
|
||||
@@ -126,7 +129,7 @@ public:
|
||||
if (NetworkGetMode() == NETWORK_MODE_NONE)
|
||||
{
|
||||
gGamePaused &= ~GAME_PAUSED_MODAL;
|
||||
OpenRCT2::Audio::Resume();
|
||||
Audio::Resume();
|
||||
}
|
||||
|
||||
WindowInvalidateByClass(WindowClass::TopToolbar);
|
||||
@@ -159,7 +162,7 @@ public:
|
||||
{
|
||||
intent = std::make_unique<Intent>(WindowClass::Loadsave);
|
||||
intent->PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE);
|
||||
intent->PutExtra(INTENT_EXTRA_PATH, gScenarioName);
|
||||
intent->PutExtra(INTENT_EXTRA_PATH, GetGameState().ScenarioName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2705,7 +2705,7 @@ public:
|
||||
{
|
||||
auto intent = Intent(WindowClass::Loadsave);
|
||||
intent.PutExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE);
|
||||
intent.PutExtra(INTENT_EXTRA_PATH, gScenarioName);
|
||||
intent.PutExtra(INTENT_EXTRA_PATH, GetGameState().ScenarioName);
|
||||
ContextOpenIntent(&intent);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -682,7 +682,7 @@ namespace OpenRCT2
|
||||
}
|
||||
else
|
||||
{
|
||||
ScenarioBegin();
|
||||
ScenarioBegin(gameState);
|
||||
#ifndef DISABLE_NETWORK
|
||||
if (_network.GetMode() == NETWORK_MODE_SERVER)
|
||||
{
|
||||
|
||||
@@ -104,19 +104,20 @@ namespace Editor
|
||||
*/
|
||||
void Load()
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
OpenRCT2::Audio::StopAll();
|
||||
ObjectListLoad();
|
||||
OpenRCT2::GetContext()->GetGameState()->InitAll(DEFAULT_MAP_SIZE);
|
||||
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
||||
gEditorStep = EditorStep::ObjectSelection;
|
||||
GetGameState().ParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
gScenarioCategory = SCENARIO_CATEGORY_OTHER;
|
||||
gameState.ParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
gameState.ScenarioCategory = SCENARIO_CATEGORY_OTHER;
|
||||
ViewportInitAll();
|
||||
WindowBase* mainWindow = OpenEditorWindows();
|
||||
mainWindow->SetLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ());
|
||||
LoadPalette();
|
||||
gScreenAge = 0;
|
||||
gScenarioName = LanguageGetString(STR_MY_NEW_SCENARIO);
|
||||
gameState.ScenarioName = LanguageGetString(STR_MY_NEW_SCENARIO);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,11 +145,12 @@ namespace Editor
|
||||
return;
|
||||
}
|
||||
|
||||
ScenarioReset();
|
||||
auto& gameState = GetGameState();
|
||||
ScenarioReset(gameState);
|
||||
|
||||
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
||||
gEditorStep = EditorStep::ObjectiveSelection;
|
||||
gScenarioCategory = SCENARIO_CATEGORY_OTHER;
|
||||
gameState.ScenarioCategory = SCENARIO_CATEGORY_OTHER;
|
||||
ViewportInitAll();
|
||||
OpenEditorWindows();
|
||||
FinaliseMainView();
|
||||
|
||||
@@ -320,7 +320,8 @@ void GameState::UpdateLogic()
|
||||
|
||||
_date.Update();
|
||||
|
||||
ScenarioUpdate();
|
||||
auto& gameState = GetGameState();
|
||||
ScenarioUpdate(gameState);
|
||||
ClimateUpdate();
|
||||
MapUpdateTiles();
|
||||
// Temporarily remove provisional paths to prevent peep from interacting with them
|
||||
@@ -362,7 +363,7 @@ void GameState::UpdateLogic()
|
||||
NetworkProcessPending();
|
||||
NetworkFlush();
|
||||
|
||||
GetGameState().CurrentTicks++;
|
||||
gameState.CurrentTicks++;
|
||||
gSavedAge++;
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "Date.h"
|
||||
#include "management/Finance.h"
|
||||
#include "scenario/Scenario.h"
|
||||
#include "world/Climate.h"
|
||||
#include "world/Location.hpp"
|
||||
|
||||
@@ -42,6 +43,15 @@ namespace OpenRCT2
|
||||
money64 WeeklyProfitAverageDividend;
|
||||
uint16_t WeeklyProfitAverageDivisor;
|
||||
money64 WeeklyProfitHistory[FINANCE_GRAPH_SIZE];
|
||||
Objective ScenarioObjective;
|
||||
uint16_t ScenarioParkRatingWarningDays;
|
||||
money64 ScenarioCompletedCompanyValue;
|
||||
money64 ScenarioCompanyValueRecord;
|
||||
|
||||
SCENARIO_CATEGORY ScenarioCategory;
|
||||
std::string ScenarioName;
|
||||
std::string ScenarioDetails;
|
||||
std::string ScenarioCompletedBy;
|
||||
};
|
||||
|
||||
GameState_t& GetGameState();
|
||||
|
||||
@@ -91,6 +91,7 @@ GameActions::Result CheatSetAction::Query() const
|
||||
|
||||
GameActions::Result CheatSetAction::Execute() const
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
switch (static_cast<CheatType>(_cheatType.id))
|
||||
{
|
||||
case CheatType::SandboxMode:
|
||||
@@ -198,7 +199,7 @@ GameActions::Result CheatSetAction::Execute() const
|
||||
Set10MinuteInspection();
|
||||
break;
|
||||
case CheatType::WinScenario:
|
||||
ScenarioSuccess();
|
||||
ScenarioSuccess(gameState);
|
||||
break;
|
||||
case CheatType::ForceWeather:
|
||||
// Todo - make sure this is safe
|
||||
@@ -214,7 +215,7 @@ GameActions::Result CheatSetAction::Execute() const
|
||||
ParkSetOpen(!ParkIsOpen());
|
||||
break;
|
||||
case CheatType::HaveFun:
|
||||
gScenarioObjective.Type = OBJECTIVE_HAVE_FUN;
|
||||
gameState.ScenarioObjective.Type = OBJECTIVE_HAVE_FUN;
|
||||
break;
|
||||
case CheatType::SetForcedParkRating:
|
||||
ParkSetForcedRating(_param1);
|
||||
|
||||
@@ -210,7 +210,7 @@ GameActions::Result RideCreateAction::Execute() const
|
||||
price = 0;
|
||||
}
|
||||
|
||||
const auto& gameState = GetGameState();
|
||||
auto& gameState = GetGameState();
|
||||
if (!(gameState.ParkFlags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
for (auto i = 0; i < RCT2::ObjectLimits::MaxShopItemsPerRideEntry; i++)
|
||||
@@ -234,7 +234,7 @@ GameActions::Result RideCreateAction::Execute() const
|
||||
ride->price[1] = GetShopItemDescriptor(rideEntry->shop_item[1]).DefaultPrice;
|
||||
}
|
||||
|
||||
if (gScenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST)
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST)
|
||||
{
|
||||
ride->price[0] = 0;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator* enumerato
|
||||
context->Initialise();
|
||||
|
||||
auto& objManager = context->GetObjectManager();
|
||||
auto& gameState = GetGameState();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -102,7 +103,6 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator* enumerato
|
||||
objManager.LoadObjects(loadResult.RequiredObjects);
|
||||
|
||||
// TODO: Have a separate GameState and exchange once loaded.
|
||||
auto& gameState = GetGameState();
|
||||
importer->Import(gameState);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
@@ -114,7 +114,7 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator* enumerato
|
||||
if (sourceFileType == FileExtension::SC4 || sourceFileType == FileExtension::SC6)
|
||||
{
|
||||
// We are converting a scenario, so reset the park
|
||||
ScenarioBegin();
|
||||
ScenarioBegin(gameState);
|
||||
}
|
||||
|
||||
try
|
||||
@@ -125,8 +125,6 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator* enumerato
|
||||
// correct initial view
|
||||
WindowCloseByClass(WindowClass::MainWindow);
|
||||
|
||||
auto& gameState = GetGameState();
|
||||
|
||||
exporter->Export(gameState, destinationPath);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
|
||||
@@ -238,10 +238,10 @@ void FinanceInit()
|
||||
gBankLoanInterestRate = 10;
|
||||
gParkValue = 0;
|
||||
gCompanyValue = 0;
|
||||
gScenarioCompletedCompanyValue = MONEY64_UNDEFINED;
|
||||
gameState.ScenarioCompletedCompanyValue = MONEY64_UNDEFINED;
|
||||
gTotalAdmissions = 0;
|
||||
gTotalIncomeFromAdmissions = 0;
|
||||
gScenarioCompletedBy = "?";
|
||||
gameState.ScenarioCompletedBy = "?";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -417,32 +417,32 @@ namespace OpenRCT2
|
||||
|
||||
void ReadWriteScenarioChunk(GameState_t& gameState, OrcaStream& os)
|
||||
{
|
||||
os.ReadWriteChunk(ParkFileChunkType::SCENARIO, [&os](OrcaStream::ChunkStream& cs) {
|
||||
cs.ReadWrite(gScenarioCategory);
|
||||
ReadWriteStringTable(cs, gScenarioName, "en-GB");
|
||||
os.ReadWriteChunk(ParkFileChunkType::SCENARIO, [&gameState, &os](OrcaStream::ChunkStream& cs) {
|
||||
cs.ReadWrite(gameState.ScenarioCategory);
|
||||
ReadWriteStringTable(cs, gameState.ScenarioName, "en-GB");
|
||||
|
||||
// TODO: Use the passed gameState instead of the global one.
|
||||
auto& park = GetContext()->GetGameState()->GetPark();
|
||||
ReadWriteStringTable(cs, park.Name, "en-GB");
|
||||
|
||||
ReadWriteStringTable(cs, gScenarioDetails, "en-GB");
|
||||
ReadWriteStringTable(cs, gameState.ScenarioDetails, "en-GB");
|
||||
|
||||
cs.ReadWrite(gScenarioObjective.Type);
|
||||
cs.ReadWrite(gScenarioObjective.Year);
|
||||
cs.ReadWrite(gScenarioObjective.NumGuests);
|
||||
cs.ReadWrite(gScenarioObjective.Currency);
|
||||
cs.ReadWrite(gameState.ScenarioObjective.Type);
|
||||
cs.ReadWrite(gameState.ScenarioObjective.Year);
|
||||
cs.ReadWrite(gameState.ScenarioObjective.NumGuests);
|
||||
cs.ReadWrite(gameState.ScenarioObjective.Currency);
|
||||
|
||||
cs.ReadWrite(gScenarioParkRatingWarningDays);
|
||||
cs.ReadWrite(gameState.ScenarioParkRatingWarningDays);
|
||||
|
||||
cs.ReadWrite(gScenarioCompletedCompanyValue);
|
||||
if (gScenarioCompletedCompanyValue == MONEY64_UNDEFINED
|
||||
|| gScenarioCompletedCompanyValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
cs.ReadWrite(gameState.ScenarioCompletedCompanyValue);
|
||||
if (gameState.ScenarioCompletedCompanyValue == MONEY64_UNDEFINED
|
||||
|| gameState.ScenarioCompletedCompanyValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
{
|
||||
cs.Write("");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.ReadWrite(gScenarioCompletedBy);
|
||||
cs.ReadWrite(gameState.ScenarioCompletedBy);
|
||||
}
|
||||
|
||||
if (cs.GetMode() == OrcaStream::Mode::READING)
|
||||
|
||||
@@ -185,8 +185,8 @@ namespace RCT1
|
||||
ImportParkName();
|
||||
ImportParkFlags(gameState);
|
||||
ImportClimate(gameState);
|
||||
ImportScenarioNameDetails();
|
||||
ImportScenarioObjective();
|
||||
ImportScenarioNameDetails(gameState);
|
||||
ImportScenarioObjective(gameState);
|
||||
ImportSavedView();
|
||||
FixLandOwnership();
|
||||
FixUrbanPark();
|
||||
@@ -327,7 +327,7 @@ namespace RCT1
|
||||
context->GetGameState()->InitAll({ mapSize, mapSize });
|
||||
gEditorStep = EditorStep::ObjectSelection;
|
||||
gameState.ParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
gScenarioCategory = SCENARIO_CATEGORY_OTHER;
|
||||
gameState.ScenarioCategory = SCENARIO_CATEGORY_OTHER;
|
||||
}
|
||||
|
||||
std::string GetRCT1ScenarioName()
|
||||
@@ -1422,7 +1422,7 @@ namespace RCT1
|
||||
}
|
||||
gCurrentExpenditure = ToMoney64(_s4.TotalExpenditure);
|
||||
|
||||
gScenarioCompletedCompanyValue = RCT12CompletedCompanyValueToOpenRCT2(_s4.CompletedCompanyValue);
|
||||
gameState.ScenarioCompletedCompanyValue = RCT12CompletedCompanyValueToOpenRCT2(_s4.CompletedCompanyValue);
|
||||
gTotalAdmissions = _s4.NumAdmissions;
|
||||
gTotalIncomeFromAdmissions = ToMoney64(_s4.AdmissionTotalIncome);
|
||||
|
||||
@@ -2292,7 +2292,7 @@ namespace RCT1
|
||||
gameState.ClimateNext.Level = static_cast<WeatherLevel>(_s4.TargetRain);
|
||||
}
|
||||
|
||||
void ImportScenarioNameDetails()
|
||||
void ImportScenarioNameDetails(GameState_t& gameState)
|
||||
{
|
||||
std::string name = String::ToStd(_s4.ScenarioName);
|
||||
std::string details;
|
||||
@@ -2318,27 +2318,27 @@ namespace RCT1
|
||||
}
|
||||
}
|
||||
|
||||
gScenarioName = std::move(name);
|
||||
gScenarioDetails = std::move(details);
|
||||
gameState.ScenarioName = std::move(name);
|
||||
gameState.ScenarioDetails = std::move(details);
|
||||
}
|
||||
|
||||
void ImportScenarioObjective()
|
||||
void ImportScenarioObjective(GameState_t& gameState)
|
||||
{
|
||||
gScenarioObjective.Type = _s4.ScenarioObjectiveType;
|
||||
gScenarioObjective.Year = _s4.ScenarioObjectiveYears;
|
||||
gScenarioObjective.NumGuests = _s4.ScenarioObjectiveNumGuests;
|
||||
gameState.ScenarioObjective.Type = _s4.ScenarioObjectiveType;
|
||||
gameState.ScenarioObjective.Year = _s4.ScenarioObjectiveYears;
|
||||
gameState.ScenarioObjective.NumGuests = _s4.ScenarioObjectiveNumGuests;
|
||||
|
||||
// RCT1 used a different way of calculating the park value.
|
||||
// This is corrected here, but since scenario_objective_currency doubles as minimum excitement rating,
|
||||
// we need to check the goal to avoid affecting scenarios like Volcania.
|
||||
if (_s4.ScenarioObjectiveType == OBJECTIVE_PARK_VALUE_BY)
|
||||
gScenarioObjective.Currency = CorrectRCT1ParkValue(_s4.ScenarioObjectiveCurrency);
|
||||
gameState.ScenarioObjective.Currency = CorrectRCT1ParkValue(_s4.ScenarioObjectiveCurrency);
|
||||
else
|
||||
gScenarioObjective.Currency = ToMoney64(_s4.ScenarioObjectiveCurrency);
|
||||
gameState.ScenarioObjective.Currency = ToMoney64(_s4.ScenarioObjectiveCurrency);
|
||||
|
||||
// This does not seem to be saved in the objective arguments, so look up the ID from the available rides instead.
|
||||
if (_s4.ScenarioObjectiveType == OBJECTIVE_BUILD_THE_BEST)
|
||||
gScenarioObjective.RideId = GetBuildTheBestRideId();
|
||||
gameState.ScenarioObjective.RideId = GetBuildTheBestRideId();
|
||||
}
|
||||
|
||||
void ImportSavedView()
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace RCT2
|
||||
Initialise();
|
||||
|
||||
gEditorStep = _s6.Info.EditorStep;
|
||||
gScenarioCategory = static_cast<SCENARIO_CATEGORY>(_s6.Info.Category);
|
||||
gameState.ScenarioCategory = static_cast<SCENARIO_CATEGORY>(_s6.Info.Category);
|
||||
|
||||
// Some scenarios have their scenario details in UTF-8, due to earlier bugs in OpenRCT2.
|
||||
auto loadMaybeUTF8 = [](std::string_view str) -> std::string {
|
||||
@@ -241,14 +241,14 @@ namespace RCT2
|
||||
|
||||
if (_s6.Header.Type == S6_TYPE_SCENARIO)
|
||||
{
|
||||
gScenarioName = loadMaybeUTF8(_s6.Info.Name);
|
||||
gScenarioDetails = loadMaybeUTF8(_s6.Info.Details);
|
||||
gameState.ScenarioName = loadMaybeUTF8(_s6.Info.Name);
|
||||
gameState.ScenarioDetails = loadMaybeUTF8(_s6.Info.Details);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Saved games do not have an info chunk
|
||||
gScenarioName = loadMaybeUTF8(_s6.ScenarioName);
|
||||
gScenarioDetails = loadMaybeUTF8(_s6.ScenarioDescription);
|
||||
gameState.ScenarioName = loadMaybeUTF8(_s6.ScenarioName);
|
||||
gameState.ScenarioDetails = loadMaybeUTF8(_s6.ScenarioDescription);
|
||||
}
|
||||
|
||||
OpenRCT2::GetContext()->GetGameState()->SetDate(OpenRCT2::Date(_s6.ElapsedMonths, _s6.CurrentDay));
|
||||
@@ -342,16 +342,16 @@ namespace RCT2
|
||||
gameState.GuestInitialCash = ToMoney64(_s6.GuestInitialCash);
|
||||
gameState.GuestInitialHunger = _s6.GuestInitialHunger;
|
||||
gameState.GuestInitialThirst = _s6.GuestInitialThirst;
|
||||
gScenarioObjective.Type = _s6.ObjectiveType;
|
||||
gScenarioObjective.Year = _s6.ObjectiveYear;
|
||||
gameState.ScenarioObjective.Type = _s6.ObjectiveType;
|
||||
gameState.ScenarioObjective.Year = _s6.ObjectiveYear;
|
||||
// Pad013580FA
|
||||
gScenarioObjective.Currency = _s6.ObjectiveCurrency;
|
||||
gameState.ScenarioObjective.Currency = _s6.ObjectiveCurrency;
|
||||
// In RCT2, the ride string IDs start at index STR_0002 and are directly mappable.
|
||||
// This is not always the case in OpenRCT2, so we use the actual ride ID.
|
||||
if (gScenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST)
|
||||
gScenarioObjective.RideId = _s6.ObjectiveGuests - RCT2_RIDE_STRING_START;
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST)
|
||||
gameState.ScenarioObjective.RideId = _s6.ObjectiveGuests - RCT2_RIDE_STRING_START;
|
||||
else
|
||||
gScenarioObjective.NumGuests = _s6.ObjectiveGuests;
|
||||
gameState.ScenarioObjective.NumGuests = _s6.ObjectiveGuests;
|
||||
ImportMarketingCampaigns();
|
||||
|
||||
gCurrentExpenditure = ToMoney64(_s6.CurrentExpenditure);
|
||||
@@ -369,7 +369,7 @@ namespace RCT2
|
||||
gParkValueHistory[i] = ToMoney64(_s6.ParkValueHistory[i]);
|
||||
}
|
||||
|
||||
gScenarioCompletedCompanyValue = RCT12CompletedCompanyValueToOpenRCT2(_s6.CompletedCompanyValue);
|
||||
gameState.ScenarioCompletedCompanyValue = RCT12CompletedCompanyValueToOpenRCT2(_s6.CompletedCompanyValue);
|
||||
gTotalAdmissions = _s6.TotalAdmissions;
|
||||
gTotalIncomeFromAdmissions = ToMoney64(_s6.IncomeFromAdmissions);
|
||||
gCompanyValue = ToMoney64(_s6.CompanyValue);
|
||||
@@ -391,19 +391,19 @@ namespace RCT2
|
||||
// Pad01358776
|
||||
// _s6.CdKey
|
||||
_gameVersion = _s6.GameVersionNumber;
|
||||
gScenarioCompanyValueRecord = _s6.CompletedCompanyValueRecord;
|
||||
gameState.ScenarioCompanyValueRecord = _s6.CompletedCompanyValueRecord;
|
||||
// _s6.LoanHash;
|
||||
// Pad013587CA
|
||||
gHistoricalProfit = ToMoney64(_s6.HistoricalProfit);
|
||||
// Pad013587D4
|
||||
gScenarioCompletedBy = std::string_view(_s6.ScenarioCompletedName, sizeof(_s6.ScenarioCompletedName));
|
||||
gameState.ScenarioCompletedBy = std::string_view(_s6.ScenarioCompletedName, sizeof(_s6.ScenarioCompletedName));
|
||||
gameState.Cash = ToMoney64(DECRYPT_MONEY(_s6.Cash));
|
||||
// Pad013587FC
|
||||
gParkRatingCasualtyPenalty = _s6.ParkRatingCasualtyPenalty;
|
||||
gMapSize = { _s6.MapSize, _s6.MapSize };
|
||||
gSamePriceThroughoutPark = _s6.SamePriceThroughout | (static_cast<uint64_t>(_s6.SamePriceThroughoutExtended) << 32);
|
||||
_suggestedGuestMaximum = _s6.SuggestedMaxGuests;
|
||||
gScenarioParkRatingWarningDays = _s6.ParkRatingWarningDays;
|
||||
gameState.ScenarioParkRatingWarningDays = _s6.ParkRatingWarningDays;
|
||||
gLastEntranceStyle = _s6.LastEntranceStyle;
|
||||
// rct1_water_colour
|
||||
// Pad01358842
|
||||
@@ -501,7 +501,7 @@ namespace RCT2
|
||||
|
||||
// Fix and set dynamic variables
|
||||
MapStripGhostFlagFromElements();
|
||||
ConvertScenarioStringsToUTF8();
|
||||
ConvertScenarioStringsToUTF8(gameState);
|
||||
DetermineRideEntranceAndExitLocations();
|
||||
|
||||
park.Name = GetUserString(_s6.ParkName);
|
||||
@@ -526,12 +526,12 @@ namespace RCT2
|
||||
_terrainEdgeEntries.AddRange(DefaultTerrainEdges);
|
||||
}
|
||||
|
||||
void ConvertScenarioStringsToUTF8()
|
||||
void ConvertScenarioStringsToUTF8(GameState_t& gameState)
|
||||
{
|
||||
// Scenario details
|
||||
gScenarioCompletedBy = RCT2StringToUTF8(gScenarioCompletedBy, RCT2LanguageId::EnglishUK);
|
||||
gScenarioName = RCT2StringToUTF8(gScenarioName, RCT2LanguageId::EnglishUK);
|
||||
gScenarioDetails = RCT2StringToUTF8(gScenarioDetails, RCT2LanguageId::EnglishUK);
|
||||
gameState.ScenarioCompletedBy = RCT2StringToUTF8(gameState.ScenarioCompletedBy, RCT2LanguageId::EnglishUK);
|
||||
gameState.ScenarioName = RCT2StringToUTF8(gameState.ScenarioName, RCT2LanguageId::EnglishUK);
|
||||
gameState.ScenarioDetails = RCT2StringToUTF8(gameState.ScenarioDetails, RCT2LanguageId::EnglishUK);
|
||||
}
|
||||
|
||||
void FixLandOwnership() const
|
||||
|
||||
@@ -67,10 +67,6 @@ const StringId ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT] = {
|
||||
STR_DLC_PARKS, STR_BUILD_YOUR_OWN_PARKS, STR_COMPETITIONS, STR_UCES_TM, STR_UCES_KD,
|
||||
};
|
||||
|
||||
SCENARIO_CATEGORY gScenarioCategory;
|
||||
std::string gScenarioName;
|
||||
std::string gScenarioDetails;
|
||||
std::string gScenarioCompletedBy;
|
||||
std::string gScenarioSavePath;
|
||||
bool gFirstTimeSaving = true;
|
||||
uint16_t gSavedAge;
|
||||
@@ -78,31 +74,26 @@ uint32_t gLastAutoSaveUpdate = 0;
|
||||
|
||||
random_engine_t gScenarioRand;
|
||||
|
||||
Objective gScenarioObjective;
|
||||
|
||||
bool gAllowEarlyCompletionInNetworkPlay;
|
||||
uint16_t gScenarioParkRatingWarningDays;
|
||||
money64 gScenarioCompletedCompanyValue;
|
||||
money64 gScenarioCompanyValueRecord;
|
||||
|
||||
std::string gScenarioFileName;
|
||||
|
||||
static void ScenarioCheckObjective();
|
||||
static void ScenarioCheckObjective(GameState_t& gameState);
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
void ScenarioBegin()
|
||||
void ScenarioBegin(GameState_t& gameState)
|
||||
{
|
||||
GameLoadInit();
|
||||
ScenarioReset();
|
||||
ScenarioReset(gameState);
|
||||
|
||||
if (gScenarioObjective.Type != OBJECTIVE_NONE && !gLoadKeepWindowsOpen)
|
||||
if (gameState.ScenarioObjective.Type != OBJECTIVE_NONE && !gLoadKeepWindowsOpen)
|
||||
ContextOpenWindowView(WV_PARK_OBJECTIVE);
|
||||
|
||||
gScreenAge = 0;
|
||||
}
|
||||
|
||||
void ScenarioReset()
|
||||
void ScenarioReset(GameState_t& gameState)
|
||||
{
|
||||
// Set the scenario pseudo-random seeds
|
||||
Random::RCT2::Seed s{ 0x1234567F ^ Platform::GetTicks(), 0x789FABCD ^ Platform::GetTicks() };
|
||||
@@ -112,7 +103,6 @@ void ScenarioReset()
|
||||
ScenerySetDefaultPlacementConfiguration();
|
||||
News::InitQueue();
|
||||
|
||||
auto& gameState = GetGameState();
|
||||
auto& park = GetContext()->GetGameState()->GetPark();
|
||||
gameState.ParkRating = park.CalculateParkRating();
|
||||
gParkValue = park.CalculateParkValue();
|
||||
@@ -122,14 +112,14 @@ void ScenarioReset()
|
||||
|
||||
{
|
||||
utf8 normalisedName[64];
|
||||
ScenarioSources::NormaliseName(normalisedName, sizeof(normalisedName), gScenarioName.c_str());
|
||||
ScenarioSources::NormaliseName(normalisedName, sizeof(normalisedName), gameState.ScenarioName.c_str());
|
||||
|
||||
StringId localisedStringIds[3];
|
||||
if (LanguageGetLocalisedScenarioStrings(normalisedName, localisedStringIds))
|
||||
{
|
||||
if (localisedStringIds[0] != STR_NONE)
|
||||
{
|
||||
gScenarioName = LanguageGetString(localisedStringIds[0]);
|
||||
gameState.ScenarioName = LanguageGetString(localisedStringIds[0]);
|
||||
}
|
||||
if (localisedStringIds[1] != STR_NONE)
|
||||
{
|
||||
@@ -137,7 +127,7 @@ void ScenarioReset()
|
||||
}
|
||||
if (localisedStringIds[2] != STR_NONE)
|
||||
{
|
||||
gScenarioDetails = LanguageGetString(localisedStringIds[2]);
|
||||
gameState.ScenarioDetails = LanguageGetString(localisedStringIds[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,8 +145,8 @@ void ScenarioReset()
|
||||
gTotalIncomeFromAdmissions = 0;
|
||||
|
||||
gameState.ParkFlags &= ~PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
gScenarioCompletedCompanyValue = MONEY64_UNDEFINED;
|
||||
gScenarioCompletedBy = "?";
|
||||
gameState.ScenarioCompletedCompanyValue = MONEY64_UNDEFINED;
|
||||
gameState.ScenarioCompletedBy = "?";
|
||||
|
||||
park.ResetHistories();
|
||||
FinanceResetHistory();
|
||||
@@ -202,9 +192,9 @@ static void ScenarioEnd()
|
||||
*
|
||||
* rct2: 0x0066A752
|
||||
*/
|
||||
void ScenarioFailure()
|
||||
void ScenarioFailure(GameState_t& gameState)
|
||||
{
|
||||
gScenarioCompletedCompanyValue = COMPANY_VALUE_ON_FAILED_OBJECTIVE;
|
||||
gameState.ScenarioCompletedCompanyValue = COMPANY_VALUE_ON_FAILED_OBJECTIVE;
|
||||
ScenarioEnd();
|
||||
}
|
||||
|
||||
@@ -212,18 +202,18 @@ void ScenarioFailure()
|
||||
*
|
||||
* rct2: 0x0066A75E
|
||||
*/
|
||||
void ScenarioSuccess()
|
||||
void ScenarioSuccess(GameState_t& gameState)
|
||||
{
|
||||
auto companyValue = gCompanyValue;
|
||||
|
||||
gScenarioCompletedCompanyValue = companyValue;
|
||||
gameState.ScenarioCompletedCompanyValue = companyValue;
|
||||
PeepApplause();
|
||||
|
||||
if (ScenarioRepositoryTryRecordHighscore(gScenarioFileName.c_str(), companyValue, nullptr))
|
||||
{
|
||||
// Allow name entry
|
||||
GetGameState().ParkFlags |= PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
gScenarioCompanyValueRecord = companyValue;
|
||||
gameState.ScenarioCompanyValueRecord = companyValue;
|
||||
}
|
||||
ScenarioEnd();
|
||||
}
|
||||
@@ -232,13 +222,13 @@ void ScenarioSuccess()
|
||||
*
|
||||
* rct2: 0x006695E8
|
||||
*/
|
||||
void ScenarioSuccessSubmitName(const char* name)
|
||||
void ScenarioSuccessSubmitName(GameState_t& gameState, const char* name)
|
||||
{
|
||||
if (ScenarioRepositoryTryRecordHighscore(gScenarioFileName.c_str(), gScenarioCompanyValueRecord, name))
|
||||
if (ScenarioRepositoryTryRecordHighscore(gScenarioFileName.c_str(), gameState.ScenarioCompanyValueRecord, name))
|
||||
{
|
||||
gScenarioCompletedBy = name;
|
||||
gameState.ScenarioCompletedBy = name;
|
||||
}
|
||||
GetGameState().ParkFlags &= ~PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
gameState.ParkFlags &= ~PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,22 +291,22 @@ void ScenarioAutosaveCheck()
|
||||
}
|
||||
}
|
||||
|
||||
static void ScenarioDayUpdate()
|
||||
static void ScenarioDayUpdate(GameState_t& gameState)
|
||||
{
|
||||
FinanceUpdateDailyProfit();
|
||||
PeepUpdateDaysInQueue();
|
||||
switch (gScenarioObjective.Type)
|
||||
switch (gameState.ScenarioObjective.Type)
|
||||
{
|
||||
case OBJECTIVE_10_ROLLERCOASTERS:
|
||||
case OBJECTIVE_GUESTS_AND_RATING:
|
||||
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
|
||||
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
|
||||
case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE:
|
||||
ScenarioCheckObjective();
|
||||
ScenarioCheckObjective(gameState);
|
||||
break;
|
||||
default:
|
||||
if (AllowEarlyCompletion())
|
||||
ScenarioCheckObjective();
|
||||
ScenarioCheckObjective(gameState);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -361,7 +351,7 @@ static void ScenarioFortnightUpdate()
|
||||
static void ScenarioMonthUpdate()
|
||||
{
|
||||
FinanceShiftExpenditureTable();
|
||||
ScenarioCheckObjective();
|
||||
ScenarioCheckObjective(GetGameState());
|
||||
ScenarioCheckEntranceFeeTooHigh();
|
||||
AwardUpdateAll();
|
||||
}
|
||||
@@ -407,7 +397,7 @@ static void ScenarioUpdateDayNightCycle()
|
||||
* Scenario and finance related update iteration.
|
||||
* rct2: 0x006C44B1
|
||||
*/
|
||||
void ScenarioUpdate()
|
||||
void ScenarioUpdate(GameState_t& gameState)
|
||||
{
|
||||
PROFILED_FUNCTION();
|
||||
|
||||
@@ -416,7 +406,7 @@ void ScenarioUpdate()
|
||||
auto& date = GetDate();
|
||||
if (date.IsDayStart())
|
||||
{
|
||||
ScenarioDayUpdate();
|
||||
ScenarioDayUpdate(gameState);
|
||||
}
|
||||
if (date.IsWeekStart())
|
||||
{
|
||||
@@ -543,9 +533,9 @@ uint32_t ScenarioRandMax(uint32_t max)
|
||||
* Prepare rides, for the finish five rollercoasters objective.
|
||||
* rct2: 0x006788F7
|
||||
*/
|
||||
static ResultWithMessage ScenarioPrepareRidesForSave()
|
||||
static ResultWithMessage ScenarioPrepareRidesForSave(GameState_t& gameState)
|
||||
{
|
||||
int32_t isFiveCoasterObjective = gScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS;
|
||||
int32_t isFiveCoasterObjective = gameState.ScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS;
|
||||
uint8_t rcs = 0;
|
||||
|
||||
for (auto& ride : GetRideManager())
|
||||
@@ -602,19 +592,19 @@ static ResultWithMessage ScenarioPrepareRidesForSave()
|
||||
*
|
||||
* rct2: 0x006726C7
|
||||
*/
|
||||
ResultWithMessage ScenarioPrepareForSave()
|
||||
ResultWithMessage ScenarioPrepareForSave(GameState_t& gameState)
|
||||
{
|
||||
// This can return false if the goal is 'Finish 5 roller coaster' and there are too few.
|
||||
const auto prepareRidesResult = ScenarioPrepareRidesForSave();
|
||||
const auto prepareRidesResult = ScenarioPrepareRidesForSave(gameState);
|
||||
if (!prepareRidesResult.Successful)
|
||||
{
|
||||
return { false, prepareRidesResult.Message };
|
||||
}
|
||||
|
||||
if (gScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
GetGameState().ParkFlags |= PARK_FLAGS_PARK_OPEN;
|
||||
|
||||
ScenarioReset();
|
||||
ScenarioReset(gameState);
|
||||
|
||||
return { true };
|
||||
}
|
||||
@@ -703,36 +693,36 @@ ObjectiveStatus Objective::CheckGuestsAndRating() const
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ParkRating < 700 && GetDate().GetMonthsElapsed() >= 1)
|
||||
{
|
||||
gScenarioParkRatingWarningDays++;
|
||||
if (gScenarioParkRatingWarningDays == 1)
|
||||
gameState.ScenarioParkRatingWarningDays++;
|
||||
if (gameState.ScenarioParkRatingWarningDays == 1)
|
||||
{
|
||||
if (gConfigNotifications.ParkRatingWarnings)
|
||||
{
|
||||
News::AddItemToQueue(News::ItemType::Graph, STR_PARK_RATING_WARNING_4_WEEKS_REMAINING, 0, {});
|
||||
}
|
||||
}
|
||||
else if (gScenarioParkRatingWarningDays == 8)
|
||||
else if (gameState.ScenarioParkRatingWarningDays == 8)
|
||||
{
|
||||
if (gConfigNotifications.ParkRatingWarnings)
|
||||
{
|
||||
News::AddItemToQueue(News::ItemType::Graph, STR_PARK_RATING_WARNING_3_WEEKS_REMAINING, 0, {});
|
||||
}
|
||||
}
|
||||
else if (gScenarioParkRatingWarningDays == 15)
|
||||
else if (gameState.ScenarioParkRatingWarningDays == 15)
|
||||
{
|
||||
if (gConfigNotifications.ParkRatingWarnings)
|
||||
{
|
||||
News::AddItemToQueue(News::ItemType::Graph, STR_PARK_RATING_WARNING_2_WEEKS_REMAINING, 0, {});
|
||||
}
|
||||
}
|
||||
else if (gScenarioParkRatingWarningDays == 22)
|
||||
else if (gameState.ScenarioParkRatingWarningDays == 22)
|
||||
{
|
||||
if (gConfigNotifications.ParkRatingWarnings)
|
||||
{
|
||||
News::AddItemToQueue(News::ItemType::Graph, STR_PARK_RATING_WARNING_1_WEEK_REMAINING, 0, {});
|
||||
}
|
||||
}
|
||||
else if (gScenarioParkRatingWarningDays == 29)
|
||||
else if (gameState.ScenarioParkRatingWarningDays == 29)
|
||||
{
|
||||
News::AddItemToQueue(News::ItemType::Graph, STR_PARK_HAS_BEEN_CLOSED_DOWN, 0, {});
|
||||
gameState.ParkFlags &= ~PARK_FLAGS_PARK_OPEN;
|
||||
@@ -740,9 +730,9 @@ ObjectiveStatus Objective::CheckGuestsAndRating() const
|
||||
return ObjectiveStatus::Failure;
|
||||
}
|
||||
}
|
||||
else if (gScenarioCompletedCompanyValue != COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
else if (gameState.ScenarioCompletedCompanyValue != COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
{
|
||||
gScenarioParkRatingWarningDays = 0;
|
||||
gameState.ScenarioParkRatingWarningDays = 0;
|
||||
}
|
||||
|
||||
if (gameState.ParkRating >= 700)
|
||||
@@ -872,16 +862,16 @@ bool AllowEarlyCompletion()
|
||||
}
|
||||
}
|
||||
|
||||
static void ScenarioCheckObjective()
|
||||
static void ScenarioCheckObjective(GameState_t& gameState)
|
||||
{
|
||||
auto status = gScenarioObjective.Check();
|
||||
auto status = gameState.ScenarioObjective.Check(gameState);
|
||||
if (status == ObjectiveStatus::Success)
|
||||
{
|
||||
ScenarioSuccess();
|
||||
ScenarioSuccess(gameState);
|
||||
}
|
||||
else if (status == ObjectiveStatus::Failure)
|
||||
{
|
||||
ScenarioFailure();
|
||||
ScenarioFailure(gameState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -889,9 +879,9 @@ static void ScenarioCheckObjective()
|
||||
* Checks the win/lose conditions of the current objective.
|
||||
* rct2: 0x0066A4B2
|
||||
*/
|
||||
ObjectiveStatus Objective::Check() const
|
||||
ObjectiveStatus Objective::Check(GameState_t& gameState) const
|
||||
{
|
||||
if (gScenarioCompletedCompanyValue != MONEY64_UNDEFINED)
|
||||
if (gameState.ScenarioCompletedCompanyValue != MONEY64_UNDEFINED)
|
||||
{
|
||||
return ObjectiveStatus::Undecided;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ struct Objective
|
||||
return objectiveAllowedByMoneyUsage && objectiveAllowedByPaymentSettings;
|
||||
}
|
||||
|
||||
ObjectiveStatus Check() const;
|
||||
ObjectiveStatus Check(OpenRCT2::GameState_t& gameState) const;
|
||||
|
||||
private:
|
||||
ObjectiveStatus CheckGuestsBy() const;
|
||||
@@ -160,16 +160,8 @@ extern const StringId ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT];
|
||||
|
||||
extern random_engine_t gScenarioRand;
|
||||
|
||||
extern Objective gScenarioObjective;
|
||||
extern bool gAllowEarlyCompletionInNetworkPlay;
|
||||
extern uint16_t gScenarioParkRatingWarningDays;
|
||||
extern money64 gScenarioCompletedCompanyValue;
|
||||
extern money64 gScenarioCompanyValueRecord;
|
||||
|
||||
extern SCENARIO_CATEGORY gScenarioCategory;
|
||||
extern std::string gScenarioName;
|
||||
extern std::string gScenarioDetails;
|
||||
extern std::string gScenarioCompletedBy;
|
||||
extern std::string gScenarioSavePath;
|
||||
extern bool gFirstTimeSaving;
|
||||
extern uint16_t gSavedAge;
|
||||
@@ -177,9 +169,9 @@ extern uint32_t gLastAutoSaveUpdate;
|
||||
|
||||
extern std::string gScenarioFileName;
|
||||
|
||||
void ScenarioBegin();
|
||||
void ScenarioReset();
|
||||
void ScenarioUpdate();
|
||||
void ScenarioBegin(OpenRCT2::GameState_t& gameState);
|
||||
void ScenarioReset(OpenRCT2::GameState_t& gameState);
|
||||
void ScenarioUpdate(OpenRCT2::GameState_t& gameState);
|
||||
bool ScenarioCreateDucks();
|
||||
bool AllowEarlyCompletion();
|
||||
|
||||
@@ -188,9 +180,9 @@ void ScenarioRandSeed(random_engine_t::result_type s0, random_engine_t::result_t
|
||||
random_engine_t::result_type ScenarioRand();
|
||||
uint32_t ScenarioRandMax(uint32_t max);
|
||||
|
||||
ResultWithMessage ScenarioPrepareForSave();
|
||||
ResultWithMessage ScenarioPrepareForSave(OpenRCT2::GameState_t& gameState);
|
||||
int32_t ScenarioSave(OpenRCT2::GameState_t& gameState, u8string_view path, int32_t flags);
|
||||
void ScenarioFailure();
|
||||
void ScenarioSuccess();
|
||||
void ScenarioSuccessSubmitName(const char* name);
|
||||
void ScenarioFailure(OpenRCT2::GameState_t& gameState);
|
||||
void ScenarioSuccess(OpenRCT2::GameState_t& gameState);
|
||||
void ScenarioSuccessSubmitName(OpenRCT2::GameState_t& gameState, const char* name);
|
||||
void ScenarioAutosaveCheck();
|
||||
@@ -44,20 +44,22 @@ namespace OpenRCT2::Scripting
|
||||
private:
|
||||
std::string type_get()
|
||||
{
|
||||
return std::string(ScenarioObjectiveTypeMap[gScenarioObjective.Type]);
|
||||
return std::string(ScenarioObjectiveTypeMap[GetGameState().ScenarioObjective.Type]);
|
||||
}
|
||||
|
||||
void type_set(const std::string& value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
gScenarioObjective.Type = ScenarioObjectiveTypeMap[value];
|
||||
GetGameState().ScenarioObjective.Type = ScenarioObjectiveTypeMap[value];
|
||||
}
|
||||
|
||||
uint16_t guests_get()
|
||||
{
|
||||
if (gScenarioObjective.Type == OBJECTIVE_GUESTS_BY || gScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_BY
|
||||
|| gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
{
|
||||
return gScenarioObjective.NumGuests;
|
||||
return gameState.ScenarioObjective.NumGuests;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -65,35 +67,42 @@ namespace OpenRCT2::Scripting
|
||||
void guests_set(uint16_t value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
if (gScenarioObjective.Type == OBJECTIVE_GUESTS_BY || gScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_BY
|
||||
|| gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
|
||||
{
|
||||
gScenarioObjective.NumGuests = value;
|
||||
gameState.ScenarioObjective.NumGuests = value;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t year_get()
|
||||
{
|
||||
if (gScenarioObjective.Type == OBJECTIVE_GUESTS_BY || gScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY)
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_BY
|
||||
|| gameState.ScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY)
|
||||
{
|
||||
return gScenarioObjective.Year;
|
||||
return gameState.ScenarioObjective.Year;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void year_set(uint8_t value)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
ThrowIfGameStateNotMutable();
|
||||
if (gScenarioObjective.Type == OBJECTIVE_GUESTS_BY || gScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY)
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_BY
|
||||
|| gameState.ScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY)
|
||||
{
|
||||
gScenarioObjective.Year = value;
|
||||
gameState.ScenarioObjective.Year = value;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t length_get()
|
||||
{
|
||||
if (gScenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
|
||||
{
|
||||
return gScenarioObjective.NumGuests;
|
||||
return gameState.ScenarioObjective.NumGuests;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -101,17 +110,19 @@ namespace OpenRCT2::Scripting
|
||||
void length_set(uint16_t value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
if (gScenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
|
||||
{
|
||||
gScenarioObjective.NumGuests = value;
|
||||
gameState.ScenarioObjective.NumGuests = value;
|
||||
}
|
||||
}
|
||||
|
||||
money64 excitement_get()
|
||||
{
|
||||
if (gScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
|
||||
{
|
||||
return gScenarioObjective.Currency;
|
||||
return gameState.ScenarioObjective.Currency;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -119,18 +130,20 @@ namespace OpenRCT2::Scripting
|
||||
void excitement_set(money64 value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
if (gScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
|
||||
{
|
||||
gScenarioObjective.Currency = value;
|
||||
gameState.ScenarioObjective.Currency = value;
|
||||
}
|
||||
}
|
||||
|
||||
money64 parkValue_get()
|
||||
{
|
||||
if (gScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|
||||
|| gScenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|
||||
|| gameState.ScenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
|
||||
{
|
||||
return gScenarioObjective.Currency;
|
||||
return gameState.ScenarioObjective.Currency;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -138,19 +151,21 @@ namespace OpenRCT2::Scripting
|
||||
void parkValue_set(money64 value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
if (gScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|
||||
|| gScenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|
||||
|| gameState.ScenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
|
||||
{
|
||||
gScenarioObjective.Currency = value;
|
||||
gameState.ScenarioObjective.Currency = value;
|
||||
}
|
||||
}
|
||||
|
||||
money64 monthlyIncome_get()
|
||||
{
|
||||
if (gScenarioObjective.Type == OBJECTIVE_MONTHLY_RIDE_INCOME
|
||||
|| gScenarioObjective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME)
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_MONTHLY_RIDE_INCOME
|
||||
|| gameState.ScenarioObjective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME)
|
||||
{
|
||||
return gScenarioObjective.Currency;
|
||||
return gameState.ScenarioObjective.Currency;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -158,10 +173,11 @@ namespace OpenRCT2::Scripting
|
||||
void monthlyIncome_set(money64 value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
if (gScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|
||||
|| gScenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
|
||||
auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|
||||
|| gameState.ScenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
|
||||
{
|
||||
gScenarioObjective.Currency = value;
|
||||
gameState.ScenarioObjective.Currency = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,35 +201,35 @@ namespace OpenRCT2::Scripting
|
||||
public:
|
||||
std::string name_get()
|
||||
{
|
||||
return gScenarioName;
|
||||
return GetGameState().ScenarioName;
|
||||
}
|
||||
|
||||
void name_set(const std::string& value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
gScenarioName = value;
|
||||
GetGameState().ScenarioName = value;
|
||||
}
|
||||
|
||||
std::string details_get()
|
||||
{
|
||||
return gScenarioDetails;
|
||||
return GetGameState().ScenarioDetails;
|
||||
}
|
||||
|
||||
void details_set(const std::string& value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
gScenarioDetails = value;
|
||||
GetGameState().ScenarioDetails = value;
|
||||
}
|
||||
|
||||
std::string completedBy_get()
|
||||
{
|
||||
return gScenarioCompletedBy;
|
||||
return GetGameState().ScenarioCompletedBy;
|
||||
}
|
||||
|
||||
void completedBy_set(const std::string& value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
gScenarioCompletedBy = value;
|
||||
GetGameState().ScenarioCompletedBy = value;
|
||||
}
|
||||
|
||||
std::string filename_get()
|
||||
@@ -234,58 +250,61 @@ namespace OpenRCT2::Scripting
|
||||
|
||||
uint16_t parkRatingWarningDays_get() const
|
||||
{
|
||||
return gScenarioParkRatingWarningDays;
|
||||
return GetGameState().ScenarioParkRatingWarningDays;
|
||||
}
|
||||
|
||||
void parkRatingWarningDays_set(uint16_t value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
gScenarioParkRatingWarningDays = value;
|
||||
GetGameState().ScenarioParkRatingWarningDays = value;
|
||||
}
|
||||
|
||||
DukValue completedCompanyValue_get() const
|
||||
{
|
||||
const auto& gameState = GetGameState();
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
if (gScenarioCompletedCompanyValue == MONEY64_UNDEFINED
|
||||
|| gScenarioCompletedCompanyValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
if (gameState.ScenarioCompletedCompanyValue == MONEY64_UNDEFINED
|
||||
|| gameState.ScenarioCompletedCompanyValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
{
|
||||
return ToDuk(ctx, nullptr);
|
||||
}
|
||||
return ToDuk(ctx, gScenarioCompletedCompanyValue);
|
||||
return ToDuk(ctx, gameState.ScenarioCompletedCompanyValue);
|
||||
}
|
||||
void completedCompanyValue_set(int32_t value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
gScenarioCompletedCompanyValue = value;
|
||||
GetGameState().ScenarioCompletedCompanyValue = value;
|
||||
}
|
||||
|
||||
std::string status_get() const
|
||||
{
|
||||
if (gScenarioCompletedCompanyValue == MONEY64_UNDEFINED)
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ScenarioCompletedCompanyValue == MONEY64_UNDEFINED)
|
||||
return "inProgress";
|
||||
if (gScenarioCompletedCompanyValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
if (gameState.ScenarioCompletedCompanyValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
||||
return "failed";
|
||||
return "completed";
|
||||
}
|
||||
void status_set(const std::string& value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
auto& gameState = GetGameState();
|
||||
if (value == "inProgress")
|
||||
gScenarioCompletedCompanyValue = MONEY64_UNDEFINED;
|
||||
gameState.ScenarioCompletedCompanyValue = MONEY64_UNDEFINED;
|
||||
else if (value == "failed")
|
||||
gScenarioCompletedCompanyValue = COMPANY_VALUE_ON_FAILED_OBJECTIVE;
|
||||
gameState.ScenarioCompletedCompanyValue = COMPANY_VALUE_ON_FAILED_OBJECTIVE;
|
||||
else if (value == "completed")
|
||||
gScenarioCompletedCompanyValue = gCompanyValue;
|
||||
gameState.ScenarioCompletedCompanyValue = gCompanyValue;
|
||||
}
|
||||
|
||||
money64 companyValueRecord_get() const
|
||||
{
|
||||
return gScenarioCompanyValueRecord;
|
||||
return GetGameState().ScenarioCompanyValueRecord;
|
||||
}
|
||||
void companyValueRecord_set(money64 value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
gScenarioCompanyValueRecord = value;
|
||||
GetGameState().ScenarioCompanyValueRecord = value;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -290,9 +290,9 @@ void Park::Initialise()
|
||||
gameState.GuestInitialHappiness = CalculateGuestInitialHappiness(50);
|
||||
gameState.GuestInitialHunger = 200;
|
||||
gameState.GuestInitialThirst = 200;
|
||||
gScenarioObjective.Type = OBJECTIVE_GUESTS_BY;
|
||||
gScenarioObjective.Year = 4;
|
||||
gScenarioObjective.NumGuests = 1000;
|
||||
gameState.ScenarioObjective.Type = OBJECTIVE_GUESTS_BY;
|
||||
gameState.ScenarioObjective.Year = 4;
|
||||
gameState.ScenarioObjective.NumGuests = 1000;
|
||||
gLandPrice = 90.00_GBP;
|
||||
gConstructionRightsPrice = 40.00_GBP;
|
||||
gameState.ParkFlags = PARK_FLAGS_NO_MONEY | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
@@ -300,8 +300,8 @@ void Park::Initialise()
|
||||
FinanceResetHistory();
|
||||
AwardReset();
|
||||
|
||||
gScenarioName.clear();
|
||||
gScenarioDetails = String::ToStd(LanguageGetString(STR_NO_DETAILS_YET));
|
||||
gameState.ScenarioName.clear();
|
||||
gameState.ScenarioDetails = String::ToStd(LanguageGetString(STR_NO_DETAILS_YET));
|
||||
}
|
||||
|
||||
void Park::Update(const Date& date)
|
||||
|
||||
Reference in new issue
Block a user