(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer

This commit is contained in:
celestar 2005-06-21 16:28:17 +00:00
parent e2df1d71d5
commit aa7334a3ec
26 changed files with 73 additions and 74 deletions

View File

@ -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;

View File

@ -942,7 +942,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
/* 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);

View File

@ -336,7 +336,7 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
_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 p1, uint32 p2, CommandCallback *callback,
#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 */

View File

@ -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;

View File

@ -378,7 +378,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_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 *from, Station *to, byte cargo_type)
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, byte cargo_type, uint16 source, uint16
// 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, uint32 flags, uint32 p1, uint32 p2)
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, uint32 flags, uint32 p1, uint32 p2)
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 flags, uint32 p1, uint32 p2)
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;

View File

@ -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);

View File

@ -904,7 +904,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
// 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 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
// 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);
}
}

View File

@ -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 *w)
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, WindowEvent *e)
{
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);

View File

@ -137,7 +137,7 @@ int32 CmdChangeCompanyName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 y, uint32 flags, uint32 p1, uint32 p2)
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 flags, uint32 p1, uint32 p2)
*/
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);

View File

@ -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, WindowEvent *e)
_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);

View File

@ -513,7 +513,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
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_CHAT)
/* 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:

View File

@ -1046,7 +1046,7 @@ void NetworkServer_HandleChat(NetworkAction action, DestType desttype, int dest,
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) {

View File

@ -810,7 +810,7 @@ static const OldChunks player_yearly_chunk[] = {
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_chunk[] = {
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_rec_chunk[] = {
};
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;

View File

@ -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);

View File

@ -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 {

View File

@ -144,7 +144,7 @@ static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
{
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(Window *w, WindowEvent *e)
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 *w, WindowEvent *e)
{
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 *w, WindowEvent *e)
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 *w, WindowEvent *e)
} 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 *w, WindowEvent *e)
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, WindowEvent *e)
{
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, WindowEvent *e)
{
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);
}

View File

@ -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 tile)
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 flags, uint32 p1, uint32 p2)
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;

View File

@ -826,7 +826,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
/* 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);

View File

@ -926,7 +926,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
/* 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);

View File

@ -154,7 +154,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
/* 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);

View File

@ -112,7 +112,7 @@ static void DrawSubsidiesWindow(Window *w)
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);

View File

@ -1556,7 +1556,7 @@ static void TownActionRoadRebuild(Town *t, int action)
SetDParam(0, t->index);
p = DEREF_PLAYER(_current_player);
p = GetPlayer(_current_player);
SetDParam(1, p->name_1);
SetDParam(2, p->name_2);

View File

@ -52,7 +52,7 @@ uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t)
}
// 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) {

View File

@ -323,7 +323,7 @@ static void ShowBuildTrainWindow(uint tile)
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 *w, WindowEvent *e)
/* 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);

View File

@ -36,7 +36,7 @@ int32 DestroyCompanyHQ(TileIndex tile, uint32 flags)
}
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, uint32 flags)
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);

View File

@ -1415,7 +1415,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* 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);