(svn r3172) static, const
authortron
Sun, 13 Nov 2005 13:43:55 +0000
changeset 2630 35249d2ded3e
parent 2629 842a290af2fb
child 2631 13daba67f217
(svn r3172) static, const
ai/default/default.c
aircraft_cmd.c
aircraft_gui.c
economy.c
economy.h
industry.h
industry_cmd.c
main_gui.c
misc_gui.c
music_gui.c
network_gui.c
order.h
order_cmd.c
player_gui.c
rail_gui.c
roadveh_cmd.c
roadveh_gui.c
ship_cmd.c
ship_gui.c
station_cmd.c
station_gui.c
strings.c
subsidy_gui.c
town_cmd.c
town_gui.c
train_cmd.c
train_gui.c
vehicle.c
vehicle.h
vehicle_gui.c
window.c
--- a/ai/default/default.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/ai/default/default.c	Sun Nov 13 13:43:55 2005 +0000
@@ -1905,7 +1905,8 @@
 static const byte _dir_table_2[] = {12, 6, 3, 9};
 
 
-static bool AiIsTileBanned(Player *p, TileIndex tile, byte val) {
+static bool AiIsTileBanned(const Player* p, TileIndex tile, byte val)
+{
 	int i;
 
 	for(i=0; i!=p->ai.banned_tile_count; i++)
--- a/aircraft_cmd.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/aircraft_cmd.c	Sun Nov 13 13:43:55 2005 +0000
@@ -544,7 +544,7 @@
 
 static void CheckIfAircraftNeedsService(Vehicle *v)
 {
-	Station *st;
+	const Station* st;
 
 	if (_patches.servint_aircraft == 0)
 		return;
@@ -1269,7 +1269,7 @@
 
 static bool ValidateAircraftInHangar( uint data_a, uint data_b )
 {
-	Vehicle *v = GetVehicle(data_a);
+	const Vehicle* v = GetVehicle(data_a);
 
 	return (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_STOPPED));
 }
@@ -1324,7 +1324,7 @@
 // set the right pos when heading to other airports after takeoff
 static void AircraftNextAirportPos_and_Order(Vehicle *v)
 {
-	Station *st;
+	const Station* st;
 	const AirportFTAClass *Airport;
 
 	if (v->current_order.type == OT_GOTO_STATION ||
@@ -1634,7 +1634,7 @@
 	AircraftEventHandler_HeliEndLanding,// HELIENDLANDING = 18
 };
 
-static void AirportClearBlock(Vehicle *v, const AirportFTAClass *Airport)
+static void AirportClearBlock(const Vehicle* v, const AirportFTAClass* Airport)
 {
 	Station *st;
 	// we have left the previous block, and entered the new one. Free the previous block
@@ -1706,16 +1706,14 @@
 // returns true if the road ahead is busy, eg. you must wait before proceeding
 static bool AirportHasBlock(Vehicle *v, AirportFTA *current_pos, const AirportFTAClass *Airport)
 {
-	Station *st;
-	uint32 airport_flags;
-	AirportFTA *next, *reference;
-	reference = &Airport->layout[v->u.air.pos];
-	next = &Airport->layout[current_pos->next_position];
+	const AirportFTA* reference = &Airport->layout[v->u.air.pos];
+	const AirportFTA* next = &Airport->layout[current_pos->next_position];
 
 	// same block, then of course we can move
 	if (Airport->layout[current_pos->position].block != next->block) {
-		airport_flags = next->block;
-		st = GetStation(v->u.air.targetairport);
+		const Station* st = GetStation(v->u.air.targetairport);
+		uint32 airport_flags = next->block;
+
 		// check additional possible extra blocks
 		if (current_pos != reference && current_pos->block != NOTHING_block) {
 			airport_flags |= current_pos->block;
--- a/aircraft_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/aircraft_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -77,10 +77,9 @@
 
 void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
-	Vehicle *v;
+	if (success) {
+		const Vehicle* v = GetVehicle(_new_aircraft_id);
 
-	if (success) {
-		v = GetVehicle(_new_aircraft_id);
 		if (v->tile == _backup_orders_tile) {
 			_backup_orders_tile = 0;
 			RestoreVehicleOrders(v, _backup_orders_data);
@@ -508,7 +507,7 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		Vehicle *v = GetVehicle(w->window_number);
+		const Vehicle* v = GetVehicle(w->window_number);
 		uint32 disabled = 1<<8;
 		StringID str;
 
--- a/economy.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/economy.c	Sun Nov 13 13:43:55 2005 +0000
@@ -825,7 +825,7 @@
 	_economy.fluct = GB(Random(), 0, 8) + 168;
 }
 
-Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode)
+Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode)
 {
 	TileIndex tile;
 	TileIndex tile2;
@@ -983,7 +983,7 @@
 
 static bool CheckSubsidyDuplicate(Subsidy *s)
 {
-	Subsidy *ss;
+	const Subsidy* ss;
 
 	for(ss=_subsidies; ss != endof(_subsidies); ss++) {
 		if (s != ss &&
--- a/economy.h	Sat Nov 12 11:10:12 2005 +0000
+++ b/economy.h	Sun Nov 13 13:43:55 2005 +0000
@@ -60,7 +60,7 @@
 
 
 VARDEF Subsidy _subsidies[MAX_PLAYERS];
-Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode);
+Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode);
 void DeleteSubsidyWithIndustry(uint16 index);
 void DeleteSubsidyWithStation(uint16 index);
 
--- a/industry.h	Sat Nov 12 11:10:12 2005 +0000
+++ b/industry.h	Sun Nov 13 13:43:55 2005 +0000
@@ -9,7 +9,7 @@
 	TileIndex xy;
 	byte width; /* swapped order of w/h with town */
 	byte height;
-	Town *town;
+	const Town* town;
 	byte produced_cargo[2];
 	uint16 cargo_waiting[2];
 	byte production_rate[2];
--- a/industry_cmd.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/industry_cmd.c	Sun Nov 13 13:43:55 2005 +0000
@@ -38,8 +38,8 @@
 /* Initialize the industry-pool */
 MemoryPool _industry_pool = { "Industry", INDUSTRY_POOL_MAX_BLOCKS, INDUSTRY_POOL_BLOCK_SIZE_BITS, sizeof(Industry), &IndustryPoolNewBlock, 0, 0, NULL };
 
-byte _industry_sound_ctr;
-TileIndex _industry_sound_tile;
+static byte _industry_sound_ctr;
+static TileIndex _industry_sound_tile;
 
 void ShowIndustryViewWindow(int industry);
 void BuildOilRig(TileIndex tile);
@@ -341,7 +341,7 @@
 
 static void DrawTile_Industry(TileInfo *ti)
 {
-	Industry *ind;
+	const Industry* ind;
 	const DrawIndustryTileStruct *dits;
 	byte z;
 	uint32 image, ormod;
@@ -425,7 +425,7 @@
 
 static void GetTileDesc_Industry(TileIndex tile, TileDesc *td)
 {
-	Industry *i = GetIndustry(_m[tile].m2);
+	const Industry* i = GetIndustry(_m[tile].m2);
 
 	td->owner = i->owner;
 	td->str = STR_4802_COAL_MINE + i->type;
@@ -863,7 +863,8 @@
 
 static void GetProducedCargo_Industry(TileIndex tile, byte *b)
 {
-	Industry *i = GetIndustry(_m[tile].m2);
+	const Industry* i = GetIndustry(_m[tile].m2);
+
 	b[0] = i->produced_cargo[0];
 	b[1] = i->produced_cargo[1];
 }
@@ -1262,10 +1263,10 @@
 	return true;
 }
 
-static Town *CheckMultipleIndustryInTown(TileIndex tile, int type)
+static const Town* CheckMultipleIndustryInTown(TileIndex tile, int type)
 {
-	Town *t;
-	Industry *i;
+	const Town* t;
+	const Industry* i;
 
 	t = ClosestTownFromTile(tile, (uint)-1);
 
@@ -1309,7 +1310,7 @@
 	16, 16, 16, 16, 16, 16, 16,
 };
 
-static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, int type, Town *t)
+static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable* it, int type, const Town* t)
 {
 	TileInfo ti;
 
@@ -1451,7 +1452,7 @@
 	return AddBlockToPool(&_industry_pool) ? AllocateIndustry() : NULL;
 }
 
-static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, Town *t, byte owner)
+static void DoCreateNewIndustry(Industry* i, TileIndex tile, int type, const IndustryTileTable* it, const Town* t, byte owner)
 {
 	const IndustrySpec *spec;
 	uint32 r;
@@ -1547,7 +1548,7 @@
  */
 int32 CmdBuildIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
-	Town *t;
+	const Town* t;
 	Industry *i;
 	TileIndex tile = TileVirtXY(x, y);
 	int num;
@@ -1601,7 +1602,7 @@
 
 Industry *CreateNewIndustry(TileIndex tile, int type)
 {
-	Town *t;
+	const Town* t;
 	const IndustryTileTable *it;
 	Industry *i;
 
--- a/main_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/main_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -566,9 +566,9 @@
 
 static int GetPlayerIndexFromMenu(int index)
 {
-	Player *p;
-
 	if (index >= 0) {
+		const Player* p;
+
 		FOR_ALL_PLAYERS(p) {
 			if (p->is_active) {
 				if (--index < 0)
@@ -582,7 +582,7 @@
 static void UpdatePlayerMenuHeight(Window *w)
 {
 	int num = 0;
-	Player *p;
+	const Player* p;
 
 	FOR_ALL_PLAYERS(p) {
 		if (p->is_active)
@@ -822,7 +822,7 @@
 
 static void ToolbarTrainClick(Window *w)
 {
-	Vehicle *v;
+	const Vehicle* v;
 	int dis = -1;
 	FOR_ALL_VEHICLES(v)
 		if (v->type == VEH_Train && v->subtype == TS_Front_Engine) CLRBIT(dis, v->owner);
@@ -831,7 +831,7 @@
 
 static void ToolbarRoadClick(Window *w)
 {
-	Vehicle *v;
+	const Vehicle* v;
 	int dis = -1;
 	FOR_ALL_VEHICLES(v)
 		if (v->type == VEH_Road) CLRBIT(dis, v->owner);
@@ -840,7 +840,7 @@
 
 static void ToolbarShipClick(Window *w)
 {
-	Vehicle *v;
+	const Vehicle* v;
 	int dis = -1;
 	FOR_ALL_VEHICLES(v)
 		if (v->type == VEH_Ship) CLRBIT(dis, v->owner);
@@ -849,7 +849,7 @@
 
 static void ToolbarAirClick(Window *w)
 {
-	Vehicle *v;
+	const Vehicle* v;
 	int dis = -1;
 	FOR_ALL_VEHICLES(v)
 		if (v->type == VEH_Aircraft) CLRBIT(dis, v->owner);
@@ -1651,11 +1651,11 @@
 {   WIDGETS_END},
 };
 
-int _industry_type_to_place;
 
 static bool AnyTownExists(void)
 {
-	Town *t;
+	const Town* t;
+
 	FOR_ALL_TOWNS(t) {
 		if (t->xy)
 			return true;
@@ -1697,6 +1697,7 @@
 	{26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36},
 };
 
+static int _industry_type_to_place;
 bool _ignore_restrictions;
 
 static void ScenEditIndustryWndProc(Window *w, WindowEvent *e)
--- a/misc_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/misc_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -29,7 +29,7 @@
 static bool _fios_path_changed;
 static bool _savegame_sort_dirty;
 
-bool _query_string_active;
+static bool _query_string_active;
 
 typedef struct LandInfoData {
 	Town *town;
@@ -41,10 +41,9 @@
 
 static void LandInfoWndProc(Window *w, WindowEvent *e)
 {
-	LandInfoData *lid;
-	StringID str;
-
 	if (e->event == WE_PAINT) {
+		const LandInfoData* lid;
+		StringID str;
 		int i;
 
 		DrawWindowWidgets(w);
@@ -883,7 +882,8 @@
  */
 void UpdateTextBufferSize(Textbuf *tb)
 {
-	char *buf;
+	const char* buf;
+
 	tb->length = 0;
 	tb->width = 0;
 
--- a/music_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/music_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -206,9 +206,9 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
+		const byte* p;
 		uint i;
 		int y;
-		byte *p;
 
 		w->disabled_state = (msf.playlist  <= 3) ? (1 << 11) : 0;
 		w->click_state |= 0x18;
--- a/network_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/network_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -79,8 +79,9 @@
 		_selected_field = 3;
 		_selected_item = NULL;
 		break;
+
 	case WE_PAINT: {
-		NetworkGameList *sel = _selected_item;
+		const NetworkGameList* sel = _selected_item;
 
 		w->disabled_state = 0;
 
@@ -891,9 +892,10 @@
 };
 
 // Finds the Xth client-info that is active
-static NetworkClientInfo *NetworkFindClientInfo(byte client_no)
+static const NetworkClientInfo* NetworkFindClientInfo(byte client_no)
 {
-	NetworkClientInfo *ci;
+	const NetworkClientInfo* ci;
+
 	for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) {
 		// Skip non-active items
 		if (ci->client_index == NETWORK_EMPTY_INDEX) continue;
@@ -1012,7 +1014,7 @@
 static Window *PopupClientList(Window *w, int client_no, int x, int y)
 {
 	int i, h;
-	NetworkClientInfo *ci;
+	const NetworkClientInfo* ci;
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
 
 	// Clean the current actions
--- a/order.h	Sat Nov 12 11:10:12 2005 +0000
+++ b/order.h	Sun Nov 13 13:43:55 2005 +0000
@@ -168,7 +168,7 @@
 
 /* Functions */
 void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *order);
-void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *order);
+void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* order);
 void DeleteDestinationFromVehicleOrder(Order dest);
 void InvalidateVehicleOrder(const Vehicle *v);
 bool VehicleHasDepotOrders(const Vehicle *v);
@@ -176,7 +176,7 @@
 void DeleteVehicleOrders(Vehicle *v);
 bool IsOrderListShared(const Vehicle *v);
 void AssignOrder(Order *order, Order data);
-bool CheckForValidOrders(Vehicle *v);
+bool CheckForValidOrders(const Vehicle* v);
 
 Order UnpackVersion4Order(uint16 packed);
 Order UnpackOldOrder(uint16 packed);
--- a/order_cmd.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/order_cmd.c	Sun Nov 13 13:43:55 2005 +0000
@@ -785,7 +785,7 @@
  * Restore vehicle orders that are backupped via BackupVehicleOrders
  *
  */
-void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *bak)
+void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* bak)
 {
 	uint i;
 
@@ -1100,7 +1100,7 @@
  * @return false if there are no valid orders
  *
  */
-bool CheckForValidOrders(Vehicle *v)
+bool CheckForValidOrders(const Vehicle* v)
 {
 	const Order *order;
 
--- a/player_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/player_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -421,7 +421,7 @@
 {
 	const int x = 110;
 	int y = 72;
-	Vehicle *v;
+	const Vehicle* v;
 	uint train,road,air,ship;
 
 	DrawString(x, y, STR_7039_VEHICLES, 0);
--- a/rail_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/rail_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -27,7 +27,7 @@
 static byte _waypoint_count=1;
 static byte _cur_waypoint_type;
 
-struct {
+static struct {
 	byte orientation;
 	byte numtracks;
 	byte platlength;
--- a/roadveh_cmd.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/roadveh_cmd.c	Sun Nov 13 13:43:55 2005 +0000
@@ -799,7 +799,7 @@
 	return u;
 }
 
-static void RoadVehArrivesAt(Vehicle *v, Station *st)
+static void RoadVehArrivesAt(const Vehicle* v, Station* st)
 {
 	if (v->cargo_type == CT_PASSENGERS) {
 		/* Check if station was ever visited before */
--- a/roadveh_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/roadveh_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -431,7 +431,7 @@
 
 void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
-	Vehicle *v;
+	const Vehicle* v;
 
 	if (!success) return;
 
--- a/ship_cmd.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/ship_cmd.c	Sun Nov 13 13:43:55 2005 +0000
@@ -57,10 +57,10 @@
 	return _ship_sprites[spritenum] + direction;
 }
 
-static Depot *FindClosestShipDepot(Vehicle *v)
+static const Depot* FindClosestShipDepot(const Vehicle* v)
 {
-	Depot *depot;
-	Depot *best_depot = NULL;
+	const Depot* depot;
+	const Depot* best_depot = NULL;
 	uint dist;
 	uint best_dist = (uint)-1;
 	TileIndex tile;
@@ -91,7 +91,7 @@
 
 static void CheckIfShipNeedsService(Vehicle *v)
 {
-	Depot *depot;
+	const Depot* depot;
 
 	if (_patches.servint_ships == 0)
 		return;
@@ -442,7 +442,7 @@
 	InvalidateWindowClasses(WC_SHIPS_LIST);
 }
 
-static void ShipArrivesAt(Vehicle *v, Station *st)
+static void ShipArrivesAt(const Vehicle* v, Station* st)
 {
 	/* Check if station was ever visited before */
 	if (!(st->had_vehicle_of_type & HVOT_SHIP)) {
--- a/ship_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/ship_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -28,7 +28,7 @@
 {
 	YearMonthDay ymd;
 	const ShipVehicleInfo *svi = ShipVehInfo(engine_number);
-	Engine *e;
+	const Engine* e;
 
 	/* Purchase cost - Max speed */
 	SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5);
@@ -301,7 +301,7 @@
 
 void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
-	Vehicle *v;
+	const Vehicle* v;
 	if (!success) return;
 
 	v = GetVehicle(_new_ship_id);
@@ -755,7 +755,7 @@
 
 static void ClonePlaceObj(TileIndex tile, const Window* w)
 {
-	Vehicle* v = CheckMouseOverVehicle();
+	const Vehicle* v = CheckMouseOverVehicle();
 
 	if (v != NULL) HandleCloneVehClick(v, w);
 }
--- a/station_cmd.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/station_cmd.c	Sun Nov 13 13:43:55 2005 +0000
@@ -2082,7 +2082,7 @@
 		//debug("Cust-o-mized %p", statspec);
 
 		if (statspec != NULL) {
-			Station *st = GetStation(_m[ti->tile].m2);
+			const Station* st = GetStation(_m[ti->tile].m2);
 
 			relocation = GetCustomStationRelocation(statspec, st, 0);
 			//debug("Relocation %d", relocation);
@@ -2197,7 +2197,7 @@
 	switch (mode) {
 		case TRANSPORT_RAIL:
 			if (i < 8) {
-				const byte tile_track_status_rail[8] = { 1, 2, 1, 2, 1, 2, 1, 2 };
+				static const byte tile_track_status_rail[] = { 1, 2, 1, 2, 1, 2, 1, 2 };
 				j = tile_track_status_rail[i];
 			}
 			j += (j << 8);
--- a/station_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/station_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -164,10 +164,8 @@
 
 		{
 			byte p = 0;
-			Station *st;
-			int x,xb = 2;
+			int xb = 2;
 			int y = 16; // offset from top of widget
-			int j;
 
 			if (w->vscroll.count == 0) { // player has no stations
 				DrawString(xb, y, STR_304A_NONE, 0);
@@ -178,7 +176,9 @@
 			assert(i < _num_station_sort[owner]); // at least one station must exist
 
 			while (i < _num_station_sort[owner]) { // do until max number of stations of owner
-				st = GetStation(_station_sort[i].index);
+				const Station* st = GetStation(_station_sort[i].index);
+				uint j;
+				int x;
 
 				assert(st->xy && st->owner == owner);
 
@@ -211,7 +211,8 @@
 
 			{
 				const PlayerID owner = w->window_number;
-				Station *st;
+				const Station* st;
+
 				id_v += (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list
 
 				if (id_v >= _num_station_sort[owner]) { return;} // click out of station bound
@@ -310,17 +311,13 @@
 
 static void DrawStationViewWindow(Window *w)
 {
-	Station *st;
-	int i;
-	int num;
+	StationID station_id = w->window_number;
+	const Station* st = GetStation(station_id);
+	uint i;
+	uint num;
 	int x,y;
 	int pos;
 	StringID str;
-	StationID station_id;
-
-	station_id = w->window_number;
-
-	st = GetStation(station_id);
 
 	num = 1;
 	for(i=0; i!=NUM_CARGO; i++) {
--- a/strings.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/strings.c	Sun Nov 13 13:43:55 2005 +0000
@@ -702,10 +702,9 @@
 		} break;
 
 		case 0x9A: { // {STATION}
-			Station *st;
+			const Station* st = GetStation(GetInt32(&argv));
 			int32 temp[2];
 
-			st = GetStation(GetInt32(&argv));
 			if (st->xy == 0) { // station doesn't exist anymore
 				buff = GetStringWithArgs(buff, STR_UNKNOWN_DESTINATION, NULL);
 				break;
@@ -716,10 +715,10 @@
 			break;
 		}
 		case 0x9B: { // {TOWN}
-			Town *t;
+			const Town* t = GetTown(GetInt32(&argv));
 			int32 temp[1];
-			t = GetTown(GetInt32(&argv));
 			assert(t->xy);
+
 			temp[0] = t->townnameparts;
 			buff = GetStringWithArgs(buff, t->townnametype, temp);
 			break;
--- a/subsidy_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/subsidy_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -16,7 +16,7 @@
 
 static void HandleSubsidyClick(int y)
 {
-	Subsidy *s;
+	const Subsidy* s;
 	int num,offs;
 	TileIndex xy;
 
@@ -74,12 +74,11 @@
 	}
 }
 
-static void DrawSubsidiesWindow(Window *w)
+static void DrawSubsidiesWindow(const Window* w)
 {
 	YearMonthDay ymd;
-	Subsidy *s;
+	const Subsidy* s;
 	int x,xt,y,num,x2;
-	Player *p;
 
 	DrawWindowWidgets(w);
 
@@ -114,6 +113,8 @@
 
 	for(s=_subsidies; s != endof(_subsidies); s++) {
 		if (s->cargo_type != CT_INVALID && s->age >= 12) {
+			const Player* p;
+
 			SetupSubsidyDecodeParam(s, 1);
 
 			p = GetPlayer(GetStation(s->to)->owner);
--- a/town_cmd.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/town_cmd.c	Sun Nov 13 13:43:55 2005 +0000
@@ -201,7 +201,7 @@
 
 static bool IsCloseToTown(TileIndex tile, uint dist)
 {
-	Town *t;
+	const Town* t;
 
 	FOR_ALL_TOWNS(t) {
 		if (t->xy != 0 && DistanceManhattan(tile, t->xy) < dist)
@@ -245,7 +245,8 @@
 uint32 GetWorldPopulation(void)
 {
 	uint32 pop;
-	Town *t;
+	const Town* t;
+
 	pop = 0;
 	FOR_ALL_TOWNS(t) {
 			pop += t->population;
--- a/town_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/town_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -107,7 +107,7 @@
 
 		{
 			int y;
-			Player *p;
+			const Player* p;
 			int r;
 			StringID str;
 
@@ -402,7 +402,7 @@
 
 static void MakeSortedTownList(void)
 {
-	Town *t;
+	const Town* t;
 	int n = 0;
 
 	/* Create array for sorting */
@@ -439,7 +439,7 @@
 		DoDrawString(_town_sort_order & 1 ? DOWNARROW : UPARROW, (_town_sort_order <= 1) ? 88 : 187, 15, 0x10);
 
 		{
-			Town *t;
+			const Town* t;
 			int n = 0;
 			uint16 i = w->vscroll.pos;
 			int y = 28;
@@ -486,7 +486,7 @@
 			if (id_v >= _num_town_sort) return; // click out of town bounds
 
 			{
-				Town *t = GetTown(_town_sort[id_v]);
+				const Town* t = GetTown(_town_sort[id_v]);
 				assert(t->xy);
 
 				ScrollMainWindowToTile(t->xy);
--- a/train_cmd.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/train_cmd.c	Sun Nov 13 13:43:55 2005 +0000
@@ -188,9 +188,10 @@
 	AM_BRAKE
 };
 
-static bool TrainShouldStop(Vehicle *v, TileIndex tile)
+static bool TrainShouldStop(const Vehicle* v, TileIndex tile)
 {
-	Order *o = &v->current_order;
+	const Order* o = &v->current_order;
+
 	assert(v->type == VEH_Train);
 	assert(IsTileType(v->tile, MP_STATION));
 	//When does a train drive through a station
@@ -590,9 +591,9 @@
 }
 
 // Move all free vehicles in the depot to the train
-static void NormalizeTrainVehInDepot(Vehicle *u)
+static void NormalizeTrainVehInDepot(const Vehicle* u)
 {
-	Vehicle *v;
+	const Vehicle* v;
 
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_Train && v->subtype == TS_Free_Car &&
@@ -624,7 +625,7 @@
 };
 
 
-int32 EstimateTrainCost(const RailVehicleInfo *rvi)
+static int32 EstimateTrainCost(const RailVehicleInfo* rvi)
 {
 	return (rvi->base_cost * (_price.build_railvehicle >> 3)) >> 5;
 }
@@ -1443,7 +1444,7 @@
 	}
 }
 
-TileIndex GetVehicleTileOutOfTunnel(const Vehicle *v, bool reverse)
+static TileIndex GetVehicleTileOutOfTunnel(const Vehicle* v, bool reverse)
 {
 	TileIndex tile;
 	byte direction = (!reverse) ? DirToDiagdir(v->direction) : ReverseDiagdir(v->direction >> 1);
@@ -1859,9 +1860,9 @@
 	1, 1, 1, 0, -1, -1, -1, 0
 };
 
-static void HandleLocomotiveSmokeCloud(Vehicle *v)
+static void HandleLocomotiveSmokeCloud(const Vehicle* v)
 {
-	Vehicle *u;
+	const Vehicle* u;
 
 	if (v->vehstatus & VS_TRAIN_SLOWING || v->load_unload_time_rem != 0 || v->cur_speed < 2)
 		return;
@@ -2054,7 +2055,7 @@
 	}
 }
 
-static void FillWithStationData(TrainTrackFollowerData *fd, Vehicle *v)
+static void FillWithStationData(TrainTrackFollowerData* fd, const Vehicle* v)
 {
         fd->dest_coords = v->dest_tile;
         if (v->current_order.type == OT_GOTO_STATION)
@@ -3535,7 +3536,7 @@
 
 static void CheckIfTrainNeedsService(Vehicle *v)
 {
-	Depot *depot;
+	const Depot* depot;
 	TrainFindDepotData tfdd;
 
 	if (PBSTileReserved(v->tile) & v->u.rail.track)
--- a/train_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/train_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -148,7 +148,7 @@
 
 void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
-	Vehicle *v;
+	const Vehicle* v;
 
 	if (!success)
 		return;
--- a/vehicle.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/vehicle.c	Sun Nov 13 13:43:55 2005 +0000
@@ -39,25 +39,25 @@
 #define CMD_STARTSTOP_VEH(x)  _veh_start_stop_proc_table[ x - VEH_Train]
 #define CMD_REFIT_VEH(x)		   _veh_refit_proc_table[ x - VEH_Train]
 
-static uint32 const _veh_build_proc_table[] = {
+static const uint32 _veh_build_proc_table[] = {
 	CMD_BUILD_RAIL_VEHICLE,
 	CMD_BUILD_ROAD_VEH,
 	CMD_BUILD_SHIP,
 	CMD_BUILD_AIRCRAFT,
 };
-static uint32 const _veh_sell_proc_table[] = {
+static const uint32 _veh_sell_proc_table[] = {
 	CMD_SELL_RAIL_WAGON,
 	CMD_SELL_ROAD_VEH,
 	CMD_SELL_SHIP,
 	CMD_SELL_AIRCRAFT,
 };
-static uint32 const _veh_start_stop_proc_table[] = {
+static const uint32 _veh_start_stop_proc_table[] = {
 	CMD_START_STOP_TRAIN,
 	CMD_START_STOP_ROADVEH,
 	CMD_START_STOP_SHIP,
 	CMD_START_STOP_AIRCRAFT,
 };
-static uint32 const _veh_refit_proc_table[] = {
+static const uint32 _veh_refit_proc_table[] = {
 	CMD_REFIT_RAIL_VEHICLE,
 	0,	// road vehicles can't be refitted
 	CMD_REFIT_SHIP,
@@ -107,7 +107,7 @@
 		(v->date_of_last_service + v->service_interval < _date);
 }
 
-void VehicleInTheWayErrMsg(Vehicle *v)
+void VehicleInTheWayErrMsg(const Vehicle* v)
 {
 	StringID id;
 
@@ -525,7 +525,7 @@
 	return (Vehicle*)v;
 }
 
-int CountVehiclesInChain(Vehicle *v)
+uint CountVehiclesInChain(const Vehicle* v)
 {
 	int count = 0;
 	do count++; while ( (v=v->next) != NULL);
@@ -570,7 +570,7 @@
 static void MaybeReplaceVehicle(Vehicle *v);
 
 // head of the linked list to tell what vehicles that visited a depot in a tick
-Vehicle *_first_veh_in_depot_list;
+static Vehicle* _first_veh_in_depot_list;
 
 /** Adds a vehicle to the list of vehicles, that visited a depot this tick
 * @param *v vehicle to add
--- a/vehicle.h	Sat Nov 12 11:10:12 2005 +0000
+++ b/vehicle.h	Sun Nov 13 13:43:55 2005 +0000
@@ -293,7 +293,7 @@
 Vehicle *GetLastVehicleInChain(Vehicle *v);
 Vehicle *GetPrevVehicleInChain(const Vehicle *v);
 Vehicle *GetFirstVehicleInChain(const Vehicle *v);
-int CountVehiclesInChain(Vehicle *v);
+uint CountVehiclesInChain(const Vehicle* v);
 void DeleteVehicle(Vehicle *v);
 void DeleteVehicleChain(Vehicle *v);
 void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
@@ -323,7 +323,7 @@
 
 uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
 
-void VehicleInTheWayErrMsg(Vehicle *v);
+void VehicleInTheWayErrMsg(const Vehicle* v);
 Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z);
 TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v);
 
--- a/vehicle_gui.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/vehicle_gui.c	Sun Nov 13 13:43:55 2005 +0000
@@ -490,9 +490,9 @@
 		}
 		case VEH_Road: {
 			int num = NUM_ROAD_ENGINES;
-			Engine *e = GetEngine(ROAD_ENGINES_INDEX);
+			const Engine* e = GetEngine(ROAD_ENGINES_INDEX);
 			byte cargo;
-			EngineInfo *info;
+			const EngineInfo* info;
 			engine_id = ROAD_ENGINES_INDEX;
 
 			do {
@@ -523,9 +523,9 @@
 
 		case VEH_Ship: {
 			int num = NUM_SHIP_ENGINES;
-			Engine *e = GetEngine(SHIP_ENGINES_INDEX);
+			const Engine* e = GetEngine(SHIP_ENGINES_INDEX);
 			byte cargo, refittable;
-			EngineInfo *info;
+			const EngineInfo* info;
 			engine_id = SHIP_ENGINES_INDEX;
 
 			do {
@@ -560,8 +560,8 @@
 		case VEH_Aircraft:{
 			int num = NUM_AIRCRAFT_ENGINES;
 			byte subtype;
-			Engine *e = GetEngine(AIRCRAFT_ENGINES_INDEX);
-			EngineInfo *info;
+			const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
+			const EngineInfo* info;
 			engine_id = AIRCRAFT_ENGINES_INDEX;
 
 			do {
@@ -635,10 +635,10 @@
 
 		case VEH_Road: {
 			int num = NUM_ROAD_ENGINES;
-			Engine *e = GetEngine(ROAD_ENGINES_INDEX);
+			const Engine* e = GetEngine(ROAD_ENGINES_INDEX);
 			EngineID engine_id = ROAD_ENGINES_INDEX;
 			byte cargo;
-			EngineInfo *info;
+			const EngineInfo* info;
 
 			if ( selected_id[0] >= ROAD_ENGINES_INDEX && selected_id[0] <= SHIP_ENGINES_INDEX ) {
 				cargo = RoadVehInfo(selected_id[0])->cargo_type;
@@ -671,10 +671,10 @@
 
 		case VEH_Ship: {
 			int num = NUM_SHIP_ENGINES;
-			Engine *e = GetEngine(SHIP_ENGINES_INDEX);
+			const Engine* e = GetEngine(SHIP_ENGINES_INDEX);
 			EngineID engine_id = SHIP_ENGINES_INDEX;
 			byte cargo, refittable;
-			EngineInfo *info;
+			const EngineInfo* info;
 
 			if ( selected_id[0] != -1 ) {
 				cargo = ShipVehInfo(selected_id[0])->cargo_type;
@@ -710,10 +710,10 @@
 		case VEH_Aircraft: {
 			if ( selected_id[0] != -1 ) {
 				int num = NUM_AIRCRAFT_ENGINES;
-				Engine *e = GetEngine(AIRCRAFT_ENGINES_INDEX);
+				const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
 				EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
 				byte subtype = AircraftVehInfo(selected_id[0])->subtype;
-				EngineInfo *info;
+				const EngineInfo* info;
 
 				do {
 					info = &_engine_info[engine_id];
--- a/window.c	Sat Nov 12 11:10:12 2005 +0000
+++ b/window.c	Sun Nov 13 13:43:55 2005 +0000
@@ -158,7 +158,7 @@
 
 void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom)
 {
-	Window *v = w;
+	const Window* v = w;
 	int x;
 
 	while (++v != _last_window) {
@@ -1574,7 +1574,7 @@
 
 void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index)
 {
-	Window *w;
+	const Window* w;
 
 	for(w=_windows; w!=_last_window; w++) {
 		if (w->window_class==cls && w->window_number==number) {
@@ -1585,7 +1585,7 @@
 
 void InvalidateWindowClasses(byte cls)
 {
-	Window *w;
+	const Window* w;
 	for(w=_windows; w!=_last_window; w++) {
 		if (w->window_class==cls)
 			SetWindowDirty(w);