Merge pull request #25017 from AaronVanGeffen/scenario-options

Introduce Scenario::Options struct
This commit is contained in:
Aaron van Geffen authored and GitHub committed 2025-08-22 20:07:54 +02:00
commit bbd92f0120
27 files changed
+354 -309

No files matched your search

+1 -1
View File
@@ -420,7 +420,7 @@ static void ShortcutQuickSaveGame()
auto intent = Intent(WindowClass::Loadsave);
intent.PutEnumExtra<LoadSaveAction>(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save);
intent.PutEnumExtra<LoadSaveType>(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::landscape);
intent.PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioName);
intent.PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioOptions.name);
ContextOpenIntent(&intent);
}
}
@@ -311,7 +311,7 @@ namespace OpenRCT2::Ui::Windows
auto intent = Intent(WindowClass::Loadsave);
intent.PutEnumExtra<LoadSaveAction>(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save);
intent.PutEnumExtra<LoadSaveType>(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::scenario);
intent.PutExtra(INTENT_EXTRA_PATH, gameState.scenarioName);
intent.PutExtra(INTENT_EXTRA_PATH, gameState.scenarioOptions.name);
intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast<CloseCallback>(SaveScenarioCallback));
ContextOpenIntent(&intent);
}
+122 -106
View File
@@ -683,7 +683,9 @@ namespace OpenRCT2::Ui::Windows
void SetObjective(int32_t objective)
{
auto& gameState = getGameState();
gameState.scenarioObjective.Type = objective;
auto& scenarioOptions = gameState.scenarioOptions;
scenarioOptions.objective.Type = objective;
Invalidate();
// Set default objective arguments
@@ -695,30 +697,30 @@ namespace OpenRCT2::Ui::Windows
case OBJECTIVE_10_ROLLERCOASTERS:
break;
case OBJECTIVE_GUESTS_BY:
gameState.scenarioObjective.Year = 3;
gameState.scenarioObjective.NumGuests = 1500;
scenarioOptions.objective.Year = 3;
scenarioOptions.objective.NumGuests = 1500;
break;
case OBJECTIVE_PARK_VALUE_BY:
gameState.scenarioObjective.Year = 3;
gameState.scenarioObjective.Currency = 50000.00_GBP;
scenarioOptions.objective.Year = 3;
scenarioOptions.objective.Currency = 50000.00_GBP;
break;
case OBJECTIVE_GUESTS_AND_RATING:
gameState.scenarioObjective.NumGuests = 2000;
scenarioOptions.objective.NumGuests = 2000;
break;
case OBJECTIVE_MONTHLY_RIDE_INCOME:
gameState.scenarioObjective.Currency = 10000.00_GBP;
scenarioOptions.objective.Currency = 10000.00_GBP;
break;
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
gameState.scenarioObjective.MinimumLength = 1200;
scenarioOptions.objective.MinimumLength = 1200;
break;
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
gameState.scenarioObjective.MinimumExcitement = RideRating::make(6, 70);
scenarioOptions.objective.MinimumExcitement = RideRating::make(6, 70);
break;
case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE:
gameState.scenarioObjective.Currency = 50000.00_GBP;
scenarioOptions.objective.Currency = 50000.00_GBP;
break;
case OBJECTIVE_MONTHLY_FOOD_INCOME:
gameState.scenarioObjective.Currency = 1000.00_GBP;
scenarioOptions.objective.Currency = 1000.00_GBP;
break;
}
}
@@ -726,10 +728,9 @@ namespace OpenRCT2::Ui::Windows
void ShowObjectiveDropdown()
{
const auto& gameState = getGameState();
int32_t numItems = 0, objectiveType;
Widget* dropdownWidget;
const auto& scenarioOptions = gameState.scenarioOptions;
dropdownWidget = &widgets[WIDX_OBJECTIVE];
int32_t numItems = 0, objectiveType;
for (auto i = 0; i < OBJECTIVE_COUNT; i++)
{
@@ -749,11 +750,12 @@ namespace OpenRCT2::Ui::Windows
}
}
Widget* dropdownWidget = &widgets[WIDX_OBJECTIVE];
WindowDropdownShowTextCustomWidth(
{ windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1,
colours[1], 0, Dropdown::Flag::StayOpen, numItems, dropdownWidget->width() - 3);
objectiveType = gameState.scenarioObjective.Type;
objectiveType = scenarioOptions.objective.Type;
for (int32_t j = 0; j < numItems; j++)
{
if (gDropdownItems[j].args - STR_OBJECTIVE_DROPDOWN_NONE == objectiveType)
@@ -766,81 +768,81 @@ namespace OpenRCT2::Ui::Windows
void ShowCategoryDropdown()
{
int32_t i;
Widget* dropdownWidget;
dropdownWidget = &widgets[WIDX_CATEGORY];
for (i = EnumValue(ScenarioCategory::beginner); i <= EnumValue(ScenarioCategory::other); i++)
for (int32_t i = EnumValue(ScenarioCategory::beginner); i <= EnumValue(ScenarioCategory::other); i++)
{
gDropdownItems[i].format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[i].args = kScenarioCategoryStringIds[i];
}
Widget* dropdownWidget = &widgets[WIDX_CATEGORY];
WindowDropdownShowTextCustomWidth(
{ windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1,
colours[1], 0, Dropdown::Flag::StayOpen, 5, dropdownWidget->width() - 3);
Dropdown::SetChecked(EnumValue(getGameState().scenarioCategory), true);
Dropdown::SetChecked(EnumValue(getGameState().scenarioOptions.category), true);
}
void Arg1Increase()
{
auto& gameState = getGameState();
switch (gameState.scenarioObjective.Type)
auto& scenarioOptions = gameState.scenarioOptions;
switch (scenarioOptions.objective.Type)
{
case OBJECTIVE_PARK_VALUE_BY:
case OBJECTIVE_MONTHLY_RIDE_INCOME:
case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE:
if (gameState.scenarioObjective.Currency >= kObjectiveCurrencyLoanAndValueMax)
if (scenarioOptions.objective.Currency >= kObjectiveCurrencyLoanAndValueMax)
{
ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.Currency += kObjectiveCurrencyLoanAndValueAdjustment;
scenarioOptions.objective.Currency += kObjectiveCurrencyLoanAndValueAdjustment;
Invalidate();
}
break;
case OBJECTIVE_MONTHLY_FOOD_INCOME:
if (gameState.scenarioObjective.Currency >= kObjectiveCurrencyFoodMax)
if (scenarioOptions.objective.Currency >= kObjectiveCurrencyFoodMax)
{
ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.Currency += kObjectiveCurrencyFoodAdjustment;
scenarioOptions.objective.Currency += kObjectiveCurrencyFoodAdjustment;
Invalidate();
}
break;
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
if (gameState.scenarioObjective.MinimumLength >= kObjectiveLengthMax)
if (scenarioOptions.objective.MinimumLength >= kObjectiveLengthMax)
{
ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.MinimumLength += kObjectiveLengthAdjustment;
scenarioOptions.objective.MinimumLength += kObjectiveLengthAdjustment;
Invalidate();
}
break;
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
if (gameState.scenarioObjective.MinimumExcitement >= kObjectiveExcitementMax)
if (scenarioOptions.objective.MinimumExcitement >= kObjectiveExcitementMax)
{
ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.MinimumExcitement += kObjectiveExcitementAdjustment;
scenarioOptions.objective.MinimumExcitement += kObjectiveExcitementAdjustment;
Invalidate();
}
break;
default:
if (gameState.scenarioObjective.NumGuests >= kObjectiveGuestsMax)
if (scenarioOptions.objective.NumGuests >= kObjectiveGuestsMax)
{
ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.NumGuests += kObjectiveGuestsAdjustment;
scenarioOptions.objective.NumGuests += kObjectiveGuestsAdjustment;
Invalidate();
}
break;
@@ -850,62 +852,64 @@ namespace OpenRCT2::Ui::Windows
void Arg1Decrease()
{
auto& gameState = getGameState();
switch (gameState.scenarioObjective.Type)
auto& scenarioOptions = gameState.scenarioOptions;
switch (scenarioOptions.objective.Type)
{
case OBJECTIVE_PARK_VALUE_BY:
case OBJECTIVE_MONTHLY_RIDE_INCOME:
case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE:
if (gameState.scenarioObjective.Currency <= kObjectiveCurrencyLoanAndValueMin)
if (scenarioOptions.objective.Currency <= kObjectiveCurrencyLoanAndValueMin)
{
ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.Currency -= kObjectiveCurrencyLoanAndValueAdjustment;
scenarioOptions.objective.Currency -= kObjectiveCurrencyLoanAndValueAdjustment;
Invalidate();
}
break;
case OBJECTIVE_MONTHLY_FOOD_INCOME:
if (gameState.scenarioObjective.Currency <= kObjectiveCurrencyFoodMin)
if (scenarioOptions.objective.Currency <= kObjectiveCurrencyFoodMin)
{
ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.Currency -= kObjectiveCurrencyFoodAdjustment;
scenarioOptions.objective.Currency -= kObjectiveCurrencyFoodAdjustment;
Invalidate();
}
break;
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
if (gameState.scenarioObjective.MinimumLength <= kObjectiveLengthMin)
if (scenarioOptions.objective.MinimumLength <= kObjectiveLengthMin)
{
ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.MinimumLength -= kObjectiveLengthAdjustment;
scenarioOptions.objective.MinimumLength -= kObjectiveLengthAdjustment;
Invalidate();
}
break;
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
if (gameState.scenarioObjective.MinimumExcitement <= kObjectiveExcitementMin)
if (scenarioOptions.objective.MinimumExcitement <= kObjectiveExcitementMin)
{
ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.MinimumExcitement -= kObjectiveExcitementAdjustment;
scenarioOptions.objective.MinimumExcitement -= kObjectiveExcitementAdjustment;
Invalidate();
}
break;
default:
if (gameState.scenarioObjective.NumGuests <= kObjectiveGuestsMin)
if (scenarioOptions.objective.NumGuests <= kObjectiveGuestsMin)
{
ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.NumGuests -= kObjectiveGuestsAdjustment;
scenarioOptions.objective.NumGuests -= kObjectiveGuestsAdjustment;
Invalidate();
}
break;
@@ -915,13 +919,15 @@ namespace OpenRCT2::Ui::Windows
void Arg2Increase()
{
auto& gameState = getGameState();
if (gameState.scenarioObjective.Year >= kObjectiveYearMax)
auto& scenarioOptions = gameState.scenarioOptions;
if (scenarioOptions.objective.Year >= kObjectiveYearMax)
{
ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.Year += kObjectiveYearAdjustment;
scenarioOptions.objective.Year += kObjectiveYearAdjustment;
Invalidate();
}
}
@@ -929,13 +935,15 @@ namespace OpenRCT2::Ui::Windows
void Arg2Decrease()
{
auto& gameState = getGameState();
if (gameState.scenarioObjective.Year <= kObjectiveYearMin)
auto& scenarioOptions = gameState.scenarioOptions;
if (scenarioOptions.objective.Year <= kObjectiveYearMin)
{
ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {});
}
else
{
gameState.scenarioObjective.Year -= kObjectiveYearAdjustment;
scenarioOptions.objective.Year -= kObjectiveYearAdjustment;
Invalidate();
}
}
@@ -1009,7 +1017,7 @@ namespace OpenRCT2::Ui::Windows
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 (gameState.scenarioObjective.Type != newObjectiveType)
if (gameState.scenarioOptions.objective.Type != newObjectiveType)
SetObjective(newObjectiveType);
break;
}
@@ -1027,7 +1035,7 @@ namespace OpenRCT2::Ui::Windows
OnPrepareDraw();
InvalidateWidget(WIDX_TAB_1);
objectiveType = getGameState().scenarioObjective.Type;
objectiveType = getGameState().scenarioOptions.objective.Type;
// Check if objective is allowed by money and pay-per-ride settings.
const bool objectiveAllowedByMoneyUsage = !(getGameState().park.flags & PARK_FLAGS_NO_MONEY)
@@ -1052,7 +1060,7 @@ namespace OpenRCT2::Ui::Windows
SetPressedTab();
switch (gameState.scenarioObjective.Type)
switch (gameState.scenarioOptions.objective.Type)
{
case OBJECTIVE_GUESTS_BY:
case OBJECTIVE_PARK_VALUE_BY:
@@ -1096,7 +1104,7 @@ namespace OpenRCT2::Ui::Windows
if (widgets[WIDX_OBJECTIVE_ARG_1_LABEL].type != WidgetType::empty)
{
// Objective argument 1 label
switch (gameState.scenarioObjective.Type)
switch (gameState.scenarioOptions.objective.Type)
{
case OBJECTIVE_GUESTS_BY:
case OBJECTIVE_GUESTS_AND_RATING:
@@ -1135,6 +1143,7 @@ namespace OpenRCT2::Ui::Windows
void ObjectiveOnDraw(RenderTarget& rt)
{
const auto& gameState = getGameState();
const auto& scenarioOptions = gameState.scenarioOptions;
DrawWidgets(rt);
DrawTabImages(rt);
@@ -1142,7 +1151,7 @@ namespace OpenRCT2::Ui::Windows
// Objective value
auto screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_OBJECTIVE].left + 1, widgets[WIDX_OBJECTIVE].top };
auto ft = Formatter();
ft.Add<StringId>(ObjectiveDropdownOptionNames[gameState.scenarioObjective.Type]);
ft.Add<StringId>(ObjectiveDropdownOptionNames[scenarioOptions.objective.Type]);
DrawTextBasic(rt, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft);
if (widgets[WIDX_OBJECTIVE_ARG_1].type != WidgetType::empty)
@@ -1154,31 +1163,31 @@ namespace OpenRCT2::Ui::Windows
screenCoords = windowPos
+ ScreenCoordsXY{ widgets[WIDX_OBJECTIVE_ARG_1].left + 1, widgets[WIDX_OBJECTIVE_ARG_1].top };
ft = Formatter();
switch (gameState.scenarioObjective.Type)
switch (scenarioOptions.objective.Type)
{
case OBJECTIVE_GUESTS_BY:
case OBJECTIVE_GUESTS_AND_RATING:
stringId = STR_WINDOW_COLOUR_2_COMMA32;
ft.Add<int32_t>(gameState.scenarioObjective.NumGuests);
ft.Add<int32_t>(scenarioOptions.objective.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>(gameState.scenarioObjective.Currency);
ft.Add<money64>(scenarioOptions.objective.Currency);
break;
case OBJECTIVE_10_ROLLERCOASTERS_LENGTH:
stringId = STR_WINDOW_COLOUR_2_LENGTH;
ft.Add<uint16_t>(gameState.scenarioObjective.MinimumLength);
ft.Add<uint16_t>(scenarioOptions.objective.MinimumLength);
break;
case OBJECTIVE_FINISH_5_ROLLERCOASTERS:
stringId = STR_WINDOW_COLOUR_2_COMMA2DP32;
ft.Add<uint16_t>(gameState.scenarioObjective.MinimumExcitement);
ft.Add<uint16_t>(scenarioOptions.objective.MinimumExcitement);
break;
default:
stringId = STR_WINDOW_COLOUR_2_COMMA2DP32;
ft.Add<money64>(gameState.scenarioObjective.Currency);
ft.Add<money64>(scenarioOptions.objective.Currency);
break;
}
DrawTextBasic(rt, screenCoords, stringId, ft, wColour2);
@@ -1190,7 +1199,7 @@ namespace OpenRCT2::Ui::Windows
screenCoords = windowPos
+ ScreenCoordsXY{ widgets[WIDX_OBJECTIVE_ARG_2].left + 1, widgets[WIDX_OBJECTIVE_ARG_2].top };
ft = Formatter();
ft.Add<uint16_t>((gameState.scenarioObjective.Year * MONTH_COUNT) - 1);
ft.Add<uint16_t>((scenarioOptions.objective.Year * MONTH_COUNT) - 1);
DrawTextBasic(rt, screenCoords, STR_WINDOW_OBJECTIVE_VALUE_DATE, ft);
}
}
@@ -1218,12 +1227,12 @@ namespace OpenRCT2::Ui::Windows
case WIDX_SCENARIO_NAME:
WindowTextInputRawOpen(
this, WIDX_SCENARIO_NAME, STR_SCENARIO_NAME, STR_ENTER_SCENARIO_NAME, {},
gameState.scenarioName.c_str(), kScenarioNameMaxLength);
gameState.scenarioOptions.name.c_str(), kScenarioNameMaxLength);
break;
case WIDX_DETAILS:
WindowTextInputRawOpen(
this, WIDX_DETAILS, STR_PARK_SCENARIO_DETAILS, STR_ENTER_SCENARIO_DESCRIPTION, {},
gameState.scenarioDetails.c_str(), kScenarioDetailsNameMaxLength);
gameState.scenarioOptions.details.c_str(), kScenarioDetailsNameMaxLength);
break;
}
}
@@ -1248,9 +1257,9 @@ namespace OpenRCT2::Ui::Windows
case WIDX_CATEGORY_DROPDOWN:
{
auto& gameState = getGameState();
if (gameState.scenarioCategory != static_cast<ScenarioCategory>(dropdownIndex))
if (gameState.scenarioOptions.category != static_cast<ScenarioCategory>(dropdownIndex))
{
gameState.scenarioCategory = static_cast<ScenarioCategory>(dropdownIndex);
gameState.scenarioOptions.category = static_cast<ScenarioCategory>(dropdownIndex);
Invalidate();
}
break;
@@ -1288,7 +1297,7 @@ namespace OpenRCT2::Ui::Windows
auto ft = Formatter();
ft.Add<StringId>(STR_STRING);
ft.Add<const char*>(gameState.scenarioName.c_str());
ft.Add<const char*>(gameState.scenarioOptions.name.c_str());
DrawTextEllipsised(rt, screenCoords, widthToSet, STR_WINDOW_SCENARIO_NAME, ft);
// Scenario details label
@@ -1301,7 +1310,7 @@ namespace OpenRCT2::Ui::Windows
ft = Formatter();
ft.Add<StringId>(STR_STRING);
ft.Add<const char*>(gameState.scenarioDetails.c_str());
ft.Add<const char*>(gameState.scenarioOptions.details.c_str());
DrawTextWrapped(rt, screenCoords, widthToSet, STR_BLACK_STRING, ft);
// Scenario category label
@@ -1311,7 +1320,7 @@ namespace OpenRCT2::Ui::Windows
// Scenario category value
screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_CATEGORY].left + 1, widgets[WIDX_CATEGORY].top };
ft = Formatter();
ft.Add<StringId>(kScenarioCategoryStringIds[EnumValue(gameState.scenarioCategory)]);
ft.Add<StringId>(kScenarioCategoryStringIds[EnumValue(gameState.scenarioOptions.category)]);
DrawTextBasic(rt, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft);
}
@@ -1325,6 +1334,8 @@ namespace OpenRCT2::Ui::Windows
return;
auto& gameState = getGameState();
auto& scenarioOptions = gameState.scenarioOptions;
switch (widgetIndex)
{
case WIDX_PARK_NAME:
@@ -1332,18 +1343,18 @@ namespace OpenRCT2::Ui::Windows
auto action = ParkSetNameAction(std::string(text));
GameActions::Execute(&action);
if (gameState.scenarioName.empty())
if (scenarioOptions.name.empty())
{
gameState.scenarioName = gameState.park.name;
scenarioOptions.name = gameState.park.name;
}
break;
}
case WIDX_SCENARIO_NAME:
gameState.scenarioName = text;
scenarioOptions.name = text;
Invalidate();
break;
case WIDX_DETAILS:
gameState.scenarioDetails = text;
scenarioOptions.details = text;
Invalidate();
break;
}
@@ -1408,10 +1419,10 @@ namespace OpenRCT2::Ui::Windows
switch (widgetIndex)
{
case WIDX_INITIAL_CASH_INCREASE:
if (gameState.initialCash < 1000000.00_GBP)
if (gameState.scenarioOptions.initialCash < 1000000.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::InitialCash, gameState.initialCash + 500.00_GBP);
ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash + 500.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1421,10 +1432,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_INITIAL_CASH_DECREASE:
if (gameState.initialCash > 0.00_GBP)
if (gameState.scenarioOptions.initialCash > 0.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::InitialCash, gameState.initialCash - 500.00_GBP);
ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash - 500.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1686,7 +1697,7 @@ namespace OpenRCT2::Ui::Windows
{
screenCoords = windowPos + ScreenCoordsXY{ initialCashWidget.left + 1, initialCashWidget.top };
auto ft = Formatter();
ft.Add<money64>(getGameState().initialCash);
ft.Add<money64>(getGameState().scenarioOptions.initialCash);
auto colour = !IsWidgetDisabled(WIDX_INITIAL_CASH) ? wColour2 : wColour2.withFlag(ColourFlag::inset, true);
DrawTextBasic(rt, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft, colour);
}
@@ -1767,14 +1778,15 @@ namespace OpenRCT2::Ui::Windows
void GuestsMouseDown(WidgetIndex widgetIndex)
{
auto& gameState = getGameState();
auto& scenarioOptions = gameState.scenarioOptions;
switch (widgetIndex)
{
case WIDX_CASH_PER_GUEST_INCREASE:
if (gameState.guestInitialCash < 1000.00_GBP)
if (scenarioOptions.guestInitialCash < 1000.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::AverageCashPerGuest, gameState.guestInitialCash + 1.00_GBP);
ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash + 1.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1784,10 +1796,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_CASH_PER_GUEST_DECREASE:
if (gameState.guestInitialCash > 0.00_GBP)
if (scenarioOptions.guestInitialCash > 0.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::AverageCashPerGuest, gameState.guestInitialCash - 1.00_GBP);
ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash - 1.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1797,10 +1809,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_GUEST_INITIAL_HAPPINESS_INCREASE:
if (gameState.guestInitialHappiness < 250)
if (scenarioOptions.guestInitialHappiness < 250)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::GuestInitialHappiness, gameState.guestInitialHappiness + 4);
ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness + 4);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1810,10 +1822,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_GUEST_INITIAL_HAPPINESS_DECREASE:
if (gameState.guestInitialHappiness > 40)
if (scenarioOptions.guestInitialHappiness > 40)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::GuestInitialHappiness, gameState.guestInitialHappiness - 4);
ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness - 4);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1823,10 +1835,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_GUEST_INITIAL_HUNGER_INCREASE:
if (gameState.guestInitialHunger > 40)
if (scenarioOptions.guestInitialHunger > 40)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::GuestInitialHunger, gameState.guestInitialHunger - 4);
ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger - 4);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1836,10 +1848,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_GUEST_INITIAL_HUNGER_DECREASE:
if (gameState.guestInitialHunger < 250)
if (scenarioOptions.guestInitialHunger < 250)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::GuestInitialHunger, gameState.guestInitialHunger + 4);
ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger + 4);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1849,10 +1861,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_GUEST_INITIAL_THIRST_INCREASE:
if (gameState.guestInitialThirst > 40)
if (scenarioOptions.guestInitialThirst > 40)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::GuestInitialThirst, gameState.guestInitialThirst - 4);
ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst - 4);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1862,10 +1874,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_GUEST_INITIAL_THIRST_DECREASE:
if (gameState.guestInitialThirst < 250)
if (scenarioOptions.guestInitialThirst < 250)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::GuestInitialThirst, gameState.guestInitialThirst + 4);
ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst + 4);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1975,7 +1987,7 @@ namespace OpenRCT2::Ui::Windows
// Cash per guest value
screenCoords = windowPos + ScreenCoordsXY{ cashPerGuestWidget.left + 1, cashPerGuestWidget.top };
auto ft = Formatter();
ft.Add<money64>(gameState.guestInitialCash);
ft.Add<money64>(gameState.scenarioOptions.guestInitialCash);
auto colour = !IsWidgetDisabled(WIDX_CASH_PER_GUEST) ? wColour2 : wColour2.withFlag(ColourFlag::inset, true);
DrawTextBasic(rt, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft, colour);
}
@@ -1986,21 +1998,21 @@ namespace OpenRCT2::Ui::Windows
const auto& initialHappinessWidget = widgets[WIDX_GUEST_INITIAL_HAPPINESS];
screenCoords = windowPos + ScreenCoordsXY{ initialHappinessWidget.left + 1, initialHappinessWidget.top };
auto ft = Formatter();
ft.Add<uint16_t>((gameState.guestInitialHappiness * 100) / 255);
ft.Add<uint16_t>((gameState.scenarioOptions.guestInitialHappiness * 100) / 255);
DrawTextBasic(rt, screenCoords, STR_PERCENT_FORMAT_LABEL, ft, colour);
// Guest initial hunger value
const auto& initialHungerWidget = widgets[WIDX_GUEST_INITIAL_HUNGER];
screenCoords = windowPos + ScreenCoordsXY{ initialHungerWidget.left + 1, initialHungerWidget.top };
ft = Formatter();
ft.Add<uint16_t>(((255 - gameState.guestInitialHunger) * 100) / 255);
ft.Add<uint16_t>(((255 - gameState.scenarioOptions.guestInitialHunger) * 100) / 255);
DrawTextBasic(rt, screenCoords, STR_PERCENT_FORMAT_LABEL, ft, colour);
// Guest initial thirst value
const auto& initialThirstWidget = widgets[WIDX_GUEST_INITIAL_THIRST];
screenCoords = windowPos + ScreenCoordsXY{ initialThirstWidget.left + 1, initialThirstWidget.top };
ft = Formatter();
ft.Add<uint16_t>(((255 - gameState.guestInitialThirst) * 100) / 255);
ft.Add<uint16_t>(((255 - gameState.scenarioOptions.guestInitialThirst) * 100) / 255);
DrawTextBasic(rt, screenCoords, STR_PERCENT_FORMAT_LABEL, ft, colour);
// Guests' intensity value
@@ -2071,13 +2083,15 @@ namespace OpenRCT2::Ui::Windows
void LandMouseDown(WidgetIndex widgetIndex)
{
auto& gameState = getGameState();
auto& scenarioOptions = gameState.scenarioOptions;
switch (widgetIndex)
{
case WIDX_LAND_COST_INCREASE:
if (gameState.landPrice < 200.00_GBP)
if (scenarioOptions.landPrice < 200.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::CostToBuyLand, gameState.landPrice + 1.00_GBP);
ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice + 1.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -2087,10 +2101,10 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_LAND_COST_DECREASE:
if (gameState.landPrice > 5.00_GBP)
if (scenarioOptions.landPrice > 5.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::CostToBuyLand, gameState.landPrice - 1.00_GBP);
ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice - 1.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -2100,10 +2114,11 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_CONSTRUCTION_RIGHTS_COST_INCREASE:
if (gameState.constructionRightsPrice < 200.00_GBP)
if (scenarioOptions.constructionRightsPrice < 200.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::CostToBuyConstructionRights, gameState.constructionRightsPrice + 1.00_GBP);
ScenarioSetSetting::CostToBuyConstructionRights,
scenarioOptions.constructionRightsPrice + 1.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -2113,10 +2128,11 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
break;
case WIDX_CONSTRUCTION_RIGHTS_COST_DECREASE:
if (gameState.constructionRightsPrice > 5.00_GBP)
if (scenarioOptions.constructionRightsPrice > 5.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::CostToBuyConstructionRights, gameState.constructionRightsPrice - 1.00_GBP);
ScenarioSetSetting::CostToBuyConstructionRights,
scenarioOptions.constructionRightsPrice - 1.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -2173,7 +2189,7 @@ namespace OpenRCT2::Ui::Windows
// Cost to buy land value
screenCoords = windowPos + ScreenCoordsXY{ landCostWidget.left + 1, landCostWidget.top };
auto ft = Formatter();
ft.Add<money64>(gameState.landPrice);
ft.Add<money64>(gameState.scenarioOptions.landPrice);
auto colour = !IsWidgetDisabled(WIDX_LAND_COST) ? wColour2 : wColour2.withFlag(ColourFlag::inset, true);
DrawTextBasic(rt, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft, colour);
}
@@ -2185,7 +2201,7 @@ namespace OpenRCT2::Ui::Windows
screenCoords = windowPos
+ ScreenCoordsXY{ constructionRightsCostWidget.left + 1, constructionRightsCostWidget.top };
auto ft = Formatter();
ft.Add<money64>(gameState.constructionRightsPrice);
ft.Add<money64>(gameState.scenarioOptions.constructionRightsPrice);
auto colour = !IsWidgetDisabled(WIDX_CONSTRUCTION_RIGHTS_COST) ? wColour2
: wColour2.withFlag(ColourFlag::inset, true);
DrawTextBasic(rt, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft, colour);
+1 -1
View File
@@ -636,7 +636,7 @@ namespace OpenRCT2::Ui::Windows
DrawTextBasic(rt, windowPos + ScreenCoordsXY{ 8, titleBarBottom + 280 }, stringId, ft);
// Objective related financial information
if (gameState.scenarioObjective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME)
{
auto lastMonthProfit = FinanceGetLastMonthShopProfit();
ft = Formatter();
+6 -5
View File
@@ -521,7 +521,7 @@ namespace OpenRCT2::Ui::Windows
widgets[WIDX_OPEN_LIGHT].image = ImageId(openLightImage);
// Only allow closing of park for guest / rating objective
if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
if (gameState.scenarioOptions.objective.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));
@@ -545,7 +545,7 @@ namespace OpenRCT2::Ui::Windows
if (ThemeGetFlags() & UITHEME_FLAG_USE_LIGHTS_PARK)
{
widgets[WIDX_OPEN_OR_CLOSE].type = WidgetType::empty;
if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING)
{
widgets[WIDX_CLOSE_LIGHT].type = WidgetType::flatBtn;
widgets[WIDX_OPEN_LIGHT].type = WidgetType::flatBtn;
@@ -1073,7 +1073,7 @@ namespace OpenRCT2::Ui::Windows
+ 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*>(gameState.scenarioDetails.c_str());
ft.Add<const char*>(gameState.scenarioOptions.details.c_str());
screenCoords.y += DrawTextWrapped(rt, screenCoords, 222, STR_BLACK_STRING, ft);
screenCoords.y += 5;
@@ -1083,9 +1083,10 @@ namespace OpenRCT2::Ui::Windows
// Objective
ft = Formatter();
formatObjective(ft, gameState.scenarioObjective);
formatObjective(ft, gameState.scenarioOptions.objective);
screenCoords.y += DrawTextWrapped(rt, screenCoords, 221, kObjectiveNames[gameState.scenarioObjective.Type], ft);
screenCoords.y += DrawTextWrapped(
rt, screenCoords, 221, kObjectiveNames[gameState.scenarioOptions.objective.Type], ft);
screenCoords.y += 5;
// Objective outcome
+1 -1
View File
@@ -169,7 +169,7 @@ namespace OpenRCT2::Ui::Windows
intent = std::make_unique<Intent>(WindowClass::Loadsave);
intent->PutEnumExtra<LoadSaveAction>(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save);
intent->PutEnumExtra<LoadSaveType>(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::landscape);
intent->PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioName);
intent->PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioOptions.name);
}
else
{
+1 -1
View File
@@ -465,7 +465,7 @@ namespace OpenRCT2::Ui::Windows
auto intent = Intent(WindowClass::Loadsave);
intent.PutEnumExtra<LoadSaveAction>(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save);
intent.PutEnumExtra<LoadSaveType>(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::landscape);
intent.PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioName);
intent.PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioOptions.name);
ContextOpenIntent(&intent);
}
else
+23 -23
View File
@@ -112,14 +112,14 @@ namespace OpenRCT2::Editor
gLegacyScene = LegacyScene::scenarioEditor;
gameState.editorStep = EditorStep::ObjectSelection;
gameState.park.flags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
gameState.scenarioCategory = ScenarioCategory::other;
gameState.scenarioOptions.category = ScenarioCategory::other;
ObjectListLoad();
ViewportInitAll();
WindowBase* mainWindow = OpenEditorWindows();
mainWindow->SetViewportLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ());
LoadPalette();
gScreenAge = 0;
gameState.scenarioName = LanguageGetString(STR_MY_NEW_SCENARIO);
gameState.scenarioOptions.name = LanguageGetString(STR_MY_NEW_SCENARIO);
GameLoadScripts();
GameNotifyMapChanged();
@@ -156,7 +156,7 @@ namespace OpenRCT2::Editor
gLegacyScene = LegacyScene::scenarioEditor;
gameState.editorStep = EditorStep::OptionsSelection;
gameState.scenarioCategory = ScenarioCategory::other;
gameState.scenarioOptions.category = ScenarioCategory::other;
ViewportInitAll();
OpenEditorWindows();
FinaliseMainView();
@@ -298,40 +298,40 @@ namespace OpenRCT2::Editor
staff->SetName({});
}
auto& gameState = getGameState();
ResetAllEntities();
UpdateConsolidatedPatrolAreas();
gameState.park.numGuestsInPark = 0;
gameState.park.numGuestsHeadingForPark = 0;
gameState.park.numGuestsInParkLastWeek = 0;
gameState.park.guestChangeModifier = 0;
auto& gameState = getGameState();
auto& park = gameState.park;
auto& scenarioOptions = gameState.scenarioOptions;
park.numGuestsInPark = 0;
park.numGuestsHeadingForPark = 0;
park.numGuestsInParkLastWeek = 0;
park.guestChangeModifier = 0;
if (fromSave)
{
gameState.park.flags |= PARK_FLAGS_NO_MONEY;
park.flags |= PARK_FLAGS_NO_MONEY;
if (gameState.park.entranceFee == 0)
if (park.entranceFee == 0)
{
gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY;
park.flags |= PARK_FLAGS_PARK_FREE_ENTRY;
}
else
{
gameState.park.flags &= ~PARK_FLAGS_PARK_FREE_ENTRY;
park.flags &= ~PARK_FLAGS_PARK_FREE_ENTRY;
}
gameState.park.flags &= ~PARK_FLAGS_SPRITES_INITIALISED;
park.flags &= ~PARK_FLAGS_SPRITES_INITIALISED;
gameState.guestInitialCash = std::clamp(gameState.guestInitialCash, 10.00_GBP, kMaxEntranceFee);
gameState.initialCash = std::min<money64>(gameState.initialCash, 100000);
scenarioOptions.guestInitialCash = std::clamp(scenarioOptions.guestInitialCash, 10.00_GBP, kMaxEntranceFee);
scenarioOptions.initialCash = std::min<money64>(scenarioOptions.initialCash, 100000);
FinanceResetCashToInitial();
gameState.park.bankLoan = std::clamp<money64>(gameState.park.bankLoan, 0.00_GBP, 5000000.00_GBP);
gameState.park.maxBankLoan = std::clamp<money64>(gameState.park.maxBankLoan, 0.00_GBP, 5000000.00_GBP);
gameState.park.bankLoanInterestRate = std::clamp<uint8_t>(
gameState.park.bankLoanInterestRate, 5, kMaxBankLoanInterestRate);
park.bankLoan = std::clamp<money64>(park.bankLoan, 0.00_GBP, 5000000.00_GBP);
park.maxBankLoan = std::clamp<money64>(park.maxBankLoan, 0.00_GBP, 5000000.00_GBP);
park.bankLoanInterestRate = std::clamp<uint8_t>(park.bankLoanInterestRate, 5, kMaxBankLoanInterestRate);
}
ClimateReset();
+2 -12
View File
@@ -19,7 +19,7 @@
#include "management/NewsItem.h"
#include "ride/Ride.h"
#include "ride/RideRatings.h"
#include "scenario/Scenario.h"
#include "scenario/ScenarioOptions.h"
#include "world/Banner.h"
#include "world/Climate.h"
#include "world/Location.hpp"
@@ -35,6 +35,7 @@ namespace OpenRCT2
struct GameState_t
{
Park::ParkData park{};
Scenario::Options scenarioOptions;
std::string pluginStorage;
uint32_t currentTicks{};
Date date;
@@ -43,28 +44,17 @@ namespace OpenRCT2
WeatherState weatherNext;
uint16_t weatherUpdateTimer;
money64 initialCash;
money64 guestInitialCash;
uint8_t guestInitialHappiness;
uint8_t guestInitialHunger;
uint8_t guestInitialThirst;
uint32_t nextGuestNumber;
Objective scenarioObjective;
uint16_t scenarioParkRatingWarningDays;
money64 scenarioCompletedCompanyValue;
money64 scenarioCompanyValueRecord;
random_engine_t scenarioRand;
TileCoordsXY mapSize;
money64 landPrice;
money64 constructionRightsPrice;
EditorStep editorStep;
ScenarioCategory scenarioCategory;
std::string scenarioName;
std::string scenarioDetails;
std::string scenarioCompletedBy;
std::string scenarioFileName;
+1 -1
View File
@@ -234,7 +234,7 @@ GameActions::Result CheatSetAction::Execute() const
ParkSetOpen(!Park::IsOpen(gameState.park));
break;
case CheatType::HaveFun:
gameState.scenarioObjective.Type = OBJECTIVE_HAVE_FUN;
gameState.scenarioOptions.objective.Type = OBJECTIVE_HAVE_FUN;
break;
case CheatType::SetForcedParkRating:
Park::SetForcedRating(_param1);
+2 -2
View File
@@ -143,7 +143,7 @@ GameActions::Result LandBuyRightsAction::MapBuyLandRightsForTile(const CoordsXY&
surfaceElement->SetOwnership(OWNERSHIP_OWNED);
Park::UpdateFencesAroundTile(loc);
}
res.Cost = getGameState().landPrice;
res.Cost = getGameState().scenarioOptions.landPrice;
return res;
case LandBuyRightSetting::BuyConstructionRights: // 2
@@ -165,7 +165,7 @@ GameActions::Result LandBuyRightsAction::MapBuyLandRightsForTile(const CoordsXY&
uint16_t baseZ = surfaceElement->GetBaseZ();
MapInvalidateTile({ loc, baseZ, baseZ + 16 });
}
res.Cost = getGameState().constructionRightsPrice;
res.Cost = getGameState().scenarioOptions.constructionRightsPrice;
return res;
default:
+4 -4
View File
@@ -193,23 +193,23 @@ GameActions::Result LandSetRightsAction::MapBuyLandRightsForTile(const CoordsXY&
{
// Buying land
if (!(currentOwnership & OWNERSHIP_OWNED) && (_ownership & OWNERSHIP_OWNED))
res.Cost = gameState.landPrice;
res.Cost = gameState.scenarioOptions.landPrice;
// Buying construction rights
if (!(currentOwnership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)
&& (_ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED))
res.Cost = gameState.constructionRightsPrice;
res.Cost = gameState.scenarioOptions.constructionRightsPrice;
}
else
{
// Selling land
if ((currentOwnership & OWNERSHIP_OWNED) && !(_ownership & OWNERSHIP_OWNED))
res.Cost = -gameState.landPrice;
res.Cost = -gameState.scenarioOptions.landPrice;
// Selling construction rights
if ((currentOwnership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)
&& !(_ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED))
res.Cost = -gameState.constructionRightsPrice;
res.Cost = -gameState.scenarioOptions.constructionRightsPrice;
}
if (isExecuting)
+1 -1
View File
@@ -226,7 +226,7 @@ GameActions::Result RideCreateAction::Execute() const
ride->price[1] = GetShopItemDescriptor(rideEntry->shop_item[1]).DefaultPrice;
}
if (gameState.scenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_BUILD_THE_BEST)
{
ride->price[0] = 0;
}
@@ -83,8 +83,8 @@ GameActions::Result ScenarioSetSettingAction::Execute() const
}
break;
case ScenarioSetSetting::InitialCash:
gameState.initialCash = std::clamp<money64>(_value, 0.00_GBP, 1000000.00_GBP);
gameState.park.cash = gameState.initialCash;
gameState.scenarioOptions.initialCash = std::clamp<money64>(_value, 0.00_GBP, 1000000.00_GBP);
gameState.park.cash = gameState.scenarioOptions.initialCash;
windowMgr->InvalidateByClass(WindowClass::Finances);
windowMgr->InvalidateByClass(WindowClass::BottomToolbar);
break;
@@ -113,16 +113,16 @@ GameActions::Result ScenarioSetSettingAction::Execute() const
}
break;
case ScenarioSetSetting::AverageCashPerGuest:
gameState.guestInitialCash = std::clamp<money64>(_value, 0.00_GBP, 1000.00_GBP);
gameState.scenarioOptions.guestInitialCash = std::clamp<money64>(_value, 0.00_GBP, 1000.00_GBP);
break;
case ScenarioSetSetting::GuestInitialHappiness:
gameState.guestInitialHappiness = std::clamp<uint8_t>(_value, 40, 250);
gameState.scenarioOptions.guestInitialHappiness = std::clamp<uint8_t>(_value, 40, 250);
break;
case ScenarioSetSetting::GuestInitialHunger:
gameState.guestInitialHunger = std::clamp<uint8_t>(_value, 40, 250);
gameState.scenarioOptions.guestInitialHunger = std::clamp<uint8_t>(_value, 40, 250);
break;
case ScenarioSetSetting::GuestInitialThirst:
gameState.guestInitialThirst = std::clamp<uint8_t>(_value, 40, 250);
gameState.scenarioOptions.guestInitialThirst = std::clamp<uint8_t>(_value, 40, 250);
break;
case ScenarioSetSetting::GuestsPreferLessIntenseRides:
if (_value != 0)
@@ -145,10 +145,10 @@ GameActions::Result ScenarioSetSettingAction::Execute() const
}
break;
case ScenarioSetSetting::CostToBuyLand:
gameState.landPrice = std::clamp<money64>(_value, 5.00_GBP, 200.00_GBP);
gameState.scenarioOptions.landPrice = std::clamp<money64>(_value, 5.00_GBP, 200.00_GBP);
break;
case ScenarioSetSetting::CostToBuyConstructionRights:
gameState.constructionRightsPrice = std::clamp<money64>(_value, 5.00_GBP, 200.00_GBP);
gameState.scenarioOptions.constructionRightsPrice = std::clamp<money64>(_value, 5.00_GBP, 200.00_GBP);
break;
case ScenarioSetSetting::ParkChargeMethod:
if (gLegacyScene == LegacyScene::scenarioEditor)
-1
View File
@@ -18,7 +18,6 @@
#include <string_view>
#include <vector>
class AudioObject;
struct CoordsXYZ;
namespace OpenRCT2::Audio
+7 -7
View File
@@ -7338,10 +7338,10 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
/* Scenario editor limits initial guest happiness to between 37..253.
* To be on the safe side, assume the value could have been hacked
* to any value 0..255. */
peep->Happiness = gameState.guestInitialHappiness;
peep->Happiness = gameState.scenarioOptions.guestInitialHappiness;
/* Assume a default initial happiness of 0 is wrong and set
* to 128 (50%) instead. */
if (gameState.guestInitialHappiness == 0)
if (gameState.scenarioOptions.guestInitialHappiness == 0)
peep->Happiness = 128;
/* Initial value will vary by -15..16 */
int8_t happinessDelta = (ScenarioRand() & 0x1F) - 15;
@@ -7354,7 +7354,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
/* Scenario editor limits initial guest hunger to between 37..253.
* To be on the safe side, assume the value could have been hacked
* to any value 0..255. */
peep->Hunger = gameState.guestInitialHunger;
peep->Hunger = gameState.scenarioOptions.guestInitialHunger;
/* Initial value will vary by -15..16 */
int8_t hungerDelta = (ScenarioRand() & 0x1F) - 15;
/* Adjust by the delta, clamping at min=0 and max=255. */
@@ -7363,7 +7363,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
/* Scenario editor limits initial guest thirst to between 37..253.
* To be on the safe side, assume the value could have been hacked
* to any value 0..255. */
peep->Thirst = gameState.guestInitialThirst;
peep->Thirst = gameState.scenarioOptions.guestInitialThirst;
/* Initial value will vary by -15..16 */
int8_t thirstDelta = (ScenarioRand() & 0x1F) - 15;
/* Adjust by the delta, clamping at min=0 and max=255. */
@@ -7376,11 +7376,11 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
peep->PeepId = gameState.nextGuestNumber++;
peep->Name = nullptr;
money64 cash = (static_cast<money64>(ScenarioRand() & 0x3) * 100) - 100 + gameState.guestInitialCash;
money64 cash = (static_cast<money64>(ScenarioRand() & 0x3) * 100) - 100 + gameState.scenarioOptions.guestInitialCash;
if (cash < 0)
cash = 0;
if (gameState.guestInitialCash == 0.00_GBP)
if (gameState.scenarioOptions.guestInitialCash == 0.00_GBP)
{
cash = 500;
}
@@ -7390,7 +7390,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
cash = 0;
}
if (gameState.guestInitialCash == kMoney64Undefined)
if (gameState.scenarioOptions.guestInitialCash == kMoney64Undefined)
{
cash = 0;
}
+14 -11
View File
@@ -565,7 +565,7 @@ static void ConsoleCommandGet(InteractiveConsole& console, const arguments_t& ar
}
else if (argv[0] == "scenario_initial_cash")
{
console.WriteLine(FormatString("scenario_initial_cash {CURRENCY2DP}", gameState.initialCash));
console.WriteLine(FormatString("scenario_initial_cash {CURRENCY2DP}", gameState.scenarioOptions.initialCash));
}
else if (argv[0] == "current_loan")
{
@@ -577,28 +577,31 @@ static void ConsoleCommandGet(InteractiveConsole& console, const arguments_t& ar
}
else if (argv[0] == "guest_initial_cash")
{
console.WriteLine(FormatString("guest_initial_cash {CURRENCY2DP}", gameState.guestInitialCash));
console.WriteLine(FormatString("guest_initial_cash {CURRENCY2DP}", gameState.scenarioOptions.guestInitialCash));
}
else if (argv[0] == "land_rights_cost")
{
console.WriteLine(FormatString("land_rights_cost {CURRENCY2DP}", gameState.landPrice));
console.WriteLine(FormatString("land_rights_cost {CURRENCY2DP}", gameState.scenarioOptions.landPrice));
}
else if (argv[0] == "construction_rights_cost")
{
console.WriteLine(FormatString("construction_rights_cost {CURRENCY2DP}", gameState.constructionRightsPrice));
console.WriteLine(
FormatString("construction_rights_cost {CURRENCY2DP}", gameState.scenarioOptions.constructionRightsPrice));
}
else if (argv[0] == "guest_initial_happiness")
{
uint32_t current_happiness = gameState.guestInitialHappiness;
uint32_t current_happiness = gameState.scenarioOptions.guestInitialHappiness;
for (int32_t i = 15; i <= 99; i++)
{
if (i == 99)
{
console.WriteFormatLine("guest_initial_happiness %d%% (%d)", 15, gameState.guestInitialHappiness);
console.WriteFormatLine(
"guest_initial_happiness %d%% (%d)", 15, gameState.scenarioOptions.guestInitialHappiness);
}
else if (current_happiness == Park::CalculateGuestInitialHappiness(i))
{
console.WriteFormatLine("guest_initial_happiness %d%% (%d)", i, gameState.guestInitialHappiness);
console.WriteFormatLine(
"guest_initial_happiness %d%% (%d)", i, gameState.scenarioOptions.guestInitialHappiness);
break;
}
}
@@ -606,14 +609,14 @@ static void ConsoleCommandGet(InteractiveConsole& console, const arguments_t& ar
else if (argv[0] == "guest_initial_hunger")
{
console.WriteFormatLine(
"guest_initial_hunger %d%% (%d)", ((255 - gameState.guestInitialHunger) * 100) / 255,
gameState.guestInitialHunger);
"guest_initial_hunger %d%% (%d)", ((255 - gameState.scenarioOptions.guestInitialHunger) * 100) / 255,
gameState.scenarioOptions.guestInitialHunger);
}
else if (argv[0] == "guest_initial_thirst")
{
console.WriteFormatLine(
"guest_initial_thirst %d%% (%d)", ((255 - gameState.guestInitialThirst) * 100) / 255,
gameState.guestInitialThirst);
"guest_initial_thirst %d%% (%d)", ((255 - gameState.scenarioOptions.guestInitialThirst) * 100) / 255,
gameState.scenarioOptions.guestInitialThirst);
}
else if (argv[0] == "guest_prefer_less_intense_rides")
{
+1
View File
@@ -548,6 +548,7 @@
<ClInclude Include="sawyer_coding\SawyerChunkReader.h" />
<ClInclude Include="sawyer_coding\SawyerChunkWriter.h" />
<ClInclude Include="scenario\Scenario.h" />
<ClInclude Include="scenario\ScenarioOptions.h" />
<ClInclude Include="scenario\ScenarioRepository.h" />
<ClInclude Include="scenario\ScenarioSources.h" />
<ClInclude Include="scenes\Scene.h" />
+3 -3
View File
@@ -235,7 +235,7 @@ void FinanceInit()
gameState.park.weeklyProfitAverageDividend = 0;
gameState.park.weeklyProfitAverageDivisor = 0;
gameState.initialCash = 10000.00_GBP; // Cheat detection
gameState.scenarioOptions.initialCash = 10000.00_GBP; // Cheat detection
gameState.park.cash = 10000.00_GBP;
gameState.park.bankLoan = 10000.00_GBP;
@@ -306,7 +306,7 @@ void FinanceUpdateDailyProfit()
money64 FinanceGetInitialCash()
{
return getGameState().initialCash;
return getGameState().scenarioOptions.initialCash;
}
money64 FinanceGetCurrentLoan()
@@ -368,7 +368,7 @@ void FinanceShiftExpenditureTable()
void FinanceResetCashToInitial()
{
auto& gameState = getGameState();
gameState.park.cash = gameState.initialCash;
gameState.park.cash = gameState.scenarioOptions.initialCash;
}
/**
+17 -17
View File
@@ -175,7 +175,7 @@ namespace OpenRCT2
}
// Initial cash will eventually be removed
gameState.initialCash = gameState.park.cash;
gameState.scenarioOptions.initialCash = gameState.park.cash;
}
void Save(GameState_t& gameState, IStream& stream, int16_t compressionLevel)
@@ -484,15 +484,15 @@ namespace OpenRCT2
void ReadWriteScenarioChunk(GameState_t& gameState, OrcaStream& os)
{
os.readWriteChunk(ParkFileChunkType::SCENARIO, [&gameState, &os](OrcaStream::ChunkStream& cs) {
cs.readWrite(gameState.scenarioCategory);
ReadWriteStringTable(cs, gameState.scenarioName, "en-GB");
cs.readWrite(gameState.scenarioOptions.category);
ReadWriteStringTable(cs, gameState.scenarioOptions.name, "en-GB");
ReadWriteStringTable(cs, gameState.park.name, "en-GB");
ReadWriteStringTable(cs, gameState.scenarioDetails, "en-GB");
ReadWriteStringTable(cs, gameState.scenarioOptions.details, "en-GB");
cs.readWrite(gameState.scenarioObjective.Type);
cs.readWrite(gameState.scenarioObjective.Year);
cs.readWrite(gameState.scenarioObjective.NumGuests);
cs.readWrite(gameState.scenarioObjective.Currency);
cs.readWrite(gameState.scenarioOptions.objective.Type);
cs.readWrite(gameState.scenarioOptions.objective.Year);
cs.readWrite(gameState.scenarioOptions.objective.NumGuests);
cs.readWrite(gameState.scenarioOptions.objective.Currency);
cs.readWrite(gameState.scenarioParkRatingWarningDays);
@@ -601,19 +601,19 @@ namespace OpenRCT2
cs.write(randState.s1);
}
cs.readWrite(gameState.guestInitialHappiness);
cs.readWrite(gameState.scenarioOptions.guestInitialHappiness);
if (version <= 18)
{
money16 tempGuestInitialCash{};
cs.readWrite(tempGuestInitialCash);
gameState.guestInitialCash = ToMoney64(tempGuestInitialCash);
gameState.scenarioOptions.guestInitialCash = ToMoney64(tempGuestInitialCash);
}
else
{
cs.readWrite(gameState.guestInitialCash);
cs.readWrite(gameState.scenarioOptions.guestInitialCash);
}
cs.readWrite(gameState.guestInitialHunger);
cs.readWrite(gameState.guestInitialThirst);
cs.readWrite(gameState.scenarioOptions.guestInitialHunger);
cs.readWrite(gameState.scenarioOptions.guestInitialThirst);
cs.readWrite(gameState.nextGuestNumber);
cs.readWriteVector(gameState.peepSpawns, [&cs](PeepSpawn& spawn) {
@@ -629,13 +629,13 @@ namespace OpenRCT2
money16 tempConstructionRightPrice{};
cs.readWrite(tempLandPrice);
cs.readWrite(tempConstructionRightPrice);
gameState.landPrice = ToMoney64(tempLandPrice);
gameState.constructionRightsPrice = ToMoney64(tempConstructionRightPrice);
gameState.scenarioOptions.landPrice = ToMoney64(tempLandPrice);
gameState.scenarioOptions.constructionRightsPrice = ToMoney64(tempConstructionRightPrice);
}
else
{
cs.readWrite(gameState.landPrice);
cs.readWrite(gameState.constructionRightsPrice);
cs.readWrite(gameState.scenarioOptions.landPrice);
cs.readWrite(gameState.scenarioOptions.constructionRightsPrice);
}
cs.readWrite(gameState.grassSceneryTileLoopPosition);
cs.readWrite(gameState.widePathTileLoopPosition);
+16 -16
View File
@@ -358,7 +358,7 @@ namespace OpenRCT2::RCT1
gameStateInitAll(gameState, { mapSize, mapSize });
gameState.editorStep = EditorStep::ObjectSelection;
gameState.park.flags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
gameState.scenarioCategory = ScenarioCategory::other;
gameState.scenarioOptions.category = ScenarioCategory::other;
}
std::string GetRCT1ScenarioName()
@@ -1501,15 +1501,15 @@ namespace OpenRCT2::RCT1
void ImportFinance(GameState_t& gameState)
{
gameState.park.entranceFee = _s4.ParkEntranceFee;
gameState.landPrice = ToMoney64(_s4.LandPrice);
gameState.constructionRightsPrice = ToMoney64(_s4.ConstructionRightsPrice);
gameState.scenarioOptions.landPrice = ToMoney64(_s4.LandPrice);
gameState.scenarioOptions.constructionRightsPrice = ToMoney64(_s4.ConstructionRightsPrice);
gameState.park.cash = ToMoney64(_s4.Cash);
gameState.park.bankLoan = ToMoney64(_s4.Loan);
gameState.park.maxBankLoan = ToMoney64(_s4.MaxLoan);
// It's more like 1.33%, but we can only use integers. Can be fixed once we have our own save format.
gameState.park.bankLoanInterestRate = 1;
gameState.initialCash = ToMoney64(_s4.Cash);
gameState.scenarioOptions.initialCash = ToMoney64(_s4.Cash);
gameState.park.companyValue = ToMoney64(_s4.CompanyValue);
gameState.park.value = CorrectRCT1ParkValue(_s4.ParkValue);
@@ -2309,10 +2309,10 @@ namespace OpenRCT2::RCT1
News::importNewsItems(gameState, recentMessages, archivedMessages);
// Initial guest status
gameState.guestInitialCash = ToMoney64(_s4.GuestInitialCash);
gameState.guestInitialHunger = _s4.GuestInitialHunger;
gameState.guestInitialThirst = _s4.GuestInitialThirst;
gameState.guestInitialHappiness = _s4.GuestInitialHappiness;
gameState.scenarioOptions.guestInitialCash = ToMoney64(_s4.GuestInitialCash);
gameState.scenarioOptions.guestInitialHunger = _s4.GuestInitialHunger;
gameState.scenarioOptions.guestInitialThirst = _s4.GuestInitialThirst;
gameState.scenarioOptions.guestInitialHappiness = _s4.GuestInitialHappiness;
gameState.park.guestGenerationProbability = _s4.GuestGenerationProbability;
@@ -2447,8 +2447,8 @@ namespace OpenRCT2::RCT1
}
}
gameState.scenarioName = std::move(name);
gameState.scenarioDetails = std::move(details);
gameState.scenarioOptions.name = std::move(name);
gameState.scenarioOptions.details = std::move(details);
if (_isScenario && !parkName.empty())
{
auto& park = getGameState().park;
@@ -2458,21 +2458,21 @@ namespace OpenRCT2::RCT1
void ImportScenarioObjective(GameState_t& gameState)
{
gameState.scenarioObjective.Type = _s4.ScenarioObjectiveType;
gameState.scenarioObjective.Year = _s4.ScenarioObjectiveYears;
gameState.scenarioObjective.NumGuests = _s4.ScenarioObjectiveNumGuests;
gameState.scenarioOptions.objective.Type = _s4.ScenarioObjectiveType;
gameState.scenarioOptions.objective.Year = _s4.ScenarioObjectiveYears;
gameState.scenarioOptions.objective.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)
gameState.scenarioObjective.Currency = CorrectRCT1ParkValue(_s4.ScenarioObjectiveCurrency);
gameState.scenarioOptions.objective.Currency = CorrectRCT1ParkValue(_s4.ScenarioObjectiveCurrency);
else
gameState.scenarioObjective.Currency = ToMoney64(_s4.ScenarioObjectiveCurrency);
gameState.scenarioOptions.objective.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)
gameState.scenarioObjective.RideId = GetBuildTheBestRideId();
gameState.scenarioOptions.objective.RideId = GetBuildTheBestRideId();
}
void ImportSavedView(GameState_t& gameState)
+20 -20
View File
@@ -350,7 +350,7 @@ namespace OpenRCT2::RCT2
Initialise(gameState);
gameState.editorStep = _s6.Info.EditorStep;
gameState.scenarioCategory = _s6.Info.Category;
gameState.scenarioOptions.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 {
@@ -359,14 +359,14 @@ namespace OpenRCT2::RCT2
if (_s6.Header.Type == S6_TYPE_SCENARIO)
{
gameState.scenarioName = loadMaybeUTF8(_s6.Info.Name);
gameState.scenarioDetails = loadMaybeUTF8(_s6.Info.Details);
gameState.scenarioOptions.name = loadMaybeUTF8(_s6.Info.Name);
gameState.scenarioOptions.details = loadMaybeUTF8(_s6.Info.Details);
}
else
{
// Saved games do not have an info chunk
gameState.scenarioName = loadMaybeUTF8(_s6.ScenarioName);
gameState.scenarioDetails = loadMaybeUTF8(_s6.ScenarioDescription);
gameState.scenarioOptions.name = loadMaybeUTF8(_s6.ScenarioName);
gameState.scenarioOptions.details = loadMaybeUTF8(_s6.ScenarioDescription);
}
gameState.date = OpenRCT2::Date{ _s6.ElapsedMonths, _s6.CurrentDay };
@@ -379,7 +379,7 @@ namespace OpenRCT2::RCT2
ImportEntities();
ConvertPeepAnimationTypeToObjects(gameState);
gameState.initialCash = ToMoney64(_s6.InitialCash);
gameState.scenarioOptions.initialCash = ToMoney64(_s6.InitialCash);
gameState.park.bankLoan = ToMoney64(_s6.CurrentLoan);
gameState.park.flags = _s6.ParkFlags & ~PARK_FLAGS_NO_MONEY_SCENARIO;
@@ -460,24 +460,24 @@ namespace OpenRCT2::RCT2
gameState.researchProgress = _s6.ResearchProgress;
gameState.researchExpectedDay = _s6.NextResearchExpectedDay;
gameState.researchExpectedMonth = _s6.NextResearchExpectedMonth;
gameState.guestInitialHappiness = _s6.GuestInitialHappiness;
gameState.scenarioOptions.guestInitialHappiness = _s6.GuestInitialHappiness;
gameState.park.size = _s6.ParkSize;
gameState.park.guestGenerationProbability = _s6.GuestGenerationProbability;
gameState.park.totalRideValueForMoney = _s6.TotalRideValueForMoney;
gameState.park.maxBankLoan = ToMoney64(_s6.MaximumLoan);
gameState.guestInitialCash = ToMoney64(_s6.GuestInitialCash);
gameState.guestInitialHunger = _s6.GuestInitialHunger;
gameState.guestInitialThirst = _s6.GuestInitialThirst;
gameState.scenarioObjective.Type = _s6.ObjectiveType;
gameState.scenarioObjective.Year = _s6.ObjectiveYear;
gameState.scenarioOptions.guestInitialCash = ToMoney64(_s6.GuestInitialCash);
gameState.scenarioOptions.guestInitialHunger = _s6.GuestInitialHunger;
gameState.scenarioOptions.guestInitialThirst = _s6.GuestInitialThirst;
gameState.scenarioOptions.objective.Type = _s6.ObjectiveType;
gameState.scenarioOptions.objective.Year = _s6.ObjectiveYear;
// Pad013580FA
gameState.scenarioObjective.Currency = _s6.ObjectiveCurrency;
gameState.scenarioOptions.objective.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 (gameState.scenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST)
gameState.scenarioObjective.RideId = _s6.ObjectiveGuests - kRCT2RideStringStart;
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_BUILD_THE_BEST)
gameState.scenarioOptions.objective.RideId = _s6.ObjectiveGuests - kRCT2RideStringStart;
else
gameState.scenarioObjective.NumGuests = _s6.ObjectiveGuests;
gameState.scenarioOptions.objective.NumGuests = _s6.ObjectiveGuests;
ImportMarketingCampaigns();
gameState.park.currentExpenditure = ToMoney64(_s6.CurrentExpenditure);
@@ -511,8 +511,8 @@ namespace OpenRCT2::RCT2
}
}
gameState.landPrice = ToMoney64(_s6.LandPrice);
gameState.constructionRightsPrice = ToMoney64(_s6.ConstructionRightsPrice);
gameState.scenarioOptions.landPrice = ToMoney64(_s6.LandPrice);
gameState.scenarioOptions.constructionRightsPrice = ToMoney64(_s6.ConstructionRightsPrice);
// unk_01358774
// Pad01358776
// _s6.CdKey
@@ -641,8 +641,8 @@ namespace OpenRCT2::RCT2
{
// Scenario details
gameState.scenarioCompletedBy = RCT2StringToUTF8(gameState.scenarioCompletedBy, RCT2LanguageId::EnglishUK);
gameState.scenarioName = RCT2StringToUTF8(gameState.scenarioName, RCT2LanguageId::EnglishUK);
gameState.scenarioDetails = RCT2StringToUTF8(gameState.scenarioDetails, RCT2LanguageId::EnglishUK);
gameState.scenarioOptions.name = RCT2StringToUTF8(gameState.scenarioOptions.name, RCT2LanguageId::EnglishUK);
gameState.scenarioOptions.details = RCT2StringToUTF8(gameState.scenarioOptions.details, RCT2LanguageId::EnglishUK);
}
void ImportRides()
+10 -10
View File
@@ -84,7 +84,7 @@ void ScenarioBegin(GameState_t& gameState)
GameLoadInit();
ScenarioReset(gameState);
if (gameState.scenarioObjective.Type != OBJECTIVE_NONE && !gLoadKeepWindowsOpen)
if (gameState.scenarioOptions.objective.Type != OBJECTIVE_NONE && !gLoadKeepWindowsOpen)
ContextOpenWindowView(WV_PARK_OBJECTIVE);
gScreenAge = 0;
@@ -106,15 +106,15 @@ void ScenarioReset(GameState_t& gameState)
gameState.park.rating = Park::CalculateParkRating();
gameState.park.value = Park::CalculateParkValue();
gameState.park.companyValue = Park::CalculateCompanyValue();
gameState.park.historicalProfit = gameState.initialCash - gameState.park.bankLoan;
gameState.park.cash = gameState.initialCash;
gameState.park.historicalProfit = gameState.scenarioOptions.initialCash - gameState.park.bankLoan;
gameState.park.cash = gameState.scenarioOptions.initialCash;
auto& objManager = GetContext()->GetObjectManager();
if (auto* textObject = objManager.GetLoadedObject<ScenarioMetaObject>(0); textObject != nullptr)
{
gameState.scenarioName = textObject->GetScenarioName();
gameState.scenarioOptions.name = textObject->GetScenarioName();
gameState.park.name = textObject->GetParkName();
gameState.scenarioDetails = textObject->GetScenarioDetails();
gameState.scenarioOptions.details = textObject->GetScenarioDetails();
}
// Set the last saved game path
@@ -285,7 +285,7 @@ static void ScenarioDayUpdate(GameState_t& gameState)
{
FinanceUpdateDailyProfit();
PeepUpdateDaysInQueue();
switch (gameState.scenarioObjective.Type)
switch (gameState.scenarioOptions.objective.Type)
{
case OBJECTIVE_10_ROLLERCOASTERS:
case OBJECTIVE_GUESTS_AND_RATING:
@@ -526,7 +526,7 @@ uint32_t ScenarioRandMax(uint32_t max)
*/
static ResultWithMessage ScenarioPrepareRidesForSave(GameState_t& gameState)
{
int32_t isFiveCoasterObjective = gameState.scenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS;
int32_t isFiveCoasterObjective = gameState.scenarioOptions.objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS;
uint8_t rcs = 0;
for (auto& ride : GetRideManager())
@@ -592,7 +592,7 @@ ResultWithMessage ScenarioPrepareForSave(GameState_t& gameState)
return { false, prepareRidesResult.Message };
}
if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING)
gameState.park.flags |= PARK_FLAGS_PARK_OPEN;
ScenarioReset(gameState);
@@ -718,7 +718,7 @@ ObjectiveStatus Objective::CheckGuestsAndRating() const
{
News::AddItemToQueue(News::ItemType::graph, STR_PARK_HAS_BEEN_CLOSED_DOWN, 0, {});
gameState.park.flags &= ~PARK_FLAGS_PARK_OPEN;
gameState.guestInitialHappiness = 50;
gameState.scenarioOptions.guestInitialHappiness = 50;
return ObjectiveStatus::Failure;
}
}
@@ -858,7 +858,7 @@ bool AllowEarlyCompletion()
static void ScenarioCheckObjective(GameState_t& gameState)
{
auto status = gameState.scenarioObjective.Check(gameState);
auto status = gameState.scenarioOptions.objective.Check(gameState);
if (status == ObjectiveStatus::Success)
{
ScenarioSuccess(gameState);
+35
View File
@@ -0,0 +1,35 @@
/*****************************************************************************
* Copyright (c) 2014-2025 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "../core/Money.hpp"
#include "Scenario.h"
#include <string>
namespace OpenRCT2::Scenario
{
struct Options
{
Objective objective;
ScenarioCategory category;
std::string name;
std::string details;
money64 initialCash;
money64 landPrice;
money64 constructionRightsPrice;
money64 guestInitialCash;
uint8_t guestInitialHappiness;
uint8_t guestInitialHunger;
uint8_t guestInitialThirst;
};
} // namespace OpenRCT2::Scenario
@@ -161,22 +161,22 @@ namespace OpenRCT2::Scripting
money64 ScPark::guestInitialCash_get() const
{
return getGameState().guestInitialCash;
return getGameState().scenarioOptions.guestInitialCash;
}
uint8_t ScPark::guestInitialHappiness_get() const
{
return getGameState().guestInitialHappiness;
return getGameState().scenarioOptions.guestInitialHappiness;
}
uint8_t ScPark::guestInitialHunger_get() const
{
return getGameState().guestInitialHunger;
return getGameState().scenarioOptions.guestInitialHunger;
}
uint8_t ScPark::guestInitialThirst_get() const
{
return getGameState().guestInitialThirst;
return getGameState().scenarioOptions.guestInitialThirst;
}
money64 ScPark::value_get() const
@@ -254,22 +254,22 @@ namespace OpenRCT2::Scripting
money64 ScPark::landPrice_get() const
{
return getGameState().landPrice;
return getGameState().scenarioOptions.landPrice;
}
void ScPark::landPrice_set(money64 value)
{
ThrowIfGameStateNotMutable();
getGameState().landPrice = value;
getGameState().scenarioOptions.landPrice = value;
}
money64 ScPark::constructionRightsPrice_get() const
{
return getGameState().constructionRightsPrice;
return getGameState().scenarioOptions.constructionRightsPrice;
}
void ScPark::constructionRightsPrice_set(money64 value)
{
ThrowIfGameStateNotMutable();
getGameState().constructionRightsPrice = value;
getGameState().scenarioOptions.constructionRightsPrice = value;
}
int16_t ScPark::casualtyPenalty_get() const
@@ -41,22 +41,22 @@ namespace OpenRCT2::Scripting
private:
std::string type_get()
{
return std::string(ScenarioObjectiveTypeMap[getGameState().scenarioObjective.Type]);
return std::string(ScenarioObjectiveTypeMap[getGameState().scenarioOptions.objective.Type]);
}
void type_set(const std::string& value)
{
ThrowIfGameStateNotMutable();
getGameState().scenarioObjective.Type = ScenarioObjectiveTypeMap[value];
getGameState().scenarioOptions.objective.Type = ScenarioObjectiveTypeMap[value];
}
uint16_t guests_get()
{
auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_BY
|| gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_BY
|| gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING)
{
return gameState.scenarioObjective.NumGuests;
return gameState.scenarioOptions.objective.NumGuests;
}
return 0;
}
@@ -65,20 +65,20 @@ namespace OpenRCT2::Scripting
{
ThrowIfGameStateNotMutable();
auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_BY
|| gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_BY
|| gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING)
{
gameState.scenarioObjective.NumGuests = value;
gameState.scenarioOptions.objective.NumGuests = value;
}
}
uint8_t year_get()
{
const auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_BY
|| gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_BY
|| gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY)
{
return gameState.scenarioObjective.Year;
return gameState.scenarioOptions.objective.Year;
}
return 0;
}
@@ -87,19 +87,19 @@ namespace OpenRCT2::Scripting
{
auto& gameState = getGameState();
ThrowIfGameStateNotMutable();
if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_BY
|| gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_BY
|| gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY)
{
gameState.scenarioObjective.Year = value;
gameState.scenarioOptions.objective.Year = value;
}
}
uint16_t length_get()
{
const auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
{
return gameState.scenarioObjective.NumGuests;
return gameState.scenarioOptions.objective.NumGuests;
}
return 0;
}
@@ -108,18 +108,18 @@ namespace OpenRCT2::Scripting
{
ThrowIfGameStateNotMutable();
auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH)
{
gameState.scenarioObjective.NumGuests = value;
gameState.scenarioOptions.objective.NumGuests = value;
}
}
money64 excitement_get()
{
const auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
{
return gameState.scenarioObjective.Currency;
return gameState.scenarioOptions.objective.Currency;
}
return 0;
}
@@ -128,19 +128,19 @@ namespace OpenRCT2::Scripting
{
ThrowIfGameStateNotMutable();
auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS)
{
gameState.scenarioObjective.Currency = value;
gameState.scenarioOptions.objective.Currency = value;
}
}
money64 parkValue_get()
{
const auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|| gameState.scenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY
|| gameState.scenarioOptions.objective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
{
return gameState.scenarioObjective.Currency;
return gameState.scenarioOptions.objective.Currency;
}
return 0;
}
@@ -149,20 +149,20 @@ namespace OpenRCT2::Scripting
{
ThrowIfGameStateNotMutable();
auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|| gameState.scenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY
|| gameState.scenarioOptions.objective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
{
gameState.scenarioObjective.Currency = value;
gameState.scenarioOptions.objective.Currency = value;
}
}
money64 monthlyIncome_get()
{
const auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_MONTHLY_RIDE_INCOME
|| gameState.scenarioObjective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_MONTHLY_RIDE_INCOME
|| gameState.scenarioOptions.objective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME)
{
return gameState.scenarioObjective.Currency;
return gameState.scenarioOptions.objective.Currency;
}
return 0;
}
@@ -171,10 +171,10 @@ namespace OpenRCT2::Scripting
{
ThrowIfGameStateNotMutable();
auto& gameState = getGameState();
if (gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY
|| gameState.scenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
if (gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY
|| gameState.scenarioOptions.objective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE)
{
gameState.scenarioObjective.Currency = value;
gameState.scenarioOptions.objective.Currency = value;
}
}
@@ -198,24 +198,24 @@ namespace OpenRCT2::Scripting
public:
std::string name_get()
{
return getGameState().scenarioName;
return getGameState().scenarioOptions.name;
}
void name_set(const std::string& value)
{
ThrowIfGameStateNotMutable();
getGameState().scenarioName = value;
getGameState().scenarioOptions.name = value;
}
std::string details_get()
{
return getGameState().scenarioDetails;
return getGameState().scenarioOptions.details;
}
void details_set(const std::string& value)
{
ThrowIfGameStateNotMutable();
getGameState().scenarioDetails = value;
getGameState().scenarioOptions.details = value;
}
std::string completedBy_get()
+11 -11
View File
@@ -309,22 +309,22 @@ namespace OpenRCT2::Park
ResearchCategory::Water, ResearchCategory::Shop, ResearchCategory::SceneryGroup);
gameState.researchFundingLevel = RESEARCH_FUNDING_NORMAL;
gameState.guestInitialCash = 50.00_GBP;
gameState.guestInitialHappiness = Park::CalculateGuestInitialHappiness(50);
gameState.guestInitialHunger = 200;
gameState.guestInitialThirst = 200;
gameState.scenarioObjective.Type = OBJECTIVE_GUESTS_BY;
gameState.scenarioObjective.Year = 4;
gameState.scenarioObjective.NumGuests = 1000;
gameState.landPrice = 90.00_GBP;
gameState.constructionRightsPrice = 40.00_GBP;
gameState.scenarioOptions.guestInitialCash = 50.00_GBP;
gameState.scenarioOptions.guestInitialHappiness = Park::CalculateGuestInitialHappiness(50);
gameState.scenarioOptions.guestInitialHunger = 200;
gameState.scenarioOptions.guestInitialThirst = 200;
gameState.scenarioOptions.objective.Type = OBJECTIVE_GUESTS_BY;
gameState.scenarioOptions.objective.Year = 4;
gameState.scenarioOptions.objective.NumGuests = 1000;
gameState.scenarioOptions.landPrice = 90.00_GBP;
gameState.scenarioOptions.constructionRightsPrice = 40.00_GBP;
gameState.park.flags = PARK_FLAGS_NO_MONEY | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
ResetHistories(gameState);
FinanceResetHistory();
AwardReset();
gameState.scenarioName.clear();
gameState.scenarioDetails = String::toStd(LanguageGetString(STR_NO_DETAILS_YET));
gameState.scenarioOptions.name.clear();
gameState.scenarioOptions.details = String::toStd(LanguageGetString(STR_NO_DETAILS_YET));
}
void Update(GameState_t& gameState, const Date& date)