(svn r2781) Fix some of the issues with variables in .h files.
authorludde
Mon, 01 Aug 2005 16:31:19 +0000
changeset 2261 d3554e5d3e86
parent 2260 10154bc4c650
child 2262 252cfd94c54d
(svn r2781) Fix some of the issues with variables in .h files.
aircraft_gui.c
economy.c
economy.h
functions.h
graph_gui.c
gui.h
main_gui.c
misc_gui.c
pathfind.c
rail_cmd.c
roadveh_gui.c
ship_gui.c
table/track_land.h
table/water_land.h
train_cmd.c
train_gui.c
tunnelbridge_cmd.c
vehicle.c
video/dedicated_v.c
water_cmd.c
waypoint.c
--- a/aircraft_gui.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/aircraft_gui.c	Mon Aug 01 16:31:19 2005 +0000
@@ -613,7 +613,7 @@
 		DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
 		DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
 		break;
-		
+
 		       case WE_MOUSELOOP:
                {
                        Vehicle *v;
@@ -817,11 +817,11 @@
 			ResetObjectToPlace();
 			ShowBuildAircraftWindow(w->window_number);
 			break;
-			
+
 				case 8: /* clone button */
 			InvalidateWidget(w, 8);
 				TOGGLEBIT(w->click_state, 8);
-				
+
 				if (HASBIT(w->click_state, 8)) {
 					_place_clicked_vehicle = NULL;
 					SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w);
@@ -845,7 +845,7 @@
 		CLRBIT(w->click_state, 8);
 		InvalidateWidget(w, 8);
 	} break;
-	
+
 	// check if a vehicle in a depot was clicked..
 	case WE_MOUSELOOP: {
 		Vehicle *v = _place_clicked_vehicle;
@@ -855,7 +855,7 @@
 			HandleCloneVehClick( v, w);
 		}
 	} break;
-	
+
 	case WE_DESTROY:
 		DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
 		break;
--- a/economy.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/economy.c	Mon Aug 01 16:31:19 2005 +0000
@@ -25,6 +25,23 @@
 #include "variables.h"
 #include "vehicle_gui.h"
 
+// Score info
+const ScoreInfo _score_info[] = {
+    {SCORE_VEHICLES,		120, 			100},
+    {SCORE_STATIONS,		80, 			100},
+    {SCORE_MIN_PROFIT,	10000,		100},
+    {SCORE_MIN_INCOME,	50000,		50},
+    {SCORE_MAX_INCOME,	100000,		100},
+    {SCORE_DELIVERED,		40000, 		400},
+    {SCORE_CARGO,				8,				50},
+    {SCORE_MONEY,				10000000,	50},
+    {SCORE_LOAN,				250000,		50},
+    {SCORE_TOTAL,				0,				0}
+};
+
+int _score_part[MAX_PLAYERS][NUM_SCORE];
+
+
 // get a mask of the allowed currencies depending on the year
 uint GetMaskOfAllowedCurrencies(void)
 {
@@ -129,7 +146,7 @@
 /* Count vehicles */
 	{
 		Vehicle *v;
-		int32 min_profit = score_info[SCORE_MIN_PROFIT].needed;
+		int32 min_profit = _score_info[SCORE_MIN_PROFIT].needed;
 		uint num = 0;
 
 		FOR_ALL_VEHICLES(v) {
@@ -228,7 +245,7 @@
 
 /* Generate score for loan */
 	{
-		_score_part[owner][SCORE_LOAN] = score_info[SCORE_LOAN].needed - p->current_loan;
+		_score_part[owner][SCORE_LOAN] = _score_info[SCORE_LOAN].needed - p->current_loan;
 	}
 
 	// Now we calculate the score for each item..
@@ -241,10 +258,12 @@
 			// Skip the total
 			if (i == SCORE_TOTAL) continue;
 			// Check the score
-			s = (_score_part[owner][i] >= score_info[i].needed) ? score_info[i].score : ((_score_part[owner][i] * score_info[i].score) / score_info[i].needed);
+			s = (_score_part[owner][i] >= _score_info[i].needed) ?
+				_score_info[i].score :
+				((_score_part[owner][i] * _score_info[i].score) / _score_info[i].needed);
 			if (s < 0) s = 0;
 			score += s;
-			total_score += score_info[i].score;
+			total_score += _score_info[i].score;
 		}
 
 		_score_part[owner][SCORE_TOTAL] = score;
--- a/economy.h	Mon Aug 01 13:01:14 2005 +0000
+++ b/economy.h	Mon Aug 01 16:31:19 2005 +0000
@@ -49,20 +49,8 @@
     int score;			// How much score it will give
 } ScoreInfo;
 
-static const ScoreInfo score_info[] = {
-    {SCORE_VEHICLES,		120, 			100},
-    {SCORE_STATIONS,		80, 			100},
-    {SCORE_MIN_PROFIT,	10000,		100},
-    {SCORE_MIN_INCOME,	50000,		50},
-    {SCORE_MAX_INCOME,	100000,		100},
-    {SCORE_DELIVERED,		40000, 		400},
-    {SCORE_CARGO,				8,				50},
-    {SCORE_MONEY,				10000000,	50},
-    {SCORE_LOAN,				250000,		50},
-    {SCORE_TOTAL,				0,				0}
-};
-
-int _score_part[MAX_PLAYERS][NUM_SCORE];
+extern const ScoreInfo _score_info[];
+extern int _score_part[MAX_PLAYERS][NUM_SCORE];
 
 int UpdateCompanyRatingAndValue(Player *p, bool update);
 void UpdatePlayerHouse(Player *p, uint score);
--- a/functions.h	Mon Aug 01 13:01:14 2005 +0000
+++ b/functions.h	Mon Aug 01 16:31:19 2005 +0000
@@ -60,6 +60,7 @@
 
 /* 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/graph_gui.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/graph_gui.c	Mon Aug 01 16:31:19 2005 +0000
@@ -936,8 +936,8 @@
 		for (i=0;i<NUM_SCORE;i++) {
 			y += 20;
     		val = _score_part[owner][i];
-    		needed = score_info[i].needed;
-    		score = score_info[i].score;
+    		needed = _score_info[i].needed;
+    		score = _score_info[i].score;
     		// SCORE_TOTAL has his own rulez ;)
     		if (i == SCORE_TOTAL) {
     			needed = total_score;
--- a/gui.h	Mon Aug 01 13:01:14 2005 +0000
+++ b/gui.h	Mon Aug 01 16:31:19 2005 +0000
@@ -121,8 +121,7 @@
 void SetFiosType(const byte fiostype);
 
 /*	FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE etc. different colours */
-static const byte _fios_colors[] = {13, 9, 9, 6, 5, 6, 5};
-
+extern const byte _fios_colors[];
 
 /* network gui */
 void ShowNetworkGameWindow(void);
--- a/main_gui.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/main_gui.c	Mon Aug 01 16:31:19 2005 +0000
@@ -29,9 +29,6 @@
 #include "network_client.h"
 #include "network_server.h"
 
-#include "table/animcursors.h"
-
-
 /* Min/Max date for scenario editor */
 static const uint MinDate = 0;     // 1920-01-01 (MAX_YEAR_BEGIN_REAL)
 static const uint MaxDate = 29220; // 2000-01-01
--- a/misc_gui.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/misc_gui.c	Mon Aug 01 16:31:19 2005 +0000
@@ -1158,6 +1158,9 @@
 };
 
 
+// Colors for fios types
+const byte _fios_colors[] = {13, 9, 9, 6, 5, 6, 5};
+
 void BuildFileList(void)
 {
 	_fios_path_changed = true;
--- a/pathfind.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/pathfind.c	Mon Aug 01 16:31:19 2005 +0000
@@ -668,7 +668,7 @@
 	FindLengthOfTunnelResult flotr;
 	int estimation;
 
-	
+
 
 	// Need to have a special case for the start.
 	// We shouldn't call the callback for the current tile.
--- a/rail_cmd.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/rail_cmd.c	Mon Aug 01 16:31:19 2005 +0000
@@ -26,6 +26,13 @@
 
 extern uint16 _custom_sprites_base;
 
+const byte _track_sloped_sprites[14] = {
+	14, 15, 22, 13,
+	 0, 21, 17, 12,
+	23,  0, 18, 20,
+	19, 16
+};
+
 void ShowTrainDepotWindow(TileIndex tile);
 
 /* Format of rail map5 byte.
@@ -1587,6 +1594,24 @@
 	}
 }
 
+void DrawDefaultWaypointSprite(int x, int y, int railtype)
+{
+	const DrawTrackSeqStruct *dtss = _track_depot_layout_table[4];
+	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
+	uint32 img;
+
+	img = dtss++->image;
+	if (img & PALETTE_MODIFIER_COLOR) img = (img & SPRITE_MASK) + rti->total_offset;
+	DrawSprite(img, x, y);
+
+	for (; dtss->image != 0; dtss++) {
+		Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
+		img = dtss->image;
+		if (img & PALETTE_MODIFIER_COLOR) img |= PLAYER_SPRITE_COLOR(_local_player);
+		DrawSprite(img, x + pt.x, y + pt.y);
+	}
+}
+
 typedef struct SetSignalsData {
 	int cur;
 	int cur_stack;
--- a/roadveh_gui.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/roadveh_gui.c	Mon Aug 01 16:31:19 2005 +0000
@@ -95,7 +95,7 @@
 
 			SetDParam(1, year);
 
-			SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);  
+			SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
 			SetDParam(2, v->max_age / 366);
 			SetDParam(3, RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running >> 8);
 			DrawString(2, 15, STR_900D_AGE_RUNNING_COST_YR, 0);
@@ -714,11 +714,11 @@
 			ResetObjectToPlace();
 			ShowBuildRoadVehWindow(w->window_number);
 			break;
-			
+
 		case 8: /* clone button */
 			InvalidateWidget(w, 8);
 				TOGGLEBIT(w->click_state, 8);
-				
+
 				if (HASBIT(w->click_state, 8)) {
 					_place_clicked_vehicle = NULL;
 					SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w);
@@ -726,14 +726,14 @@
 					ResetObjectToPlace();
 				}
 					break;
-				
+
 			case 9: /* scroll to tile */
 				ResetObjectToPlace();
 				ScrollMainWindowToTile(w->window_number);
 					break;
 		}
 	} break;
-	
+
 		case WE_PLACE_OBJ: {
 		ClonePlaceObj(e->place.tile, w);
 	} break;
@@ -742,7 +742,7 @@
 		CLRBIT(w->click_state, 8);
 		InvalidateWidget(w, 8);
 	} break;
-	
+
 	// check if a vehicle in a depot was clicked..
 	case WE_MOUSELOOP: {
 		Vehicle *v = _place_clicked_vehicle;
--- a/ship_gui.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/ship_gui.c	Mon Aug 01 16:31:19 2005 +0000
@@ -511,7 +511,7 @@
 					case OT_LEAVESTATION:
 						str = STR_882F_LOADING_UNLOADING;
 						break;
-						
+
 					default:
 						if (v->num_orders == 0) {
 							str = STR_NO_ORDERS + _patches.vehicle_speed;
@@ -792,11 +792,11 @@
 			ResetObjectToPlace();
 			ShowBuildShipWindow(w->window_number);
 			break;
-			
+
 			case 8: /* clone button */
 			InvalidateWidget(w, 8);
 				TOGGLEBIT(w->click_state, 8);
-				
+
 				if (HASBIT(w->click_state, 8)) {
 					_place_clicked_vehicle = NULL;
 					SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w);
@@ -811,7 +811,7 @@
 			break;
 		}
 		break;
-		
+
 	case WE_PLACE_OBJ: {
 		//ClonePlaceObj(e->place.tile, w);
 		ClonePlaceObj(w->window_number, w);
@@ -821,7 +821,7 @@
 		CLRBIT(w->click_state, 8);
 		InvalidateWidget(w, 8);
 	} break;
-	
+
 	// check if a vehicle in a depot was clicked..
 	case WE_MOUSELOOP: {
 		Vehicle *v = _place_clicked_vehicle;
--- a/table/track_land.h	Mon Aug 01 13:01:14 2005 +0000
+++ b/table/track_land.h	Mon Aug 01 16:31:19 2005 +0000
@@ -63,9 +63,3 @@
 	_track_waypoint_table_1,
 };
 
-static const byte _track_sloped_sprites[14] = {
-	14, 15, 22, 13,
-	 0, 21, 17, 12,
-	23,  0, 18, 20,
-	19, 16
-};
--- a/table/water_land.h	Mon Aug 01 13:01:14 2005 +0000
+++ b/table/water_land.h	Mon Aug 01 16:31:19 2005 +0000
@@ -149,8 +149,3 @@
 
 #undef BEGIN
 #undef END
-
-
-static const SpriteID _water_shore_sprites[15] = {
-	0, 0xFDF, 0xFE0, 0xFE4, 0xFDE, 0, 0xFE2, 0, 0xFE1, 0xFE5, 0, 0, 0xFE3, 0, 0
-};
--- a/train_cmd.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/train_cmd.c	Mon Aug 01 16:31:19 2005 +0000
@@ -602,11 +602,11 @@
 	if (rvi->flags & RVI_WAGON) return CmdBuildRailWagon(p1, tile, flags);
 
 	value = EstimateTrainCost(rvi);
-		
+
 	//make sure we only pay for half a dualheaded engine if we only requested half of it
 	if (rvi->flags&RVI_MULTIHEAD && HASBIT(p2,0))
 		value /= 2;
-	
+
 
 	if (!(flags & DC_QUERY_COST)) {
 		v = AllocateVehicle();
--- a/train_gui.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/train_gui.c	Mon Aug 01 16:31:19 2005 +0000
@@ -666,7 +666,7 @@
 
  		}
  	} break;
- 
+
 	case WE_PLACE_OBJ: {
 		ClonePlaceObj(e->place.tile, w);
 	} break;
@@ -675,7 +675,7 @@
 		CLRBIT(w->click_state, 9);
 		InvalidateWidget(w, 9);
 	} break;
-	
+
 	// check if a vehicle in a depot was clicked..
 	case WE_MOUSELOOP: {
 		Vehicle *v = _place_clicked_vehicle;
@@ -924,7 +924,7 @@
 
 		/* draw widgets & caption */
 		SetDParam(0, v->string_id);
-		SetDParam(1, v->unitnumber); 
+		SetDParam(1, v->unitnumber);
 		DrawWindowWidgets(w);
 
 		if (v->u.rail.crash_anim_pos != 0) {
--- a/tunnelbridge_cmd.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/tunnelbridge_cmd.c	Mon Aug 01 16:31:19 2005 +0000
@@ -17,6 +17,12 @@
 #include "debug.h"
 #include "variables.h"
 
+#include "table/bridge_land.h"
+#include "table/tunnel_land.h"
+
+extern const byte _track_sloped_sprites[14];
+extern const SpriteID _water_shore_sprites[15];
+
 extern void DrawCanalWater(TileIndex tile);
 
 static const byte _bridge_available_year[MAX_BRIDGES] = {
@@ -944,11 +950,6 @@
 
 extern const byte _road_sloped_sprites[14];
 
-#include "table/track_land.h"
-#include "table/bridge_land.h"
-#include "table/tunnel_land.h"
-#include "table/water_land.h"
-
 static void DrawBridgePillars(TileInfo *ti, int x, int y, int z)
 {
 	const uint32 *b;
--- a/vehicle.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/vehicle.c	Mon Aug 01 16:31:19 2005 +0000
@@ -1676,7 +1676,7 @@
 int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2);
 int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2);
 int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2);
- 
+
 
 typedef int32 VehBuildProc(int x, int y, uint32 flags, uint32 p1, uint32 p2);
 
@@ -1691,7 +1691,7 @@
 	&_new_train_id,
 	&_new_roadveh_id,
 	&_new_ship_id,
-	&_new_aircraft_id,	
+	&_new_aircraft_id,
 };
 
 /** Clone a vehicle. If it is a train, it will clone all the cars too
@@ -1712,7 +1712,7 @@
 	if (!IsVehicleIndex(p1))
 		return CMD_ERROR;
 	v = GetVehicle(p1);
-	wfront = v; 
+	wfront = v;
 	w1 = v;
 	vfront = v;
 
@@ -1775,7 +1775,7 @@
 				w1 = w1->next;
 				v = v->next;
 			}
-			
+
 		}
 	}
 	if (flags & DC_EXEC && needs_refitting != 255 && vfront->type != VEH_Road) {	// right now we do not refit road vehicles
--- a/video/dedicated_v.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/video/dedicated_v.c	Mon Aug 01 16:31:19 2005 +0000
@@ -26,7 +26,7 @@
 
 #	define STDIN 0  /* file descriptor for standard input */
 
-/** 
+/**
  * Switches OpenTTD to a console app at run-time, instead of a PM app
  * Necessary to see stdout, etc. */
 static void OS2_SwitchToConsoleMode(void)
--- a/water_cmd.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/water_cmd.c	Mon Aug 01 16:31:19 2005 +0000
@@ -16,6 +16,11 @@
 #include "depot.h"
 #include "vehicle_gui.h"
 
+const SpriteID _water_shore_sprites[15] = {
+	0, 0xFDF, 0xFE0, 0xFE4, 0xFDE, 0, 0xFE2, 0, 0xFE1, 0xFE5, 0, 0, 0xFE3, 0, 0
+};
+
+
 static void FloodVehicle(Vehicle *v);
 
 static bool IsClearWaterTile(TileIndex tile)
--- a/waypoint.c	Mon Aug 01 13:01:14 2005 +0000
+++ b/waypoint.c	Mon Aug 01 16:31:19 2005 +0000
@@ -16,7 +16,6 @@
 #include "variables.h"
 #include "table/sprites.h"
 #include "table/strings.h"
-#include "table/track_land.h"
 
 enum {
 	/* Max waypoints: 64000 (8 * 8000) */
@@ -359,6 +358,7 @@
 
 extern uint16 _custom_sprites_base;
 
+
 /* Draw a waypoint */
 void DrawWaypointSprite(int x, int y, int stat_id, uint railtype)
 {
@@ -376,18 +376,7 @@
 
 	/* draw default waypoint graphics of ID 0 */
 	if (stat_id == 0) {
-		const DrawTrackSeqStruct *dtss = _track_depot_layout_table[4];
-
-		img = dtss++->image;
-		if (img & PALETTE_MODIFIER_COLOR) img = (img & SPRITE_MASK) + rti->total_offset;
-		DrawSprite(img, x, y);
-
-		for (; dtss->image != 0; dtss++) {
-			Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
-			img = dtss->image;
-			if (img & PALETTE_MODIFIER_COLOR) img |= ormod;
-			DrawSprite(img, x + pt.x, y + pt.y);
-		}
+		DrawDefaultWaypointSprite(x, y, railtype);
 		return;
 	}
 
@@ -407,7 +396,6 @@
 	foreach_draw_tile_seq(seq, cust->seq) {
 		Point pt = RemapCoords(seq->delta_x, seq->delta_y, seq->delta_z);
 		uint32 image = seq->image + relocation;
-
 		DrawSprite((image & SPRITE_MASK) | ormod, x + pt.x, y + pt.y);
 	}
 }