From a993ad84087652e81bb060df6cc3c121ce0994ca Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Mon, 8 Jun 2020 23:34:35 -0300 Subject: [PATCH] Rename Peep::energy to Energy --- src/openrct2-ui/windows/Guest.cpp | 2 +- src/openrct2/GameStateSnapshots.cpp | 2 +- src/openrct2/actions/SetCheatAction.hpp | 4 +- src/openrct2/actions/StaffHireNewAction.hpp | 2 +- src/openrct2/interface/InteractiveConsole.cpp | 4 +- src/openrct2/peep/Guest.cpp | 38 +++++++++---------- src/openrct2/peep/Peep.cpp | 8 ++-- src/openrct2/peep/Peep.h | 2 +- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/rct2/S6Importer.cpp | 2 +- src/openrct2/scripting/ScEntity.hpp | 4 +- test/tests/S6ImportExportTests.cpp | 2 +- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index f518519828..ea1554b7d9 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1418,7 +1418,7 @@ void window_guest_stats_paint(rct_window* w, rct_drawpixelinfo* dpi) y += LIST_ROW_HEIGHT; gfx_draw_string_left(dpi, STR_GUEST_STAT_ENERGY_LABEL, gCommonFormatArgs, COLOUR_BLACK, x, y); - int32_t energy = ((peep->energy - PEEP_MIN_ENERGY) * 255) / (PEEP_MAX_ENERGY - PEEP_MIN_ENERGY); + int32_t energy = ((peep->Energy - PEEP_MIN_ENERGY) * 255) / (PEEP_MAX_ENERGY - PEEP_MIN_ENERGY); ebp = COLOUR_BRIGHT_GREEN; if (energy < 50) { diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 7ebe8253a8..ca68e145ac 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -227,7 +227,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Peep, destination_y); COMPARE_FIELD(Peep, destination_tolerance); COMPARE_FIELD(Peep, var_37); - COMPARE_FIELD(Peep, energy); + COMPARE_FIELD(Peep, Energy); COMPARE_FIELD(Peep, EnergyTarget); COMPARE_FIELD(Peep, Happiness); COMPARE_FIELD(Peep, HappinessTarget); diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index ee643b86b6..9ac2260a9b 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -594,7 +594,7 @@ private: } break; case GUEST_PARAMETER_ENERGY: - peep->energy = value; + peep->Energy = value; peep->EnergyTarget = value; break; case GUEST_PARAMETER_HUNGER: @@ -734,7 +734,7 @@ private: FOR_ALL_STAFF (spriteIndex, peep) { - peep->energy = value; + peep->Energy = value; peep->EnergyTarget = value; } } diff --git a/src/openrct2/actions/StaffHireNewAction.hpp b/src/openrct2/actions/StaffHireNewAction.hpp index 8698c2e1bc..6315a5eb62 100644 --- a/src/openrct2/actions/StaffHireNewAction.hpp +++ b/src/openrct2/actions/StaffHireNewAction.hpp @@ -242,7 +242,7 @@ private: newPeep->trousers_colour = colour; // Staff energy determines their walking speed - newPeep->energy = 0x60; + newPeep->Energy = 0x60; newPeep->EnergyTarget = 0x60; newPeep->StaffMowingTimeout = 0; diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 1bd164561e..9a62689da3 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -443,7 +443,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv) { auto name = peep->GetName(); console.WriteFormatLine( - "staff id %03d type: %02u energy %03u name %s", i, peep->staff_type, peep->energy, name.c_str()); + "staff id %03d type: %02u energy %03u name %s", i, peep->staff_type, peep->Energy, name.c_str()); } } else if (argv[0] == "set") @@ -474,7 +474,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv) { Peep* peep = GET_PEEP(int_val[0]); - peep->energy = int_val[1]; + peep->Energy = int_val[1]; peep->EnergyTarget = int_val[1]; } } diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 69b188dc5c..62ecbef7a0 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -578,7 +578,7 @@ void Guest::HandleEasterEggName() { Happiness = 250; HappinessTarget = 250; - energy = 127; + Energy = 127; EnergyTarget = 127; Nausea = 0; NauseaTarget = 0; @@ -846,7 +846,7 @@ void Guest::Tick128UpdateGuest(int32_t index) } else { - if (energy <= 70 && Happiness < 128) + if (Energy <= 70 && Happiness < 128) { possible_thoughts[num_thoughts++] = PEEP_THOUGHT_TYPE_TIRED; } @@ -866,7 +866,7 @@ void Guest::Tick128UpdateGuest(int32_t index) possible_thoughts[num_thoughts++] = PEEP_THOUGHT_TYPE_TOILET; } - if (!(gParkFlags & PARK_FLAGS_NO_MONEY) && CashInPocket <= MONEY(9, 00) && Happiness >= 105 && energy >= 70) + if (!(gParkFlags & PARK_FLAGS_NO_MONEY) && CashInPocket <= MONEY(9, 00) && Happiness >= 105 && Energy >= 70) { /* The energy check was originally a second check on happiness. * This was superfluous so should probably check something else. @@ -1021,9 +1021,9 @@ void Guest::Tick128UpdateGuest(int32_t index) NauseaTarget = std::max(NauseaTarget - 2, 0); - if (energy <= 50) + if (Energy <= 50) { - energy = std::max(energy - 2, 0); + Energy = std::max(Energy - 2, 0); } if (Hunger < 10) @@ -1117,7 +1117,7 @@ void Guest::Tick128UpdateGuest(int32_t index) } } - uint8_t newEnergy = energy; + uint8_t newEnergy = Energy; uint8_t newTargetEnergy = EnergyTarget; if (newEnergy >= newTargetEnergy) { @@ -1138,9 +1138,9 @@ void Guest::Tick128UpdateGuest(int32_t index) /* Previous code here suggested maximum energy is 128. */ newEnergy = std::min(static_cast(PEEP_MAX_ENERGY), newEnergy); - if (newEnergy != energy) + if (newEnergy != Energy) { - energy = newEnergy; + Energy = newEnergy; WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_2; } @@ -1239,7 +1239,7 @@ void Guest::UpdateSitting() sub_state = PEEP_SITTING_SAT_DOWN; // Sets time to sit on seat - TimeToSitdown = (129 - energy) * 16 + 50; + TimeToSitdown = (129 - Energy) * 16 + 50; } else if (sub_state == PEEP_SITTING_SAT_DOWN) { @@ -2874,7 +2874,7 @@ static bool peep_should_go_on_ride_again(Peep* peep, Ride* ride) return false; if (peep->Happiness < 180) return false; - if (peep->energy < 100) + if (peep->Energy < 100) return false; if (peep->Nausea > 160) return false; @@ -3086,14 +3086,14 @@ static void peep_decide_whether_to_leave_park(Peep* peep) { if (gParkFlags & PARK_FLAGS_NO_MONEY) { - if (peep->energy >= 70 && peep->Happiness >= 60) + if (peep->Energy >= 70 && peep->Happiness >= 60) { return; } } else { - if (peep->energy >= 55 && peep->Happiness >= 45 && peep->CashInPocket >= MONEY(5, 00)) + if (peep->Energy >= 55 && peep->Happiness >= 45 && peep->CashInPocket >= MONEY(5, 00)) { return; } @@ -3330,7 +3330,7 @@ static bool peep_should_use_cash_machine(Peep* peep, ride_id_t rideIndex) return false; if (115 + (scenario_rand() % 128) > peep->Happiness) return false; - if (peep->energy < 80) + if (peep->Energy < 80) return false; auto ride = get_ride(rideIndex); @@ -4837,7 +4837,7 @@ void Guest::UpdateRideMazePathfinding() if (Action >= PEEP_ACTION_NONE_1) { - if (energy > 64 && (scenario_rand() & 0xFFFF) <= 2427) + if (Energy > 64 && (scenario_rand() & 0xFFFF) <= 2427) { Action = PEEP_ACTION_JUMP; ActionFrame = 0; @@ -5749,7 +5749,7 @@ void Guest::UpdateWatching() sub_state++; - TimeToStand = std::clamp(((129 - energy) * 16 + 50) / 2, 0, 255); + TimeToStand = std::clamp(((129 - Energy) * 16 + 50) / 2, 0, 255); UpdateSpriteType(); } else if (sub_state == 1) @@ -6003,7 +6003,7 @@ bool Guest::ShouldFindBench() } } - if (Nausea <= 170 && energy > 50) + if (Nausea <= 170 && Energy > 50) { return false; } @@ -6206,7 +6206,7 @@ static void peep_update_walking_break_scenery(Peep* peep) { if (peep->Happiness >= 48) return; - if (peep->energy < 85) + if (peep->Energy < 85) return; if (peep->state != PEEP_STATE_WALKING) return; @@ -6920,13 +6920,13 @@ void Guest::UpdateSpriteType() return; } - if (energy <= 64 && Happiness < 128) + if (Energy <= 64 && Happiness < 128) { SetSpriteType(PEEP_SPRITE_TYPE_HEAD_DOWN); return; } - if (energy <= 80 && Happiness < 128) + if (Energy <= 80 && Happiness < 128) { SetSpriteType(PEEP_SPRITE_TYPE_ARMS_CROSSED); return; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index f84dea561c..e9acc8348e 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -1110,7 +1110,7 @@ void Peep::Update() } // Walking speed logic - uint32_t stepsToTake = energy; + uint32_t stepsToTake = Energy; if (stepsToTake < 95 && state == PEEP_STATE_QUEUING) stepsToTake = 95; if ((PeepFlags & PEEP_FLAGS_SLOW_WALK) && state != PEEP_STATE_QUEUING) @@ -1775,7 +1775,7 @@ Peep* Peep::Generate(const CoordsXYZ& coords) /* Minimum energy is capped at 32 and maximum at 128, so this initialises * a peep with approx 34%-100% energy. (65 - 32) / (128 - 32) ≈ 34% */ uint8_t energy = (scenario_rand() % 64) + 65; - peep->energy = energy; + peep->Energy = energy; peep->EnergyTarget = energy; increment_guests_heading_for_park(); @@ -2178,11 +2178,11 @@ static int32_t get_face_sprite_offset(Peep* peep) return PEEP_FACE_OFFSET_SICK; // VERY_TIRED - if (peep->energy < 46) + if (peep->Energy < 46) return PEEP_FACE_OFFSET_VERY_TIRED; // TIRED - if (peep->energy < 70) + if (peep->Energy < 70) return PEEP_FACE_OFFSET_TIRED; int32_t offset = PEEP_FACE_OFFSET_VERY_VERY_UNHAPPY; diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 543b421d54..32ab3d5879 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -615,7 +615,7 @@ struct Peep : SpriteBase uint16_t destination_y; uint8_t destination_tolerance; // How close to destination before next action/state 0 = exact uint8_t var_37; - uint8_t energy; + uint8_t Energy; uint8_t EnergyTarget; uint8_t Happiness; uint8_t HappinessTarget; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 244c219801..3e12cb24b7 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1448,7 +1448,7 @@ private: dst->destination_tolerance = src->destination_tolerance; dst->PeepDirection = src->direction; - dst->energy = src->energy; + dst->Energy = src->energy; dst->EnergyTarget = src->energy_target; dst->Happiness = src->happiness; dst->HappinessTarget = src->happiness_target; diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 9928e606c8..dde84c1ce8 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1149,7 +1149,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) dst->destination_y = src->destination_y; dst->destination_tolerance = src->destination_tolerance; dst->var_37 = src->var_37; - dst->energy = src->energy; + dst->energy = src->Energy; dst->energy_target = src->EnergyTarget; dst->happiness = src->Happiness; dst->happiness_target = src->HappinessTarget; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index d9f6fd1c6a..64929e1e0e 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1414,7 +1414,7 @@ public: dst->destination_y = src->destination_y; dst->destination_tolerance = src->destination_tolerance; dst->var_37 = src->var_37; - dst->energy = src->energy; + dst->Energy = src->energy; dst->EnergyTarget = src->energy_target; dst->Happiness = src->happiness; dst->HappinessTarget = src->happiness_target; diff --git a/src/openrct2/scripting/ScEntity.hpp b/src/openrct2/scripting/ScEntity.hpp index ca3bbe57cf..82fec97adb 100644 --- a/src/openrct2/scripting/ScEntity.hpp +++ b/src/openrct2/scripting/ScEntity.hpp @@ -303,7 +303,7 @@ namespace OpenRCT2::Scripting uint8_t energy_get() const { auto peep = GetPeep(); - return peep != nullptr ? peep->energy : 0; + return peep != nullptr ? peep->Energy : 0; } void energy_set(uint8_t value) { @@ -311,7 +311,7 @@ namespace OpenRCT2::Scripting auto peep = GetPeep(); if (peep != nullptr) { - peep->energy = value; + peep->Energy = value; } } diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index 3e9dcbe5a3..232714561e 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -171,7 +171,7 @@ static void CompareSpriteDataPeep(const Peep& left, const Peep& right) COMPARE_FIELD(destination_y); COMPARE_FIELD(destination_tolerance); COMPARE_FIELD(var_37); - COMPARE_FIELD(energy); + COMPARE_FIELD(Energy); COMPARE_FIELD(EnergyTarget); COMPARE_FIELD(Happiness); COMPARE_FIELD(HappinessTarget);