diff --git a/ai_pathfinder.c b/ai_pathfinder.c --- a/ai_pathfinder.c +++ b/ai_pathfinder.c @@ -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; diff --git a/aircraft_gui.c b/aircraft_gui.c --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -942,7 +942,7 @@ static void PlayerAircraftWndProc(Window /* 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); diff --git a/command.c b/command.c --- a/command.c +++ b/command.c @@ -336,7 +336,7 @@ int32 DoCommand(int x, int y, uint32 p1, _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 @@ int32 GetAvailableMoneyForCommand(void) { 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 @@ bool DoCommandP(TileIndex tile, uint32 p #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 */ diff --git a/console_cmds.c b/console_cmds.c --- a/console_cmds.c +++ b/console_cmds.c @@ -544,7 +544,7 @@ DEF_CONSOLE_CMD(ConResetCompany) /* Check if company does exist */ index--; - p = DEREF_PLAYER(index); + p = GetPlayer(index); if (!p->is_active) { IConsoleError("Company does not exist."); return true; diff --git a/economy.c b/economy.c --- a/economy.c +++ b/economy.c @@ -378,7 +378,7 @@ void ChangeOwnershipOfPlayerItems(Player 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 @@ void DrawNewsBankrupcy(Window *w) 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 @@ void DrawNewsBankrupcy(Window *w) 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 @@ static bool CheckSubsidised(Station *fro 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 @@ static int32 DeliverGoods(int num_pieces // 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 @@ static void DoAcquireCompany(Player *p) 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 @@ int32 CmdBuyShareInCompany(int x, int y, 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 @@ int32 CmdSellShareInCompany(int x, int y 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 @@ int32 CmdBuyCompany(int x, int y, uint32 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; diff --git a/engine.c b/engine.c --- a/engine.c +++ b/engine.c @@ -754,7 +754,7 @@ StringID GetCustomEngineName(int engine) void AcceptEnginePreview(Engine *e, PlayerID player) { - Player *p = DEREF_PLAYER(player); + Player *p = GetPlayer(player); SETBIT(e->player_avail, player); diff --git a/graph_gui.c b/graph_gui.c --- a/graph_gui.c +++ b/graph_gui.c @@ -904,7 +904,7 @@ static void PerformanceRatingDetailWndPr // Paint the player icons for (i=0;iis_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 @@ static void PerformanceRatingDetailWndPr // Hide the player who are not active for (i=0;iis_active) { + if (!GetPlayer(i)->is_active) { w->disabled_state += 1 << (i+13); } } diff --git a/main_gui.c b/main_gui.c --- a/main_gui.c +++ b/main_gui.c @@ -84,7 +84,7 @@ void HandleOnEditText(WindowEvent *e) 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 MenuClickShowAir(int index) 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 ToolbarZoomOutClick(Window * 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 @@ static void StatusBarWndProc(Window *w, { 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); diff --git a/misc_cmd.c b/misc_cmd.c --- a/misc_cmd.c +++ b/misc_cmd.c @@ -137,7 +137,7 @@ int32 CmdChangeCompanyName(int x, int y, 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 @@ int32 CmdChangePresidentName(int x, int 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 CmdMoneyCheat(int x, int y, uint32 */ 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); diff --git a/misc_gui.c b/misc_gui.c --- a/misc_gui.c +++ b/misc_gui.c @@ -131,9 +131,9 @@ static void Place_LandInfo(uint tile) 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 @@ static void ErrmsgWndProc(Window *w, Win _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 @@ static void GenerateFileName(void) /* 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); diff --git a/network_client.c b/network_client.c --- a/network_client.c +++ b/network_client.c @@ -513,7 +513,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER 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 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER /* 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: diff --git a/network_server.c b/network_server.c --- a/network_server.c +++ b/network_server.c @@ -1046,7 +1046,7 @@ void NetworkServer_HandleChat(NetworkAct 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) { diff --git a/oldloader.c b/oldloader.c --- a/oldloader.c +++ b/oldloader.c @@ -810,7 +810,7 @@ static const OldChunks player_yearly_chu 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 const OldChunks player_economy_ch 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 const OldChunks player_ai_build_r }; 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 const OldChunks player_ai_chunk[] }; 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 const OldChunks player_chunk[] = }; static bool LoadOldPlayer(LoadgameState *ls, int num) { - Player *p = DEREF_PLAYER(num); + Player *p = GetPlayer(num); _current_player_id = num; diff --git a/openttd.c b/openttd.c --- a/openttd.c +++ b/openttd.c @@ -1033,7 +1033,7 @@ static void DoAutosave(void) 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); diff --git a/player.h b/player.h --- a/player.h +++ b/player.h @@ -197,14 +197,13 @@ void UpdatePlayerMoney32(Player *p); #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 { diff --git a/player_gui.c b/player_gui.c --- a/player_gui.c +++ b/player_gui.c @@ -144,7 +144,7 @@ static void PlayerFinancesWndProc(Window { 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 @@ static void SelectPlayerFaceWndProc(Wind 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 @@ static void PlayerCompanyWndProc(Window { 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 @@ static void PlayerCompanyWndProc(Window 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 @@ static void PlayerCompanyWndProc(Window } 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 @@ static void PlayerCompanyWndProc(Window 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 @@ static void BuyCompanyWndProc(Window *w, { 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 @@ static void EndGameWndProc(Window *w, Wi { 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 @@ void ShowEndGameChart(void) 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 @@ void ShowEndGameChart(void) 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); } diff --git a/players.c b/players.c --- a/players.c +++ b/players.c @@ -194,7 +194,7 @@ bool CheckPlayerHasMoney(int32 cost) { 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 @@ void SubtractMoneyFromPlayer(int32 cost) { 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 @@ void GetNameOfOwner(byte owner, uint til 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 @@ void OnTick_Players(void) 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 @@ void PlayersYearlyLoop(void) 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 @@ static void DeletePlayerStuff(int pi) 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 @@ int32 CmdPlayerCtrl(int x, int y, uint32 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 @@ static void Load_PLYR(void) { 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; diff --git a/roadveh_gui.c b/roadveh_gui.c --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -826,7 +826,7 @@ static void PlayerRoadVehWndProc(Window /* 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); diff --git a/ship_gui.c b/ship_gui.c --- a/ship_gui.c +++ b/ship_gui.c @@ -926,7 +926,7 @@ static void PlayerShipsWndProc(Window *w /* 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); diff --git a/station_gui.c b/station_gui.c --- a/station_gui.c +++ b/station_gui.c @@ -154,7 +154,7 @@ static void PlayerStationsWndProc(Window /* 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); diff --git a/subsidy_gui.c b/subsidy_gui.c --- a/subsidy_gui.c +++ b/subsidy_gui.c @@ -112,7 +112,7 @@ static void DrawSubsidiesWindow(Window * 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); diff --git a/town_cmd.c b/town_cmd.c --- a/town_cmd.c +++ b/town_cmd.c @@ -1556,7 +1556,7 @@ static void TownActionRoadRebuild(Town * SetDParam(0, t->index); - p = DEREF_PLAYER(_current_player); + p = GetPlayer(_current_player); SetDParam(1, p->name_1); SetDParam(2, p->name_2); diff --git a/town_gui.c b/town_gui.c --- a/town_gui.c +++ b/town_gui.c @@ -52,7 +52,7 @@ uint GetMaskOfTownActions(int *nump, Pla } // 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) { diff --git a/train_gui.c b/train_gui.c --- a/train_gui.c +++ b/train_gui.c @@ -323,7 +323,7 @@ static void ShowBuildTrainWindow(uint ti 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 @@ static void PlayerTrainsWndProc(Window * /* 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); diff --git a/unmovable_cmd.c b/unmovable_cmd.c --- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -36,7 +36,7 @@ int32 DestroyCompanyHQ(TileIndex tile, u } 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 DestroyCompanyHQ(TileIndex tile, u 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); diff --git a/vehicle.c b/vehicle.c --- a/vehicle.c +++ b/vehicle.c @@ -1415,7 +1415,7 @@ int32 CmdReplaceVehicle(int x, int y, ui /* 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);