Changeset - r3346:134319cc6f99
[Not reviewed]
master
0 5 0
Darkvater - 18 years ago 2006-03-26 22:41:56
darkvater@openttd.org
(svn r4130) - CodeChange: Add proper semantics for TownID for such variables instead of using the general uint16-type. We probably need to change GetTown() and IsTownIndex() as well to use TownID.
5 files changed with 7 insertions and 5 deletions:
0 comments (0 inline, 0 general)
depot.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef DEPOT_H
 
#define DEPOT_H
 

	
 
/** @file depot.h Header files for depots (not hangars)
 
  * @see depot.c */
 

	
 
#include "direction.h"
 
#include "pool.h"
 
#include "rail_map.h"
 
#include "road_map.h"
 
#include "tile.h"
 
#include "variables.h"
 

	
 
struct Depot {
 
	TileIndex xy;
 
	uint16 town_index;
 
	TownID town_index;
 
	uint16 index;
 
};
 

	
 
extern MemoryPool _depot_pool;
 

	
 
/**
 
 * Get the pointer to the depot with index 'index'
 
 */
 
static inline Depot *GetDepot(uint index)
 
{
 
	return (Depot*)GetItemFromPool(&_depot_pool, index);
 
}
 

	
 
/**
 
 * Get the current size of the DepotPool
 
 */
 
static inline uint16 GetDepotPoolSize(void)
 
{
 
	return _depot_pool.total_items;
 
}
 

	
 
static inline bool IsDepotIndex(uint index)
 
{
 
	return index < GetDepotPoolSize();
economy.h
Show inline comments
 
@@ -2,48 +2,49 @@
 

	
 
#ifndef ECONOMY_H
 
#define ECONOMY_H
 

	
 
void ResetPriceBaseMultipliers(void);
 
void SetPriceBaseMultiplier(uint price, byte factor);
 

	
 
typedef struct {
 
	// Maximum possible loan
 
	int32 max_loan;
 
	int32 max_loan_unround;
 
	// Economy fluctuation status
 
	int fluct;
 
	// Interest
 
	byte interest_rate;
 
	byte infl_amount;
 
	byte infl_amount_pr;
 
} Economy;
 

	
 
VARDEF Economy _economy;
 

	
 
typedef struct Subsidy {
 
	CargoID cargo_type;
 
	byte age;
 
	/* from and to can either be TownID, StationID or IndustryID */
 
	uint16 from;
 
	uint16 to;
 
} Subsidy;
 

	
 

	
 
enum {
 
    SCORE_VEHICLES = 0,
 
    SCORE_STATIONS = 1,
 
    SCORE_MIN_PROFIT = 2,
 
    SCORE_MIN_INCOME = 3,
 
    SCORE_MAX_INCOME = 4,
 
    SCORE_DELIVERED = 5,
 
    SCORE_CARGO = 6,
 
    SCORE_MONEY = 7,
 
    SCORE_LOAN = 8,
 
    SCORE_TOTAL = 9, // This must always be the last entry
 

	
 
    NUM_SCORE = 10, // How many scores are there..
 

	
 
    SCORE_MAX = 1000, 	// The max score that can be in the performance history
 
    					//  the scores together of score_info is allowed to be more!
 
};
 

	
 
typedef struct ScoreInfo {
openttd.h
Show inline comments
 
@@ -40,48 +40,49 @@ typedef struct YearMonthDay {
 
* increased by 885. When it overflows, the new day loop is called.
 
* * this that means 1 day is : 65536 / 885 = 74 ticks
 
* * 1 tick is approximately 27ms.
 
* * 1 day is thus about 2 seconds (74*27 = 1998) on a machine that can run OpenTTD normally
 
*/
 
#define DAY_TICKS 74
 
#define MAX_YEAR_BEGIN_REAL 1920
 
#define MAX_YEAR_END_REAL 2090
 
#define MAX_YEAR_END 170
 

	
 
#include "map.h"
 

	
 
// Forward declarations of structs.
 
typedef struct Vehicle Vehicle;
 
typedef struct Depot Depot;
 
typedef struct Waypoint Waypoint;
 
typedef struct Window Window;
 
typedef struct Station Station;
 
typedef struct ViewPort ViewPort;
 
typedef struct Town Town;
 
typedef struct NewsItem NewsItem;
 
typedef struct Industry Industry;
 
typedef struct DrawPixelInfo DrawPixelInfo;
 
typedef uint16 VehicleID;
 
typedef uint16 TownID;
 
typedef byte PlayerID;
 
typedef byte OrderID;
 
typedef byte CargoID;
 
typedef uint16 StringID;
 
typedef uint32 SpriteID;    ///< The number of a sprite, without mapping bits and colortables
 
typedef uint32 PalSpriteID; ///< The number of a sprite plus all the mapping bits and colortables
 
typedef uint32 CursorID;
 
typedef uint16 EngineID; ///< All enginenumbers should be of this type
 
typedef uint16 UnitID;   ///< All unitnumber stuff is of this type (or anyway, should be)
 

	
 
typedef uint32 WindowNumber;
 
typedef byte WindowClass;
 

	
 

	
 
enum GameModes {
 
	GM_MENU,
 
	GM_NORMAL,
 
	GM_EDITOR
 
};
 

	
 
enum SwitchModes {
 
	SM_NONE = 0,
 
	SM_NEWGAME = 1,
 
	SM_EDITOR = 2,
town.h
Show inline comments
 
@@ -49,59 +49,59 @@ struct Town {
 
	// Amount of passengers that were transported.
 
	byte pct_pass_transported;
 
	byte pct_mail_transported;
 

	
 
	// Amount of food and paper that was transported. Actually a bit mask would be enough.
 
	uint16 act_food;
 
	uint16 act_water;
 
	uint16 new_act_food;
 
	uint16 new_act_water;
 

	
 
	// Time until we rebuild a house.
 
	byte time_until_rebuild;
 

	
 
	// When to grow town next time.
 
	byte grow_counter;
 
	byte growth_rate;
 

	
 
	// Fund buildings program in action?
 
	byte fund_buildings_months;
 

	
 
	// Fund road reconstruction in action?
 
	byte road_build_months;
 

	
 
	// Index in town array
 
	uint16 index;
 
	TownID index;
 

	
 
	// NOSAVE: UpdateTownRadius updates this given the house count.
 
	uint16 radius[5];
 
};
 

	
 
uint32 GetWorldPopulation(void);
 

	
 
void UpdateTownVirtCoord(Town *t);
 
void InitializeTown(void);
 
void ShowTownViewWindow(uint town);
 
void ShowTownViewWindow(TownID town);
 
void DeleteTown(Town *t);
 
void ExpandTown(Town *t);
 
Town *CreateRandomTown(uint attempts);
 

	
 
enum {
 
	ROAD_REMOVE = 0,
 
	UNMOVEABLE_REMOVE = 1,
 
	TUNNELBRIDGE_REMOVE = 1,
 
	INDUSTRY_REMOVE = 2
 
};
 

	
 
enum {
 
	// These refer to the maximums, so Appalling is -1000 to -400
 
	// MAXIMUM RATINGS BOUNDARIES
 
	RATING_MINIMUM 		= -1000,
 
	RATING_APPALLING 	= -400,
 
	RATING_VERYPOOR 	= -200,
 
	RATING_POOR 			= 0,
 
	RATING_MEDIOCRE		= 200,
 
	RATING_GOOD				= 400,
 
	RATING_VERYGOOD		= 600,
 
	RATING_EXCELLENT	= 800,
 
	RATING_OUTSTANDING= 1000, 	// OUTSTANDING
 

	
 
@@ -109,49 +109,49 @@ enum {
 

	
 
	// RATINGS AFFECTING NUMBERS
 
	RATING_TREE_DOWN_STEP = -35,
 
	RATING_TREE_MINIMUM = RATING_MINIMUM,
 
	RATING_TREE_UP_STEP = 7,
 
	RATING_TREE_MAXIMUM = 220,
 

	
 
	RATING_TUNNEL_BRIDGE_DOWN_STEP = -250,
 
	RATING_TUNNEL_BRIDGE_MINIMUM = 0,
 

	
 
	RATING_INDUSTRY_DOWN_STEP = -1500,
 
	RATING_INDUSTRY_MINIMUM = RATING_MINIMUM,
 

	
 
	RATING_ROAD_DOWN_STEP = -50,
 
	RATING_ROAD_MINIMUM = -100,
 
	RATING_HOUSE_MINIMUM = RATING_MINIMUM,
 

	
 
	RATING_BRIBE_UP_STEP = 200,
 
	RATING_BRIBE_MAXIMUM = 800,
 
	RATING_BRIBE_DOWN_TO = -50 					// XXX SHOULD BE SOMETHING LOWER?
 
};
 

	
 
bool CheckforTownRating(uint32 flags, Town *t, byte type);
 

	
 
VARDEF uint16 *_town_sort;
 
VARDEF TownID *_town_sort;
 

	
 
extern MemoryPool _town_pool;
 

	
 
/**
 
 * Check if a Town really exists.
 
 */
 
static inline bool IsValidTown(const Town* town)
 
{
 
	return town->xy != 0; /* XXX: Replace by INVALID_TILE someday */
 
}
 

	
 
/**
 
 * Get the pointer to the town with index 'index'
 
 */
 
static inline Town *GetTown(uint index)
 
{
 
	return (Town*)GetItemFromPool(&_town_pool, index);
 
}
 

	
 
/**
 
 * Get the current size of the TownPool
 
 */
 
static inline uint16 GetTownPoolSize(void)
 
{
waypoint.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef WAYPOINT_H
 
#define WAYPOINT_H
 

	
 
#include "pool.h"
 
#include "rail_map.h"
 

	
 
struct Waypoint {
 
	TileIndex xy;      ///< Tile of waypoint
 
	uint16 index;      ///< Index of waypoint
 

	
 
	uint16 town_index; ///< Town associated with the waypoint
 
	TownID town_index; ///< Town associated with the waypoint
 
	byte town_cn;      ///< The Nth waypoint for this town (consecutive number)
 
	StringID string;   ///< If this is zero (i.e. no custom name), town + town_cn is used for naming
 

	
 
	ViewportSign sign; ///< Dimensions of sign (not saved)
 
	uint16 build_date; ///< Date of construction
 

	
 
	byte stat_id;      ///< ID of waypoint within the waypoint class (not saved)
 
	uint32 grfid;      ///< ID of GRF file
 
	byte localidx;     ///< Index of station within GRF file
 

	
 
	byte deleted;      ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
 
};
 

	
 
enum {
 
	RAIL_TYPE_WAYPOINT = 0xC4,
 
	RAIL_WAYPOINT_TRACK_MASK = 1,
 
};
 

	
 
extern MemoryPool _waypoint_pool;
 

	
 
/**
 
 * Get the pointer to the waypoint with index 'index'
 
 */
 
static inline Waypoint *GetWaypoint(uint index)
0 comments (0 inline, 0 general)