(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
authorDarkvater
Sun, 18 Sep 2005 20:56:44 +0000
changeset 2436 7d5df545bd5d
parent 2435 9b9d43988058
child 2437 15ebf7766f40
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
- change a lot of byte player types to PlayerID
- beautify header files, same "#endif /* filename */" ending
aircraft_gui.c
aystar.h
callback_table.h
clear_cmd.c
currency.h
debug.h
driver.h
dummy_land.c
economy.c
engine.h
engine_gui.c
functions.h
gfx.c
gfx.h
gfxinit.h
graph_gui.c
industry.h
industry_cmd.c
lzoconf.h
main_gui.c
map.h
md5.h
minilzo.h
mixer.h
namegen.h
network_client.h
network_data.h
network_server.h
network_udp.h
npf.h
openttd.h
order_gui.c
pbs.h
player.h
player_gui.c
players.c
pool.h
rail.h
rail_cmd.c
road_cmd.c
roadveh_gui.c
screenshot.h
sdl.h
ship_gui.c
signs.h
sprite.h
spritecache.h
station.h
station_cmd.c
stdafx.h
string.h
strings.h
tile.h
town.h
town_cmd.c
train_cmd.c
train_gui.c
tree_cmd.c
tunnelbridge_cmd.c
unmovable_cmd.c
vehicle.c
vehicle.h
vehicle_gui.c
vehicle_gui.h
water_cmd.c
widget.c
win32.h
window.c
window.h
--- a/aircraft_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/aircraft_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -700,7 +700,7 @@
 	}
 }
 
-static int GetVehicleFromAircraftDepotWndPt(Window *w, int x, int y, Vehicle **veh) {
+static int GetVehicleFromAircraftDepotWndPt(const Window *w, int x, int y, Vehicle **veh) {
 	uint xt,row,xm,ym;
 	Vehicle *v;
 	TileIndex tile;
@@ -951,7 +951,7 @@
 	}
 }
 
-static void DrawSmallOrderList(Vehicle *v, int x, int y) {
+static void DrawSmallOrderList(const Vehicle *v, int x, int y) {
 	const Order *order;
 	int sel, i = 0;
 
--- a/aystar.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/aystar.h	Sun Sep 18 20:56:44 2005 +0000
@@ -182,4 +182,4 @@
 void init_AyStar(AyStar* aystar, Hash_HashProc hash, uint num_buckets);
 
 
-#endif
+#endif /* AYSTAR_H */
--- a/callback_table.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/callback_table.h	Sun Sep 18 20:56:44 2005 +0000
@@ -8,4 +8,4 @@
 extern CommandCallback *_callback_table[];
 extern const int _callback_table_count;
 
-#endif
+#endif /* CALLBACK_TABLE_H */
--- a/clear_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/clear_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -483,12 +483,12 @@
 #include "table/clear_land.h"
 
 
-void DrawClearLandTile(TileInfo *ti, byte set)
+void DrawClearLandTile(const TileInfo *ti, byte set)
 {
 	DrawGroundSprite(0xF54 + _tileh_to_sprite[ti->tileh] + set * 19);
 }
 
-void DrawHillyLandTile(TileInfo *ti)
+void DrawHillyLandTile(const TileInfo *ti)
 {
 	if (ti->tileh != 0) {
 		DrawGroundSprite(0xFA0 + _tileh_to_sprite[ti->tileh]);
@@ -553,7 +553,7 @@
 	return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Clear(TileInfo *ti)
+static uint GetSlopeTileh_Clear(const TileInfo *ti)
 {
 	return ti->tileh;
 }
@@ -831,7 +831,7 @@
 	td->owner = GetTileOwner(tile);
 }
 
-static void ChangeTileOwner_Clear(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	return;
 }
--- a/currency.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/currency.h	Sun Sep 18 20:56:44 2005 +0000
@@ -26,4 +26,4 @@
 uint GetCurrentCurrencyRate(void);
 void CheckSwitchToEuro(void);
 
-#endif
+#endif /* CURRENCY_H */
--- a/debug.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/debug.h	Sun Sep 18 20:56:44 2005 +0000
@@ -34,4 +34,4 @@
 void gpmi_debug_openttd(int level, char *s);
 #endif /* GPMI */
 
-#endif
+#endif /* DEBUG_H */
--- a/driver.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/driver.h	Sun Sep 18 20:56:44 2005 +0000
@@ -10,4 +10,4 @@
 
 void GetDriverList(char* p);
 
-#endif
+#endif /* DRIVER_H */
--- a/dummy_land.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/dummy_land.c	Sun Sep 18 20:56:44 2005 +0000
@@ -17,7 +17,7 @@
 	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Dummy(TileInfo *ti) {
+static uint GetSlopeTileh_Dummy(const TileInfo *ti) {
 	return ti->tileh;
 }
 
@@ -53,7 +53,7 @@
 	/* not used */
 }
 
-static void ChangeTileOwner_Dummy(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Dummy(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	/* not used */
 }
--- a/economy.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/economy.c	Sun Sep 18 20:56:44 2005 +0000
@@ -555,11 +555,11 @@
 	}
 }
 
-StringID GetNewsStringBankrupcy(NewsItem *ni)
+StringID GetNewsStringBankrupcy(const NewsItem *ni)
 {
-	Player *p = GetPlayer(ni->string_id & 0xF);
+	const Player *p = GetPlayer(ni->string_id & 0xF);
 
-	switch(ni->string_id >> 4) {
+	switch (ni->string_id >> 4) {
 	case 1:
 		SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE);
 		SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED);
--- a/engine.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/engine.h	Sun Sep 18 20:56:44 2005 +0000
@@ -271,4 +271,4 @@
 	return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
 }
 
-#endif
+#endif /* ENGINE_H */
--- a/engine_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/engine_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -165,7 +165,7 @@
 	DrawTrainEngineInfo(engine, w->width >> 1, 129, w->width - 52);
 }
 
-StringID GetNewsStringNewTrainAvail(NewsItem *ni)
+StringID GetNewsStringNewTrainAvail(const NewsItem *ni)
 {
 	int engine = ni->string_id;
 	SetDParam(0, STR_8859_NEW_NOW_AVAILABLE);
@@ -205,7 +205,7 @@
 	DrawAircraftEngineInfo(engine, w->width >> 1, 131, w->width - 52);
 }
 
-StringID GetNewsStringNewAircraftAvail(NewsItem *ni)
+StringID GetNewsStringNewAircraftAvail(const NewsItem *ni)
 {
 	int engine = ni->string_id;
 	SetDParam(0, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE);
@@ -245,7 +245,7 @@
 	DrawRoadVehEngineInfo(engine, w->width >> 1, 129, w->width - 52);
 }
 
-StringID GetNewsStringNewRoadVehAvail(NewsItem *ni)
+StringID GetNewsStringNewRoadVehAvail(const NewsItem *ni)
 {
 	int engine = ni->string_id;
 	SetDParam(0, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE);
@@ -283,7 +283,7 @@
 	DrawShipEngineInfo(engine, w->width >> 1, 131, w->width - 52);
 }
 
-StringID GetNewsStringNewShipAvail(NewsItem *ni)
+StringID GetNewsStringNewShipAvail(const NewsItem *ni)
 {
 	int engine = ni->string_id;
 	SetDParam(0, STR_982C_NEW_SHIP_NOW_AVAILABLE);
--- a/functions.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/functions.h	Sun Sep 18 20:56:44 2005 +0000
@@ -50,8 +50,8 @@
 
 
 /* clear_land.c */
-void DrawHillyLandTile(TileInfo *ti);
-void DrawClearLandTile(TileInfo *ti, byte set);
+void DrawHillyLandTile(const TileInfo *ti);
+void DrawClearLandTile(const TileInfo *ti, byte set);
 void DrawClearLandFence(const TileInfo *ti);
 void TileLoopClearHelper(TileIndex tile);
 
@@ -72,10 +72,10 @@
 /* players.c */
 bool CheckPlayerHasMoney(int32 cost);
 void SubtractMoneyFromPlayer(int32 cost);
-void SubtractMoneyFromPlayerFract(byte player, int32 cost);
-bool CheckOwnership(byte owner);
+void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost);
+bool CheckOwnership(PlayerID owner);
 bool CheckTileOwnership(TileIndex tile);
-StringID GetPlayerNameString(byte player, byte index);
+StringID GetPlayerNameString(PlayerID player, PlayerID index);
 
 /* standard */
 void ShowInfo(const char *str);
@@ -229,7 +229,7 @@
 void ChangeTownRating(Town *t, int add, int max);
 
 uint GetRoadBitsByTile(TileIndex tile);
-int GetTownRadiusGroup(Town *t, TileIndex tile);
+int GetTownRadiusGroup(const Town *t, TileIndex tile);
 void ShowNetworkChatQueryWindow(byte desttype, byte dest);
 void ShowNetworkGiveMoneyWindow(byte player);
 void ShowNetworkNeedGamePassword(void);
--- a/gfx.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/gfx.c	Sun Sep 18 20:56:44 2005 +0000
@@ -1991,7 +1991,7 @@
 	qsort(_resolutions, count, sizeof(_resolutions[0]), compare_res);
 }
 
-uint16 GetDrawStringPlayerColor(byte player)
+uint16 GetDrawStringPlayerColor(PlayerID player)
 {
 	// Get the color for DrawString-subroutines which matches the color
 	//  of the player
--- a/gfx.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/gfx.h	Sun Sep 18 20:56:44 2005 +0000
@@ -64,7 +64,7 @@
 void GfxFillRect(int left, int top, int right, int bottom, int color);
 void GfxDrawLine(int left, int top, int right, int bottom, int color);
 void DrawFrameRect(int left, int top, int right, int bottom, int color, int flags);
-uint16 GetDrawStringPlayerColor(byte player);
+uint16 GetDrawStringPlayerColor(PlayerID player);
 
 int GetStringWidth(const char *str);
 void LoadStringWidthTable(void);
@@ -124,4 +124,4 @@
 	IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor
 } StringColorFlags;
 
-#endif
+#endif /* GFX_H */
--- a/gfxinit.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/gfxinit.h	Sun Sep 18 20:56:44 2005 +0000
@@ -5,4 +5,4 @@
 
 void GfxLoadSprites(void);
 
-#endif
+#endif /* GFXINIT_H */
--- a/graph_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/graph_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -44,7 +44,7 @@
 
 #define INVALID_VALUE 0x80000000
 
-static void DrawGraph(GraphDrawer *gw)
+static void DrawGraph(const GraphDrawer *gw)
 {
 
 	int i,j,k;
@@ -52,7 +52,7 @@
 	int color;
 	int right, bottom;
 	int num_x, num_dataset;
-	uint64 *row_ptr, *col_ptr;
+	const uint64 *row_ptr, *col_ptr;
 	int64 mx;
 	int adj_height;
 	uint64 y_scaling, tmp;
--- a/industry.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/industry.h	Sun Sep 18 20:56:44 2005 +0000
@@ -107,4 +107,4 @@
 	IT_SUGAR_MINE = 36,
 };
 
-#endif
+#endif /* INDUSTRY_H */
--- a/industry_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/industry_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -255,7 +255,7 @@
 };
 
 
-static void IndustryDrawTileProc1(TileInfo *ti)
+static void IndustryDrawTileProc1(const TileInfo *ti)
 {
 	const DrawIndustrySpec1Struct *d;
 	uint32 image;
@@ -275,7 +275,7 @@
 			_drawtile_proc1_x[image-1], _drawtile_proc1_y[image-1]);
 }
 
-static void IndustryDrawTileProc2(TileInfo *ti)
+static void IndustryDrawTileProc2(const TileInfo *ti)
 {
 	int x = 0;
 
@@ -289,7 +289,7 @@
 	AddChildSpriteScreen(0x129E, 6, 0xE);
 }
 
-static void IndustryDrawTileProc3(TileInfo *ti)
+static void IndustryDrawTileProc3(const TileInfo *ti)
 {
 	if (_m[ti->tile].m1 & 0x80) {
 		AddChildSpriteScreen(0x128B, 5,
@@ -298,7 +298,7 @@
 	AddChildSpriteScreen(4746, 3, 67);
 }
 
-static void IndustryDrawTileProc4(TileInfo *ti)
+static void IndustryDrawTileProc4(const TileInfo *ti)
 {
 	const DrawIndustrySpec4Struct *d;
 
@@ -316,7 +316,7 @@
 	AddChildSpriteScreen(0x126D, 0, 42);
 }
 
-static void DrawCoalPlantSparkles(TileInfo *ti)
+static void DrawCoalPlantSparkles(const TileInfo *ti)
 {
 	int image = _m[ti->tile].m1;
 	if (image & 0x80) {
@@ -330,7 +330,7 @@
 	}
 }
 
-typedef void IndustryDrawTileProc(TileInfo *ti);
+typedef void IndustryDrawTileProc(const TileInfo *ti);
 static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = {
 	IndustryDrawTileProc1,
 	IndustryDrawTileProc2,
@@ -402,7 +402,7 @@
 	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Industry(TileInfo *ti) {
+static uint GetSlopeTileh_Industry(const TileInfo *ti) {
 	return 0;
 }
 
@@ -866,7 +866,7 @@
 	b[1] = i->produced_cargo[1];
 }
 
-static void ChangeTileOwner_Industry(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Industry(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	/* not used */
 }
--- a/lzoconf.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/lzoconf.h	Sun Sep 18 20:56:44 2005 +0000
@@ -34,8 +34,8 @@
  */
 
 
-#ifndef __LZOCONF_H
-#define __LZOCONF_H
+#ifndef LZOCONF_H
+#define LZOCONF_H
 
 #define LZO_VERSION             0x1080
 #define LZO_VERSION_STRING      "1.08"
@@ -449,5 +449,5 @@
 } /* extern "C" */
 #endif
 
-#endif /* already included */
+#endif /* LZOCONF_H */
 
--- a/main_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/main_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -2170,7 +2170,7 @@
 extern GetNewsStringCallbackProc * const _get_news_string_callback[];
 
 
-static bool DrawScrollingStatusText(NewsItem *ni, int pos)
+static bool DrawScrollingStatusText(const NewsItem *ni, int pos)
 {
 	char buf[512];
 	StringID str;
--- a/map.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/map.h	Sun Sep 18 20:56:44 2005 +0000
@@ -177,4 +177,4 @@
  * This value should be sqrt(2)/2 ~ 0.7071 */
 #define STRAIGHT_TRACK_LENGTH 7071/10000
 
-#endif
+#endif /* MAP_H */
--- a/md5.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/md5.h	Sun Sep 18 20:56:44 2005 +0000
@@ -49,8 +49,8 @@
   1999-05-03 lpd Original version.
  */
 
-#ifndef md5_INCLUDED
-#  define md5_INCLUDED
+#ifndef MD5_INCLUDED
+#define MD5_INCLUDED
 
 /*
  * This package supports both compile-time and run-time determination of CPU
@@ -90,4 +90,4 @@
 }  /* end extern "C" */
 #endif
 
-#endif /* md5_INCLUDED */
+#endif /* MD5_INCLUDED */
--- a/minilzo.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/minilzo.h	Sun Sep 18 20:56:44 2005 +0000
@@ -40,8 +40,8 @@
  */
 
 
-#ifndef __MINILZO_H
-#define __MINILZO_H
+#ifndef MINILZO_H
+#define MINILZO_H
 
 #define MINILZO_VERSION         0x1080
 
@@ -98,5 +98,5 @@
 } /* extern "C" */
 #endif
 
-#endif /* already included */
+#endif /* MINILZO_H */
 
--- a/mixer.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/mixer.h	Sun Sep 18 20:56:44 2005 +0000
@@ -23,4 +23,4 @@
 void MxSetChannelVolume(MixerChannel *mc, uint left, uint right);
 void MxActivateChannel(MixerChannel*);
 
-#endif
+#endif /* MIXER_H */
--- a/namegen.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/namegen.h	Sun Sep 18 20:56:44 2005 +0000
@@ -7,4 +7,4 @@
 
 extern TownNameGenerator * const _town_name_generators[];
 
-#endif
+#endif /* NAMEGEN_H */
--- a/network_client.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/network_client.h	Sun Sep 18 20:56:44 2005 +0000
@@ -22,4 +22,4 @@
 
 #endif /* ENABLE_NETWORK */
 
-#endif // NETWORK_CLIENT_H
+#endif /* NETWORK_CLIENT_H */
--- a/network_data.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/network_data.h	Sun Sep 18 20:56:44 2005 +0000
@@ -231,4 +231,4 @@
 
 #endif /* ENABLE_NETWORK */
 
-#endif // NETWORK_DATA_H
+#endif /* NETWORK_DATA_H */
--- a/network_server.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/network_server.h	Sun Sep 18 20:56:44 2005 +0000
@@ -22,4 +22,4 @@
 
 #endif /* ENABLE_NETWORK */
 
-#endif // NETWORK_SERVER_H
+#endif /* NETWORK_SERVER_H */
--- a/network_udp.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/network_udp.h	Sun Sep 18 20:56:44 2005 +0000
@@ -1,7 +1,7 @@
 /* $Id$ */
 
-#ifndef NETWORK_LAN_H
-#define NETWORK_LAN_H
+#ifndef NETWORK_UDP_H
+#define NETWORK_UDP_H
 
 #ifdef ENABLE_NETWORK
 
@@ -16,4 +16,4 @@
 
 #endif
 
-#endif /* NETWORK_LAN_H */
+#endif /* NETWORK_UDP_H */
--- a/npf.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/npf.h	Sun Sep 18 20:56:44 2005 +0000
@@ -121,4 +121,4 @@
 		CLRBIT(node->user_data[NPF_NODE_FLAGS], flag);
 }
 
-#endif // NPF_H
+#endif /* NPF_H */
--- a/openttd.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/openttd.h	Sun Sep 18 20:56:44 2005 +0000
@@ -319,14 +319,14 @@
 typedef void ClickTileProc(TileIndex tile);
 typedef void AnimateTileProc(TileIndex tile);
 typedef void TileLoopProc(TileIndex tile);
-typedef void ChangeTileOwnerProc(TileIndex tile, byte old_player, byte new_player);
+typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
 /* Return value has bit 0x2 set, when the vehicle enters a station. Then,
  * result << 8 contains the id of the station entered. If the return value has
  * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
  * other bits that can be set? */
 typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
 typedef void VehicleLeaveTileProc(Vehicle *v, TileIndex tile, int x, int y);
-typedef uint GetSlopeTilehProc(TileInfo *ti);
+typedef uint GetSlopeTilehProc(const TileInfo *ti);
 
 typedef struct {
 	DrawTileProc *draw_tile_proc;
--- a/order_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/order_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -186,7 +186,7 @@
 	}
 }
 
-static Order GetOrderCmdFromTile(Vehicle *v, TileIndex tile)
+static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
 {
 	Order order;
 	Station *st;
--- a/pbs.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/pbs.h	Sun Sep 18 20:56:44 2005 +0000
@@ -83,4 +83,4 @@
  * @return True when the depot is inside a pbs block
  */
 
-#endif
+#endif /* PBS_H */
--- a/player.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/player.h	Sun Sep 18 20:56:44 2005 +0000
@@ -169,7 +169,7 @@
 	TileIndex location_of_house;
 	TileIndex last_build_coordinate;
 
-	byte share_owners[4];
+	PlayerID share_owners[4];
 
 	byte inaugurated_year;
 	byte num_valid_stat_ent;
@@ -193,8 +193,8 @@
 	uint32 engine_renew_money;
 } Player;
 
-void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player);
-void GetNameOfOwner(byte owner, TileIndex tile);
+void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player);
+void GetNameOfOwner(PlayerID owner, TileIndex tile);
 int64 CalculateCompanyValue(Player *p);
 void InvalidatePlayerWindows(Player *p);
 void AiDoGameLoop(Player *p);
@@ -209,7 +209,7 @@
 // NOSAVE: can be determined from player structs
 VARDEF byte _player_colors[MAX_PLAYERS];
 
-static inline Player* GetPlayer(uint i)
+static inline Player* GetPlayer(PlayerID i)
 {
 	assert(i < lengthof(_players));
 	return &_players[i];
@@ -223,7 +223,7 @@
 /** Returns the number of rail types the player can build
   * @param *p Player in question
   */
-static inline int GetNumRailtypes(Player *p)
+static inline int GetNumRailtypes(const Player *p)
 {
 	int num = 0;
 	int i;
@@ -239,7 +239,7 @@
 
 /** Finds out if a Player has a certain railtype available
   */
-static inline bool HasRailtypeAvail(Player *p, RailType Railtype)
+static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
 {
 	return HASBIT(p->avail_railtypes, Railtype);
 }
@@ -254,7 +254,7 @@
   * @param p the player "in action"
   * @return The "best" railtype a player has available
   */
-static inline byte GetBestRailtype(Player *p)
+static inline byte GetBestRailtype(const Player *p)
 {
 	if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
 	if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO;
--- a/player_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/player_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -24,10 +24,11 @@
 static void DoShowPlayerFinances(int player, bool show_small, bool show_stickied);
 
 
-static void DrawPlayerEconomyStats(Player *p, byte mode)
+static void DrawPlayerEconomyStats(const Player *p, byte mode)
 {
 	int x,y,i,j,year;
-	int64 (*tbl)[13], sum,cost;
+	const int64 (*tbl)[13];
+	int64 sum, cost;
 	StringID str;
 
 	if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status
@@ -415,7 +416,7 @@
 {   WIDGETS_END},
 };
 
-static void DrawPlayerVehiclesAmount(int player)
+static void DrawPlayerVehiclesAmount(PlayerID player)
 {
 	const int x = 110;
 	int y = 72;
@@ -470,7 +471,7 @@
 	}
 }
 
-int GetAmountOwnedBy(Player *p, byte owner)
+int GetAmountOwnedBy(const Player *p, PlayerID owner)
 {
 	return (p->share_owners[0] == owner) +
 				 (p->share_owners[1] == owner) +
@@ -478,7 +479,7 @@
 				 (p->share_owners[3] == owner);
 }
 
-static void DrawCompanyOwnerText(Player *p)
+static void DrawCompanyOwnerText(const Player *p)
 {
 	int num = -1;
 	Player *p2;
--- a/players.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/players.c	Sun Sep 18 20:56:44 2005 +0000
@@ -228,7 +228,7 @@
 		SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
 }
 
-void SubtractMoneyFromPlayerFract(byte player, int32 cost)
+void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost)
 {
 	Player *p = GetPlayer(player);
 	byte m = p->player_money_fraction;
@@ -251,7 +251,7 @@
 		p->player_money = (int32)p->money64;
 }
 
-void GetNameOfOwner(byte owner, TileIndex tile)
+void GetNameOfOwner(PlayerID owner, TileIndex tile)
 {
 	SetDParam(2, owner);
 
@@ -271,7 +271,7 @@
 }
 
 
-bool CheckOwnership(byte owner)
+bool CheckOwnership(PlayerID owner)
 {
 	assert(owner <= OWNER_WATER);
 
@@ -568,7 +568,7 @@
 }
 
 // index is the next parameter in _decode_parameters to set up
-StringID GetPlayerNameString(byte player, byte index)
+StringID GetPlayerNameString(PlayerID player, PlayerID index)
 {
 	if (IS_HUMAN_PLAYER(player) && player < MAX_PLAYERS) {
 		SetDParam(index, player+1);
--- a/pool.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/pool.h	Sun Sep 18 20:56:44 2005 +0000
@@ -46,7 +46,7 @@
  */
 bool AddBlockIfNeeded(MemoryPool *array, uint index);
 
-static inline byte *GetItemFromPool(MemoryPool *pool, uint index)
+static inline byte *GetItemFromPool(const MemoryPool *pool, uint index)
 {
 	assert(index < pool->total_items);
 	return (pool->blocks[index >> pool->block_size_bits] + (index & ((1 << pool->block_size_bits) - 1)) * pool->item_size);
--- a/rail.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/rail.h	Sun Sep 18 20:56:44 2005 +0000
@@ -576,4 +576,4 @@
 	return HASBIT(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype);
 }
 
-#endif // RAIL_H
+#endif /* RAIL_H */
--- a/rail_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/rail_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -1209,7 +1209,7 @@
 	0x1E,0xAC,0x64,0xE1,0x4A,0x10,0xEE,0xC5,0xDB,0x34,0x4D,0xB3
 };
 
-static void DrawSignalHelper(TileInfo *ti, byte condition, uint32 image_and_pos)
+static void DrawSignalHelper(const TileInfo *ti, byte condition, uint32 image_and_pos)
 {
 	bool otherside = _opt.road_side & _patches.signal_side;
 
@@ -1223,7 +1223,7 @@
 static uint32 _drawtile_track_palette;
 
 
-static void DrawTrackFence_NW(TileInfo *ti)
+static void DrawTrackFence_NW(const TileInfo *ti)
 {
 	uint32 image = 0x515;
 	if (ti->tileh != 0) {
@@ -1236,7 +1236,7 @@
 		ti->x, ti->y+1, 16, 1, 4, ti->z);
 }
 
-static void DrawTrackFence_SE(TileInfo *ti)
+static void DrawTrackFence_SE(const TileInfo *ti)
 {
 	uint32 image = 0x515;
 	if (ti->tileh != 0) {
@@ -1249,13 +1249,13 @@
 		ti->x, ti->y+15, 16, 1, 4, ti->z);
 }
 
-static void DrawTrackFence_NW_SE(TileInfo *ti)
+static void DrawTrackFence_NW_SE(const TileInfo *ti)
 {
 	DrawTrackFence_NW(ti);
 	DrawTrackFence_SE(ti);
 }
 
-static void DrawTrackFence_NE(TileInfo *ti)
+static void DrawTrackFence_NE(const TileInfo *ti)
 {
 	uint32 image = 0x516;
 	if (ti->tileh != 0) {
@@ -1268,7 +1268,7 @@
 		ti->x+1, ti->y, 1, 16, 4, ti->z);
 }
 
-static void DrawTrackFence_SW(TileInfo *ti)
+static void DrawTrackFence_SW(const TileInfo *ti)
 {
 	uint32 image = 0x516;
 	if (ti->tileh != 0) {
@@ -1281,13 +1281,13 @@
 		ti->x+15, ti->y, 1, 16, 4, ti->z);
 }
 
-static void DrawTrackFence_NE_SW(TileInfo *ti)
+static void DrawTrackFence_NE_SW(const TileInfo *ti)
 {
 	DrawTrackFence_NE(ti);
 	DrawTrackFence_SW(ti);
 }
 
-static void DrawTrackFence_NS_1(TileInfo *ti)
+static void DrawTrackFence_NS_1(const TileInfo *ti)
 {
 	int z = ti->z;
 	if (ti->tileh & 1)
@@ -1296,7 +1296,7 @@
 		ti->x + 8, ti->y + 8, 1, 1, 4, z);
 }
 
-static void DrawTrackFence_NS_2(TileInfo *ti)
+static void DrawTrackFence_NS_2(const TileInfo *ti)
 {
 	int z = ti->z;
 	if (ti->tileh & 4)
@@ -1305,7 +1305,7 @@
 		ti->x + 8, ti->y + 8, 1, 1, 4, z);
 }
 
-static void DrawTrackFence_WE_1(TileInfo *ti)
+static void DrawTrackFence_WE_1(const TileInfo *ti)
 {
 	int z = ti->z;
 	if (ti->tileh & 8)
@@ -1314,7 +1314,7 @@
 		ti->x + 8, ti->y + 8, 1, 1, 4, z);
 }
 
-static void DrawTrackFence_WE_2(TileInfo *ti)
+static void DrawTrackFence_WE_2(const TileInfo *ti)
 {
 	int z = ti->z;
 	if (ti->tileh & 2)
@@ -1323,12 +1323,12 @@
 		ti->x + 8, ti->y + 8, 1, 1, 4, z);
 }
 
-static void DetTrackDrawProc_Null(TileInfo *ti)
+static void DetTrackDrawProc_Null(const TileInfo *ti)
 {
 	/* nothing should be here */
 }
 
-typedef void DetailedTrackProc(TileInfo *ti);
+typedef void DetailedTrackProc(const TileInfo *ti);
 DetailedTrackProc * const _detailed_track_proc[16] = {
 	DetTrackDrawProc_Null,
 	DetTrackDrawProc_Null,
@@ -1943,7 +1943,7 @@
 	return z;
 }
 
-static uint GetSlopeTileh_Track(TileInfo *ti)
+static uint GetSlopeTileh_Track(const TileInfo *ti)
 {
 	// check if it's a foundation
 	if (ti->tileh != 0) {
@@ -2146,7 +2146,7 @@
 	}
 }
 
-static void ChangeTileOwner_Track(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Track(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	if (!IsTileOwner(tile, old_player)) return;
 
--- a/road_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/road_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -936,7 +936,7 @@
 	return z; // normal Z if no slope
 }
 
-static uint GetSlopeTileh_Road(TileInfo *ti)
+static uint GetSlopeTileh_Road(const TileInfo *ti)
 {
 	// check if it's a foundation
 	if (ti->tileh != 0) {
@@ -1166,7 +1166,7 @@
 	}
 }
 
-static void ChangeTileOwner_Road(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	byte b;
 
--- a/roadveh_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/roadveh_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -597,7 +597,7 @@
 	}
 }
 
-static int GetVehicleFromRoadDepotWndPt(Window *w, int x, int y, Vehicle **veh)
+static int GetVehicleFromRoadDepotWndPt(const Window *w, int x, int y, Vehicle **veh)
 {
 	uint xt,row,xm;
 	TileIndex tile;
--- a/screenshot.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/screenshot.h	Sun Sep 18 20:56:44 2005 +0000
@@ -15,4 +15,4 @@
 extern uint _num_screenshot_formats;
 extern uint _cur_screenshot_format;
 
-#endif
+#endif /* SCREENSHOT_H */
--- a/sdl.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/sdl.h	Sun Sep 18 20:56:44 2005 +0000
@@ -50,4 +50,4 @@
 	#define SDL_CALL
 #endif
 
-#endif
+#endif /* SDL_H */
--- a/ship_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/ship_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -673,7 +673,7 @@
 	}
 }
 
-static int GetVehicleFromShipDepotWndPt(Window *w, int x, int y, Vehicle **veh)
+static int GetVehicleFromShipDepotWndPt(const Window *w, int x, int y, Vehicle **veh)
 {
 	uint xt,row,xm,ym;
 	TileIndex tile;
@@ -928,7 +928,7 @@
 }
 
 
-static void DrawSmallOrderList(Vehicle *v, int x, int y) {
+static void DrawSmallOrderList(const Vehicle *v, int x, int y) {
 	const Order *order;
 	int sel, i = 0;
 
--- a/signs.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/signs.h	Sun Sep 18 20:56:44 2005 +0000
@@ -22,7 +22,7 @@
 /**
  * Check if a Sign really exists.
  */
-static inline bool IsValidSign(SignStruct* ss)
+static inline bool IsValidSign(const SignStruct* ss)
 {
 	return ss->str != 0;
 }
--- a/sprite.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/sprite.h	Sun Sep 18 20:56:44 2005 +0000
@@ -153,4 +153,4 @@
  * (then they are |ed to @waiting_triggers instead). */
 byte RandomizedSpriteGroupTriggeredBits(const RandomizedSpriteGroup *rsg, byte triggers, byte *waiting_triggers);
 
-#endif
+#endif /* SPRITE_H */
--- a/spritecache.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/spritecache.h	Sun Sep 18 20:56:44 2005 +0000
@@ -31,4 +31,4 @@
 void DupSprite(SpriteID old, SpriteID new);
 void SkipSprites(uint count);
 
-#endif
+#endif /* SPRITECACHE_H */
--- a/station.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/station.h	Sun Sep 18 20:56:44 2005 +0000
@@ -190,7 +190,7 @@
 
 void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad);
 void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
-uint GetStationPlatforms(Station *st, TileIndex tile);
+uint GetStationPlatforms(const Station *st, TileIndex tile);
 
 
 /* Station layout for given dimensions - it is a two-dimensional array
@@ -267,7 +267,7 @@
 /* Get sprite offset for a given custom station and station structure (may be
  * NULL if ctype is set - that means we are in a build dialog). The station
  * structure is used for variational sprite groups. */
-uint32 GetCustomStationRelocation(StationSpec *spec, Station *stat, byte ctype);
+uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, byte ctype);
 int GetCustomStationsCount(StationClass sclass);
 
 RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type);
--- a/station_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/station_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -1090,7 +1090,7 @@
 	return cost;
 }
 
-static bool TileBelongsToRailStation(Station *st, TileIndex tile)
+static bool TileBelongsToRailStation(const Station *st, TileIndex tile)
 {
 	return IsTileType(tile, MP_STATION) && _m[tile].m2 == st->index && _m[tile].m5 < 8;
 }
@@ -1188,7 +1188,7 @@
 }
 
 // determine the number of platforms for the station
-uint GetStationPlatforms(Station *st, TileIndex tile)
+uint GetStationPlatforms(const Station *st, TileIndex tile)
 {
 	uint t;
 	int dir,delta;
@@ -1264,14 +1264,14 @@
 	return &_station_spec[sclass][stid];
 }
 
-static RealSpriteGroup *ResolveStationSpriteGroup(SpriteGroup *spritegroup, Station *stat)
+static const RealSpriteGroup *ResolveStationSpriteGroup(const SpriteGroup *spg, const Station *st)
 {
-	switch (spritegroup->type) {
+	switch (spg->type) {
 		case SGT_REAL:
-			return &spritegroup->g.real;
+			return &spg->g.real;
 
 		case SGT_DETERMINISTIC: {
-			DeterministicSpriteGroup *dsg = &spritegroup->g.determ;
+			const DeterministicSpriteGroup *dsg = &spg->g.determ;
 			SpriteGroup *target;
 			int value = -1;
 
@@ -1280,7 +1280,7 @@
 				value = GetDeterministicSpriteValue(dsg->variable);
 
 			} else {
-				if (stat == NULL) {
+				if (st == NULL) {
 					/* We are in a build dialog of something,
 					 * and we are checking for something undefined.
 					 * That means we should get the first target
@@ -1308,25 +1308,25 @@
 						// Variable is 0x70 + offset in the TTD's station structure
 						switch (dsg->variable - 0x70) {
 							case 0x80:
-								value = stat->facilities;
+								value = st->facilities;
 								break;
 							case 0x81:
-								value = stat->airport_type;
+								value = st->airport_type;
 								break;
 							case 0x82:
-								value = stat->truck_stops->status;
+								value = st->truck_stops->status;
 								break;
 							case 0x83:
-								value = stat->bus_stops->status;
+								value = st->bus_stops->status;
 								break;
 							case 0x86:
-								value = stat->airport_flags & 0xFFFF;
+								value = st->airport_flags & 0xFFFF;
 								break;
 							case 0x87:
-								value = stat->airport_flags & 0xFF;
+								value = st->airport_flags & 0xFF;
 								break;
 							case 0x8A:
-								value = stat->build_date;
+								value = st->build_date;
 								break;
 						}
 					}
@@ -1334,7 +1334,7 @@
 			}
 
 			target = value != -1 ? EvalDeterministicSpriteGroup(dsg, value) : dsg->default_group;
-			return ResolveStationSpriteGroup(target, stat);
+			return ResolveStationSpriteGroup(target, st);
 		}
 
 		default:
@@ -1344,18 +1344,14 @@
 	}
 }
 
-uint32 GetCustomStationRelocation(StationSpec *spec, Station *stat, byte ctype)
+uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, byte ctype)
 {
-	RealSpriteGroup *rsg;
-
-	rsg = ResolveStationSpriteGroup(&spec->spritegroup[ctype], stat);
+	const RealSpriteGroup *rsg = ResolveStationSpriteGroup(&spec->spritegroup[ctype], st);
 
 	if (rsg->sprites_per_set != 0) {
-		if (rsg->loading_count != 0) {
-			return rsg->loading[0];
-		} else if (rsg->loaded_count != 0) {
-			return rsg->loaded[0];
-		}
+		if (rsg->loading_count != 0) return rsg->loading[0];
+
+		if (rsg->loaded_count != 0) return rsg->loaded[0];
 	}
 
 	error("Custom station 0x%08x::0x%02x has no sprites associated.",
@@ -2237,7 +2233,7 @@
 	return z;
 }
 
-static uint GetSlopeTileh_Station(TileInfo *ti)
+static uint GetSlopeTileh_Station(const TileInfo *ti)
 {
 	return 0;
 }
@@ -2952,7 +2948,7 @@
 	DeleteStation(st);
 }
 
-static void ChangeTileOwner_Station(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	if (!IsTileOwner(tile, old_player)) return;
 
--- a/stdafx.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/stdafx.h	Sun Sep 18 20:56:44 2005 +0000
@@ -1,22 +1,22 @@
 /* $Id$ */
 
-#if !defined(_STDAFX_H)
-#define _STDAFX_H
+#ifndef STDAFX_H
+#define STDAFX_H
 
 #if defined(_MSC_VER)
-#pragma once
+	#pragma once
 
-#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
-#pragma warning(disable: 4100) // parameter not used
-#pragma warning(disable: 4244) // conversion
-#pragma warning(disable: 4245) // conversion
-#pragma warning(disable: 4305) // 'initializing' : truncation from 'const int ' to 'char '
-#pragma warning(disable: 4018) // warning C4018: '==' : signed/unsigned mismatch
-#pragma warning(disable: 4201) // nameless union
-#pragma warning(disable: 4514) // removed unref inline
-#pragma warning(disable: 4127) // constant conditional expression
-#pragma warning(disable: 4276) // MSVC BUG??? Complains about function body not declared when using function pointers
-#pragma warning(disable: 4761) // warning C4761: integral size mismatch in argument; conversion supplied
+	#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
+	#pragma warning(disable: 4018) // 'expression' : signed/unsigned mismatch
+	#pragma warning(disable: 4100) // 'identifier' : unreferenced formal parameter
+	#pragma warning(disable: 4127) // conditional expression is constant
+	#pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union
+	#pragma warning(disable: 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data
+	#pragma warning(disable: 4245) // 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
+	#pragma warning(disable: 4276) // 'fucntion' : no prototype provided; assumed no parameters (MSVC BUG???)
+	#pragma warning(disable: 4305) // 'identifier' : truncation from 'type1' to 'type2'
+	#pragma warning(disable: 4514) // 'function' : unreferenced inline function has been removed
+	#pragma warning(disable: 4761) // integral size mismatch in argument : conversion supplied
 #endif
 
 #include <stdio.h>
@@ -252,4 +252,4 @@
 #define Point OTTD_AMIGA_POINT
 #endif
 
-#endif // !defined(_STDAFX_H)
+#endif /* STDAFX_H */
--- a/string.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/string.h	Sun Sep 18 20:56:44 2005 +0000
@@ -25,4 +25,4 @@
 
 char* CDECL str_fmt(const char* str, ...);
 
-#endif
+#endif /* STRING_H */
--- a/strings.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/strings.h	Sun Sep 18 20:56:44 2005 +0000
@@ -19,4 +19,4 @@
 void InjectDParam(int amount);
 int32 GetParamInt32(void);
 
-#endif
+#endif /* STRINGS_H */
--- a/tile.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/tile.h	Sun Sep 18 20:56:44 2005 +0000
@@ -127,4 +127,4 @@
 	return GetTileOwner(tile) == owner;
 }
 
-#endif
+#endif /* TILE_H */
--- a/town.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/town.h	Sun Sep 18 20:56:44 2005 +0000
@@ -138,7 +138,7 @@
 /**
  * Check if a Town really exists.
  */
-static inline bool IsValidTown(Town* town)
+static inline bool IsValidTown(const Town* town)
 {
 	return town->xy != 0; /* XXX: Replace by INVALID_TILE someday */
 }
--- a/town_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/town_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -76,12 +76,12 @@
 #include "table/town_land.h"
 
 
-static void TownDrawHouseLift(TileInfo *ti)
+static void TownDrawHouseLift(const TileInfo *ti)
 {
 	AddChildSpriteScreen(0x5A3, 0xE, 0x3C - (_m[ti->tile].m1 & 0x7F));
 }
 
-typedef void TownDrawTileProc(TileInfo *ti);
+typedef void TownDrawTileProc(const TileInfo *ti);
 static TownDrawTileProc * const _town_draw_tile_procs[1] = {
 	TownDrawHouseLift
 };
@@ -150,7 +150,7 @@
 	return (uint16) z;
 }
 
-static uint GetSlopeTileh_Town(TileInfo *ti)
+static uint GetSlopeTileh_Town(const TileInfo *ti)
 {
 	return ti->tileh;
 }
@@ -400,7 +400,7 @@
 	return 0;
 }
 
-static void ChangeTileOwner_Town(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Town(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	/* not used */
 }
@@ -1155,7 +1155,7 @@
 	return DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR) != CMD_ERROR;
 }
 
-int GetTownRadiusGroup(Town *t, TileIndex tile)
+int GetTownRadiusGroup(const Town *t, TileIndex tile)
 {
 	uint dist;
 	int i,smallest;
@@ -1165,7 +1165,7 @@
 		return 4;
 
 	smallest = 0;
-	for(i=0; i!=lengthof(t->radius); i++) {
+	for (i = 0; i != lengthof(t->radius); i++) {
 		if (dist < t->radius[i])
 			smallest = i;
 	}
--- a/train_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/train_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -2407,14 +2407,14 @@
 	return _new_vehicle_direction_table[offs];
 }
 
-static int GetNewVehicleDirection(Vehicle *v, int x, int y)
+static int GetNewVehicleDirection(const Vehicle *v, int x, int y)
 {
 	uint offs = (y - v->y_pos + 1) * 4 + (x - v->x_pos + 1);
 	assert(offs < 11);
 	return _new_vehicle_direction_table[offs];
 }
 
-static int GetDirectionToVehicle(Vehicle *v, int x, int y)
+static int GetDirectionToVehicle(const Vehicle *v, int x, int y)
 {
 	byte offs;
 
--- a/train_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/train_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -466,7 +466,7 @@
 	Vehicle *wagon;
 } GetDepotVehiclePtData;
 
-static int GetVehicleFromTrainDepotWndPt(Window *w, int x, int y, GetDepotVehiclePtData *d)
+static int GetVehicleFromTrainDepotWndPt(const Window *w, int x, int y, GetDepotVehiclePtData *d)
 {
 	int row;
 	int skip = 0;
--- a/tree_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/tree_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -343,7 +343,7 @@
 	return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Trees(TileInfo *ti) {
+static uint GetSlopeTileh_Trees(const TileInfo *ti) {
 	return ti->tileh;
 }
 
@@ -617,7 +617,7 @@
 	return 0;
 }
 
-static void ChangeTileOwner_Trees(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Trees(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	/* not used */
 }
--- a/tunnelbridge_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/tunnelbridge_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -956,7 +956,7 @@
 
 extern const byte _road_sloped_sprites[14];
 
-static void DrawBridgePillars(TileInfo *ti, int x, int y, int z)
+static void DrawBridgePillars(const TileInfo *ti, int x, int y, int z)
 {
 	const uint32 *b;
 	uint32 image;
@@ -1229,7 +1229,7 @@
 					// make sure that the slope is not inclined foundation
 					if (IS_BYTE_INSIDE(f, 1, 15)) return z;
 
-					// change foundation type?
+					// change foundation type? XXX - should be const; accessor function!
 					if (f) ti->tileh = _inclined_tileh[f - 15];
 				}
 
@@ -1252,7 +1252,7 @@
 	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + z;
 }
 
-static uint GetSlopeTileh_TunnelBridge(TileInfo *ti) {
+static uint GetSlopeTileh_TunnelBridge(const TileInfo *ti) {
 	// not accurate, but good enough for slope graphics drawing
 	return 0;
 }
@@ -1397,7 +1397,7 @@
 	return 0;
 }
 
-static void ChangeTileOwner_TunnelBridge(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	if (!IsTileOwner(tile, old_player)) return;
 
--- a/unmovable_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/unmovable_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -193,7 +193,7 @@
 	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Unmovable(TileInfo *ti)
+static uint GetSlopeTileh_Unmovable(const TileInfo *ti)
 {
 	return 0;
 }
@@ -393,7 +393,7 @@
 	} while (--i);
 }
 
-static void ChangeTileOwner_Unmovable(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Unmovable(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	if (!IsTileOwner(tile, old_player)) return;
 
--- a/vehicle.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/vehicle.c	Sun Sep 18 20:56:44 2005 +0000
@@ -556,7 +556,7 @@
 	return true;
 }
 
-static void DoDrawVehicle(Vehicle *v)
+static void DoDrawVehicle(const Vehicle *v)
 {
 	uint32 image = v->cur_image;
 
@@ -1819,7 +1819,7 @@
 }
 
 /* returns true if staying in the same tile */
-bool GetNewVehiclePos(Vehicle *v, GetNewVehiclePosResult *gp)
+bool GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp)
 {
 	static const int8 _delta_coord[16] = {
 		-1,-1,-1, 0, 1, 1, 1, 0, /* x */
@@ -1842,7 +1842,7 @@
 	2, 3, 4,
 };
 
-byte GetDirectionTowards(Vehicle *v, int x, int y)
+byte GetDirectionTowards(const Vehicle *v, int x, int y)
 {
 	byte dirdiff, dir;
 	int i = 0;
--- a/vehicle.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/vehicle.h	Sun Sep 18 20:56:44 2005 +0000
@@ -350,8 +350,8 @@
 Trackdir GetVehicleTrackdir(const Vehicle* v);
 
 /* returns true if staying in the same tile */
-bool GetNewVehiclePos(Vehicle *v, GetNewVehiclePosResult *gp);
-byte GetDirectionTowards(Vehicle *v, int x, int y);
+bool GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp);
+byte GetDirectionTowards(const Vehicle *v, int x, int y);
 
 #define BEGIN_ENUM_WAGONS(v) do {
 #define END_ENUM_WAGONS(v) } while ( (v=v->next) != NULL);
--- a/vehicle_gui.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/vehicle_gui.c	Sun Sep 18 20:56:44 2005 +0000
@@ -165,7 +165,7 @@
 }
 
 // draw the vehicle profit button in the vehicle list window.
-void DrawVehicleProfitButton(Vehicle *v, int x, int y)
+void DrawVehicleProfitButton(const Vehicle *v, int x, int y)
 {
 	uint32 ormod;
 
--- a/vehicle_gui.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/vehicle_gui.h	Sun Sep 18 20:56:44 2005 +0000
@@ -7,7 +7,7 @@
 
 struct vehiclelist_d;
 
-void DrawVehicleProfitButton(Vehicle *v, int x, int y);
+void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
 CargoID DrawVehicleRefitWindow(const Vehicle *v, int sel);
 void InitializeVehiclesGuiList(void);
 
--- a/water_cmd.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/water_cmd.c	Sun Sep 18 20:56:44 2005 +0000
@@ -388,7 +388,7 @@
 
 #include "table/water_land.h"
 
-static void DrawWaterStuff(TileInfo *ti, const WaterDrawTileStruct *wdts,
+static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
 	uint32 palette, uint base
 )
 {
@@ -451,7 +451,7 @@
 	return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
 }
 
-static uint GetSlopeTileh_Water(TileInfo *ti)
+static uint GetSlopeTileh_Water(const TileInfo *ti)
 {
 	return ti->tileh;
 }
@@ -693,7 +693,7 @@
 	}
 }
 
-static void ChangeTileOwner_Water(TileIndex tile, byte old_player, byte new_player)
+static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID new_player)
 {
 	if (!IsTileOwner(tile, old_player)) return;
 
--- a/widget.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/widget.c	Sun Sep 18 20:56:44 2005 +0000
@@ -10,7 +10,7 @@
 #include "gfx.h"
 #include "viewport.h"
 
-static Point HandleScrollbarHittest(Scrollbar *sb, int top, int bottom)
+static Point HandleScrollbarHittest(const Scrollbar *sb, int top, int bottom)
 {
 	Point pt;
 	int height, count, pos, cap;
@@ -135,7 +135,7 @@
  * @param  x,y Window client coordinates
  * @return A widget index, or -1 if no widget was found.
  */
-int GetWidgetFromPos(Window *w, int x, int y)
+int GetWidgetFromPos(const Window *w, int x, int y)
 {
 	const Widget *wi;
 	int index, found_index = -1;
@@ -156,7 +156,7 @@
 }
 
 
-void DrawWindowWidgets(Window *w)
+void DrawWindowWidgets(const Window *w)
 {
 	const Widget *wi;
 	DrawPixelInfo *dpi = _cur_dpi;
@@ -457,7 +457,7 @@
 {   WIDGETS_END},
 };
 
-static int GetDropdownItem(Window *w)
+static int GetDropdownItem(const Window *w)
 {
 	uint item;
 	int y;
--- a/win32.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/win32.h	Sun Sep 18 20:56:44 2005 +0000
@@ -8,4 +8,4 @@
 typedef void (*Function)(int);
 bool LoadLibraryList(Function proc[], const char* dll);
 
-#endif
+#endif /* WIN32_H */
--- a/window.c	Sat Sep 17 13:57:01 2005 +0000
+++ b/window.c	Sun Sep 18 20:56:44 2005 +0000
@@ -1529,7 +1529,7 @@
 }
 
 
-int GetMenuItemIndex(Window *w, int x, int y)
+int GetMenuItemIndex(const Window *w, int x, int y)
 {
 	if ((x -= w->left) >= 0 && x < w->width && (y -= w->top + 1) >= 0) {
 		y /= 10;
--- a/window.h	Sat Sep 17 13:57:01 2005 +0000
+++ b/window.h	Sun Sep 18 20:56:44 2005 +0000
@@ -602,7 +602,7 @@
 void InitWindowSystem(void);
 void UnInitWindowSystem(void);
 void ResetWindowSystem(void);
-int GetMenuItemIndex(Window *w, int x, int y);
+int GetMenuItemIndex(const Window *w, int x, int y);
 void InputLoop(void);
 void UpdateWindows(void);
 void InvalidateWidget(Window *w, byte widget_index);
@@ -615,8 +615,8 @@
 int PositionMainToolbar(Window *w);
 
 /* widget.c */
-int GetWidgetFromPos(Window *w, int x, int y);
-void DrawWindowWidgets(Window *w);
+int GetWidgetFromPos(const Window *w, int x, int y);
+void DrawWindowWidgets(const Window *w);
 void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, bool remove_filtered_strings);
 
 void HandleButtonClick(Window *w, byte widget);