summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-09-30 20:37:25 +0000
committertron <tron@openttd.org>2005-09-30 20:37:25 +0000
commited8c9c91d66f593dc3fae5cef4469ded311f6d75 (patch)
tree1e61685bece04279bd25b3f79e645384c1d83405
parentaf5b74f0edfb02077f55d6c1ac6713d3aa18d753 (diff)
downloadopenttd-ed8c9c91d66f593dc3fae5cef4469ded311f6d75.tar.xz
(svn r3001) s/Player*/const Player*/
s/byte/PlayerID/ s/int/PlayerID/ and related changes
-rw-r--r--aircraft_cmd.c4
-rw-r--r--economy.c7
-rw-r--r--functions.h2
-rw-r--r--graph_gui.c18
-rw-r--r--gui.h6
-rw-r--r--misc_gui.c2
-rw-r--r--player.h8
-rw-r--r--player_gui.c23
-rw-r--r--players.c4
-rw-r--r--station.h2
-rw-r--r--station_gui.c2
-rw-r--r--train_cmd.c2
12 files changed, 41 insertions, 39 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 69b008be7..55568c474 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -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
diff --git a/economy.c b/economy.c
index 8d9366039..10676e417 100644
--- a/economy.c
+++ b/economy.c
@@ -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
diff --git a/functions.h b/functions.h
index 7afcd6244..52abb297b 100644
--- a/functions.h
+++ b/functions.h
@@ -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);
diff --git a/graph_gui.c b/graph_gui.c
index 76d008259..e861de2a7 100644
--- a/graph_gui.c
+++ b/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;
diff --git a/gui.h b/gui.h
index 6090b1489..823111c8d 100644
--- a/gui.h
+++ b/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);
diff --git a/misc_gui.c b/misc_gui.c
index 6383b2ec4..00062b5e2 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -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(
diff --git a/player.h b/player.h
index 645cb31ad..88a5ba7e4 100644
--- a/player.h
+++ b/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];
diff --git a/player_gui.c b/player_gui.c
index e9867d234..41fdf9e92 100644
--- 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 @@ 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);
diff --git a/players.c b/players.c
index 11f2cff28..e0ec098b1 100644
--- a/players.c
+++ b/players.c
@@ -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);
diff --git a/station.h b/station.h
index 15989193f..837031399 100644
--- a/station.h
+++ b/station.h
@@ -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;
diff --git a/station_gui.c b/station_gui.c
index 7fede26c5..00376daae 100644
--- a/station_gui.c
+++ b/station_gui.c
@@ -259,7 +259,7 @@ static const WindowDesc _player_stations_desc = {
};
-void ShowPlayerStations(int player)
+void ShowPlayerStations(PlayerID player)
{
Window *w;
diff --git a/train_cmd.c b/train_cmd.c
index b9687da4d..cc34c3169 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -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