diff options
author | glx <glx@openttd.org> | 2008-01-03 23:50:58 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2008-01-03 23:50:58 +0000 |
commit | 42bddcf723fdcabf6ea8d4069effc086710ef156 (patch) | |
tree | 026efa2300b2925d9151a9d24da6c7fc6329a271 /src/town_cmd.cpp | |
parent | aebcd80088bfe4ecba84f37f55fbef1e4ffdb187 (diff) | |
download | openttd-42bddcf723fdcabf6ea8d4069effc086710ef156.tar.xz |
(svn r11749) -Fix (r11352): when a bankrupted company is bought, reset vehicle color mapping so the vehicles use the new owner color
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r-- | src/town_cmd.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 9abf01875..2f4b3de9d 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -522,8 +522,8 @@ static CommandCost ClearTile_Town(TileIndex tile, byte flags) } } + ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM); if (flags & DC_EXEC) { - ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM); ClearTownHouse(t, tile); } @@ -2261,6 +2261,23 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold) } } +static bool _town_rating_test = false; + +void SetTownRatingTestMode(bool mode) +{ + static int ref_count = 0; + if (mode) { + if (ref_count == 0) { + Town *t; + FOR_ALL_TOWNS(t) t->test_rating = t->ratings[_current_player]; + } + ref_count++; + } else { + assert(ref_count > 0); + ref_count--; + } + _town_rating_test = !(ref_count == 0); +} void ChangeTownRating(Town *t, int add, int max) { @@ -2275,7 +2292,7 @@ void ChangeTownRating(Town *t, int add, int max) SetBit(t->have_ratings, _current_player); - rating = t->ratings[_current_player]; + rating = _town_rating_test ? t->test_rating : t->ratings[_current_player]; if (add < 0) { if (rating > max) { @@ -2288,7 +2305,11 @@ void ChangeTownRating(Town *t, int add, int max) if (rating > max) rating = max; } } - t->ratings[_current_player] = rating; + if (_town_rating_test) { + t->test_rating = rating; + } else { + t->ratings[_current_player] = rating; + } } /* penalty for removing town-owned stuff */ @@ -2313,7 +2334,7 @@ bool CheckforTownRating(uint32 flags, Town *t, byte type) */ modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type]; - if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) { + if ((_town_rating_test ? t->test_rating : t->ratings[_current_player]) < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) { SetDParam(0, t->index); _error_message = STR_2009_LOCAL_AUTHORITY_REFUSES; return false; |