Zoning: Ensure that screen is refreshed when necessary in authority overlay
This commit is contained in:
		@@ -694,6 +694,9 @@ static CommandCost BuildStationPart(Station **st, DoCommandFlag flags, bool reus
 | 
			
		||||
			(*st)->string_id = GenerateStationName(*st, area.tile, name_class);
 | 
			
		||||
 | 
			
		||||
			if (Company::IsValidID(_current_company)) {
 | 
			
		||||
				if (_local_company == _current_company && !HasBit((*st)->town->have_ratings, _current_company)) {
 | 
			
		||||
					ZoningTownAuthorityRatingChange();
 | 
			
		||||
				}
 | 
			
		||||
				SetBit((*st)->town->have_ratings, _current_company);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,7 @@
 | 
			
		||||
#include "ai/ai.hpp"
 | 
			
		||||
#include "game/game.hpp"
 | 
			
		||||
#include "zoom_func.h"
 | 
			
		||||
#include "zoning.h"
 | 
			
		||||
 | 
			
		||||
#include "table/strings.h"
 | 
			
		||||
#include "table/town_land.h"
 | 
			
		||||
@@ -3622,7 +3623,8 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int rating = GetRating(t);
 | 
			
		||||
	const int prev_rating = GetRating(t);
 | 
			
		||||
	int rating = prev_rating;
 | 
			
		||||
	if (add < 0) {
 | 
			
		||||
		if (rating > max) {
 | 
			
		||||
			rating += add;
 | 
			
		||||
@@ -3637,6 +3639,9 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
 | 
			
		||||
	if (_town_rating_test) {
 | 
			
		||||
		_town_test_ratings[t] = rating;
 | 
			
		||||
	} else {
 | 
			
		||||
		if (_local_company == _current_company && (!HasBit(t->have_ratings, _current_company) || ((prev_rating > 0) != (rating > 0)))) {
 | 
			
		||||
			ZoningTownAuthorityRatingChange();
 | 
			
		||||
		}
 | 
			
		||||
		SetBit(t->have_ratings, _current_company);
 | 
			
		||||
		t->ratings[_current_company] = rating;
 | 
			
		||||
		t->UpdateVirtCoord();
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,7 @@ void ZoningMarkDirtyStationCoverageArea(const Station *st, ZoningModeMask mask =
 | 
			
		||||
inline void ZoningMarkDirtyStationCoverageArea(const Waypoint *st) { } // no-op
 | 
			
		||||
 | 
			
		||||
void ZoningStationWindowOpenClose(const Station *st);
 | 
			
		||||
void ZoningTownAuthorityRatingChange();
 | 
			
		||||
 | 
			
		||||
void SetZoningMode(bool inner, ZoningEvaluationMode mode);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -477,6 +477,16 @@ void ZoningStationWindowOpenClose(const Station *st)
 | 
			
		||||
	if (mask != ZMM_NOTHING) ZoningMarkDirtyStationCoverageArea(st, mask);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ZoningTownAuthorityRatingChange()
 | 
			
		||||
{
 | 
			
		||||
	ZoningModeMask mask = ZMM_NOTHING;
 | 
			
		||||
	if (_zoning.inner == ZEM_AUTHORITY) mask |= ZMM_INNER;
 | 
			
		||||
	if (_zoning.outer == ZEM_AUTHORITY) mask |= ZMM_OUTER;
 | 
			
		||||
	if (mask != ZMM_NOTHING) {
 | 
			
		||||
		MarkWholeScreenDirty();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClearZoningCaches()
 | 
			
		||||
{
 | 
			
		||||
	_zoning_cache_inner.clear();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user