(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
authorcelestar
Tue, 21 Jun 2005 16:28:17 +0000
changeset 1962 51ee4f459268
parent 1961 10ce7350f76b
child 1963 8a398139fb87
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
ai_pathfinder.c
aircraft_gui.c
command.c
console_cmds.c
economy.c
engine.c
graph_gui.c
main_gui.c
misc_cmd.c
misc_gui.c
network_client.c
network_server.c
oldloader.c
openttd.c
player.h
player_gui.c
players.c
roadveh_gui.c
ship_gui.c
station_gui.c
subsidy_gui.c
town_cmd.c
town_gui.c
train_gui.c
unmovable_cmd.c
vehicle.c
--- a/ai_pathfinder.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/ai_pathfinder.c	Tue Jun 21 16:28:17 2005 +0000
@@ -13,7 +13,7 @@
 // TODO: make it train compatible
 static bool TestCanBuildStationHere(uint tile, byte dir)
 {
-	Player *p = DEREF_PLAYER(_current_player);
+	Player *p = GetPlayer(_current_player);
 
 	if (dir == TEST_STATION_NO_DIR) {
 		int32 ret;
--- a/aircraft_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/aircraft_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -942,7 +942,7 @@
 
 		/* draw the widgets */
 		{
-			const Player *p = DEREF_PLAYER(owner);
+			const Player *p = GetPlayer(owner);
 			if (station == -1) {
 				/* Company Name -- (###) Aircraft */
 				SetDParam(0, p->name_1);
--- a/command.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/command.c	Tue Jun 21 16:28:17 2005 +0000
@@ -336,7 +336,7 @@
 		_error_message = INVALID_STRING_ID;
 		// update last build coord of player
 		if ( (x|y) != 0 && _current_player < MAX_PLAYERS) {
-			DEREF_PLAYER(_current_player)->last_build_coordinate = TILE_FROM_XY(x,y);
+			GetPlayer(_current_player)->last_build_coordinate = TILE_FROM_XY(x,y);
 		}
 	}
 
@@ -386,7 +386,7 @@
 {
 	PlayerID pid = _current_player;
 	if (pid >= MAX_PLAYERS) return 0x7FFFFFFF; // max int
-	return DEREF_PLAYER(pid)->player_money;
+	return GetPlayer(pid)->player_money;
 }
 
 // toplevel network safe docommand function for the current player. must not be called recursively.
@@ -497,7 +497,7 @@
 #endif /* ENABLE_NETWORK */
 
 	// update last build coordinate of player.
-	if ( tile != 0 && _current_player < MAX_PLAYERS) DEREF_PLAYER(_current_player)->last_build_coordinate = tile;
+	if ( tile != 0 && _current_player < MAX_PLAYERS) GetPlayer(_current_player)->last_build_coordinate = tile;
 
 	/* Actually try and execute the command. If no cost-type is given
 	 * use the construction one */
--- a/console_cmds.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/console_cmds.c	Tue Jun 21 16:28:17 2005 +0000
@@ -544,7 +544,7 @@
 
 	/* Check if company does exist */
 	index--;
-	p = DEREF_PLAYER(index);
+	p = GetPlayer(index);
 	if (!p->is_active) {
 		IConsoleError("Company does not exist.");
 		return true;
--- a/economy.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/economy.c	Tue Jun 21 16:28:17 2005 +0000
@@ -378,7 +378,7 @@
 					p->share_owners[i] = 0xFF;
 			}
 		}
-		p = DEREF_PLAYER(_current_player);
+		p = GetPlayer(_current_player);
 		/* Sell all the shares that people have on this company */
 		for (i = 0; i < 4; i++)
 			p->share_owners[i] = 0xFF;
@@ -484,7 +484,7 @@
 
 	DrawNewsBorder(w);
 
-	p = DEREF_PLAYER(WP(w,news_d).ni->string_id & 15);
+	p = GetPlayer(WP(w,news_d).ni->string_id & 15);
 	DrawPlayerFace(p->face, p->player_color, 2, 23);
 	GfxFillRect(3, 23, 3+91, 23+118, 0x4323);
 
@@ -553,7 +553,7 @@
 
 StringID GetNewsStringBankrupcy(NewsItem *ni)
 {
-	Player *p = DEREF_PLAYER(ni->string_id & 0xF);
+	Player *p = GetPlayer(ni->string_id & 0xF);
 
 	switch(ni->string_id >> 4) {
 	case 1:
@@ -1199,7 +1199,7 @@
 			pair = SetupSubsidyDecodeParam(s, 0);
 			InjectDParam(2);
 
-			p = DEREF_PLAYER(_current_player);
+			p = GetPlayer(_current_player);
 			SetDParam(0, p->name_1);
 			SetDParam(1, p->name_2);
 			AddNewsItem(
@@ -1224,7 +1224,7 @@
 
 	// Update player statistics
 	{
-		Player *p = DEREF_PLAYER(_current_player);
+		Player *p = GetPlayer(_current_player);
 		p->cur_economy.delivered_cargo += num_pieces;
 		SETBIT(p->cargo_types, cargo_type);
 	}
@@ -1525,14 +1525,14 @@
 	ChangeOwnershipOfPlayerItems(pi, _current_player);
 
 	if (p->bankrupt_value == 0) {
-		owner = DEREF_PLAYER(_current_player);
+		owner = GetPlayer(_current_player);
 		owner->current_loan += p->current_loan;
 	}
 
 	value = CalculateCompanyValue(p) >> 2;
 	for(i=0; i!=4; i++) {
 		if (p->share_owners[i] != 0xFF) {
-			owner = DEREF_PLAYER(p->share_owners[i]);
+			owner = GetPlayer(p->share_owners[i]);
 			owner->money64 += value;
 			owner->yearly_expenses[0][EXPENSES_OTHER] += value;
 			UpdatePlayerMoney32(owner);
@@ -1561,7 +1561,7 @@
 	if (p1 >= MAX_PLAYERS || !_patches.allow_shares) return CMD_ERROR;
 
 	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-	p = DEREF_PLAYER(p1);
+	p = GetPlayer(p1);
 
 	/* Protect new companies from hostile takeovers */
 	if (_cur_year - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED);
@@ -1606,7 +1606,7 @@
 	if (p1 >= MAX_PLAYERS || !_patches.allow_shares) return CMD_ERROR;
 
 	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-	p = DEREF_PLAYER(p1);
+	p = GetPlayer(p1);
 
 	/* Those lines are here for network-protection (clients can be slow) */
 	if (GetAmountOwnedBy(p, _current_player) == 0) return 0;
@@ -1640,7 +1640,7 @@
 	if (p1 >= MAX_PLAYERS || _networking) return CMD_ERROR;
 
 	SET_EXPENSES_TYPE(EXPENSES_OTHER);
-	p = DEREF_PLAYER(p1);
+	p = GetPlayer(p1);
 
 	if (!p->is_ai) return CMD_ERROR;
 
--- a/engine.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/engine.c	Tue Jun 21 16:28:17 2005 +0000
@@ -754,7 +754,7 @@
 
 void AcceptEnginePreview(Engine *e, PlayerID player)
 {
-	Player *p = DEREF_PLAYER(player);
+	Player *p = GetPlayer(player);
 
 	SETBIT(e->player_avail, player);
 
--- a/graph_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/graph_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -904,7 +904,7 @@
 
 		// Paint the player icons
 		for (i=0;i<MAX_PLAYERS;i++) {
-       		if (!DEREF_PLAYER(i)->is_active) {
+       		if (!GetPlayer(i)->is_active) {
        			// Check if we have the player as an active player
        			if (!(w->disabled_state & (1 << (i+13)))) {
        				// Bah, player gone :(
@@ -1024,7 +1024,7 @@
 
         	// Hide the player who are not active
         	for (i=0;i<MAX_PLAYERS;i++) {
-        		if (!DEREF_PLAYER(i)->is_active) {
+        		if (!GetPlayer(i)->is_active) {
         			w->disabled_state += 1 << (i+13);
         		}
         	}
--- a/main_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/main_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -84,7 +84,7 @@
 			NetworkServer_HandleChat(NETWORK_ACTION_CHAT + (id & 0xFF), id & 0xFF, (id >> 8) & 0xFF, e->edittext.str, NETWORK_SERVER_INDEX);
 		break;
 	case 3: { /* Give money, you can only give money in excess of loan */
-		const Player *p = DEREF_PLAYER(_current_player);
+		const Player *p = GetPlayer(_current_player);
 		int32 money = min(p->money64 - p->current_loan, atoi(e->edittext.str) / GetCurrentCurrencyRate());
 		char msg[20];
 
@@ -329,7 +329,7 @@
 
 static void MenuClickBuildRail(int index)
 {
-	Player *p = DEREF_PLAYER(_local_player);
+	Player *p = GetPlayer(_local_player);
 	_last_built_railtype = min(index, p->max_railtype-1);
 	ShowBuildRailToolbar(_last_built_railtype, -1);
 }
@@ -941,7 +941,7 @@
 
 static void ToolbarBuildRailClick(Window *w)
 {
-	Player *p = DEREF_PLAYER(_local_player);
+	Player *p = GetPlayer(_local_player);
 	Window *w2;
 	w2 = PopupMainToolbMenu(w, 457, 19, STR_1015_RAILROAD_CONSTRUCTION, p->max_railtype);
 	WP(w2,menu_d).sel_index = _last_built_railtype;
@@ -2211,7 +2211,7 @@
 {
 	switch (e->event) {
 	case WE_PAINT: {
-		const Player *p = (_local_player == OWNER_SPECTATOR) ? NULL : DEREF_PLAYER(_local_player);
+		const Player *p = (_local_player == OWNER_SPECTATOR) ? NULL : GetPlayer(_local_player);
 
 		DrawWindowWidgets(w);
 		SetDParam(0, _date);
--- a/misc_cmd.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/misc_cmd.c	Tue Jun 21 16:28:17 2005 +0000
@@ -137,7 +137,7 @@
 	if (str == 0) return CMD_ERROR;
 
 	if (flags & DC_EXEC) {
-		p = DEREF_PLAYER(_current_player);
+		p = GetPlayer(_current_player);
 		DeleteName(p->name_1);
 		p->name_1 = str;
 		MarkWholeScreenDirty();
@@ -163,7 +163,7 @@
 	if (str == 0) return CMD_ERROR;
 
 	if (flags & DC_EXEC) {
-		p = DEREF_PLAYER(_current_player);
+		p = GetPlayer(_current_player);
 		DeleteName(p->president_name_1);
 		p->president_name_1 = str;
 
@@ -226,7 +226,7 @@
  */
 int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
-	const Player *p = DEREF_PLAYER(_current_player);
+	const Player *p = GetPlayer(_current_player);
 	int32 amount = min((int32)p1, 20000000);
 
 	SET_EXPENSES_TYPE(EXPENSES_OTHER);
--- a/misc_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/misc_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -131,9 +131,9 @@
 	lid.town = ClosestTownFromTile(tile, _patches.dist_local_authority);
 
 	if (_local_player >= MAX_PLAYERS)
-		p = DEREF_PLAYER(0);
+		p = GetPlayer(0);
 	else
-		p = DEREF_PLAYER(_local_player);
+		p = GetPlayer(_local_player);
 
 	old_money = p->money64;
 	p->money64 = p->player_money = 0x7fffffff;
@@ -470,7 +470,7 @@
 					_errmsg_message_1,
 					238);
 		} else {
-			Player *p = DEREF_PLAYER(GetDParamX(_errmsg_decode_params,2));
+			Player *p = GetPlayer(GetDParamX(_errmsg_decode_params,2));
 			DrawPlayerFace(p->face, p->player_color, 2, 16);
 
 			DrawStringMultiCenter(
@@ -1201,9 +1201,9 @@
 	/* Check if we are not a specatator who wants to generate a name..
 	    Let's use the name of player #0 for now. */
 	if (_local_player < MAX_PLAYERS)
-		p = DEREF_PLAYER(_local_player);
+		p = GetPlayer(_local_player);
 	else
-		p = DEREF_PLAYER(0);
+		p = GetPlayer(0);
 
 	SetDParam(0, p->name_1);
 	SetDParam(1, p->name_2);
--- a/network_client.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/network_client.c	Tue Jun 21 16:28:17 2005 +0000
@@ -513,7 +513,7 @@
 		SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
 
 		if (_network_playas == 0 || _network_playas > MAX_PLAYERS ||
-				!DEREF_PLAYER(_network_playas - 1)->is_active) {
+				!GetPlayer(_network_playas - 1)->is_active) {
 
 			if (_network_playas == OWNER_SPECTATOR) {
 				// The client wants to be a spectator..
@@ -632,7 +632,7 @@
 				/* For speak to player or give money, we need the player-name */
 				if (ci_to->client_playas > MAX_PLAYERS)
 					return NETWORK_RECV_STATUS_OKAY; // This should never happen
-				GetString(name, DEREF_PLAYER(ci_to->client_playas-1)->name_1);
+				GetString(name, GetPlayer(ci_to->client_playas-1)->name_1);
 				ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
 				break;
 			default:
--- a/network_server.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/network_server.c	Tue Jun 21 16:28:17 2005 +0000
@@ -1046,7 +1046,7 @@
 		if (ci != NULL && show_local) {
 			if (from_index == NETWORK_SERVER_INDEX) {
 				char name[NETWORK_NAME_LENGTH];
-				GetString(name, DEREF_PLAYER(ci_to->client_playas-1)->name_1);
+				GetString(name, GetPlayer(ci_to->client_playas-1)->name_1);
 				NetworkTextMessage(action, GetDrawStringPlayerColor(ci_own->client_playas-1), true, name, "%s", msg);
 			} else {
 				FOR_ALL_CLIENTS(cs) {
--- a/oldloader.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/oldloader.c	Tue Jun 21 16:28:17 2005 +0000
@@ -810,7 +810,7 @@
 static bool OldPlayerYearly(LoadgameState *ls, int num)
 {
 	int i;
-	Player *p = DEREF_PLAYER(_current_player_id);
+	Player *p = GetPlayer(_current_player_id);
 
 	for (i = 0; i < 13; i++) {
 		if (!LoadChunk(ls, NULL, player_yearly_chunk))
@@ -834,7 +834,7 @@
 static bool OldPlayerEconomy(LoadgameState *ls, int num)
 {
 	int i;
-	Player *p = DEREF_PLAYER(_current_player_id);
+	Player *p = GetPlayer(_current_player_id);
 
 	if (!LoadChunk(ls, &p->cur_economy, player_economy_chunk))
 		return false;
@@ -872,7 +872,7 @@
 };
 static bool OldLoadAIBuildRec(LoadgameState *ls, int num)
 {
-	Player *p = DEREF_PLAYER(_current_player_id);
+	Player *p = GetPlayer(_current_player_id);
 
 	switch (num) {
 		case 0: return LoadChunk(ls, &p->ai.src, player_ai_build_rec_chunk);
@@ -987,7 +987,7 @@
 };
 static bool OldPlayerAI(LoadgameState *ls, int num)
 {
-	Player *p = DEREF_PLAYER(_current_player_id);
+	Player *p = GetPlayer(_current_player_id);
 
 	return LoadChunk(ls, &p->ai, player_ai_chunk);
 }
@@ -1035,7 +1035,7 @@
 };
 static bool LoadOldPlayer(LoadgameState *ls, int num)
 {
-	Player *p = DEREF_PLAYER(num);
+	Player *p = GetPlayer(num);
 
 	_current_player_id = num;
 
--- a/openttd.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/openttd.c	Tue Jun 21 16:28:17 2005 +0000
@@ -1033,7 +1033,7 @@
 	char buf[200];
 
 	if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) {
-		const Player *p = DEREF_PLAYER(_local_player);
+		const Player *p = GetPlayer(_local_player);
 		char *s;
 		sprintf(buf, "%s%s", _path.autosave_dir, PATHSEP);
 
--- a/player.h	Tue Jun 21 14:50:08 2005 +0000
+++ b/player.h	Tue Jun 21 16:28:17 2005 +0000
@@ -197,14 +197,13 @@
 #define MAX_PLAYERS 8
 VARDEF Player _players[MAX_PLAYERS];
 
-#define DEREF_PLAYER(i) (GetPlayer(i))
 static inline Player* GetPlayer(uint i)
 {
   assert(i < lengthof(_players));
   return &_players[i];
 }
 
-#define IS_HUMAN_PLAYER(p) (!DEREF_PLAYER((byte)(p))->is_ai)
+#define IS_HUMAN_PLAYER(p) (!GetPlayer((byte)(p))->is_ai)
 #define IS_INTERACTIVE_PLAYER(p) (((byte)p) == _local_player)
 
 typedef struct HighScore {
--- a/player_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/player_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -144,7 +144,7 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		Player *p = DEREF_PLAYER(w->window_number);
+		Player *p = GetPlayer(w->window_number);
 
 		w->disabled_state = p->current_loan != 0 ? 0 : (1 << 7);
 
@@ -319,7 +319,7 @@
 		Player *p;
 		w->click_state = (w->click_state & ~(1<<5|1<<6)) | ((1<<5) << WP(w,facesel_d).gender);
 		DrawWindowWidgets(w);
-		p = DEREF_PLAYER(w->window_number);
+		p = GetPlayer(w->window_number);
 		DrawPlayerFace(WP(w,facesel_d).face, p->player_color, 2, 16);
 	} break;
 
@@ -501,7 +501,7 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		Player *p = DEREF_PLAYER(w->window_number);
+		Player *p = GetPlayer(w->window_number);
 		uint32 dis = 0;
 
 		if (!IsWindowOfPrototype(w, _other_player_company_widgets)) {
@@ -561,7 +561,7 @@
 			Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number);
 			if (wf) {
 				wf->caption_color = w->window_number;
-				WP(wf,facesel_d).face = DEREF_PLAYER(wf->window_number)->face;
+				WP(wf,facesel_d).face = GetPlayer(wf->window_number)->face;
 				WP(wf,facesel_d).gender = 0;
 			}
 		} break;
@@ -575,21 +575,21 @@
 		} break;
 
 		case 5: {/* change president name */
-			Player *p = DEREF_PLAYER(w->window_number);
+			Player *p = GetPlayer(w->window_number);
 			WP(w,def_d).byte_1 = 0;
 			SetDParam(0, p->president_name_2);
 			ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w->window_class, w->window_number);
 		} break;
 
 		case 6: {/* change company name */
-			Player *p = DEREF_PLAYER(w->window_number);
+			Player *p = GetPlayer(w->window_number);
 			WP(w,def_d).byte_1 = 1;
 			SetDParam(0, p->name_2);
 			ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w->window_class, w->window_number);
 		} break;
 
 		case 7: {/* build hq */
-			TileIndex tile = DEREF_PLAYER(w->window_number)->location_of_house;
+			TileIndex tile = GetPlayer(w->window_number)->location_of_house;
 			if (tile == 0) {
 				if ((byte)w->window_number != _local_player)
 					return;
@@ -632,7 +632,7 @@
 
 	case WE_PLACE_OBJ: {
 		/* You cannot destroy a HQ, only relocate it. So build_HQ is called, just with different flags */
-		TileIndex tile = DEREF_PLAYER(w->window_number)->location_of_house;
+		TileIndex tile = GetPlayer(w->window_number)->location_of_house;
 		if (DoCommandP(e->place.tile, (tile == 0) ? 0 : 1 | w->window_number, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
 			ResetObjectToPlace();
 		break;
@@ -700,7 +700,7 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		Player *p = DEREF_PLAYER(w->window_number);
+		Player *p = GetPlayer(w->window_number);
 		SetDParam(0, p->name_1);
 		SetDParam(1, p->name_2);
 		DrawWindowWidgets(w);
@@ -779,7 +779,7 @@
 {
 	switch (e->event) {
 	case WE_PAINT: {
-		const Player *p = DEREF_PLAYER(_local_player);
+		const Player *p = GetPlayer(_local_player);
 		uint x, y;
 
 		SetupHighScoreEndWindow(w, &x, &y);
@@ -918,7 +918,7 @@
 		WP(w, highscore_d).background_img = SPR_TYCOON_IMG1_BEGIN;
 
 		if (_local_player != OWNER_SPECTATOR) {
-			const Player *p = DEREF_PLAYER(_local_player);
+			const Player *p = GetPlayer(_local_player);
 			if (p->old_economy[0].performance_history == SCORE_MAX)
 				WP(w, highscore_d).background_img = SPR_TYCOON_IMG2_BEGIN;
 		}
@@ -930,7 +930,7 @@
 			WP(w, highscore_d).rank = SaveHighScoreValueNetwork();
 		} else {
 			// in single player _local player is always valid
-			const Player *p = DEREF_PLAYER(_local_player);
+			const Player *p = GetPlayer(_local_player);
 			w->window_number = _opt.diff_level;
 			WP(w, highscore_d).rank = SaveHighScoreValue(p);
 		}
--- a/players.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/players.c	Tue Jun 21 16:28:17 2005 +0000
@@ -194,7 +194,7 @@
 {
 	if (cost > 0) {
 		uint pid = _current_player;
-		if (pid < MAX_PLAYERS && cost > DEREF_PLAYER(pid)->player_money) {
+		if (pid < MAX_PLAYERS && cost > GetPlayer(pid)->player_money) {
 			SetDParam(0, cost);
 			_error_message = STR_0003_NOT_ENOUGH_CASH_REQUIRES;
 			return false;
@@ -222,12 +222,12 @@
 {
 	PlayerID pid = _current_player;
 	if (pid < MAX_PLAYERS)
-		SubtractMoneyFromAnyPlayer(DEREF_PLAYER(pid), cost);
+		SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
 }
 
 void SubtractMoneyFromPlayerFract(byte player, int32 cost)
 {
-	Player *p = DEREF_PLAYER(player);
+	Player *p = GetPlayer(player);
 	byte m = p->player_money_fraction;
 	p->player_money_fraction = m - (byte)cost;
 	cost >>= 8;
@@ -256,7 +256,7 @@
 		if (owner >= 8)
 			SetDParam(0, STR_0150_SOMEONE);
 		else {
-			Player *p = DEREF_PLAYER(owner);
+			Player *p = GetPlayer(owner);
 			SetDParam(0, p->name_1);
 			SetDParam(1, p->name_2);
 		}
@@ -544,7 +544,7 @@
 	if (_game_mode == GM_EDITOR)
 		return;
 
-	p = DEREF_PLAYER(_cur_player_tick_index);
+	p = GetPlayer(_cur_player_tick_index);
 	_cur_player_tick_index = (_cur_player_tick_index + 1) % MAX_PLAYERS;
 	if (p->name_1 != 0) GenerateCompanyName(p);
 
@@ -600,7 +600,7 @@
 
 	if (_patches.show_finances && _local_player != OWNER_SPECTATOR) {
 		ShowPlayerFinances(_local_player);
-		p = DEREF_PLAYER(_local_player);
+		p = GetPlayer(_local_player);
 		if (p->num_valid_stat_ent > 5 && p->old_economy[0].performance_history < p->old_economy[4].performance_history) {
 			SndPlayFx(SND_01_BAD_YEAR);
 		} else {
@@ -628,7 +628,7 @@
 	Player *p;
 
 	DeletePlayerWindows(pi);
-	p = DEREF_PLAYER(pi);
+	p = GetPlayer(pi);
 	DeleteName(p->name_1);
 	DeleteName(p->president_name_1);
 	p->name_1 = 0;
@@ -735,7 +735,7 @@
 
 		if (!(flags & DC_EXEC)) return 0;
 
-		p = DEREF_PLAYER(p2);
+		p = GetPlayer(p2);
 
 		/* Only allow removal of HUMAN companies */
 		if (IS_HUMAN_PLAYER(p->index)) {
@@ -1115,7 +1115,7 @@
 {
 	int index;
 	while ((index = SlIterateArray()) != -1) {
-		Player *p = DEREF_PLAYER(index);
+		Player *p = GetPlayer(index);
 		p->is_ai = (index != 0);
 		SaveLoad_PLYR(p);
 		_player_colors[index] = p->player_color;
--- a/roadveh_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/roadveh_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -826,7 +826,7 @@
 
 		/* draw the widgets */
 		{
-			const Player *p = DEREF_PLAYER(owner);
+			const Player *p = GetPlayer(owner);
 			if (station == -1) {
 				/* Company Name -- (###) Road vehicles */
 				SetDParam(0, p->name_1);
--- a/ship_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/ship_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -926,7 +926,7 @@
 
 		/* draw the widgets */
 		{
-			const Player *p = DEREF_PLAYER(owner);
+			const Player *p = GetPlayer(owner);
 			if (station == -1) {
 				/* Company Name -- (###) Trains */
 				SetDParam(0, p->name_1);
--- a/station_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/station_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -154,7 +154,7 @@
 
 		/* draw widgets, with player's name in the caption */
 		{
-			Player *p = DEREF_PLAYER(window_number);
+			Player *p = GetPlayer(window_number);
 			SetDParam(0, p->name_1);
 			SetDParam(1, p->name_2);
 			SetDParam(2, w->vscroll.count);
--- a/subsidy_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/subsidy_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -112,7 +112,7 @@
 		if (s->cargo_type != 0xFF && s->age >= 12) {
 			SetupSubsidyDecodeParam(s, 1);
 
-			p = DEREF_PLAYER(GetStation(s->to)->owner);
+			p = GetPlayer(GetStation(s->to)->owner);
 			SetDParam(3, p->name_1);
 			SetDParam(4, p->name_2);
 
--- a/town_cmd.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/town_cmd.c	Tue Jun 21 16:28:17 2005 +0000
@@ -1556,7 +1556,7 @@
 
 	SetDParam(0, t->index);
 
-	p = DEREF_PLAYER(_current_player);
+	p = GetPlayer(_current_player);
 	SetDParam(1, p->name_1);
 	SetDParam(2, p->name_2);
 
--- a/town_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/town_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -52,7 +52,7 @@
 		}
 
 		// Things worth more than this are not shown
-		avail = DEREF_PLAYER(pid)->player_money + _price.station_value * 200;
+		avail = GetPlayer(pid)->player_money + _price.station_value * 200;
 		ref = _price.build_industry >> 8;
 
 		for (i = 0; i != lengthof(_town_action_costs); i++, avail_buttons >>= 1) {
--- a/train_gui.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/train_gui.c	Tue Jun 21 16:28:17 2005 +0000
@@ -323,7 +323,7 @@
 		WP(w,buildtrain_d).railtype = _map3_lo[tile] & 0xF;
 	} else {
 		w->caption_color = _local_player;
-		WP(w,buildtrain_d).railtype = DEREF_PLAYER(_local_player)->max_railtype - 1;
+		WP(w,buildtrain_d).railtype = GetPlayer(_local_player)->max_railtype - 1;
 	}
 }
 
@@ -1305,7 +1305,7 @@
 
 		/* draw the widgets */
 		{
-			const Player *p = DEREF_PLAYER(owner);
+			const Player *p = GetPlayer(owner);
 			if (station == -1) {
 				/* Company Name -- (###) Trains */
 				SetDParam(0, p->name_1);
--- a/unmovable_cmd.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/unmovable_cmd.c	Tue Jun 21 16:28:17 2005 +0000
@@ -36,7 +36,7 @@
 		}
 		if (!dodelete) return CMD_ERROR;
 	} else /* Destruction was initiated by player */
-		p = DEREF_PLAYER(_current_player);
+		p = GetPlayer(_current_player);
 
 		if (p->location_of_house == 0) return CMD_ERROR;
 
@@ -62,7 +62,7 @@
 int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
 	TileIndex tile = TILE_FROM_XY(x,y);
-	Player *p = DEREF_PLAYER(_current_player);
+	Player *p = GetPlayer(_current_player);
 	int cost;
 
 	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
--- a/vehicle.c	Tue Jun 21 14:50:08 2005 +0000
+++ b/vehicle.c	Tue Jun 21 16:28:17 2005 +0000
@@ -1415,7 +1415,7 @@
 
 	/* Check if there is money for the upgrade.. if not, give a nice news-item
 	    (that is needed, because this CMD is called automaticly) */
-	if ( DEREF_PLAYER(v->owner)->money64 < (int32)(autorefit_money + build_cost + rear_engine_cost - v->value)) {
+	if ( GetPlayer(v->owner)->money64 < (int32)(autorefit_money + build_cost + rear_engine_cost - v->value)) {
 		if (( _local_player == v->owner ) && ( v->unitnumber != 0 )) {  //v->unitnumber = 0 for train cars
 			int message;
 			SetDParam(0, v->unitnumber);