summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2011-12-03 22:23:10 +0000
committerterkhen <terkhen@openttd.org>2011-12-03 22:23:10 +0000
commitde0bf0663aaeec26845d048e2eaa5e08edf21f63 (patch)
tree2407406d652876b0bc72bd634fc406d789464819 /src
parent0e5f334315f8d461a62cc45b76193eddca6ce2a2 (diff)
downloadopenttd-de0bf0663aaeec26845d048e2eaa5e08edf21f63.tar.xz
(svn r23407) -Codechange: Keep a bitmap of all cargos accepted by towns.
Diffstat (limited to 'src')
-rw-r--r--src/saveload/town_sl.cpp1
-rw-r--r--src/town.h3
-rw-r--r--src/town_cmd.cpp14
3 files changed, 18 insertions, 0 deletions
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp
index 71dc4cd5b..df0dad0e3 100644
--- a/src/saveload/town_sl.cpp
+++ b/src/saveload/town_sl.cpp
@@ -99,6 +99,7 @@ void UpdateHousesAndTowns()
UpdateTownRadius(town);
UpdateTownCargos(town);
}
+ UpdateTownCargoBitmap();
}
/** Save and load of towns. */
diff --git a/src/town.h b/src/town.h
index c276be26b..19068ea53 100644
--- a/src/town.h
+++ b/src/town.h
@@ -185,6 +185,7 @@ void UpdateTownMaxPass(Town *t);
void UpdateTownRadius(Town *t);
void UpdateTownCargos(Town *t);
void UpdateTownCargoTotal(Town *t);
+void UpdateTownCargoBitmap();
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags);
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags);
@@ -284,4 +285,6 @@ void MakeDefaultName(T *obj)
obj->town_cn = (uint16)next; // set index...
}
+extern uint32 _town_cargos_accepted;
+
#endif /* TOWN_H */
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 39e4ebc3e..60bb58e09 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -52,6 +52,7 @@
#include "table/town_land.h"
TownID _new_town_id;
+uint32 _town_cargos_accepted; ///< Bitmap of all cargos accepted by houses.
/* Initialize the town-pool */
TownPool _town_pool("Town");
@@ -742,6 +743,17 @@ void UpdateTownCargos(Town *t)
UpdateTownCargoTotal(t);
}
+/** Updates the bitmap of all cargos accepted by houses. */
+void UpdateTownCargoBitmap()
+{
+ Town *town;
+ _town_cargos_accepted = 0;
+
+ FOR_ALL_TOWNS(town) {
+ _town_cargos_accepted |= town->cargo_accepted_total;
+ }
+}
+
static bool GrowTown(Town *t);
static void TownTickHandler(Town *t)
@@ -3143,6 +3155,8 @@ void TownsMonthlyLoop()
UpdateTownUnwanted(t);
UpdateTownCargos(t);
}
+
+ UpdateTownCargoBitmap();
}
void TownsYearlyLoop()