Update to 1.10.0-RC1
This commit is contained in:
@@ -153,7 +153,7 @@ Town::~Town()
|
||||
*/
|
||||
void Town::PostDestructor(size_t index)
|
||||
{
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 0);
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_FORCE_REBUILD);
|
||||
UpdateNearestTownForRoadTiles(false);
|
||||
|
||||
/* Give objects a new home! */
|
||||
@@ -199,6 +199,13 @@ void Town::InitializeLayout(TownLayout layout)
|
||||
return Town::Get(index);
|
||||
}
|
||||
|
||||
void Town::FillCachedName() const
|
||||
{
|
||||
char buf[MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH];
|
||||
char *end = GetTownName(buf, this, lastof(buf));
|
||||
this->cached_name.assign(buf, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cost for removing this house
|
||||
* @return the cost (inflation corrected etc)
|
||||
@@ -412,6 +419,13 @@ void UpdateAllTownVirtCoords()
|
||||
}
|
||||
}
|
||||
|
||||
void ClearAllTownCachedNames()
|
||||
{
|
||||
for (Town *t : Town::Iterate()) {
|
||||
t->cached_name.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the towns population
|
||||
* @param t Town which population has changed
|
||||
@@ -423,7 +437,7 @@ static void ChangePopulation(Town *t, int mod)
|
||||
InvalidateWindowData(WC_TOWN_VIEW, t->index); // Cargo requirements may appear/vanish for small populations
|
||||
if (_settings_client.gui.population_in_label) t->UpdateVirtCoord();
|
||||
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_POPULATION_CHANGE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1777,7 +1791,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
|
||||
t->townnameparts = townnameparts;
|
||||
|
||||
t->UpdateVirtCoord();
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 0);
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_FORCE_REBUILD);
|
||||
|
||||
t->InitializeLayout(layout);
|
||||
|
||||
@@ -2681,11 +2695,14 @@ CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
t->cached_name.clear();
|
||||
free(t->name);
|
||||
t->name = reset ? nullptr : stredup(text);
|
||||
|
||||
t->UpdateVirtCoord();
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_FORCE_RESORT);
|
||||
ClearAllStationCachedNames();
|
||||
ClearAllIndustryCachedNames();
|
||||
UpdateAllStationVirtCoords();
|
||||
}
|
||||
return CommandCost();
|
||||
@@ -2804,6 +2821,35 @@ CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the rating of a company in a town
|
||||
* @param tile Unused.
|
||||
* @param flags Type of operation.
|
||||
* @param p1 Bit 0..15 = Town ID to change, bit 16..23 = Company ID to change.
|
||||
* @param p2 Bit 0..15 = New rating of company (signed int16).
|
||||
* @param text Unused.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
TownID town_id = (TownID)GB(p1, 0, 16);
|
||||
Town *t = Town::GetIfValid(town_id);
|
||||
if (t == nullptr) return CMD_ERROR;
|
||||
|
||||
CompanyID company_id = (CompanyID)GB(p1, 16, 8);
|
||||
if (!Company::IsValidID(company_id)) return CMD_ERROR;
|
||||
|
||||
int16 new_rating = Clamp((int16)GB(p2, 0, 16), RATING_MINIMUM, RATING_MAXIMUM);
|
||||
if (flags & DC_EXEC) {
|
||||
t->ratings[company_id] = new_rating;
|
||||
InvalidateWindowData(WC_TOWN_AUTHORITY, town_id);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a town (scenario editor only).
|
||||
* @param tile Unused.
|
||||
|
||||
Reference in New Issue
Block a user