Remove Cheats/ExtraCheats distinction
It is not necessary as there is no longer a need to preserve the size/order of struct Cheats
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
/** All the cheats. */
|
||||
Cheats _cheats;
|
||||
ExtraCheats _extra_cheats;
|
||||
|
||||
std::map<std::string, Cheat> _unknown_cheats;
|
||||
|
||||
@@ -25,7 +24,6 @@ std::map<std::string, Cheat> _unknown_cheats;
|
||||
void InitializeCheats()
|
||||
{
|
||||
memset(&_cheats, 0, sizeof(Cheats));
|
||||
memset(&_extra_cheats, 0, sizeof(ExtraCheats));
|
||||
_unknown_cheats.clear();
|
||||
}
|
||||
|
||||
@@ -43,12 +41,5 @@ bool CheatHasBeenUsed()
|
||||
if (cht->been_used) return true;
|
||||
}
|
||||
|
||||
cht = (Cheat*)&_extra_cheats;
|
||||
cht_last = &cht[sizeof(_extra_cheats) / sizeof(Cheat)];
|
||||
|
||||
for (; cht != cht_last; cht++) {
|
||||
if (cht->been_used) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include "cheat_type.h"
|
||||
|
||||
extern Cheats _cheats;
|
||||
extern ExtraCheats _extra_cheats;
|
||||
|
||||
void ShowCheatWindow();
|
||||
|
||||
|
@@ -196,10 +196,10 @@ static const CheatEntry _cheats_ui[] = {
|
||||
{CNM_LOCAL_ONLY, SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
|
||||
{CNM_LOCAL_ONLY, SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.map_height_limit, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
|
||||
{CNM_LOCAL_ONLY, SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_date_ymd.year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
|
||||
{CNM_ALL, SLF_ALLOW_CONTROL, STR_CHEAT_INFLATION_COST, &_economy.inflation_prices, &_extra_cheats.inflation_cost.been_used, nullptr },
|
||||
{CNM_ALL, SLF_ALLOW_CONTROL, STR_CHEAT_INFLATION_INCOME, &_economy.inflation_payment, &_extra_cheats.inflation_income.been_used, nullptr },
|
||||
{CNM_ALL, SLF_ALLOW_CONTROL, STR_CHEAT_INFLATION_COST, &_economy.inflation_prices, &_cheats.inflation_cost.been_used, nullptr },
|
||||
{CNM_ALL, SLF_ALLOW_CONTROL, STR_CHEAT_INFLATION_INCOME, &_economy.inflation_payment, &_cheats.inflation_income.been_used, nullptr },
|
||||
{CNM_ALL, SLE_BOOL, STR_CHEAT_STATION_RATING, &_cheats.station_rating.value, &_cheats.station_rating.been_used, nullptr },
|
||||
{CNM_ALL, SLE_BOOL, STR_CHEAT_TOWN_RATING, &_extra_cheats.town_rating.value, &_extra_cheats.town_rating.been_used, nullptr },
|
||||
{CNM_ALL, SLE_BOOL, STR_CHEAT_TOWN_RATING, &_cheats.town_rating.value, &_cheats.town_rating.been_used, nullptr },
|
||||
};
|
||||
|
||||
static bool IsCheatAllowed(CheatNetworkMode mode)
|
||||
|
@@ -18,11 +18,6 @@ struct Cheat {
|
||||
bool value; ///< tells if the bool cheat is active or not
|
||||
};
|
||||
|
||||
/**
|
||||
* WARNING! Do _not_ remove entries in Cheats struct or change the order
|
||||
* of the existing ones! Would break downward compatibility.
|
||||
* Only add new entries at the end of the struct!
|
||||
*/
|
||||
struct Cheats {
|
||||
Cheat magic_bulldozer; ///< dynamite industries, objects
|
||||
Cheat switch_company; ///< change to another company
|
||||
@@ -33,9 +28,7 @@ struct Cheats {
|
||||
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%
|
||||
};
|
||||
|
||||
struct ExtraCheats {
|
||||
/* non-trunk cheats follow */
|
||||
Cheat inflation_cost; ///< inflation cost factor
|
||||
Cheat inflation_income; ///< inflation income factor
|
||||
Cheat town_rating; ///< 100% town local authority rating
|
||||
@@ -60,6 +53,5 @@ enum CheatNumbers {
|
||||
};
|
||||
|
||||
extern Cheats _cheats;
|
||||
extern ExtraCheats _extra_cheats;
|
||||
|
||||
#endif /* CHEAT_TYPE_H */
|
||||
|
@@ -267,11 +267,11 @@ CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||
|
||||
case CHT_INFLATION_INCOME:
|
||||
if (flags & DC_EXEC) {
|
||||
_extra_cheats.inflation_income.been_used = true;
|
||||
_cheats.inflation_income.been_used = true;
|
||||
_economy.inflation_payment = Clamp<uint64>(p2, 1 << 16, MAX_INFLATION);
|
||||
if (_economy.inflation_payment > _economy.inflation_prices) {
|
||||
_economy.inflation_prices = _economy.inflation_payment;
|
||||
_extra_cheats.inflation_cost.been_used = true;
|
||||
_cheats.inflation_cost.been_used = true;
|
||||
}
|
||||
RecomputePrices();
|
||||
SetWindowDirty(WC_CHEATS, 0);
|
||||
@@ -280,11 +280,11 @@ CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||
|
||||
case CHT_INFLATION_COST:
|
||||
if (flags & DC_EXEC) {
|
||||
_extra_cheats.inflation_cost.been_used = true;
|
||||
_cheats.inflation_cost.been_used = true;
|
||||
_economy.inflation_prices = Clamp<uint64>(p2, 1 << 16, MAX_INFLATION);
|
||||
if (_economy.inflation_payment > _economy.inflation_prices) {
|
||||
_economy.inflation_payment = _economy.inflation_prices;
|
||||
_extra_cheats.inflation_income.been_used = true;
|
||||
_cheats.inflation_income.been_used = true;
|
||||
}
|
||||
RecomputePrices();
|
||||
SetWindowDirty(WC_CHEATS, 0);
|
||||
@@ -296,7 +296,7 @@ CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||
break;
|
||||
|
||||
case CHT_TOWN_RATING:
|
||||
cht = &_extra_cheats.town_rating;
|
||||
cht = &_cheats.town_rating;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -26,10 +26,10 @@ struct ExtraCheatNameDesc {
|
||||
};
|
||||
|
||||
static ExtraCheatNameDesc _extra_cheat_descs[] = {
|
||||
{ "inflation_cost", &_extra_cheats.inflation_cost },
|
||||
{ "inflation_income", &_extra_cheats.inflation_income },
|
||||
{ "inflation_cost", &_cheats.inflation_cost },
|
||||
{ "inflation_income", &_cheats.inflation_income },
|
||||
{ "station_rating", &_cheats.station_rating },
|
||||
{ "town_rating", &_extra_cheats.town_rating },
|
||||
{ "town_rating", &_cheats.town_rating },
|
||||
};
|
||||
|
||||
static const SaveLoad _cheats_desc[] = {
|
||||
|
@@ -799,7 +799,7 @@ static CommandCost BuildStationPart(Station **st, DoCommandFlag flags, bool reus
|
||||
ZoningTownAuthorityRatingChange();
|
||||
}
|
||||
SetBit((*st)->town->have_ratings, _current_company);
|
||||
if (_extra_cheats.town_rating.value) {
|
||||
if (_cheats.town_rating.value) {
|
||||
(*st)->town->ratings[_current_company] = RATING_MAXIMUM;
|
||||
}
|
||||
}
|
||||
|
@@ -823,7 +823,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
||||
if (rating > t->ratings[_current_company]
|
||||
&& !(flags & DC_NO_TEST_TOWN_RATING)
|
||||
&& !_cheats.magic_bulldozer.value
|
||||
&& !_extra_cheats.town_rating.value
|
||||
&& !_cheats.town_rating.value
|
||||
&& _settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) {
|
||||
SetDParam(0, t->index);
|
||||
return_cmd_error(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS);
|
||||
@@ -3386,7 +3386,7 @@ CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
if (!Company::IsValidID(company_id)) return CMD_ERROR;
|
||||
|
||||
int16 new_rating = Clamp((int16)GB(p2, 0, 16), RATING_MINIMUM, RATING_MAXIMUM);
|
||||
if (_extra_cheats.town_rating.value) {
|
||||
if (_cheats.town_rating.value) {
|
||||
new_rating = RATING_MAXIMUM;
|
||||
}
|
||||
if (flags & DC_EXEC) {
|
||||
@@ -3960,7 +3960,7 @@ static void ForAllStationsNearTown(Town *t, Func func)
|
||||
|
||||
static void UpdateTownRating(Town *t)
|
||||
{
|
||||
if (_extra_cheats.town_rating.value) return;
|
||||
if (_cheats.town_rating.value) return;
|
||||
|
||||
/* Increase company ratings if they're low */
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
@@ -4294,13 +4294,13 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
|
||||
/* if magic_bulldozer cheat is active, town doesn't penalize for removing stuff */
|
||||
if (t == nullptr || (flags & DC_NO_MODIFY_TOWN_RATING) ||
|
||||
!Company::IsValidID(_current_company) ||
|
||||
((_cheats.magic_bulldozer.value || _extra_cheats.town_rating.value) && add < 0)) {
|
||||
((_cheats.magic_bulldozer.value || _cheats.town_rating.value) && add < 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int prev_rating = GetRating(t);
|
||||
int rating = prev_rating;
|
||||
if (_extra_cheats.town_rating.value) {
|
||||
if (_cheats.town_rating.value) {
|
||||
rating = RATING_MAXIMUM;
|
||||
} else if (add < 0) {
|
||||
if (rating > max) {
|
||||
@@ -4329,7 +4329,7 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
|
||||
|
||||
void UpdateAllTownRatings()
|
||||
{
|
||||
if (_extra_cheats.town_rating.value) {
|
||||
if (_cheats.town_rating.value) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (Company::IsValidID(_local_company) && HasBit(t->have_ratings, _local_company) && t->ratings[_local_company] <= 0) {
|
||||
ZoningTownAuthorityRatingChange();
|
||||
@@ -4356,7 +4356,7 @@ CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType
|
||||
{
|
||||
/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
|
||||
if (t == nullptr || !Company::IsValidID(_current_company) ||
|
||||
_cheats.magic_bulldozer.value || _extra_cheats.town_rating.value || (flags & DC_NO_TEST_TOWN_RATING)) {
|
||||
_cheats.magic_bulldozer.value || _cheats.town_rating.value || (flags & DC_NO_TEST_TOWN_RATING)) {
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user