mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r15452) -Codechange: Add DC_NO_MODIFY_TOWN_RATING.
This commit is contained in:
parent
92584d0149
commit
032346cf8a
|
@ -304,6 +304,7 @@ enum DoCommandFlag {
|
|||
DC_BANKRUPT = 0x040, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases
|
||||
DC_AUTOREPLACE = 0x080, ///< autoreplace/autorenew is in progress, this shall disable vehicle limits when building, and ignore certain restrictions when undoing things (like vehicle attach callback)
|
||||
DC_ALL_TILES = 0x100, ///< allow this command also on MP_VOID tiles
|
||||
DC_NO_MODIFY_TOWN_RATING = 0x200, ///< do not change town rating
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(DoCommandFlag);
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType
|
|||
}
|
||||
rating_decrease = RATING_ROAD_DOWN_STEP_INNER;
|
||||
}
|
||||
ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM);
|
||||
ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM, flags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -355,7 +355,7 @@ void UpdateTownMaxPass(Town *t);
|
|||
void UpdateTownRadius(Town *t);
|
||||
bool CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags);
|
||||
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
|
||||
void ChangeTownRating(Town *t, int add, int max);
|
||||
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags);
|
||||
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile);
|
||||
void SetTownRatingTestMode(bool mode);
|
||||
uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t);
|
||||
|
|
|
@ -537,7 +537,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
|||
}
|
||||
}
|
||||
|
||||
ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM);
|
||||
ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM, flags);
|
||||
if (flags & DC_EXEC) {
|
||||
ClearTownHouse(t, tile);
|
||||
}
|
||||
|
@ -2278,7 +2278,7 @@ static void TownActionBribe(Town *t)
|
|||
InvalidateWindow(WC_TOWN_AUTHORITY, t->index);
|
||||
}
|
||||
} else {
|
||||
ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM);
|
||||
ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DC_EXEC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2591,10 +2591,17 @@ static int GetRating(const Town *t)
|
|||
return t->ratings[_current_company];
|
||||
}
|
||||
|
||||
void ChangeTownRating(Town *t, int add, int max)
|
||||
/**
|
||||
* Changes town rating of the current company
|
||||
* @param t Town to affect
|
||||
* @param add Value to add
|
||||
* @param max Minimum (add < 0) resp. maximum (add > 0) rating that should be archievable with this change
|
||||
* @param flags Command flags, especially DC_NO_MODIFY_TOWN_RATING is tested
|
||||
*/
|
||||
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
|
||||
{
|
||||
/* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */
|
||||
if (t == NULL ||
|
||||
if (t == NULL || (flags & DC_NO_MODIFY_TOWN_RATING) ||
|
||||
!IsValidCompanyID(_current_company) ||
|
||||
(_cheats.magic_bulldozer.value && add < 0)) {
|
||||
return;
|
||||
|
|
|
@ -389,7 +389,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
|
||||
if (_game_mode != GM_EDITOR && IsValidCompanyID(_current_company)) {
|
||||
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
||||
if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
|
||||
if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM, flags);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
|
@ -532,7 +532,7 @@ static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlag flags)
|
|||
|
||||
if (IsValidCompanyID(_current_company)) {
|
||||
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
||||
if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
|
||||
if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM, flags);
|
||||
}
|
||||
|
||||
num = GetTreeCount(tile);
|
||||
|
|
|
@ -617,7 +617,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
|||
/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
|
||||
* you have a "Poor" (0) town rating */
|
||||
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
|
||||
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
|
||||
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
|
@ -683,7 +683,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
|
|||
/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
|
||||
* you have a "Poor" (0) town rating */
|
||||
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
|
||||
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
|
||||
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
|
|
Loading…
Reference in New Issue