(svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).

This commit is contained in:
terkhen
2011-12-03 22:21:27 +00:00
parent e9e62b1629
commit 59d8b0204f
4 changed files with 133 additions and 0 deletions

View File

@@ -19,6 +19,7 @@
#include "subsidy_type.h"
#include "newgrf_storage.h"
#include "cargotype.h"
#include "tilematrix_type.hpp"
#include <list>
template <typename T>
@@ -27,6 +28,8 @@ struct BuildingCounts {
T class_count[HOUSE_CLASS_MAX];
};
typedef TileMatrix<uint32, 4> AcceptanceMatrix;
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY = 4; ///< value for custom town number in difficulty settings
static const uint CUSTOM_TOWN_MAX_NUMBER = 5000; ///< this is the maximum number of towns a user can specify in customisation
@@ -76,6 +79,11 @@ struct Town : TownPool::PoolItem<&_town_pool> {
inline byte GetPercentTransported(CargoID cid) const { return this->supplied[cid].old_act * 256 / (this->supplied[cid].old_max + 1); }
/* Cargo production and acceptance stats. */
uint32 cargo_produced; ///< Bitmap of all cargos produced by houses in this town.
AcceptanceMatrix cargo_accepted; ///< Bitmap of cargos accepted by houses for each 4*4 map square of the town.
uint32 cargo_accepted_total; ///< NOSAVE: Bitmap of all cargos accepted by houses in this town.
uint16 time_until_rebuild; ///< time until we rebuild a house
uint16 grow_counter; ///< counter to count when to grow
@@ -175,6 +183,8 @@ void ResetHouses();
void ClearTownHouse(Town *t, TileIndex tile);
void UpdateTownMaxPass(Town *t);
void UpdateTownRadius(Town *t);
void UpdateTownCargos(Town *t);
void UpdateTownCargoTotal(Town *t);
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags);
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags);