mirror of https://github.com/OpenTTD/OpenTTD
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
IS_INTERACTIVE_PLAYERrelease/0.5
parent
91ac1fa186
commit
2dcdeb985d
|
@ -3773,7 +3773,7 @@ static void AiHandleTakeover(Player *p)
|
||||||
AskExitToGameMenu();
|
AskExitToGameMenu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (IS_HUMAN_PLAYER(_current_player)) return;
|
if (IsHumanPlayer(_current_player)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->bankrupt_asked == 255) return;
|
if (p->bankrupt_asked == 255) return;
|
||||||
|
@ -3809,7 +3809,7 @@ static void AiHandleTakeover(Player *p)
|
||||||
ShowBuyCompanyDialog(_current_player);
|
ShowBuyCompanyDialog(_current_player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (IS_HUMAN_PLAYER(best_pl->index)) return;
|
if (IsHumanPlayer(best_pl->index)) return;
|
||||||
|
|
||||||
// Too little money for computer to buy it?
|
// Too little money for computer to buy it?
|
||||||
if (best_pl->player_money >> 1 >= p->bankrupt_value) {
|
if (best_pl->player_money >> 1 >= p->bankrupt_value) {
|
||||||
|
@ -3866,7 +3866,7 @@ void AiDoGameLoop(Player *p)
|
||||||
// or in %
|
// or in %
|
||||||
_ai_service_interval = _patches.servint_ispercent?80:180;
|
_ai_service_interval = _patches.servint_ispercent?80:180;
|
||||||
|
|
||||||
if (IS_HUMAN_PLAYER(_current_player)) return;
|
if (IsHumanPlayer(_current_player)) return;
|
||||||
|
|
||||||
AiAdjustLoan(p);
|
AiAdjustLoan(p);
|
||||||
AiBuildCompanyHQ(p);
|
AiBuildCompanyHQ(p);
|
||||||
|
|
|
@ -627,7 +627,7 @@ int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
_returned_refit_capacity = pass;
|
_returned_refit_capacity = pass;
|
||||||
|
|
||||||
cost = 0;
|
cost = 0;
|
||||||
if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) {
|
if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
|
||||||
cost = GetRefitCost(v->engine_type);
|
cost = GetRefitCost(v->engine_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ static void DisasterClearSquare(TileIndex tile)
|
||||||
|
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (IS_HUMAN_PLAYER(GetTileOwner(tile)) && !IsRailWaypoint(tile)) {
|
if (IsHumanPlayer(GetTileOwner(tile)) && !IsRailWaypoint(tile)) {
|
||||||
PlayerID p = _current_player;
|
PlayerID p = _current_player;
|
||||||
_current_player = OWNER_WATER;
|
_current_player = OWNER_WATER;
|
||||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||||
|
@ -188,7 +188,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||||
if (IsValidTile(tile) &&
|
if (IsValidTile(tile) &&
|
||||||
IsTileType(tile, MP_STATION) &&
|
IsTileType(tile, MP_STATION) &&
|
||||||
IsAirport(tile) &&
|
IsAirport(tile) &&
|
||||||
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
|
IsHumanPlayer(GetTileOwner(tile))) {
|
||||||
v->current_order.dest = 1;
|
v->current_order.dest = 1;
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||||
if (IsValidTile(tile) &&
|
if (IsValidTile(tile) &&
|
||||||
IsTileType(tile, MP_STATION) &&
|
IsTileType(tile, MP_STATION) &&
|
||||||
IsAirport(tile) &&
|
IsAirport(tile) &&
|
||||||
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
|
IsHumanPlayer(GetTileOwner(tile))) {
|
||||||
st = GetStationByTile(tile);
|
st = GetStationByTile(tile);
|
||||||
CLRBITS(st->airport_flags, RUNWAY_IN_block);
|
CLRBITS(st->airport_flags, RUNWAY_IN_block);
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||||
if (IsValidTile(tile) &&
|
if (IsValidTile(tile) &&
|
||||||
IsTileType(tile, MP_STATION) &&
|
IsTileType(tile, MP_STATION) &&
|
||||||
IsAirport(tile) &&
|
IsAirport(tile) &&
|
||||||
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
|
IsHumanPlayer(GetTileOwner(tile))) {
|
||||||
st = GetStationByTile(tile);
|
st = GetStationByTile(tile);
|
||||||
SETBITS(st->airport_flags, RUNWAY_IN_block);
|
SETBITS(st->airport_flags, RUNWAY_IN_block);
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ static void DisasterTick_UFO(Vehicle *v)
|
||||||
v->current_order.dest = 1;
|
v->current_order.dest = 1;
|
||||||
|
|
||||||
FOR_ALL_VEHICLES(u) {
|
FOR_ALL_VEHICLES(u) {
|
||||||
if (u->type == VEH_Road && IS_HUMAN_PLAYER(u->owner)) {
|
if (u->type == VEH_Road && IsHumanPlayer(u->owner)) {
|
||||||
v->dest_tile = u->index;
|
v->dest_tile = u->index;
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -595,7 +595,7 @@ static void DisasterTick_4(Vehicle *v)
|
||||||
do {
|
do {
|
||||||
if (IsTileType(tile, MP_RAILWAY) &&
|
if (IsTileType(tile, MP_RAILWAY) &&
|
||||||
IsPlainRailTile(tile) &&
|
IsPlainRailTile(tile) &&
|
||||||
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
|
IsHumanPlayer(GetTileOwner(tile))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tile = TILE_MASK(tile+1);
|
tile = TILE_MASK(tile+1);
|
||||||
|
@ -726,7 +726,7 @@ static void Disaster0_Init(void)
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->airport_tile != 0 &&
|
if (st->airport_tile != 0 &&
|
||||||
st->airport_type <= 1 &&
|
st->airport_type <= 1 &&
|
||||||
IS_HUMAN_PLAYER(st->owner)) {
|
IsHumanPlayer(st->owner)) {
|
||||||
x = (TileX(st->xy) + 2) * TILE_SIZE;
|
x = (TileX(st->xy) + 2) * TILE_SIZE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
12
economy.c
12
economy.c
|
@ -388,7 +388,7 @@ static void PlayersCheckBankrupt(Player *p)
|
||||||
case 3: {
|
case 3: {
|
||||||
/* XXX - In multiplayer, should we ask other players if it wants to take
|
/* XXX - In multiplayer, should we ask other players if it wants to take
|
||||||
over when it is a human company? -- TrueLight */
|
over when it is a human company? -- TrueLight */
|
||||||
if (IS_HUMAN_PLAYER(owner)) {
|
if (IsHumanPlayer(owner)) {
|
||||||
AddNewsItem( (StringID)(owner + 16),
|
AddNewsItem( (StringID)(owner + 16),
|
||||||
NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
|
NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
|
||||||
break;
|
break;
|
||||||
|
@ -415,12 +415,12 @@ static void PlayersCheckBankrupt(Player *p)
|
||||||
AddNewsItem( (StringID)(owner + 16*3), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
|
AddNewsItem( (StringID)(owner + 16*3), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
|
||||||
|
|
||||||
// If the player is human, and it is no network play, leave the player playing
|
// If the player is human, and it is no network play, leave the player playing
|
||||||
if (IS_HUMAN_PLAYER(owner) && !_networking) {
|
if (IsHumanPlayer(owner) && !_networking) {
|
||||||
p->bankrupt_asked = 255;
|
p->bankrupt_asked = 255;
|
||||||
p->bankrupt_timeout = 0x456;
|
p->bankrupt_timeout = 0x456;
|
||||||
} else {
|
} else {
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
if (IS_HUMAN_PLAYER(owner) && _network_server) {
|
if (IsHumanPlayer(owner) && _network_server) {
|
||||||
// If we are the server, make sure it is clear that his player is no
|
// If we are the server, make sure it is clear that his player is no
|
||||||
// longer with us!
|
// longer with us!
|
||||||
NetworkClientInfo *ci;
|
NetworkClientInfo *ci;
|
||||||
|
@ -436,7 +436,7 @@ static void PlayersCheckBankrupt(Player *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Make sure the player no longer controls the company
|
// Make sure the player no longer controls the company
|
||||||
if (IS_HUMAN_PLAYER(owner) && owner == _local_player) {
|
if (IsHumanPlayer(owner) && owner == _local_player) {
|
||||||
// Switch the player to spectator..
|
// Switch the player to spectator..
|
||||||
_local_player = OWNER_SPECTATOR;
|
_local_player = OWNER_SPECTATOR;
|
||||||
}
|
}
|
||||||
|
@ -447,9 +447,9 @@ static void PlayersCheckBankrupt(Player *p)
|
||||||
// Register the player as not-active
|
// Register the player as not-active
|
||||||
p->is_active = false;
|
p->is_active = false;
|
||||||
|
|
||||||
if (!IS_HUMAN_PLAYER(owner) && (!_networking || _network_server) && _ai.enabled)
|
if (!IsHumanPlayer(owner) && (!_networking || _network_server) && _ai.enabled)
|
||||||
AI_PlayerDied(owner);
|
AI_PlayerDied(owner);
|
||||||
if (IS_HUMAN_PLAYER(owner) && owner == _local_player && _ai.network_client)
|
if (IsHumanPlayer(owner) && owner == _local_player && _ai.network_client)
|
||||||
AI_PlayerDied(owner);
|
AI_PlayerDied(owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
engine.c
4
engine.c
|
@ -268,13 +268,13 @@ void EnginesDailyLoop(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_HUMAN_PLAYER(best_player)) {
|
if (!IsHumanPlayer(best_player)) {
|
||||||
/* XXX - TTDBUG: TTD has a bug here ???? */
|
/* XXX - TTDBUG: TTD has a bug here ???? */
|
||||||
AcceptEnginePreview(e, best_player);
|
AcceptEnginePreview(e, best_player);
|
||||||
} else {
|
} else {
|
||||||
e->flags |= ENGINE_PREVIEWING;
|
e->flags |= ENGINE_PREVIEWING;
|
||||||
e->preview_wait = 20;
|
e->preview_wait = 20;
|
||||||
if (IS_INTERACTIVE_PLAYER(best_player)) ShowEnginePreviewWindow(i);
|
if (IsInteractivePlayer(best_player)) ShowEnginePreviewWindow(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ int32 CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* Loan the maximum amount or not? */
|
/* Loan the maximum amount or not? */
|
||||||
int32 loan = (p2) ? _economy.max_loan - p->current_loan : (IS_HUMAN_PLAYER(_current_player) || _patches.ainew_active) ? 10000 : 50000;
|
int32 loan = (p2) ? _economy.max_loan - p->current_loan : (IsHumanPlayer(_current_player) || _patches.ainew_active) ? 10000 : 50000;
|
||||||
|
|
||||||
p->money64 += loan;
|
p->money64 += loan;
|
||||||
p->current_loan += loan;
|
p->current_loan += loan;
|
||||||
|
@ -160,7 +160,7 @@ int32 CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
loan = max(loan, 10000);
|
loan = max(loan, 10000);
|
||||||
loan -= loan % 10000;
|
loan -= loan % 10000;
|
||||||
} else {
|
} else {
|
||||||
loan = min(loan, (IS_HUMAN_PLAYER(_current_player) || _patches.ainew_active) ? 10000 : 50000);
|
loan = min(loan, (IsHumanPlayer(_current_player) || _patches.ainew_active) ? 10000 : 50000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->player_money < loan) {
|
if (p->player_money < loan) {
|
||||||
|
|
|
@ -997,7 +997,7 @@ static bool LoadOldPlayer(LoadgameState *ls, int num)
|
||||||
* really figured out as of now, p->ai.cur_veh; needed for 'sell vehicle'
|
* really figured out as of now, p->ai.cur_veh; needed for 'sell vehicle'
|
||||||
* is NULL and the function will crash. To fix this, just change the state
|
* is NULL and the function will crash. To fix this, just change the state
|
||||||
* to some harmless state, like 'loop vehicle'; 1 */
|
* to some harmless state, like 'loop vehicle'; 1 */
|
||||||
if (!IS_HUMAN_PLAYER(num) && p->ai.state == 20) p->ai.state = 1;
|
if (!IsHumanPlayer(num) && p->ai.state == 20) p->ai.state = 1;
|
||||||
|
|
||||||
if (p->is_ai && (!_networking || _network_server) && _ai.enabled)
|
if (p->is_ai && (!_networking || _network_server) && _ai.enabled)
|
||||||
AI_StartNewAI(p->index);
|
AI_StartNewAI(p->index);
|
||||||
|
|
|
@ -352,7 +352,7 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
/* For ships, make sure that the station is not too far away from the
|
/* For ships, make sure that the station is not too far away from the
|
||||||
* previous destination, for human players with new pathfinding disabled */
|
* previous destination, for human players with new pathfinding disabled */
|
||||||
if (v->type == VEH_Ship && IS_HUMAN_PLAYER(v->owner) &&
|
if (v->type == VEH_Ship && IsHumanPlayer(v->owner) &&
|
||||||
sel_ord != 0 && GetVehicleOrder(v, sel_ord - 1)->type == OT_GOTO_STATION
|
sel_ord != 0 && GetVehicleOrder(v, sel_ord - 1)->type == OT_GOTO_STATION
|
||||||
&& !_patches.new_pathfinding_all) {
|
&& !_patches.new_pathfinding_all) {
|
||||||
|
|
||||||
|
|
13
player.h
13
player.h
|
@ -248,6 +248,16 @@ static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
|
||||||
return HASBIT(p->avail_railtypes, Railtype);
|
return HASBIT(p->avail_railtypes, Railtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool IsHumanPlayer(PlayerID pi)
|
||||||
|
{
|
||||||
|
return !GetPlayer(pi)->is_ai;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool IsInteractivePlayer(PlayerID pi)
|
||||||
|
{
|
||||||
|
return pi == _local_player;
|
||||||
|
}
|
||||||
|
|
||||||
/* Validate functions for rail building */
|
/* Validate functions for rail building */
|
||||||
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);}
|
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);}
|
||||||
|
|
||||||
|
@ -265,9 +275,6 @@ static inline RailType GetBestRailtype(const Player* p)
|
||||||
return RAILTYPE_RAIL;
|
return RAILTYPE_RAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_HUMAN_PLAYER(p) (!GetPlayer(p)->is_ai)
|
|
||||||
#define IS_INTERACTIVE_PLAYER(p) ((p) == _local_player)
|
|
||||||
|
|
||||||
typedef struct HighScore {
|
typedef struct HighScore {
|
||||||
char company[100];
|
char company[100];
|
||||||
StringID title; // NO_SAVE, has troubles with changing string-numbers.
|
StringID title; // NO_SAVE, has troubles with changing string-numbers.
|
||||||
|
|
|
@ -341,7 +341,7 @@ set_name:;
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
|
||||||
if (!IS_HUMAN_PLAYER(p->index)) {
|
if (!IsHumanPlayer(p->index)) {
|
||||||
SetDParam(0, t->index);
|
SetDParam(0, t->index);
|
||||||
AddNewsItem(p->index + (4 << 4), NEWS_FLAGS(NM_CALLBACK, NF_TILE, NT_COMPANY_INFO, DNC_BANKRUPCY), p->last_build_coordinate, 0);
|
AddNewsItem(p->index + (4 << 4), NEWS_FLAGS(NM_CALLBACK, NF_TILE, NT_COMPANY_INFO, DNC_BANKRUPCY), p->last_build_coordinate, 0);
|
||||||
}
|
}
|
||||||
|
@ -584,7 +584,7 @@ void OnTick_Players(void)
|
||||||
// index is the next parameter in _decode_parameters to set up
|
// index is the next parameter in _decode_parameters to set up
|
||||||
StringID GetPlayerNameString(PlayerID player, uint index)
|
StringID GetPlayerNameString(PlayerID player, uint index)
|
||||||
{
|
{
|
||||||
if (IS_HUMAN_PLAYER(player) && player < MAX_PLAYERS) {
|
if (IsHumanPlayer(player) && player < MAX_PLAYERS) {
|
||||||
SetDParam(index, player+1);
|
SetDParam(index, player+1);
|
||||||
return STR_7002_PLAYER;
|
return STR_7002_PLAYER;
|
||||||
}
|
}
|
||||||
|
@ -917,7 +917,7 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
p = GetPlayer(p2);
|
p = GetPlayer(p2);
|
||||||
|
|
||||||
/* Only allow removal of HUMAN companies */
|
/* Only allow removal of HUMAN companies */
|
||||||
if (IS_HUMAN_PLAYER(p->index)) {
|
if (IsHumanPlayer(p->index)) {
|
||||||
/* Delete any open window of the company */
|
/* Delete any open window of the company */
|
||||||
DeletePlayerWindows(p->index);
|
DeletePlayerWindows(p->index);
|
||||||
|
|
||||||
|
@ -1268,7 +1268,7 @@ static void SaveLoad_PLYR(Player* p)
|
||||||
SlObject(p, _player_desc);
|
SlObject(p, _player_desc);
|
||||||
|
|
||||||
// Write AI?
|
// Write AI?
|
||||||
if (!IS_HUMAN_PLAYER(p->index)) {
|
if (!IsHumanPlayer(p->index)) {
|
||||||
SlObject(&p->ai, _player_ai_desc);
|
SlObject(&p->ai, _player_ai_desc);
|
||||||
for (i = 0; i != p->ai.num_build_rec; i++) {
|
for (i = 0; i != p->ai.num_build_rec; i++) {
|
||||||
SlObject(&p->ai.src + i, _player_ai_build_rec_desc);
|
SlObject(&p->ai.src + i, _player_ai_build_rec_desc);
|
||||||
|
|
|
@ -1804,7 +1804,7 @@ int32 CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
_returned_refit_capacity = capacity;
|
_returned_refit_capacity = capacity;
|
||||||
|
|
||||||
cost = 0;
|
cost = 0;
|
||||||
if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) {
|
if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
|
||||||
cost = GetRefitCost(v->engine_type);
|
cost = GetRefitCost(v->engine_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1089,7 +1089,7 @@ int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
_returned_refit_capacity = capacity;
|
_returned_refit_capacity = capacity;
|
||||||
|
|
||||||
cost = 0;
|
cost = 0;
|
||||||
if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) {
|
if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
|
||||||
cost = GetRefitCost(v->engine_type);
|
cost = GetRefitCost(v->engine_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue