Changeset - r11106:7af0cd6ebe11
[Not reviewed]
master
0 6 0
frosch - 16 years ago 2009-02-11 18:50:47
frosch@openttd.org
(svn r15452) -Codechange: Add DC_NO_MODIFY_TOWN_RATING.
6 files changed with 18 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/command_type.h
Show inline comments
 
@@ -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);
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -157,7 +157,7 @@ bool CheckAllowRemoveRoad(TileIndex tile
 
		}
 
		rating_decrease = RATING_ROAD_DOWN_STEP_INNER;
 
	}
 
	ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM);
 
	ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM, flags);
 

	
 
	return true;
 
}
src/town.h
Show inline comments
 
@@ -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);
src/town_cmd.cpp
Show inline comments
 
@@ -537,7 +537,7 @@ static CommandCost ClearTile_Town(TileIn
 
		}
 
	}
 

	
 
	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;
src/tree_cmd.cpp
Show inline comments
 
@@ -389,7 +389,7 @@ CommandCost CmdPlantTree(TileIndex tile,
 

	
 
					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(TileI
 

	
 
	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);
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -617,7 +617,7 @@ static CommandCost DoClearTunnel(TileInd
 
	/* 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(TileInd
 
	/* 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) {
0 comments (0 inline, 0 general)