changeset 2475:30fd66837bbd draft

(svn r3001) s/Player*/const Player*/ s/byte/PlayerID/ s/int/PlayerID/ and related changes
author tron <tron@openttd.org>
date Fri, 30 Sep 2005 20:37:25 +0000
parents e95f617d4637
children c6e1054ca173
files aircraft_cmd.c economy.c functions.h graph_gui.c gui.h misc_gui.c player.h player_gui.c players.c station.h station_gui.c train_cmd.c
diffstat 12 files changed, 41 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -1518,7 +1518,7 @@
 
 static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass *Airport)
 {
-	Player *p = GetPlayer(v->owner);
+	const Player* p = GetPlayer(v->owner);
 	v->sprite_width = v->sprite_height = 24; // ??? no idea what this is
 	v->u.air.state = FLYING;
 	// get the next position to go to, differs per airport
@@ -1582,7 +1582,7 @@
 
 static void AircraftEventHandler_Landing(Vehicle *v, const AirportFTAClass *Airport)
 {
-	Player *p = GetPlayer(v->owner);
+	const Player* p = GetPlayer(v->owner);
 	AircraftLandAirplane(v);  // maybe crash airplane
 	v->u.air.state = ENDLANDING;
 	// check if the aircraft needs to be replaced or renewed and send it to a hangar if needed
--- a/economy.c
+++ b/economy.c
@@ -72,8 +72,9 @@
 	MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
 }
 
-int64 CalculateCompanyValue(Player *p) {
-	byte owner = p->index;
+int64 CalculateCompanyValue(const Player *p)
+{
+	PlayerID owner = p->index;
 	int64 value;
 
 	{
@@ -394,7 +395,7 @@
 
 static void PlayersCheckBankrupt(Player *p)
 {
-	int owner;
+	PlayerID owner;
 	int64 val;
 
 	// If the player has money again, it does not go bankrupt
--- a/functions.h
+++ b/functions.h
@@ -75,7 +75,7 @@
 void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost);
 bool CheckOwnership(PlayerID owner);
 bool CheckTileOwnership(TileIndex tile);
-StringID GetPlayerNameString(PlayerID player, PlayerID index);
+StringID GetPlayerNameString(PlayerID player, uint index);
 
 /* standard */
 void ShowInfo(const char *str);
--- a/graph_gui.c
+++ b/graph_gui.c
@@ -219,7 +219,7 @@
 
 static void GraphLegendWndProc(Window *w, WindowEvent *e)
 {
-	Player *p;
+	const Player* p;
 
 	switch(e->event) {
 	case WE_PAINT:
@@ -291,7 +291,7 @@
 
 static void SetupGraphDrawerForPlayers(GraphDrawer *gd)
 {
-	Player *p;
+	const Player* p;
 	uint excludebits = _legend_excludebits;
 	int nums;
 	int mo,yr;
@@ -325,7 +325,7 @@
 	switch(e->event) {
 	case WE_PAINT: {
 		GraphDrawer gd;
-		Player *p;
+		const Player* p;
 		int i,j;
 		int numd;
 
@@ -399,7 +399,7 @@
 	switch(e->event) {
 	case WE_PAINT: {
 		GraphDrawer gd;
-		Player *p;
+		const Player* p;
 		int i,j;
 		int numd;
 
@@ -472,7 +472,7 @@
 	switch(e->event) {
 	case WE_PAINT: {
 		GraphDrawer gd;
-		Player *p;
+		const Player* p;
 		int i,j;
 		int numd;
 
@@ -545,7 +545,7 @@
 	switch(e->event) {
 	case WE_PAINT: {
 		GraphDrawer gd;
-		Player *p;
+		const Player* p;
 		int i,j;
 		int numd;
 
@@ -621,7 +621,7 @@
 	switch(e->event) {
 	case WE_PAINT: {
 		GraphDrawer gd;
-		Player *p;
+		const Player* p;
 		int i,j;
 		int numd;
 
@@ -826,8 +826,8 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		Player *p;
-		Player *plist[MAX_PLAYERS];
+		const Player* p;
+		const Player* plist[MAX_PLAYERS];
 		uint pl_num;
 		uint i;
 
--- a/gui.h
+++ b/gui.h
@@ -86,9 +86,9 @@
 void ShowTownDirectory(void);
 void ShowIndustryDirectory(void);
 void ShowSubsidiesList(void);
-void ShowPlayerStations(int player);
-void ShowPlayerFinances(int player);
-void ShowPlayerCompany(int player);
+void ShowPlayerStations(PlayerID player);
+void ShowPlayerFinances(PlayerID player);
+void ShowPlayerCompany(PlayerID player);
 void ShowSignList(void);
 
 void ShowEstimatedCostOrIncome(int32 cost, int x, int y);
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -484,7 +484,7 @@
 					_errmsg_message_1,
 					238);
 		} else {
-			Player *p = GetPlayer(GetDParamX(_errmsg_decode_params,2));
+			const Player* p = GetPlayer(GetDParamX(_errmsg_decode_params,2));
 			DrawPlayerFace(p->face, p->player_color, 2, 16);
 
 			DrawStringMultiCenter(
--- a/player.h
+++ b/player.h
@@ -195,8 +195,8 @@
 
 void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player);
 void GetNameOfOwner(PlayerID owner, TileIndex tile);
-int64 CalculateCompanyValue(Player *p);
-void InvalidatePlayerWindows(Player *p);
+int64 CalculateCompanyValue(const Player* p);
+void InvalidatePlayerWindows(const Player* p);
 void UpdatePlayerMoney32(Player *p);
 #define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++)
 
@@ -260,8 +260,8 @@
 	return RAILTYPE_RAIL;
 }
 
-#define IS_HUMAN_PLAYER(p) (!GetPlayer((byte)(p))->is_ai)
-#define IS_INTERACTIVE_PLAYER(p) (((byte)p) == _local_player)
+#define IS_HUMAN_PLAYER(p) (!GetPlayer(p)->is_ai)
+#define IS_INTERACTIVE_PLAYER(p) ((p) == _local_player)
 
 typedef struct HighScore {
 	char company[100];
--- a/player_gui.c
+++ b/player_gui.c
@@ -21,7 +21,7 @@
 #include "network_client.h"
 #endif
 
-static void DoShowPlayerFinances(int player, bool show_small, bool show_stickied);
+static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied);
 
 
 static void DrawPlayerEconomyStats(const Player *p, byte mode)
@@ -149,13 +149,14 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		Player *p = GetPlayer(w->window_number);
+		PlayerID player = w->window_number;
+		const Player* p = GetPlayer(player);
 
 		w->disabled_state = p->current_loan != 0 ? 0 : (1 << 7);
 
 		SetDParam(0, p->name_1);
 		SetDParam(1, p->name_2);
-		SetDParam(2, GetPlayerNameString((byte)w->window_number, 3));
+		SetDParam(2, GetPlayerNameString(player, 3));
 		SetDParam(4, 10000);
 		DrawWindowWidgets(w);
 
@@ -167,7 +168,7 @@
 		case 2: {/* toggle size */
 			byte mode = (byte)WP(w,def_d).data_1;
 			bool stickied = !!(w->flags4 & WF_STICKY);
-			int player = w->window_number;
+			PlayerID player = w->window_number;
 			DeleteWindow(w);
 			DoShowPlayerFinances(player, !HASBIT(mode, 0), stickied);
 		} break;
@@ -221,12 +222,12 @@
 	&_other_player_finances_desc,&_other_player_finances_small_desc,
 };
 
-static void DoShowPlayerFinances(int player, bool show_small, bool show_stickied)
+static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied)
 {
 	Window *w;
 	int mode;
 
-	mode = ((byte)player != _local_player)*2 + show_small;
+	mode = (player != _local_player) * 2 + show_small;
 	w = AllocateWindowDescFront( desc_table[mode], player);
 	if (w) {
 		w->caption_color = w->window_number;
@@ -238,7 +239,7 @@
 	}
 }
 
-void ShowPlayerFinances(int player)
+void ShowPlayerFinances(PlayerID player)
 {
 	DoShowPlayerFinances(player, false, false);
 }
@@ -247,7 +248,7 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		Player *p;
+		const Player* p;
 		uint used_colors = 0;
 		int num_free = 16;
 		int x,y,pos;
@@ -481,8 +482,8 @@
 
 static void DrawCompanyOwnerText(const Player *p)
 {
+	const Player* p2;
 	int num = -1;
-	Player *p2;
 	int amt;
 
 	FOR_ALL_PLAYERS(p2) {
@@ -506,7 +507,7 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		Player *p = GetPlayer(w->window_number);
+		const Player* p = GetPlayer(w->window_number);
 		uint32 dis = 0;
 
 		if (!IsWindowOfPrototype(w, _other_player_company_widgets)) {
@@ -687,7 +688,7 @@
 	PlayerCompanyWndProc
 };
 
-void ShowPlayerCompany(int player)
+void ShowPlayerCompany(PlayerID player)
 {
 	Window *w;
 	w = AllocateWindowDescFront((byte)player == _local_player ? &_my_player_company_desc : &_other_player_company_desc,  player);
--- a/players.c
+++ b/players.c
@@ -185,7 +185,7 @@
 	}
 }
 
-void InvalidatePlayerWindows(Player *p)
+void InvalidatePlayerWindows(const Player *p)
 {
 	PlayerID pid = p->index;
 
@@ -568,7 +568,7 @@
 }
 
 // index is the next parameter in _decode_parameters to set up
-StringID GetPlayerNameString(PlayerID player, PlayerID index)
+StringID GetPlayerNameString(PlayerID player, uint index)
 {
 	if (IS_HUMAN_PLAYER(player) && player < MAX_PLAYERS) {
 		SetDParam(index, player+1);
--- a/station.h
+++ b/station.h
@@ -63,7 +63,7 @@
 	byte time_since_load;
 	byte time_since_unload;
 	byte delete_ctr;
-	byte owner;
+	PlayerID owner;
 	byte facilities;
 	byte airport_type;
 
--- a/station_gui.c
+++ b/station_gui.c
@@ -259,7 +259,7 @@
 };
 
 
-void ShowPlayerStations(int player)
+void ShowPlayerStations(PlayerID player)
 {
 	Window *w;
 
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1564,7 +1564,7 @@
 typedef struct TrainFindDepotData {
 	uint best_length;
 	TileIndex tile;
-	byte owner;
+	PlayerID owner;
 	/**
 	 * true if reversing is necesarry for the train to get to this depot This
 	 * value is unused when new depot finding and NPF are both disabled