summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-09-18 20:56:44 +0000
committerDarkvater <darkvater@openttd.org>2005-09-18 20:56:44 +0000
commit8e6a911700de2875db95d254e5a5771e73ceedd7 (patch)
tree2e474d7261d3d1f3a5a381895f572bd5b78fe606
parent3097ee24292dc0c9fc19e98078a0403b96654787 (diff)
downloadopenttd-8e6a911700de2875db95d254e5a5771e73ceedd7.tar.xz
(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
-rw-r--r--aircraft_gui.c4
-rw-r--r--aystar.h2
-rw-r--r--callback_table.h2
-rw-r--r--clear_cmd.c8
-rw-r--r--currency.h2
-rw-r--r--debug.h2
-rw-r--r--driver.h2
-rw-r--r--dummy_land.c4
-rw-r--r--economy.c6
-rw-r--r--engine.h2
-rw-r--r--engine_gui.c8
-rw-r--r--functions.h12
-rw-r--r--gfx.c2
-rw-r--r--gfx.h4
-rw-r--r--gfxinit.h2
-rw-r--r--graph_gui.c4
-rw-r--r--industry.h2
-rw-r--r--industry_cmd.c16
-rw-r--r--lzoconf.h6
-rw-r--r--main_gui.c2
-rw-r--r--map.h2
-rw-r--r--md5.h6
-rw-r--r--minilzo.h6
-rw-r--r--mixer.h2
-rw-r--r--namegen.h2
-rw-r--r--network_client.h2
-rw-r--r--network_data.h2
-rw-r--r--network_server.h2
-rw-r--r--network_udp.h6
-rw-r--r--npf.h2
-rw-r--r--openttd.h4
-rw-r--r--order_gui.c2
-rw-r--r--pbs.h2
-rw-r--r--player.h14
-rw-r--r--player_gui.c11
-rw-r--r--players.c8
-rw-r--r--pool.h2
-rw-r--r--rail.h2
-rw-r--r--rail_cmd.c30
-rw-r--r--road_cmd.c4
-rw-r--r--roadveh_gui.c2
-rw-r--r--screenshot.h2
-rw-r--r--sdl.h2
-rw-r--r--ship_gui.c4
-rw-r--r--signs.h2
-rw-r--r--sprite.h2
-rw-r--r--spritecache.h2
-rw-r--r--station.h4
-rw-r--r--station_cmd.c48
-rw-r--r--stdafx.h30
-rw-r--r--string.h2
-rw-r--r--strings.h2
-rw-r--r--tile.h2
-rw-r--r--town.h2
-rw-r--r--town_cmd.c12
-rw-r--r--train_cmd.c4
-rw-r--r--train_gui.c2
-rw-r--r--tree_cmd.c4
-rw-r--r--tunnelbridge_cmd.c8
-rw-r--r--unmovable_cmd.c4
-rw-r--r--vehicle.c6
-rw-r--r--vehicle.h4
-rw-r--r--vehicle_gui.c2
-rw-r--r--vehicle_gui.h2
-rw-r--r--water_cmd.c6
-rw-r--r--widget.c8
-rw-r--r--win32.h2
-rw-r--r--window.c2
-rw-r--r--window.h6
69 files changed, 189 insertions, 192 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index eec495518..8d20e6dfd 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -700,7 +700,7 @@ static void DrawAircraftDepotWindow(Window *w)
}
}
-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 @@ void ShowAircraftDepotWindow(TileIndex tile)
}
}
-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;
diff --git a/aystar.h b/aystar.h
index 29a3d8990..a72f33056 100644
--- a/aystar.h
+++ b/aystar.h
@@ -182,4 +182,4 @@ void AyStarMain_Clear(AyStar *aystar);
void init_AyStar(AyStar* aystar, Hash_HashProc hash, uint num_buckets);
-#endif
+#endif /* AYSTAR_H */
diff --git a/callback_table.h b/callback_table.h
index d75147091..15c8d4d6a 100644
--- a/callback_table.h
+++ b/callback_table.h
@@ -8,4 +8,4 @@
extern CommandCallback *_callback_table[];
extern const int _callback_table_count;
-#endif
+#endif /* CALLBACK_TABLE_H */
diff --git a/clear_cmd.c b/clear_cmd.c
index c7b1208a9..47967fee4 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -483,12 +483,12 @@ int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
#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 @@ static uint GetSlopeZ_Clear(TileInfo *ti)
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 @@ static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
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;
}
diff --git a/currency.h b/currency.h
index 5b3300773..297346273 100644
--- a/currency.h
+++ b/currency.h
@@ -26,4 +26,4 @@ uint GetMaskOfAllowedCurrencies(void);
uint GetCurrentCurrencyRate(void);
void CheckSwitchToEuro(void);
-#endif
+#endif /* CURRENCY_H */
diff --git a/debug.h b/debug.h
index b89722685..d364f94c5 100644
--- a/debug.h
+++ b/debug.h
@@ -34,4 +34,4 @@ const char *GetDebugString(void);
void gpmi_debug_openttd(int level, char *s);
#endif /* GPMI */
-#endif
+#endif /* DEBUG_H */
diff --git a/driver.h b/driver.h
index fafcacdcb..23964c01a 100644
--- a/driver.h
+++ b/driver.h
@@ -10,4 +10,4 @@ int GetDriverParamInt(const char* const* parm, const char* name, int def);
void GetDriverList(char* p);
-#endif
+#endif /* DRIVER_H */
diff --git a/dummy_land.c b/dummy_land.c
index 31ce46f10..498ed6338 100644
--- a/dummy_land.c
+++ b/dummy_land.c
@@ -17,7 +17,7 @@ static uint GetSlopeZ_Dummy(TileInfo *ti) {
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 @@ static void ClickTile_Dummy(TileIndex tile)
/* 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 */
}
diff --git a/economy.c b/economy.c
index 3f4788b3b..02f7a07b0 100644
--- a/economy.c
+++ b/economy.c
@@ -555,11 +555,11 @@ void DrawNewsBankrupcy(Window *w)
}
}
-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);
diff --git a/engine.h b/engine.h
index 772cb4d7d..07196d555 100644
--- a/engine.h
+++ b/engine.h
@@ -271,4 +271,4 @@ static inline RoadVehicleInfo *RoadVehInfo(uint e)
return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
}
-#endif
+#endif /* ENGINE_H */
diff --git a/engine_gui.c b/engine_gui.c
index c8b67486b..0c89c81c5 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -165,7 +165,7 @@ void DrawNewsNewTrainAvail(Window *w)
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 @@ void DrawNewsNewAircraftAvail(Window *w)
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 @@ void DrawNewsNewRoadVehAvail(Window *w)
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 @@ void DrawNewsNewShipAvail(Window *w)
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);
diff --git a/functions.h b/functions.h
index 073a85517..8bbd67ac1 100644
--- a/functions.h
+++ b/functions.h
@@ -50,8 +50,8 @@ static inline Point RemapCoords2(int x, int y)
/* 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 @@ void TileLoop_Water(TileIndex tile);
/* 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 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold);
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);
diff --git a/gfx.c b/gfx.c
index 368aaa39b..e9f8ee98d 100644
--- a/gfx.c
+++ b/gfx.c
@@ -1991,7 +1991,7 @@ void SortResolutions(int count)
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
diff --git a/gfx.h b/gfx.h
index 92f62a4ec..c5c962315 100644
--- a/gfx.h
+++ b/gfx.h
@@ -64,7 +64,7 @@ void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, u
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 @@ typedef enum StringColorFlags {
IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor
} StringColorFlags;
-#endif
+#endif /* GFX_H */
diff --git a/gfxinit.h b/gfxinit.h
index f2756e142..f37110ba1 100644
--- a/gfxinit.h
+++ b/gfxinit.h
@@ -5,4 +5,4 @@
void GfxLoadSprites(void);
-#endif
+#endif /* GFXINIT_H */
diff --git a/graph_gui.c b/graph_gui.c
index e7b0b21f0..64e4bfdd7 100644
--- a/graph_gui.c
+++ b/graph_gui.c
@@ -44,7 +44,7 @@ typedef struct GraphDrawer {
#define INVALID_VALUE 0x80000000
-static void DrawGraph(GraphDrawer *gw)
+static void DrawGraph(const GraphDrawer *gw)
{
int i,j,k;
@@ -52,7 +52,7 @@ static void DrawGraph(GraphDrawer *gw)
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;
diff --git a/industry.h b/industry.h
index 51693c1a6..0e2fb5876 100644
--- a/industry.h
+++ b/industry.h
@@ -107,4 +107,4 @@ enum {
IT_SUGAR_MINE = 36,
};
-#endif
+#endif /* INDUSTRY_H */
diff --git a/industry_cmd.c b/industry_cmd.c
index 8a158b724..ea11fd1ee 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -255,7 +255,7 @@ static const StringID _industry_close_strings[] = {
};
-static void IndustryDrawTileProc1(TileInfo *ti)
+static void IndustryDrawTileProc1(const TileInfo *ti)
{
const DrawIndustrySpec1Struct *d;
uint32 image;
@@ -275,7 +275,7 @@ static void IndustryDrawTileProc1(TileInfo *ti)
_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 @@ static void IndustryDrawTileProc2(TileInfo *ti)
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 @@ static void IndustryDrawTileProc3(TileInfo *ti)
AddChildSpriteScreen(4746, 3, 67);
}
-static void IndustryDrawTileProc4(TileInfo *ti)
+static void IndustryDrawTileProc4(const TileInfo *ti)
{
const DrawIndustrySpec4Struct *d;
@@ -316,7 +316,7 @@ static void IndustryDrawTileProc4(TileInfo *ti)
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 @@ static void DrawCoalPlantSparkles(TileInfo *ti)
}
}
-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 @@ static uint GetSlopeZ_Industry(TileInfo *ti) {
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 @@ static void GetProducedCargo_Industry(TileIndex tile, byte *b)
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 */
}
diff --git a/lzoconf.h b/lzoconf.h
index bf4e7cabe..5cc37bb30 100644
--- a/lzoconf.h
+++ b/lzoconf.h
@@ -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 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
} /* extern "C" */
#endif
-#endif /* already included */
+#endif /* LZOCONF_H */
diff --git a/main_gui.c b/main_gui.c
index 2828386f4..1f1dd1076 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -2170,7 +2170,7 @@ static const WindowDesc _toolb_scen_desc = {
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;
diff --git a/map.h b/map.h
index 5a1705710..7d76c700c 100644
--- a/map.h
+++ b/map.h
@@ -177,4 +177,4 @@ static inline TileIndexDiff TileOffsByDir(uint dir)
* This value should be sqrt(2)/2 ~ 0.7071 */
#define STRAIGHT_TRACK_LENGTH 7071/10000
-#endif
+#endif /* MAP_H */
diff --git a/md5.h b/md5.h
index 68460b9ad..49b6b9926 100644
--- a/md5.h
+++ b/md5.h
@@ -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 @@ void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
} /* end extern "C" */
#endif
-#endif /* md5_INCLUDED */
+#endif /* MD5_INCLUDED */
diff --git a/minilzo.h b/minilzo.h
index 7d45d0c3a..3b9807f75 100644
--- a/minilzo.h
+++ b/minilzo.h
@@ -40,8 +40,8 @@
*/
-#ifndef __MINILZO_H
-#define __MINILZO_H
+#ifndef MINILZO_H
+#define MINILZO_H
#define MINILZO_VERSION 0x1080
@@ -98,5 +98,5 @@ lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len,
} /* extern "C" */
#endif
-#endif /* already included */
+#endif /* MINILZO_H */
diff --git a/mixer.h b/mixer.h
index bfd83c9e8..6228349ed 100644
--- a/mixer.h
+++ b/mixer.h
@@ -23,4 +23,4 @@ void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, uint size, uint rate, uint
void MxSetChannelVolume(MixerChannel *mc, uint left, uint right);
void MxActivateChannel(MixerChannel*);
-#endif
+#endif /* MIXER_H */
diff --git a/namegen.h b/namegen.h
index 24280a8c4..4c9a52041 100644
--- a/namegen.h
+++ b/namegen.h
@@ -7,4 +7,4 @@ typedef byte TownNameGenerator(char *buf, uint32 seed);
extern TownNameGenerator * const _town_name_generators[];
-#endif
+#endif /* NAMEGEN_H */
diff --git a/network_client.h b/network_client.h
index 75d7e88c3..2dd776ac1 100644
--- a/network_client.h
+++ b/network_client.h
@@ -22,4 +22,4 @@ void NetworkClient_Connected(void);
#endif /* ENABLE_NETWORK */
-#endif // NETWORK_CLIENT_H
+#endif /* NETWORK_CLIENT_H */
diff --git a/network_data.h b/network_data.h
index 7c074de1e..a8d748c42 100644
--- a/network_data.h
+++ b/network_data.h
@@ -231,4 +231,4 @@ unsigned long NetworkResolveHost(const char *hostname);
#endif /* ENABLE_NETWORK */
-#endif // NETWORK_DATA_H
+#endif /* NETWORK_DATA_H */
diff --git a/network_server.h b/network_server.h
index d1a1530b8..e603acb64 100644
--- a/network_server.h
+++ b/network_server.h
@@ -22,4 +22,4 @@ void NetworkServerYearlyLoop(void);
#endif /* ENABLE_NETWORK */
-#endif // NETWORK_SERVER_H
+#endif /* NETWORK_SERVER_H */
diff --git a/network_udp.h b/network_udp.h
index 827adbd55..ecf91b2cb 100644
--- a/network_udp.h
+++ b/network_udp.h
@@ -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 @@ void NetworkUDPRemoveAdvertise(void);
#endif
-#endif /* NETWORK_LAN_H */
+#endif /* NETWORK_UDP_H */
diff --git a/npf.h b/npf.h
index e47977e5d..89bcf20c6 100644
--- a/npf.h
+++ b/npf.h
@@ -121,4 +121,4 @@ static inline void NPFSetFlag(AyStarNode* node, NPFNodeFlag flag, bool value)
CLRBIT(node->user_data[NPF_NODE_FLAGS], flag);
}
-#endif // NPF_H
+#endif /* NPF_H */
diff --git a/openttd.h b/openttd.h
index 2648cfe4c..0796778db 100644
--- a/openttd.h
+++ b/openttd.h
@@ -319,14 +319,14 @@ typedef void GetProducedCargoProc(TileIndex tile, byte *b);
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;
diff --git a/order_gui.c b/order_gui.c
index b266d603b..686ed7b91 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -186,7 +186,7 @@ static void DrawOrdersWindow(Window *w)
}
}
-static Order GetOrderCmdFromTile(Vehicle *v, TileIndex tile)
+static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
{
Order order;
Station *st;
diff --git a/pbs.h b/pbs.h
index 50e0d48a2..68f0ad88b 100644
--- a/pbs.h
+++ b/pbs.h
@@ -83,4 +83,4 @@ bool PBSIsPbsSegment(uint tile, Trackdir trackdir);
* @return True when the depot is inside a pbs block
*/
-#endif
+#endif /* PBS_H */
diff --git a/player.h b/player.h
index 7b59913f0..001b43f7c 100644
--- a/player.h
+++ b/player.h
@@ -169,7 +169,7 @@ typedef struct Player {
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 @@ typedef struct Player {
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 @@ VARDEF Player _players[MAX_PLAYERS];
// 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 @@ static inline bool IsLocalPlayer(void)
/** 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 @@ byte GetPlayerRailtypes(int p);
/** 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 @@ static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_curr
* @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;
diff --git a/player_gui.c b/player_gui.c
index 650a829c3..5d9918dae 100644
--- a/player_gui.c
+++ b/player_gui.c
@@ -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 @@ static const Widget _my_player_company_bh_widgets[] = {
{ WIDGETS_END},
};
-static void DrawPlayerVehiclesAmount(int player)
+static void DrawPlayerVehiclesAmount(PlayerID player)
{
const int x = 110;
int y = 72;
@@ -470,7 +471,7 @@ static void DrawPlayerVehiclesAmount(int player)
}
}
-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 @@ int GetAmountOwnedBy(Player *p, byte owner)
(p->share_owners[3] == owner);
}
-static void DrawCompanyOwnerText(Player *p)
+static void DrawCompanyOwnerText(const Player *p)
{
int num = -1;
Player *p2;
diff --git a/players.c b/players.c
index f19ad1ebe..77d788c3f 100644
--- a/players.c
+++ b/players.c
@@ -228,7 +228,7 @@ void SubtractMoneyFromPlayer(int32 cost)
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 @@ void UpdatePlayerMoney32(Player *p)
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 @@ void GetNameOfOwner(byte owner, TileIndex tile)
}
-bool CheckOwnership(byte owner)
+bool CheckOwnership(PlayerID owner)
{
assert(owner <= OWNER_WATER);
@@ -568,7 +568,7 @@ void OnTick_Players(void)
}
// 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);
diff --git a/pool.h b/pool.h
index eebbfd374..1994a441d 100644
--- a/pool.h
+++ b/pool.h
@@ -46,7 +46,7 @@ bool AddBlockToPool(MemoryPool *array);
*/
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);
diff --git a/rail.h b/rail.h
index 6aecc6859..d7a7d6908 100644
--- a/rail.h
+++ b/rail.h
@@ -576,4 +576,4 @@ static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
return HASBIT(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype);
}
-#endif // RAIL_H
+#endif /* RAIL_H */
diff --git a/rail_cmd.c b/rail_cmd.c
index bf1a7d705..8720dae0c 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -1209,7 +1209,7 @@ static const byte _signal_position[24] = {
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 void DrawSignalHelper(TileInfo *ti, byte condition, uint32 image_and_pos)
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 @@ static void DrawTrackFence_NW(TileInfo *ti)
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 @@ static void DrawTrackFence_SE(TileInfo *ti)
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 @@ static void DrawTrackFence_NE(TileInfo *ti)
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 @@ static void DrawTrackFence_SW(TileInfo *ti)
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 @@ static void DrawTrackFence_NS_1(TileInfo *ti)
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 @@ static void DrawTrackFence_NS_2(TileInfo *ti)
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 @@ static void DrawTrackFence_WE_1(TileInfo *ti)
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 @@ static void DrawTrackFence_WE_2(TileInfo *ti)
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 @@ static uint GetSlopeZ_Track(TileInfo *ti)
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 GetTileDesc_Track(TileIndex tile, TileDesc *td)
}
}
-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;
diff --git a/road_cmd.c b/road_cmd.c
index 17aac26d6..aa60867e5 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -936,7 +936,7 @@ static uint GetSlopeZ_Road(TileInfo *ti)
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 VehicleLeave_Road(Vehicle *v, TileIndex tile, int x, int y)
}
}
-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;
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 9f86e863f..167e17ef7 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -597,7 +597,7 @@ static void DrawRoadDepotWindow(Window *w)
}
}
-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;
diff --git a/screenshot.h b/screenshot.h
index 68d39f3e6..97f5e73ba 100644
--- a/screenshot.h
+++ b/screenshot.h
@@ -15,4 +15,4 @@ extern char _screenshot_format_name[8];
extern uint _num_screenshot_formats;
extern uint _cur_screenshot_format;
-#endif
+#endif /* SCREENSHOT_H */
diff --git a/sdl.h b/sdl.h
index 995dba346..8faa85024 100644
--- a/sdl.h
+++ b/sdl.h
@@ -50,4 +50,4 @@ void SdlClose(uint32 x);
#define SDL_CALL
#endif
-#endif
+#endif /* SDL_H */
diff --git a/ship_gui.c b/ship_gui.c
index a39d94c73..8362d8409 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -673,7 +673,7 @@ static void DrawShipDepotWindow(Window *w)
}
}
-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 @@ void ShowShipDepotWindow(TileIndex tile)
}
-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;
diff --git a/signs.h b/signs.h
index 9e4e37d20..cdb00c49a 100644
--- a/signs.h
+++ b/signs.h
@@ -22,7 +22,7 @@ extern MemoryPool _sign_pool;
/**
* Check if a Sign really exists.
*/
-static inline bool IsValidSign(SignStruct* ss)
+static inline bool IsValidSign(const SignStruct* ss)
{
return ss->str != 0;
}
diff --git a/sprite.h b/sprite.h
index 5d21dcee5..68c7848d1 100644
--- a/sprite.h
+++ b/sprite.h
@@ -153,4 +153,4 @@ SpriteGroup *EvalRandomizedSpriteGroup(const RandomizedSpriteGroup *rsg, byte ra
* (then they are |ed to @waiting_triggers instead). */
byte RandomizedSpriteGroupTriggeredBits(const RandomizedSpriteGroup *rsg, byte triggers, byte *waiting_triggers);
-#endif
+#endif /* SPRITE_H */
diff --git a/spritecache.h b/spritecache.h
index ebc37de2b..93df8c106 100644
--- a/spritecache.h
+++ b/spritecache.h
@@ -31,4 +31,4 @@ bool LoadNextSprite(int load_index, byte file_index);
void DupSprite(SpriteID old, SpriteID new);
void SkipSprites(uint count);
-#endif
+#endif /* SPRITECACHE_H */
diff --git a/station.h b/station.h
index 0f9e1848f..15989193f 100644
--- a/station.h
+++ b/station.h
@@ -190,7 +190,7 @@ VARDEF bool _global_station_sort_dirty;
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 @@ StationSpec *GetCustomStation(StationClass sclass, byte stid);
/* 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);
diff --git a/station_cmd.c b/station_cmd.c
index 1abdee7e4..699ef71b4 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -1090,7 +1090,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdRemoveFromRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32
}
// 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 @@ StationSpec *GetCustomStation(StationClass sclass, byte stid)
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 @@ static RealSpriteGroup *ResolveStationSpriteGroup(SpriteGroup *spritegroup, Stat
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 @@ static RealSpriteGroup *ResolveStationSpriteGroup(SpriteGroup *spritegroup, Stat
// 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 @@ static RealSpriteGroup *ResolveStationSpriteGroup(SpriteGroup *spritegroup, Stat
}
target = value != -1 ? EvalDeterministicSpriteGroup(dsg, value) : dsg->default_group;
- return ResolveStationSpriteGroup(target, stat);
+ return ResolveStationSpriteGroup(target, st);
}
default:
@@ -1344,18 +1344,14 @@ static RealSpriteGroup *ResolveStationSpriteGroup(SpriteGroup *spritegroup, Stat
}
}
-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 @@ static uint GetSlopeZ_Station(TileInfo *ti)
return z;
}
-static uint GetSlopeTileh_Station(TileInfo *ti)
+static uint GetSlopeTileh_Station(const TileInfo *ti)
{
return 0;
}
@@ -2952,7 +2948,7 @@ void DeleteOilRig(TileIndex tile)
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;
diff --git a/stdafx.h b/stdafx.h
index b085d18f8..bc2b4c243 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -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 @@ assert_compile(sizeof(uint8) == 1);
#define Point OTTD_AMIGA_POINT
#endif
-#endif // !defined(_STDAFX_H)
+#endif /* STDAFX_H */
diff --git a/string.h b/string.h
index a3f8264d7..1b673a8c0 100644
--- a/string.h
+++ b/string.h
@@ -25,4 +25,4 @@ char* strecpy(char* dst, const char* src, const char* last);
char* CDECL str_fmt(const char* str, ...);
-#endif
+#endif /* STRING_H */
diff --git a/strings.h b/strings.h
index 6bb6a62e6..f984bd480 100644
--- a/strings.h
+++ b/strings.h
@@ -19,4 +19,4 @@ extern char _userstring[128];
void InjectDParam(int amount);
int32 GetParamInt32(void);
-#endif
+#endif /* STRINGS_H */
diff --git a/tile.h b/tile.h
index 4dc3218cd..11607ce39 100644
--- a/tile.h
+++ b/tile.h
@@ -127,4 +127,4 @@ static inline bool IsTileOwner(TileIndex tile, Owner owner)
return GetTileOwner(tile) == owner;
}
-#endif
+#endif /* TILE_H */
diff --git a/town.h b/town.h
index 25c835ae1..89a5cbb1c 100644
--- a/town.h
+++ b/town.h
@@ -138,7 +138,7 @@ extern MemoryPool _town_pool;
/**
* 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 */
}
diff --git a/town_cmd.c b/town_cmd.c
index 2a4ca21e0..b95270c0a 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -76,12 +76,12 @@ typedef struct DrawTownTileStruct {
#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 @@ static uint GetSlopeZ_Town(TileInfo *ti)
return (uint16) z;
}
-static uint GetSlopeTileh_Town(TileInfo *ti)
+static uint GetSlopeTileh_Town(const TileInfo *ti)
{
return ti->tileh;
}
@@ -400,7 +400,7 @@ static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode)
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 @@ static bool CheckBuildHouseMode(Town *t1, TileIndex tile, uint tileh, int mode)
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 @@ int GetTownRadiusGroup(Town *t, TileIndex tile)
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;
}
diff --git a/train_cmd.c b/train_cmd.c
index c37d5d221..716c795b7 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -2407,14 +2407,14 @@ static int GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile)
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;
diff --git a/train_gui.c b/train_gui.c
index 978591633..f3b80206b 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -466,7 +466,7 @@ typedef struct GetDepotVehiclePtData {
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;
diff --git a/tree_cmd.c b/tree_cmd.c
index 0406ec240..efc180ebc 100644
--- a/tree_cmd.c
+++ b/tree_cmd.c
@@ -343,7 +343,7 @@ static uint GetSlopeZ_Trees(TileInfo *ti) {
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 @@ static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode)
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 */
}
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index fa451b330..4b2d84f27 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -956,7 +956,7 @@ static const byte _bridge_foundations[2][16] = {
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 @@ static uint GetSlopeZ_TunnelBridge(TileInfo *ti) {
// 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 @@ static uint GetSlopeZ_TunnelBridge(TileInfo *ti) {
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 @@ static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode
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;
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 5d69dbad1..1df55d764 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -193,7 +193,7 @@ static uint GetSlopeZ_Unmovable(TileInfo *ti)
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 @@ restart:
} 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;
diff --git a/vehicle.c b/vehicle.c
index 131b9a51a..b80426a43 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -556,7 +556,7 @@ bool CanRefitTo(const Vehicle *v, CargoID cid_to)
return true;
}
-static void DoDrawVehicle(Vehicle *v)
+static void DoDrawVehicle(const Vehicle *v)
{
uint32 image = v->cur_image;
@@ -1819,7 +1819,7 @@ void EndVehicleMove(Vehicle *v)
}
/* 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 @@ static const byte _new_direction_table[9] = {
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;
diff --git a/vehicle.h b/vehicle.h
index 796315552..c61a672f0 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -350,8 +350,8 @@ typedef struct GetNewVehiclePosResult {
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);
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 064ad0f18..5cf2b5dae 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -165,7 +165,7 @@ void InitializeVehiclesGuiList(void)
}
// 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;
diff --git a/vehicle_gui.h b/vehicle_gui.h
index caa245055..ccb0d889b 100644
--- a/vehicle_gui.h
+++ b/vehicle_gui.h
@@ -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);
diff --git a/water_cmd.c b/water_cmd.c
index e8243dad9..5c9e18861 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -388,7 +388,7 @@ typedef struct LocksDrawTileStruct {
#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 @@ static uint GetSlopeZ_Water(TileInfo *ti)
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 ClickTile_Water(TileIndex tile)
}
}
-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;
diff --git a/widget.c b/widget.c
index 3f8fc7dc2..d0b331905 100644
--- a/widget.c
+++ b/widget.c
@@ -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 @@ void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y)
* @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 @@ int GetWidgetFromPos(Window *w, int x, int y)
}
-void DrawWindowWidgets(Window *w)
+void DrawWindowWidgets(const Window *w)
{
const Widget *wi;
DrawPixelInfo *dpi = _cur_dpi;
@@ -457,7 +457,7 @@ static const Widget _dropdown_menu_widgets[] = {
{ WIDGETS_END},
};
-static int GetDropdownItem(Window *w)
+static int GetDropdownItem(const Window *w)
{
uint item;
int y;
diff --git a/win32.h b/win32.h
index f28481ff4..be308af78 100644
--- a/win32.h
+++ b/win32.h
@@ -8,4 +8,4 @@ bool MyShowCursor(bool show);
typedef void (*Function)(int);
bool LoadLibraryList(Function proc[], const char* dll);
-#endif
+#endif /* WIN32_H */
diff --git a/window.c b/window.c
index 04f679c5e..349f28d6c 100644
--- a/window.c
+++ b/window.c
@@ -1529,7 +1529,7 @@ void UpdateWindows(void)
}
-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;
diff --git a/window.h b/window.h
index f4b9c35c5..ccb14e81a 100644
--- a/window.h
+++ b/window.h
@@ -602,7 +602,7 @@ void DrawWindowViewport(Window *w);
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 @@ void RelocateAllWindows(int neww, int newh);
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);