Update to 1.10.0-beta2
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
@@ -69,8 +67,7 @@ TownKdtree _town_kdtree(&Kdtree_TownXYFunc);
|
||||
void RebuildTownKdtree()
|
||||
{
|
||||
std::vector<TownID> townids;
|
||||
Town *town;
|
||||
FOR_ALL_TOWNS(town) {
|
||||
for (const Town *town : Town::Iterate()) {
|
||||
townids.push_back(town->index);
|
||||
}
|
||||
_town_kdtree.Build(townids.begin(), townids.end());
|
||||
@@ -114,12 +111,10 @@ Town::~Town()
|
||||
DeleteWindowById(WC_TOWN_VIEW, this->index);
|
||||
|
||||
/* Check no industry is related to us. */
|
||||
const Industry *i;
|
||||
FOR_ALL_INDUSTRIES(i) assert(i->town != this);
|
||||
for (const Industry *i : Industry::Iterate()) assert(i->town != this);
|
||||
|
||||
/* ... and no object is related to us. */
|
||||
const Object *o;
|
||||
FOR_ALL_OBJECTS(o) assert(o->town != this);
|
||||
for (const Object *o : Object::Iterate()) assert(o->town != this);
|
||||
|
||||
/* Check no tile is related to us. */
|
||||
for (TileIndex tile = 0; tile < MapSize(); ++tile) {
|
||||
@@ -162,8 +157,7 @@ void Town::PostDestructor(size_t index)
|
||||
UpdateNearestTownForRoadTiles(false);
|
||||
|
||||
/* Give objects a new home! */
|
||||
Object *o;
|
||||
FOR_ALL_OBJECTS(o) {
|
||||
for (Object *o : Object::Iterate()) {
|
||||
if (o->town == nullptr) o->town = CalcClosestTownFromTile(o->location.tile, UINT_MAX);
|
||||
}
|
||||
}
|
||||
@@ -396,21 +390,24 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
|
||||
void Town::UpdateVirtCoord()
|
||||
{
|
||||
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
|
||||
|
||||
if (this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index));
|
||||
|
||||
SetDParam(0, this->index);
|
||||
SetDParam(1, this->cache.population);
|
||||
this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE,
|
||||
_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN,
|
||||
STR_VIEWPORT_TOWN);
|
||||
|
||||
_viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(this->index));
|
||||
|
||||
SetWindowDirty(WC_TOWN_VIEW, this->index);
|
||||
}
|
||||
|
||||
/** Update the virtual coords needed to draw the town sign for all towns. */
|
||||
void UpdateAllTownVirtCoords()
|
||||
{
|
||||
Town *t;
|
||||
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
t->UpdateVirtCoord();
|
||||
}
|
||||
}
|
||||
@@ -437,9 +434,7 @@ static void ChangePopulation(Town *t, int mod)
|
||||
uint32 GetWorldPopulation()
|
||||
{
|
||||
uint32 pop = 0;
|
||||
const Town *t;
|
||||
|
||||
FOR_ALL_TOWNS(t) pop += t->cache.population;
|
||||
for (const Town *t : Town::Iterate()) pop += t->cache.population;
|
||||
return pop;
|
||||
}
|
||||
|
||||
@@ -844,10 +839,9 @@ void UpdateTownCargoes(Town *t)
|
||||
/** Updates the bitmap of all cargoes accepted by houses. */
|
||||
void UpdateTownCargoBitmap()
|
||||
{
|
||||
Town *town;
|
||||
_town_cargoes_accepted = 0;
|
||||
|
||||
FOR_ALL_TOWNS(town) {
|
||||
for (const Town *town : Town::Iterate()) {
|
||||
_town_cargoes_accepted |= town->cargo_accepted_total;
|
||||
}
|
||||
}
|
||||
@@ -874,8 +868,7 @@ void OnTick_Town()
|
||||
{
|
||||
if (_game_mode == GM_EDITOR) return;
|
||||
|
||||
Town *t;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
TownTickHandler(t);
|
||||
}
|
||||
}
|
||||
@@ -1784,7 +1777,6 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
|
||||
t->townnameparts = townnameparts;
|
||||
|
||||
t->UpdateVirtCoord();
|
||||
_viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(t->index));
|
||||
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 0);
|
||||
|
||||
t->InitializeLayout(layout);
|
||||
@@ -1843,9 +1835,7 @@ static CommandCost TownCanBePlacedHere(TileIndex tile)
|
||||
*/
|
||||
static bool IsUniqueTownName(const char *name)
|
||||
{
|
||||
const Town *t;
|
||||
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (const Town *t : Town::Iterate()) {
|
||||
if (t->name != nullptr && strcmp(t->name, name) == 0) return false;
|
||||
}
|
||||
|
||||
@@ -2870,8 +2860,7 @@ CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
if (t == nullptr) return CMD_ERROR;
|
||||
|
||||
/* Stations refer to towns. */
|
||||
const Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
for (const Station *st : Station::Iterate()) {
|
||||
if (st->town == t) {
|
||||
/* Non-oil rig stations are always a problem. */
|
||||
if (!(st->facilities & FACIL_AIRPORT) || st->airport.type != AT_OILRIG) return CMD_ERROR;
|
||||
@@ -2882,8 +2871,7 @@ CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
}
|
||||
|
||||
/* Depots refer to towns. */
|
||||
const Depot *d;
|
||||
FOR_ALL_DEPOTS(d) {
|
||||
for (const Depot *d : Depot::Iterate()) {
|
||||
if (d->town == t) return CMD_ERROR;
|
||||
}
|
||||
|
||||
@@ -2944,7 +2932,7 @@ CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
/* The town destructor will delete the other things related to the town. */
|
||||
if (flags & DC_EXEC) {
|
||||
_town_kdtree.Remove(t->index);
|
||||
_viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(t->index));
|
||||
if (t->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(t->index));
|
||||
delete t;
|
||||
}
|
||||
|
||||
@@ -3157,8 +3145,7 @@ static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
|
||||
t->unwanted[_current_company] = 6;
|
||||
|
||||
/* set all close by station ratings to 0 */
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
for (Station *st : Station::Iterate()) {
|
||||
if (st->town == t && st->owner == _current_company) {
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) st->goods[i].rating = 0;
|
||||
}
|
||||
@@ -3292,8 +3279,7 @@ static void ForAllStationsNearTown(Town *t, Func func)
|
||||
static void UpdateTownRating(Town *t)
|
||||
{
|
||||
/* Increase company ratings if they're low */
|
||||
const Company *c;
|
||||
FOR_ALL_COMPANIES(c) {
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (t->ratings[c->index] < RATING_GROWTH_MAXIMUM) {
|
||||
t->ratings[c->index] = min((int)RATING_GROWTH_MAXIMUM, t->ratings[c->index] + RATING_GROWTH_UP_STEP);
|
||||
}
|
||||
@@ -3362,6 +3348,11 @@ static int CountActiveStations(Town *t)
|
||||
*/
|
||||
static uint GetNormalGrowthRate(Town *t)
|
||||
{
|
||||
/**
|
||||
* Note:
|
||||
* Unserviced+unfunded towns get an additional malus in UpdateTownGrowth(),
|
||||
* so the "320" is actually not better than the "420".
|
||||
*/
|
||||
static const uint16 _grow_count_values[2][6] = {
|
||||
{ 120, 120, 120, 100, 80, 60 }, // Fund new buildings has been activated
|
||||
{ 320, 420, 300, 220, 160, 100 } // Normal values
|
||||
@@ -3444,9 +3435,7 @@ static void UpdateTownAmounts(Town *t)
|
||||
|
||||
static void UpdateTownUnwanted(Town *t)
|
||||
{
|
||||
const Company *c;
|
||||
|
||||
FOR_ALL_COMPANIES(c) {
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (t->unwanted[c->index] > 0) t->unwanted[c->index]--;
|
||||
}
|
||||
}
|
||||
@@ -3644,9 +3633,7 @@ CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType
|
||||
|
||||
void TownsMonthlyLoop()
|
||||
{
|
||||
Town *t;
|
||||
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (t->road_build_months != 0) t->road_build_months--;
|
||||
|
||||
if (t->exclusive_counter != 0) {
|
||||
|
||||
Reference in New Issue
Block a user