Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Cheat to fix station ratings at 100% #11346

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cheat_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ enum CheatNumbers {
CHT_CROSSINGTUNNELS, ///< Allow tunnels to cross each other.
CHT_NO_JETCRASH, ///< Disable jet-airplane crashes.
CHT_SETUP_PROD, ///< Allow manually editing of industry production.
CHT_STATION_RATING, ///< Fix station ratings at 100%.
CHT_EDIT_MAX_HL, ///< Edit maximum allowed heightlevel
CHT_CHANGE_DATE, ///< Do time traveling.

Expand Down Expand Up @@ -196,6 +197,7 @@ static const CheatEntry _cheats_ui[] = {
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
{SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
{SLE_BOOL, STR_CHEAT_STATION_RATING, &_cheats.station_rating.value, &_cheats.station_rating.been_used, nullptr },
{SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.map_height_limit, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &TimerGameCalendar::year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
};
Expand Down
1 change: 1 addition & 0 deletions src/cheat_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct Cheats {
Cheat change_date; ///< changes date ingame
Cheat setup_prod; ///< setup raw-material production in game
Cheat edit_max_hl; ///< edit the maximum heightlevel; this is a cheat because of the fact that it needs to reset NewGRF game state and doing so as a simple configuration breaks the expectation of many
Cheat station_rating; ///< Fix station ratings at 100%
};

extern Cheats _cheats;
Expand Down
1 change: 1 addition & 0 deletions src/lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,7 @@ STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT :{WHITE}Edit the
STR_CHEAT_CHANGE_DATE :{LTBLUE}Change date: {ORANGE}{DATE_SHORT}
STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Change current year
STR_CHEAT_SETUP_PROD :{LTBLUE}Enable modifying production values: {ORANGE}{STRING1}
STR_CHEAT_STATION_RATING :{LTBLUE}Fix station ratings at 100%: {ORANGE}{STRING1}

# Livery window
STR_LIVERY_CAPTION :{WHITE}{COMPANY} - Colour Scheme
Expand Down
2 changes: 2 additions & 0 deletions src/saveload/cheat_sl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ static const SaveLoad _cheats_desc[] = {
SLE_VAR(Cheats, setup_prod.value, SLE_BOOL),
SLE_VAR(Cheats, edit_max_hl.been_used, SLE_BOOL),
SLE_VAR(Cheats, edit_max_hl.value, SLE_BOOL),
SLE_CONDVAR(Cheats, station_rating.been_used, SLE_BOOL, SLV_STATION_RATING_CHEAT, SL_MAX_VERSION),
SLE_CONDVAR(Cheats, station_rating.value, SLE_BOOL, SLV_STATION_RATING_CHEAT, SL_MAX_VERSION),
};


Expand Down
2 changes: 2 additions & 0 deletions src/saveload/saveload.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ enum SaveLoadVersion : uint16_t {
SLV_REMOVE_LOADED_AT_XY, ///< 318 PR#11276 Remove loaded_at_xy variable from CargoPacket.
SLV_CARGO_TRAVELLED, ///< 319 PR#11283 CargoPacket now tracks how far it travelled inside a vehicle.

SLV_STATION_RATING_CHEAT, ///< 320 PR#11346 Add cheat to fix station ratings at 100%.

SL_MAX_VERSION, ///< Highest possible saveload version
};

Expand Down
3 changes: 2 additions & 1 deletion src/station_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#include "newgrf_storage.h"
#include "bitmap_type.h"

static const byte INITIAL_STATION_RATING = 175;
static const uint8_t INITIAL_STATION_RATING = 175;
static const uint8_t MAX_STATION_RATING = 255;

/**
* Flow statistics telling how much flow should be sent along a link. This is
Expand Down
6 changes: 5 additions & 1 deletion src/station_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "timer/timer.h"
#include "timer/timer_game_calendar.h"
#include "timer/timer_game_tick.h"
#include "cheat_type.h"

#include "table/strings.h"

Expand Down Expand Up @@ -3678,7 +3679,10 @@ static void UpdateStationRating(Station *st)
*/
uint waiting_avg = waiting / (num_dests + 1);

if (HasBit(cs->callback_mask, CBM_CARGO_STATION_RATING_CALC)) {
if (_cheats.station_rating.value) {
ge->rating = rating = MAX_STATION_RATING;
skip = true;
} else if (HasBit(cs->callback_mask, CBM_CARGO_STATION_RATING_CALC)) {
/* Perform custom station rating. If it succeeds the speed, days in transit and
* waiting cargo ratings must not be executed. */

Expand Down