(svn r3049) Replace byte/int/uint by RailType where appropriate
authortron
Sun, 16 Oct 2005 09:13:04 +0000
changeset 2520 75eb66d6e371
parent 2519 67a2d670c17e
child 2521 4450cdf804f6
(svn r3049) Replace byte/int/uint by RailType where appropriate
functions.h
gui.h
main_gui.c
player.h
rail.h
rail_cmd.c
rail_gui.c
station.h
station_cmd.c
train_gui.c
vehicle_gui.c
waypoint.c
waypoint.h
--- a/functions.h	Sun Oct 16 07:58:15 2005 +0000
+++ b/functions.h	Sun Oct 16 09:13:04 2005 +0000
@@ -55,13 +55,6 @@
 void DrawClearLandFence(const TileInfo *ti);
 void TileLoopClearHelper(TileIndex tile);
 
-/* station_land.c */
-void StationPickerDrawSprite(int x, int y, int railtype, int image);
-
-/* track_land.c */
-void DrawTrainDepotSprite(int x, int y, int image, int railtype);
-void DrawDefaultWaypointSprite(int x, int y, int railtype);
-
 /* road_land.c */
 void DrawRoadDepotSprite(int x, int y, int image);
 
--- a/gui.h	Sun Oct 16 07:58:15 2005 +0000
+++ b/gui.h	Sun Oct 16 09:13:04 2005 +0000
@@ -35,7 +35,7 @@
 void ShowMessageHistory(void);
 
 /* traintoolb_gui.c */
-void ShowBuildRailToolbar(int index, int button);
+void ShowBuildRailToolbar(RailType railtype, int button);
 void PlaceProc_BuyLand(TileIndex tile);
 
 /* train_gui.c */
--- a/main_gui.c	Sun Oct 16 07:58:15 2005 +0000
+++ b/main_gui.c	Sun Oct 16 09:13:04 2005 +0000
@@ -39,7 +39,7 @@
 static int _rename_what;
 
 static byte _terraform_size = 1;
-static byte _last_built_railtype;
+static RailType _last_built_railtype;
 extern void GenerateWorld(int mode, uint size_x, uint size_y);
 
 extern void GenerateIndustries(void);
--- a/player.h	Sun Oct 16 07:58:15 2005 +0000
+++ b/player.h	Sun Oct 16 09:13:04 2005 +0000
@@ -253,7 +253,7 @@
   * @param p the player "in action"
   * @return The "best" railtype a player has available
   */
-static inline byte GetBestRailtype(const Player *p)
+static inline RailType GetBestRailtype(const Player* p)
 {
 	if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
 	if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO;
--- a/rail.h	Sun Oct 16 07:58:15 2005 +0000
+++ b/rail.h	Sun Oct 16 09:13:04 2005 +0000
@@ -590,5 +590,7 @@
 }
 
 void DrawTrackBits(TileInfo *ti, TrackBits track, bool earth, bool snow, bool flat);
+void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
+void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
 
 #endif /* RAIL_H */
--- a/rail_cmd.c	Sun Oct 16 07:58:15 2005 +0000
+++ b/rail_cmd.c	Sun Oct 16 09:13:04 2005 +0000
@@ -1584,7 +1584,7 @@
 	}
 }
 
-void DrawTrainDepotSprite(int x, int y, int image, int railtype)
+void DrawTrainDepotSprite(int x, int y, int image, RailType railtype)
 {
 	uint32 ormod, img;
 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
@@ -1611,7 +1611,7 @@
 	}
 }
 
-void DrawDefaultWaypointSprite(int x, int y, int railtype)
+void DrawDefaultWaypointSprite(int x, int y, RailType railtype)
 {
 	const DrawTrackSeqStruct *dtss = _track_depot_layout_table[4];
 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
--- a/rail_gui.c	Sun Oct 16 07:58:15 2005 +0000
+++ b/rail_gui.c	Sun Oct 16 09:13:04 2005 +0000
@@ -21,7 +21,7 @@
 #include "debug.h"
 #include "variables.h"
 
-static uint _cur_railtype;
+static RailType _cur_railtype;
 static bool _remove_button_clicked;
 static byte _build_depot_direction;
 static byte _waypoint_count=1;
@@ -539,7 +539,7 @@
  * @param railtype the railtype to display
  * @param w the window to modify
  */
-static void SetupRailToolbar(uint16 railtype, Window *w)
+static void SetupRailToolbar(RailType railtype, Window *w)
 {
 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
 
@@ -555,7 +555,7 @@
 	w->widget[RTW_BUILD_TUNNEL].unkA = rti->gui_sprites.build_tunnel;
 }
 
-void ShowBuildRailToolbar(int index, int button)
+void ShowBuildRailToolbar(RailType railtype, int button)
 {
 	Window *w;
 
@@ -564,9 +564,9 @@
 	// don't recreate the window if we're clicking on a button and the window exists.
 	if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
 		DeleteWindowById(WC_BUILD_TOOLBAR, 0);
-		_cur_railtype = (byte)index;
+		_cur_railtype = railtype;
 		w = AllocateWindowDesc(&_build_rail_desc);
-		SetupRailToolbar( (byte) index, w);
+		SetupRailToolbar(railtype, w);
 	}
 
 	_remove_button_clicked = false;
@@ -763,7 +763,7 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		int r;
+		RailType r;
 
 		w->click_state = (1 << 3) << _build_depot_direction;
 		DrawWindowWidgets(w);
--- a/station.h	Sun Oct 16 07:58:15 2005 +0000
+++ b/station.h	Sun Oct 16 09:13:04 2005 +0000
@@ -193,6 +193,9 @@
 uint GetStationPlatforms(const Station *st, TileIndex tile);
 
 
+void StationPickerDrawSprite(int x, int y, RailType railtype, int image);
+
+
 /* Station layout for given dimensions - it is a two-dimensional array
  * where index is computed as (x * platforms) + platform. */
 typedef byte *StationLayout;
--- a/station_cmd.c	Sun Oct 16 07:58:15 2005 +0000
+++ b/station_cmd.c	Sun Oct 16 09:13:04 2005 +0000
@@ -2131,7 +2131,7 @@
 	uint32 image;
 	const DrawTileSeqStruct *dtss;
 	const DrawTileSprites *t = NULL;
-	byte railtype = GB(_m[ti->tile].m3, 0, 4);
+	RailType railtype = GB(_m[ti->tile].m3, 0, 4);
 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
 	SpriteID offset;
 	uint32 relocation = 0;
@@ -2203,7 +2203,7 @@
 	}
 }
 
-void StationPickerDrawSprite(int x, int y, int railtype, int image)
+void StationPickerDrawSprite(int x, int y, RailType railtype, int image)
 {
 	uint32 ormod, img;
 	const DrawTileSeqStruct *dtss;
--- a/train_gui.c	Sun Oct 16 07:58:15 2005 +0000
+++ b/train_gui.c	Sun Oct 16 09:13:04 2005 +0000
@@ -173,7 +173,7 @@
 }
 
 static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
-	EngineID* selected_id, byte railtype, byte show_max, bool is_engine)
+	EngineID* selected_id, RailType railtype, byte show_max, bool is_engine)
 {
 	EngineID i;
 
@@ -208,7 +208,7 @@
 
 		{
 			int count = 0;
-			byte railtype = WP(w,buildtrain_d).railtype;
+			RailType railtype = WP(w,buildtrain_d).railtype;
 			EngineID i;
 
 			for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
@@ -224,7 +224,7 @@
 		DrawWindowWidgets(w);
 
 		{
-			byte railtype = WP(w,buildtrain_d).railtype;
+			RailType railtype = WP(w,buildtrain_d).railtype;
 			int sel = WP(w,buildtrain_d).sel_index;
 			int pos = w->vscroll.pos;
 			int x = 1;
--- a/vehicle_gui.c	Sun Oct 16 07:58:15 2005 +0000
+++ b/vehicle_gui.c	Sun Oct 16 09:13:04 2005 +0000
@@ -25,7 +25,7 @@
 static bool   _internal_sort_order;     // descending/ascending
 
 static uint16 _player_num_engines[256];
-static byte _railtype_selected_in_replace_gui;
+static RailType _railtype_selected_in_replace_gui;
 
 
 typedef int CDECL VehicleSortListingTypeFunction(const void*, const void*);
@@ -414,7 +414,7 @@
 /*  if show_outdated is selected, it do not sort psudo engines properly but it draws all engines
  *	if used compined with show_cars set to false, it will work as intended. Replace window do it like that
  *  this was a big hack even before show_outdated was added. Stupid newgrf :p										*/
-static void train_engine_drawing_loop(int *x, int *y, int *pos, int *sel, int *selected_id, byte railtype,
+static void train_engine_drawing_loop(int *x, int *y, int *pos, int *sel, int *selected_id, RailType railtype,
 	uint8 lines_drawn, bool is_engine, bool show_cars, bool show_outdated)
 {
 	EngineID i;
@@ -462,7 +462,7 @@
 
 static void SetupScrollStuffForReplaceWindow(Window *w)
 {
-	byte railtype;
+	RailType railtype;
 	int selected_id[2] = {-1,-1};
 	int sel[2];
 	int count = 0;
@@ -625,7 +625,7 @@
 
 	switch (WP(w,replaceveh_d).vehicletype) {
 		case VEH_Train: {
-			byte railtype = _railtype_selected_in_replace_gui;
+			RailType railtype = _railtype_selected_in_replace_gui;
 			DrawString(157, 99 + (14 * w->vscroll.cap), _rail_types_list[railtype], 0x10);
 			/* draw sorting criteria string */
 
--- a/waypoint.c	Sun Oct 16 07:58:15 2005 +0000
+++ b/waypoint.c	Sun Oct 16 09:13:04 2005 +0000
@@ -360,7 +360,7 @@
 
 
 /* Draw a waypoint */
-void DrawWaypointSprite(int x, int y, int stat_id, uint railtype)
+void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
 {
 	StationSpec *stat;
 	uint32 relocation;
--- a/waypoint.h	Sun Oct 16 07:58:15 2005 +0000
+++ b/waypoint.h	Sun Oct 16 09:13:04 2005 +0000
@@ -59,7 +59,7 @@
 Station *ComposeWaypointStation(TileIndex tile);
 Waypoint *GetWaypointByTile(TileIndex tile);
 void ShowRenameWaypointWindow(const Waypoint *cp);
-void DrawWaypointSprite(int x, int y, int image, uint railtype);
+void DrawWaypointSprite(int x, int y, int image, RailType railtype);
 void UpdateWaypointSign(Waypoint *cp);
 void FixOldWaypoints(void);
 void UpdateAllWaypointSigns(void);