mirror of https://github.com/OpenRCT2/OpenRCT2.git
Move gClimate to GameState_t
This commit is contained in:
parent
7ca5b1cd65
commit
0f283dc2a9
|
@ -428,7 +428,7 @@ private:
|
|||
WindowDropdownShowTextCustomWidth(
|
||||
{ windowPos.x + dropdownWidget.left, windowPos.y + dropdownWidget.top }, dropdownWidget.height() + 1, colours[1], 0,
|
||||
Dropdown::Flag::StayOpen, static_cast<uint8_t>(ClimateType::Count), dropdownWidget.width() - 3);
|
||||
Dropdown::SetChecked(static_cast<uint8_t>(gClimate), true);
|
||||
Dropdown::SetChecked(static_cast<uint8_t>(GetGameState().Climate), true);
|
||||
}
|
||||
|
||||
void FinancialMouseDown(WidgetIndex widgetIndex)
|
||||
|
@ -1110,7 +1110,7 @@ private:
|
|||
break;
|
||||
}
|
||||
case WIDX_CLIMATE_DROPDOWN:
|
||||
if (static_cast<uint8_t>(gClimate) != static_cast<uint8_t>(dropdownIndex))
|
||||
if (static_cast<uint8_t>(GetGameState().Climate) != static_cast<uint8_t>(dropdownIndex))
|
||||
{
|
||||
auto gameAction = ClimateSetAction(ClimateType{ static_cast<uint8_t>(dropdownIndex) });
|
||||
GameActions::Execute(&gameAction);
|
||||
|
@ -1255,7 +1255,7 @@ private:
|
|||
// Climate value
|
||||
screenCoords = windowPos + ScreenCoordsXY{ climateWidget.left + 1, climateWidget.top };
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(ClimateNames[static_cast<uint8_t>(gClimate)]);
|
||||
ft.Add<StringId>(ClimateNames[static_cast<uint8_t>(GetGameState().Climate)]);
|
||||
DrawTextBasic(dpi, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft);
|
||||
}
|
||||
|
||||
|
|
|
@ -313,6 +313,8 @@ namespace Editor
|
|||
staff->SetName({});
|
||||
}
|
||||
|
||||
auto& gameState = GetGameState();
|
||||
|
||||
ResetAllEntities();
|
||||
UpdateConsolidatedPatrolAreas();
|
||||
gNumGuestsInPark = 0;
|
||||
|
@ -346,7 +348,7 @@ namespace Editor
|
|||
gBankLoanInterestRate = std::clamp<uint8_t>(gBankLoanInterestRate, 5, MaxBankLoanInterestRate);
|
||||
}
|
||||
|
||||
ClimateReset(gClimate);
|
||||
ClimateReset(gameState.Climate);
|
||||
|
||||
News::InitQueue();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace OpenRCT2
|
|||
struct GameState_t
|
||||
{
|
||||
uint32_t CurrentTicks{};
|
||||
ClimateType Climate;
|
||||
ClimateState ClimateNext;
|
||||
money64 Cash;
|
||||
money64 InitialCash;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "ClimateSetAction.h"
|
||||
|
||||
#include "../GameState.h"
|
||||
|
||||
ClimateSetAction::ClimateSetAction(ClimateType climate)
|
||||
: _climate(climate)
|
||||
{
|
||||
|
@ -43,7 +45,7 @@ GameActions::Result ClimateSetAction::Query() const
|
|||
|
||||
GameActions::Result ClimateSetAction::Execute() const
|
||||
{
|
||||
gClimate = ClimateType{ _climate };
|
||||
OpenRCT2::GetGameState().Climate = ClimateType{ _climate };
|
||||
|
||||
GfxInvalidateScreen();
|
||||
|
||||
|
|
|
@ -551,6 +551,8 @@ static int32_t ConsoleCommandStaff(InteractiveConsole& console, const arguments_
|
|||
|
||||
static int32_t ConsoleCommandGet(InteractiveConsole& console, const arguments_t& argv)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
|
||||
if (!argv.empty())
|
||||
{
|
||||
if (argv[0] == "park_rating")
|
||||
|
@ -669,7 +671,8 @@ static int32_t ConsoleCommandGet(InteractiveConsole& console, const arguments_t&
|
|||
else if (argv[0] == "climate")
|
||||
{
|
||||
console.WriteFormatLine(
|
||||
"climate %s (%d)", ClimateNames[static_cast<uint8_t>(gClimate)], static_cast<uint8_t>(gClimate));
|
||||
"climate %s (%d)", ClimateNames[static_cast<uint8_t>(gameState.Climate)],
|
||||
static_cast<uint8_t>(gameState.Climate));
|
||||
}
|
||||
else if (argv[0] == "game_speed")
|
||||
{
|
||||
|
|
|
@ -781,7 +781,7 @@ namespace OpenRCT2
|
|||
void ReadWriteClimateChunk(GameState_t& gameState, OrcaStream& os)
|
||||
{
|
||||
os.ReadWriteChunk(ParkFileChunkType::CLIMATE, [&gameState](OrcaStream::ChunkStream& cs) {
|
||||
cs.ReadWrite(gClimate);
|
||||
cs.ReadWrite(gameState.Climate);
|
||||
cs.ReadWrite(gClimateUpdateTimer);
|
||||
|
||||
for (auto* cl : { &gClimateCurrent, &gameState.ClimateNext })
|
||||
|
|
|
@ -2278,7 +2278,7 @@ namespace RCT1
|
|||
|
||||
void ImportClimate(GameState_t& gameState)
|
||||
{
|
||||
gClimate = ClimateType{ _s4.Climate };
|
||||
gameState.Climate = ClimateType{ _s4.Climate };
|
||||
gClimateUpdateTimer = _s4.ClimateTimer;
|
||||
gClimateCurrent.Temperature = _s4.Temperature;
|
||||
gClimateCurrent.Weather = WeatherType{ _s4.Weather };
|
||||
|
|
|
@ -451,7 +451,7 @@ namespace RCT2
|
|||
// unk_13CA73E
|
||||
// Pad13CA73F
|
||||
// unk_13CA740
|
||||
gClimate = ClimateType{ _s6.Climate };
|
||||
gameState.Climate = ClimateType{ _s6.Climate };
|
||||
// Pad13CA741;
|
||||
// Byte13CA742
|
||||
// Pad013CA747
|
||||
|
|
|
@ -102,7 +102,8 @@ namespace OpenRCT2::Scripting
|
|||
|
||||
std::string type_get() const
|
||||
{
|
||||
return ClimateTypeToString(gClimate);
|
||||
auto& gameState = OpenRCT2::GetGameState();
|
||||
return ClimateTypeToString(gameState.Climate);
|
||||
}
|
||||
|
||||
std::shared_ptr<ScClimateState> current_get() const
|
||||
|
|
|
@ -54,7 +54,6 @@ extern const WeatherState ClimateWeatherData[EnumValue(WeatherType::Count)];
|
|||
extern const FilterPaletteID ClimateWeatherGloomColours[4];
|
||||
|
||||
// Climate data
|
||||
ClimateType gClimate;
|
||||
ClimateState gClimateCurrent;
|
||||
uint16_t gClimateUpdateTimer;
|
||||
uint16_t gClimateLightningFlash;
|
||||
|
@ -91,12 +90,13 @@ int32_t ClimateCelsiusToFahrenheit(int32_t celsius)
|
|||
*/
|
||||
void ClimateReset(ClimateType climate)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
auto weather = WeatherType::PartiallyCloudy;
|
||||
int32_t month = GetDate().GetMonth();
|
||||
const WeatherTransition* transition = &ClimateTransitions[static_cast<uint8_t>(climate)][month];
|
||||
const WeatherState* weatherState = &ClimateWeatherData[EnumValue(weather)];
|
||||
|
||||
gClimate = climate;
|
||||
gameState.Climate = climate;
|
||||
gClimateCurrent.Weather = weather;
|
||||
gClimateCurrent.Temperature = transition->BaseTemperature + weatherState->TemperatureDelta;
|
||||
gClimateCurrent.WeatherEffect = weatherState->EffectLevel;
|
||||
|
@ -201,8 +201,9 @@ void ClimateUpdate()
|
|||
|
||||
void ClimateForceWeather(WeatherType weather)
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
int32_t month = GetDate().GetMonth();
|
||||
const WeatherTransition* transition = &ClimateTransitions[static_cast<uint8_t>(gClimate)][month];
|
||||
const WeatherTransition* transition = &ClimateTransitions[static_cast<uint8_t>(gameState.Climate)][month];
|
||||
const auto weatherState = &ClimateWeatherData[EnumValue(weather)];
|
||||
|
||||
gClimateCurrent.Weather = weather;
|
||||
|
@ -304,7 +305,7 @@ static void ClimateDetermineFutureWeather(int32_t randomDistribution)
|
|||
|
||||
// Generate a random variable with values 0 up to DistributionSize-1 and chose weather from the distribution table
|
||||
// accordingly
|
||||
const WeatherTransition* transition = &ClimateTransitions[static_cast<uint8_t>(gClimate)][month];
|
||||
const WeatherTransition* transition = &ClimateTransitions[static_cast<uint8_t>(gameState.Climate)][month];
|
||||
WeatherType nextWeather = (transition->Distribution[((randomDistribution & 0xFF) * transition->DistributionSize) >> 8]);
|
||||
gameState.ClimateNext.Weather = nextWeather;
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ struct ClimateState
|
|||
WeatherLevel Level;
|
||||
};
|
||||
|
||||
extern ClimateType gClimate;
|
||||
extern ClimateState gClimateCurrent;
|
||||
extern uint16_t gClimateUpdateTimer;
|
||||
extern uint16_t gClimateLightningFlash;
|
||||
|
|
Loading…
Reference in New Issue