mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r3001) s/Player*/const Player*/
s/byte/PlayerID/ s/int/PlayerID/ and related changes
This commit is contained in:
parent
af5b74f0ed
commit
ed8c9c91d6
@ -1518,7 +1518,7 @@ static void AircraftEventHandler_EndTakeOff(Vehicle *v, const AirportFTAClass *A
|
||||
|
||||
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_Flying(Vehicle *v, const AirportFTAClass *Airpo
|
||||
|
||||
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
|
||||
|
@ -72,8 +72,9 @@ void UpdatePlayerHouse(Player *p, uint score)
|
||||
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 @@ extern void DeletePlayerWindows(int pi);
|
||||
|
||||
static void PlayersCheckBankrupt(Player *p)
|
||||
{
|
||||
int owner;
|
||||
PlayerID owner;
|
||||
int64 val;
|
||||
|
||||
// If the player has money again, it does not go bankrupt
|
||||
|
@ -75,7 +75,7 @@ void SubtractMoneyFromPlayer(int32 cost);
|
||||
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);
|
||||
|
18
graph_gui.c
18
graph_gui.c
@ -219,7 +219,7 @@ void DrawPlayerIcon(int p, int x, int y)
|
||||
|
||||
static void GraphLegendWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
Player *p;
|
||||
const Player* p;
|
||||
|
||||
switch(e->event) {
|
||||
case WE_PAINT:
|
||||
@ -291,7 +291,7 @@ static void ShowGraphLegend(void)
|
||||
|
||||
static void SetupGraphDrawerForPlayers(GraphDrawer *gd)
|
||||
{
|
||||
Player *p;
|
||||
const Player* p;
|
||||
uint excludebits = _legend_excludebits;
|
||||
int nums;
|
||||
int mo,yr;
|
||||
@ -325,7 +325,7 @@ static void OperatingProfitWndProc(Window *w, WindowEvent *e)
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
GraphDrawer gd;
|
||||
Player *p;
|
||||
const Player* p;
|
||||
int i,j;
|
||||
int numd;
|
||||
|
||||
@ -399,7 +399,7 @@ static void IncomeGraphWndProc(Window *w, WindowEvent *e)
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
GraphDrawer gd;
|
||||
Player *p;
|
||||
const Player* p;
|
||||
int i,j;
|
||||
int numd;
|
||||
|
||||
@ -472,7 +472,7 @@ static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e)
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
GraphDrawer gd;
|
||||
Player *p;
|
||||
const Player* p;
|
||||
int i,j;
|
||||
int numd;
|
||||
|
||||
@ -545,7 +545,7 @@ static void PerformanceHistoryWndProc(Window *w, WindowEvent *e)
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
GraphDrawer gd;
|
||||
Player *p;
|
||||
const Player* p;
|
||||
int i,j;
|
||||
int numd;
|
||||
|
||||
@ -621,7 +621,7 @@ static void CompanyValueGraphWndProc(Window *w, WindowEvent *e)
|
||||
switch(e->event) {
|
||||
case WE_PAINT: {
|
||||
GraphDrawer gd;
|
||||
Player *p;
|
||||
const Player* p;
|
||||
int i,j;
|
||||
int numd;
|
||||
|
||||
@ -826,8 +826,8 @@ static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
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;
|
||||
|
||||
|
6
gui.h
6
gui.h
@ -86,9 +86,9 @@ void ShowBuildTreesScenToolbar(void);
|
||||
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);
|
||||
|
@ -484,7 +484,7 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e)
|
||||
_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(
|
||||
|
8
player.h
8
player.h
@ -195,8 +195,8 @@ typedef struct Player {
|
||||
|
||||
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 @@ static inline byte GetBestRailtype(const Player *p)
|
||||
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];
|
||||
|
23
player_gui.c
23
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 @@ static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
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 @@ static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
|
||||
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 @@ static const WindowDesc * const desc_table[2*2] = {
|
||||
&_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 @@ static void DoShowPlayerFinances(int player, bool show_small, bool show_stickied
|
||||
}
|
||||
}
|
||||
|
||||
void ShowPlayerFinances(int player)
|
||||
void ShowPlayerFinances(PlayerID player)
|
||||
{
|
||||
DoShowPlayerFinances(player, false, false);
|
||||
}
|
||||
@ -247,7 +248,7 @@ static void SelectPlayerColorWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
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 @@ int GetAmountOwnedBy(const Player *p, PlayerID owner)
|
||||
|
||||
static void DrawCompanyOwnerText(const Player *p)
|
||||
{
|
||||
const Player* p2;
|
||||
int num = -1;
|
||||
Player *p2;
|
||||
int amt;
|
||||
|
||||
FOR_ALL_PLAYERS(p2) {
|
||||
@ -506,7 +507,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
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 @@ static const WindowDesc _other_player_company_desc = {
|
||||
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);
|
||||
|
@ -185,7 +185,7 @@ void DrawPlayerFace(uint32 face, int color, int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void InvalidatePlayerWindows(Player *p)
|
||||
void InvalidatePlayerWindows(const Player *p)
|
||||
{
|
||||
PlayerID pid = p->index;
|
||||
|
||||
@ -568,7 +568,7 @@ void OnTick_Players(void)
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
@ -63,7 +63,7 @@ struct Station {
|
||||
byte time_since_load;
|
||||
byte time_since_unload;
|
||||
byte delete_ctr;
|
||||
byte owner;
|
||||
PlayerID owner;
|
||||
byte facilities;
|
||||
byte airport_type;
|
||||
|
||||
|
@ -259,7 +259,7 @@ static const WindowDesc _player_stations_desc = {
|
||||
};
|
||||
|
||||
|
||||
void ShowPlayerStations(int player)
|
||||
void ShowPlayerStations(PlayerID player)
|
||||
{
|
||||
Window *w;
|
||||
|
||||
|
@ -1564,7 +1564,7 @@ int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user