summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-09-30 20:39:50 +0000
committerrubidium <rubidium@openttd.org>2008-09-30 20:39:50 +0000
commit3b798599b63067c2e92aa49906ea66a07ae8de44 (patch)
tree69fb7ae1d9bdadb9e7386cb70b0a26621ad9b57f
parentcc1e761edab14f8264dba44d09f7272d931bdd93 (diff)
downloadopenttd-3b798599b63067c2e92aa49906ea66a07ae8de44.tar.xz
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
-rw-r--r--src/ai/ai.cpp94
-rw-r--r--src/ai/ai.h10
-rw-r--r--src/ai/default/default.cpp1856
-rw-r--r--src/ai/default/default.h8
-rw-r--r--src/ai/trolly/build.cpp54
-rw-r--r--src/ai/trolly/pathfinder.cpp6
-rw-r--r--src/ai/trolly/shared.cpp20
-rw-r--r--src/ai/trolly/trolly.cpp719
-rw-r--r--src/ai/trolly/trolly.h30
-rw-r--r--src/aircraft_cmd.cpp46
-rw-r--r--src/airport_gui.cpp2
-rw-r--r--src/autoreplace_cmd.cpp30
-rw-r--r--src/autoreplace_func.h48
-rw-r--r--src/autoreplace_gui.cpp38
-rw-r--r--src/autoreplace_type.h4
-rw-r--r--src/autoslope.h8
-rw-r--r--src/build_vehicle_gui.cpp18
-rw-r--r--src/cheat_gui.cpp36
-rw-r--r--src/cheat_type.h2
-rw-r--r--src/clear_cmd.cpp2
-rw-r--r--src/command.cpp68
-rw-r--r--src/command_type.h8
-rw-r--r--src/console.cpp2
-rw-r--r--src/console_cmds.cpp118
-rw-r--r--src/console_gui.cpp2
-rw-r--r--src/core/random_func.cpp2
-rw-r--r--src/date.cpp8
-rw-r--r--src/depot_gui.cpp4
-rw-r--r--src/disaster_cmd.cpp26
-rw-r--r--src/dock_gui.cpp2
-rw-r--r--src/dummy_land.cpp2
-rw-r--r--src/economy.cpp417
-rw-r--r--src/economy_func.h8
-rw-r--r--src/elrail.cpp4
-rw-r--r--src/engine.cpp154
-rw-r--r--src/engine_base.h4
-rw-r--r--src/engine_func.h2
-rw-r--r--src/engine_type.h4
-rw-r--r--src/functions.h8
-rw-r--r--src/genworld.cpp12
-rw-r--r--src/genworld.h2
-rw-r--r--src/graph_gui.cpp232
-rw-r--r--src/group.h12
-rw-r--r--src/group_cmd.cpp58
-rw-r--r--src/group_gui.cpp34
-rw-r--r--src/group_gui.h2
-rw-r--r--src/industry_cmd.cpp64
-rw-r--r--src/industry_gui.cpp4
-rw-r--r--src/landscape.cpp8
-rw-r--r--src/livery.h8
-rw-r--r--src/main_gui.cpp16
-rw-r--r--src/misc.cpp6
-rw-r--r--src/misc_cmd.cpp126
-rw-r--r--src/misc_gui.cpp26
-rw-r--r--src/network/core/config.h4
-rw-r--r--src/network/core/game.h2
-rw-r--r--src/network/core/tcp.h4
-rw-r--r--src/network/network.cpp68
-rw-r--r--src/network/network.h4
-rw-r--r--src/network/network_chat_gui.cpp4
-rw-r--r--src/network/network_client.cpp102
-rw-r--r--src/network/network_data.cpp16
-rw-r--r--src/network/network_func.h14
-rw-r--r--src/network/network_gui.cpp114
-rw-r--r--src/network/network_gui.h2
-rw-r--r--src/network/network_internal.h2
-rw-r--r--src/network/network_server.cpp258
-rw-r--r--src/network/network_type.h24
-rw-r--r--src/network/network_udp.cpp28
-rw-r--r--src/newgrf_callbacks.h2
-rw-r--r--src/newgrf_engine.cpp10
-rw-r--r--src/newgrf_house.cpp6
-rw-r--r--src/newgrf_industries.cpp10
-rw-r--r--src/newgrf_station.cpp10
-rw-r--r--src/news_gui.cpp78
-rw-r--r--src/news_type.h12
-rw-r--r--src/npf.cpp2
-rw-r--r--src/oldloader.cpp359
-rw-r--r--src/openttd.cpp217
-rw-r--r--src/order_cmd.cpp8
-rw-r--r--src/order_gui.cpp24
-rw-r--r--src/order_type.h2
-rw-r--r--src/player_base.h58
-rw-r--r--src/player_face.h242
-rw-r--r--src/player_func.h36
-rw-r--r--src/player_gui.cpp937
-rw-r--r--src/player_gui.h22
-rw-r--r--src/player_type.h40
-rw-r--r--src/players.cpp872
-rw-r--r--src/rail.cpp18
-rw-r--r--src/rail.h24
-rw-r--r--src/rail_cmd.cpp52
-rw-r--r--src/rail_gui.cpp8
-rw-r--r--src/road.cpp14
-rw-r--r--src/road_cmd.cpp48
-rw-r--r--src/road_func.h16
-rw-r--r--src/road_gui.cpp4
-rw-r--r--src/roadveh_cmd.cpp38
-rw-r--r--src/saveload.cpp4
-rw-r--r--src/saveload.h2
-rw-r--r--src/screenshot.cpp4
-rw-r--r--src/settings.cpp24
-rw-r--r--src/settings_type.h16
-rw-r--r--src/ship_cmd.cpp18
-rw-r--r--src/signal.cpp10
-rw-r--r--src/signs.cpp8
-rw-r--r--src/signs_base.h6
-rw-r--r--src/signs_gui.cpp4
-rw-r--r--src/smallmap_gui.cpp10
-rw-r--r--src/sprite.h2
-rw-r--r--src/station.cpp2
-rw-r--r--src/station_base.h2
-rw-r--r--src/station_cmd.cpp104
-rw-r--r--src/station_func.h4
-rw-r--r--src/station_gui.cpp68
-rw-r--r--src/station_gui.h4
-rw-r--r--src/statusbar_gui.cpp18
-rw-r--r--src/strings.cpp34
-rw-r--r--src/subsidy_gui.cpp3
-rw-r--r--src/table/sprites.h4
-rw-r--r--src/terraform_gui.cpp20
-rw-r--r--src/tile_cmd.h4
-rw-r--r--src/tile_map.h2
-rw-r--r--src/timetable_gui.cpp2
-rw-r--r--src/toolbar_gui.cpp88
-rw-r--r--src/town.h16
-rw-r--r--src/town_cmd.cpp100
-rw-r--r--src/town_gui.cpp42
-rw-r--r--src/train_cmd.cpp36
-rw-r--r--src/transparency.h2
-rw-r--r--src/transparency_gui.cpp4
-rw-r--r--src/tree_cmd.cpp6
-rw-r--r--src/tree_gui.cpp2
-rw-r--r--src/tunnelbridge_cmd.cpp38
-rw-r--r--src/unmovable.h2
-rw-r--r--src/unmovable_cmd.cpp72
-rw-r--r--src/variables.h4
-rw-r--r--src/vehicle.cpp90
-rw-r--r--src/vehicle_base.h4
-rw-r--r--src/vehicle_func.h14
-rw-r--r--src/vehicle_gui.cpp64
-rw-r--r--src/vehicle_gui.h8
-rw-r--r--src/vehicle_gui_base.h2
-rw-r--r--src/vehiclelist.cpp4
-rw-r--r--src/vehiclelist.h2
-rw-r--r--src/video/dedicated_v.cpp4
-rw-r--r--src/viewport.cpp8
-rw-r--r--src/water_cmd.cpp32
-rw-r--r--src/waypoint.cpp4
-rw-r--r--src/waypoint.h2
-rw-r--r--src/widget.cpp2
-rw-r--r--src/window.cpp36
-rw-r--r--src/window_func.h2
-rw-r--r--src/window_gui.h2
-rw-r--r--src/window_type.h4
-rw-r--r--src/yapf/follow_track.hpp2
-rw-r--r--src/yapf/yapf_base.hpp2
-rw-r--r--src/yapf/yapf_destrail.hpp4
158 files changed, 4684 insertions, 4698 deletions
diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp
index 182831702..d6e616883 100644
--- a/src/ai/ai.cpp
+++ b/src/ai/ai.cpp
@@ -16,16 +16,16 @@
#include "../signal_func.h"
AIStruct _ai;
-AIPlayer _ai_player[MAX_PLAYERS];
+AICompany _ai_company[MAX_COMPANIES];
/**
* Dequeues commands put in the queue via AI_PutCommandInQueue.
*/
-static void AI_DequeueCommands(PlayerID player)
+static void AI_DequeueCommands(CompanyID company)
{
AICommand *com, *entry_com;
- entry_com = _ai_player[player].queue;
+ entry_com = _ai_company[company].queue;
/* It happens that DoCommandP issues a new DoCommandAI which adds a new command
* to this very same queue (don't argue about this, if it currently doesn't
@@ -33,12 +33,12 @@ static void AI_DequeueCommands(PlayerID player)
* do not make the queue NULL, that commands will be dequeued immediatly.
* Therefor we safe the entry-point to entry_com, and make the queue NULL, so
* the new queue can be safely built up. */
- _ai_player[player].queue = NULL;
- _ai_player[player].queue_tail = NULL;
+ _ai_company[company].queue = NULL;
+ _ai_company[company].queue_tail = NULL;
/* Dequeue all commands */
while ((com = entry_com) != NULL) {
- _current_player = player;
+ _current_company = company;
_cmd_text = com->text;
DoCommandP(com->tile, com->p1, com->p2, com->callback, com->procc);
@@ -54,22 +54,22 @@ static void AI_DequeueCommands(PlayerID player)
* Needed for SP; we need to delay DoCommand with 1 tick, because else events
* will make infinite loops (AIScript).
*/
-static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint32 procc, CommandCallback* callback)
+static void AI_PutCommandInQueue(CompanyID company, TileIndex tile, uint32 p1, uint32 p2, uint32 procc, CommandCallback* callback)
{
AICommand *com;
- if (_ai_player[player].queue_tail == NULL) {
+ if (_ai_company[company].queue_tail == NULL) {
/* There is no item in the queue yet, create the queue */
- _ai_player[player].queue = MallocT<AICommand>(1);
- _ai_player[player].queue_tail = _ai_player[player].queue;
+ _ai_company[company].queue = MallocT<AICommand>(1);
+ _ai_company[company].queue_tail = _ai_company[company].queue;
} else {
/* Add an item at the end */
- _ai_player[player].queue_tail->next = MallocT<AICommand>(1);
- _ai_player[player].queue_tail = _ai_player[player].queue_tail->next;
+ _ai_company[company].queue_tail->next = MallocT<AICommand>(1);
+ _ai_company[company].queue_tail = _ai_company[company].queue_tail->next;
}
/* This is our new item */
- com = _ai_player[player].queue_tail;
+ com = _ai_company[company].queue_tail;
/* Assign the info */
com->tile = tile;
@@ -92,7 +92,7 @@ static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uin
*/
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc, CommandCallback* callback)
{
- PlayerID old_lp;
+ CompanyID old_local_company;
CommandCost res;
const char* tmp_cmdtext;
@@ -113,10 +113,10 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
/* Restore _cmd_text */
_cmd_text = tmp_cmdtext;
- /* NetworkSend_Command needs _local_player to be set correctly, so
+ /* NetworkSend_Command needs _local_company to be set correctly, so
* adjust it, and put it back right after the function */
- old_lp = _local_player;
- _local_player = _current_player;
+ old_local_company = _local_company;
+ _local_company = _current_company;
#ifdef ENABLE_NETWORK
/* Send the command */
@@ -129,11 +129,11 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
#endif
/* If we execute BuildCommands directly in SP, we have a big problem with events
* so we need to delay is for 1 tick */
- AI_PutCommandInQueue(_current_player, tile, p1, p2, procc, callback);
+ AI_PutCommandInQueue(_current_company, tile, p1, p2, procc, callback);
}
- /* Set _local_player back */
- _local_player = old_lp;
+ /* Set _local_company back */
+ _local_company = old_local_company;
return res;
}
@@ -148,20 +148,20 @@ CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uin
/**
* Run 1 tick of the AI. Don't overdo it, keep it realistic.
*/
-static void AI_RunTick(PlayerID player)
+static void AI_RunTick(CompanyID company)
{
- extern void AiNewDoGameLoop(Player *p);
+ extern void AiNewDoGameLoop(Company *c);
- Player *p = GetPlayer(player);
- _current_player = player;
+ Company *c = GetCompany(company);
+ _current_company = company;
if (_settings_game.ai.ainew_active) {
- AiNewDoGameLoop(p);
+ AiNewDoGameLoop(c);
} else {
/* Enable all kind of cheats the old AI needs in order to operate correctly... */
- _is_old_ai_player = true;
- AiDoGameLoop(p);
- _is_old_ai_player = false;
+ _is_old_ai_company = true;
+ AiDoGameLoop(c);
+ _is_old_ai_company = false;
}
/* AI could change some track, so update signals */
@@ -191,47 +191,47 @@ void AI_RunGameLoop()
/* Check for AI-client (so joining a network with an AI) */
if (!_networking || _network_server) {
/* Check if we want to run AIs (server or SP only) */
- const Player* p;
+ const Company *c;
- FOR_ALL_PLAYERS(p) {
- if (p->is_ai) {
+ FOR_ALL_COMPANIES(c) {
+ if (c->is_ai) {
/* This should always be true, else something went wrong... */
- assert(_ai_player[p->index].active);
+ assert(_ai_company[c->index].active);
/* Run the script */
- AI_DequeueCommands(p->index);
- AI_RunTick(p->index);
+ AI_DequeueCommands(c->index);
+ AI_RunTick(c->index);
}
}
}
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
}
/**
* A new AI sees the day of light. You can do here what ever you think is needed.
*/
-void AI_StartNewAI(PlayerID player)
+void AI_StartNewAI(CompanyID company)
{
- assert(IsValidPlayerID(player));
+ assert(IsValidCompanyID(company));
/* Called if a new AI is booted */
- _ai_player[player].active = true;
+ _ai_company[company].active = true;
}
/**
- * This AI player died. Give it some chance to make a final puf.
+ * This AI company died. Give it some chance to make a final puf.
*/
-void AI_PlayerDied(PlayerID player)
+void AI_CompanyDied(CompanyID company)
{
/* Called if this AI died */
- _ai_player[player].active = false;
+ _ai_company[company].active = false;
- if (_players_ainew[player].pathfinder == NULL) return;
+ if (_companies_ainew[company].pathfinder == NULL) return;
- AyStarMain_Free(_players_ainew[player].pathfinder);
- delete _players_ainew[player].pathfinder;
- _players_ainew[player].pathfinder = NULL;
+ AyStarMain_Free(_companies_ainew[company].pathfinder);
+ delete _companies_ainew[company].pathfinder;
+ _companies_ainew[company].pathfinder = NULL;
}
@@ -244,7 +244,7 @@ void AI_Initialize()
AI_Uninitialize();
memset(&_ai, 0, sizeof(_ai));
- memset(&_ai_player, 0, sizeof(_ai_player));
+ memset(&_ai_company, 0, sizeof(_ai_company));
_ai.enabled = true;
}
@@ -254,5 +254,5 @@ void AI_Initialize()
*/
void AI_Uninitialize()
{
- for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) AI_PlayerDied(p);
+ for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) AI_CompanyDied(c);
}
diff --git a/src/ai/ai.h b/src/ai/ai.h
index e7c1b1f64..89cddea11 100644
--- a/src/ai/ai.h
+++ b/src/ai/ai.h
@@ -24,8 +24,8 @@ struct AICommand {
AICommand *next;
};
-/* The struct for an AIScript Player */
-struct AIPlayer {
+/* The struct for an AIScript Company */
+struct AICompany {
bool active; ///< Is this AI active?
AICommand *queue; ///< The commands that he has in his queue
AICommand *queue_tail; ///< The tail of this queue
@@ -39,11 +39,11 @@ struct AIStruct {
};
extern AIStruct _ai;
-extern AIPlayer _ai_player[MAX_PLAYERS];
+extern AICompany _ai_company[MAX_COMPANIES];
// ai.c
-void AI_StartNewAI(PlayerID player);
-void AI_PlayerDied(PlayerID player);
+void AI_StartNewAI(CompanyID company);
+void AI_CompanyDied(CompanyID company);
void AI_RunGameLoop();
void AI_Initialize();
void AI_Uninitialize();
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 6b26622cf..e269535ae 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -37,9 +37,9 @@
// remove some day perhaps?
static uint _ai_service_interval;
-PlayerAI _players_ai[MAX_PLAYERS];
+CompanyAI _companies_ai[MAX_COMPANIES];
-typedef void AiStateAction(Player *p);
+typedef void AiStateAction(Company *c);
enum {
AIS_0 = 0,
@@ -75,27 +75,27 @@ static inline TrackBits GetRailTrackStatus(TileIndex tile)
}
-static void AiCase0(Player *p)
+static void AiCase0(Company *c)
{
- _players_ai[p->index].state = AIS_REMOVE_TRACK;
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].state = AIS_REMOVE_TRACK;
+ _companies_ai[c->index].state_counter = 0;
}
-static void AiCase1(Player *p)
+static void AiCase1(Company *c)
{
- _players_ai[p->index].cur_veh = NULL;
- _players_ai[p->index].state = AIS_VEH_LOOP;
+ _companies_ai[c->index].cur_veh = NULL;
+ _companies_ai[c->index].state = AIS_VEH_LOOP;
}
-static void AiStateVehLoop(Player *p)
+static void AiStateVehLoop(Company *c)
{
Vehicle *v;
uint index;
- index = (_players_ai[p->index].cur_veh == NULL) ? 0 : _players_ai[p->index].cur_veh->index + 1;
+ index = (_companies_ai[c->index].cur_veh == NULL) ? 0 : _companies_ai[c->index].cur_veh->index + 1;
FOR_ALL_VEHICLES_FROM(v, index) {
- if (v->owner != _current_player) continue;
+ if (v->owner != _current_company) continue;
if ((v->type == VEH_TRAIN && v->subtype == 0) ||
v->type == VEH_ROAD ||
@@ -103,9 +103,9 @@ static void AiStateVehLoop(Player *p)
v->type == VEH_SHIP) {
/* replace engine? */
if (v->type == VEH_TRAIN && v->engine_type < 3 &&
- (_price.build_railvehicle >> 3) < p->player_money) {
- _players_ai[p->index].state = AIS_VEH_CHECK_REPLACE_VEHICLE;
- _players_ai[p->index].cur_veh = v;
+ (_price.build_railvehicle >> 3) < c->money) {
+ _companies_ai[c->index].state = AIS_VEH_CHECK_REPLACE_VEHICLE;
+ _companies_ai[c->index].cur_veh = v;
return;
}
@@ -113,9 +113,9 @@ static void AiStateVehLoop(Player *p)
if (v->age >= 730 &&
v->profit_last_year < _price.station_value * 5 * 256 &&
v->profit_this_year < _price.station_value * 5 * 256) {
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].state = AIS_SELL_VEHICLE;
- _players_ai[p->index].cur_veh = v;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].state = AIS_SELL_VEHICLE;
+ _companies_ai[c->index].cur_veh = v;
return;
}
@@ -124,15 +124,15 @@ static void AiStateVehLoop(Player *p)
v->age != 0 &&
GetEngine(v->engine_type)->reliability < 35389
)) {
- _players_ai[p->index].state = AIS_VEH_CHECK_REPLACE_VEHICLE;
- _players_ai[p->index].cur_veh = v;
+ _companies_ai[c->index].state = AIS_VEH_CHECK_REPLACE_VEHICLE;
+ _companies_ai[c->index].cur_veh = v;
return;
}
}
}
- _players_ai[p->index].state = AIS_WANT_NEW_ROUTE;
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].state = AIS_WANT_NEW_ROUTE;
+ _companies_ai[c->index].state_counter = 0;
}
static EngineID AiChooseTrainToBuild(RailType railtype, Money money, byte flag, TileIndex tile)
@@ -148,7 +148,7 @@ static EngineID AiChooseTrainToBuild(RailType railtype, Money money, byte flag,
if (!IsCompatibleRail(rvi->railtype, railtype) ||
rvi->railveh_type == RAILVEH_WAGON ||
(rvi->railveh_type == RAILVEH_MULTIHEAD && flag & 1) ||
- !HasBit(e->player_avail, _current_player) ||
+ !HasBit(e->company_avail, _current_company) ||
e->reliability < 0x8A3D) {
continue;
}
@@ -176,7 +176,7 @@ static EngineID AiChooseRoadVehToBuild(CargoID cargo, Money money, TileIndex til
EngineID i = e->index;
const RoadVehicleInfo *rvi = &e->u.road;
- if (!HasBit(e->player_avail, _current_player) || e->reliability < 0x8A3D) {
+ if (!HasBit(e->company_avail, _current_company) || e->reliability < 0x8A3D) {
continue;
}
@@ -217,7 +217,7 @@ static EngineID AiChooseAircraftToBuild(Money money, byte forbidden)
EngineID i = e->index;
const AircraftVehicleInfo *avi = &e->u.air;
- if (!HasBit(e->player_avail, _current_player) || e->reliability < 0x8A3D) {
+ if (!HasBit(e->company_avail, _current_company) || e->reliability < 0x8A3D) {
continue;
}
@@ -233,12 +233,12 @@ static EngineID AiChooseAircraftToBuild(Money money, byte forbidden)
return best_veh_index;
}
-static Money AiGetBasePrice(const Player* p)
+static Money AiGetBasePrice(const Company *c)
{
Money base = _price.station_value;
// adjust base price when more expensive vehicles are available
- switch (_players_ai[p->index].railtype_to_use) {
+ switch (_companies_ai[c->index].railtype_to_use) {
default: NOT_REACHED();
case RAILTYPE_RAIL: break;
case RAILTYPE_ELECTRIC: break;
@@ -249,15 +249,15 @@ static Money AiGetBasePrice(const Player* p)
return base;
}
-static EngineID AiChooseRoadVehToReplaceWith(const Player* p, const Vehicle* v)
+static EngineID AiChooseRoadVehToReplaceWith(const Company *c, const Vehicle *v)
{
- Money avail_money = p->player_money + v->value;
+ Money avail_money = c->money + v->value;
return AiChooseRoadVehToBuild(v->cargo_type, avail_money, v->tile);
}
-static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v)
+static EngineID AiChooseAircraftToReplaceWith(const Company *c, const Vehicle *v)
{
- Money avail_money = p->player_money + v->value;
+ Money avail_money = c->money + v->value;
/* determine forbidden aircraft bits */
byte forbidden = 0;
@@ -279,10 +279,10 @@ static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v)
);
}
-static EngineID AiChooseTrainToReplaceWith(const Player* p, const Vehicle* v)
+static EngineID AiChooseTrainToReplaceWith(const Company *c, const Vehicle *v)
{
- Money avail_money = p->player_money + v->value;
- const Vehicle* u = v;
+ Money avail_money = c->money + v->value;
+ const Vehicle *u = v;
int num = 0;
while (++num, u->Next() != NULL) {
@@ -293,25 +293,25 @@ static EngineID AiChooseTrainToReplaceWith(const Player* p, const Vehicle* v)
return AiChooseTrainToBuild(v->u.rail.railtype, avail_money, 0, v->tile);
}
-static EngineID AiChooseShipToReplaceWith(const Player* p, const Vehicle* v)
+static EngineID AiChooseShipToReplaceWith(const Company *p, const Vehicle *v)
{
/* Ships are not implemented in this (broken) AI */
return INVALID_ENGINE;
}
-static void AiHandleGotoDepot(Player *p, int cmd)
+static void AiHandleGotoDepot(Company *c, int cmd)
{
- if (!_players_ai[p->index].cur_veh->current_order.IsType(OT_GOTO_DEPOT))
- DoCommand(0, _players_ai[p->index].cur_veh->index, 0, DC_EXEC, cmd);
+ if (!_companies_ai[c->index].cur_veh->current_order.IsType(OT_GOTO_DEPOT))
+ DoCommand(0, _companies_ai[c->index].cur_veh->index, 0, DC_EXEC, cmd);
- if (++_players_ai[p->index].state_counter <= 1387) {
- _players_ai[p->index].state = AIS_VEH_DO_REPLACE_VEHICLE;
+ if (++_companies_ai[c->index].state_counter <= 1387) {
+ _companies_ai[c->index].state = AIS_VEH_DO_REPLACE_VEHICLE;
return;
}
- if (_players_ai[p->index].cur_veh->current_order.IsType(OT_GOTO_DEPOT)) {
- _players_ai[p->index].cur_veh->current_order.MakeDummy();
- InvalidateWindow(WC_VEHICLE_VIEW, _players_ai[p->index].cur_veh->index);
+ if (_companies_ai[c->index].cur_veh->current_order.IsType(OT_GOTO_DEPOT)) {
+ _companies_ai[c->index].cur_veh->current_order.MakeDummy();
+ InvalidateWindow(WC_VEHICLE_VIEW, _companies_ai[c->index].cur_veh->index);
}
}
@@ -325,19 +325,19 @@ static void AiRestoreVehicleOrders(Vehicle *v, BackuppedOrders *bak)
}
}
-static void AiHandleReplaceTrain(Player *p)
+static void AiHandleReplaceTrain(Company *c)
{
- const Vehicle* v = _players_ai[p->index].cur_veh;
+ const Vehicle* v = _companies_ai[c->index].cur_veh;
BackuppedOrders orderbak;
EngineID veh;
// wait until the vehicle reaches the depot.
if (!IsRailDepotTile(v->tile) || v->u.rail.track != TRACK_BIT_DEPOT || !(v->vehstatus & VS_STOPPED)) {
- AiHandleGotoDepot(p, CMD_SEND_TRAIN_TO_DEPOT);
+ AiHandleGotoDepot(c, CMD_SEND_TRAIN_TO_DEPOT);
return;
}
- veh = AiChooseTrainToReplaceWith(p, v);
+ veh = AiChooseTrainToReplaceWith(c, v);
if (veh != INVALID_ENGINE) {
TileIndex tile;
@@ -355,18 +355,18 @@ static void AiHandleReplaceTrain(Player *p)
}
}
-static void AiHandleReplaceRoadVeh(Player *p)
+static void AiHandleReplaceRoadVeh(Company *c)
{
- const Vehicle* v = _players_ai[p->index].cur_veh;
+ const Vehicle* v = _companies_ai[c->index].cur_veh;
BackuppedOrders orderbak;
EngineID veh;
if (!v->IsStoppedInDepot()) {
- AiHandleGotoDepot(p, CMD_SEND_ROADVEH_TO_DEPOT);
+ AiHandleGotoDepot(c, CMD_SEND_ROADVEH_TO_DEPOT);
return;
}
- veh = AiChooseRoadVehToReplaceWith(p, v);
+ veh = AiChooseRoadVehToReplaceWith(c, v);
if (veh != INVALID_ENGINE) {
TileIndex tile;
@@ -384,18 +384,18 @@ static void AiHandleReplaceRoadVeh(Player *p)
}
}
-static void AiHandleReplaceAircraft(Player *p)
+static void AiHandleReplaceAircraft(Company *c)
{
- const Vehicle* v = _players_ai[p->index].cur_veh;
+ const Vehicle* v = _companies_ai[c->index].cur_veh;
BackuppedOrders orderbak;
EngineID veh;
if (!v->IsStoppedInDepot()) {
- AiHandleGotoDepot(p, CMD_SEND_AIRCRAFT_TO_HANGAR);
+ AiHandleGotoDepot(c, CMD_SEND_AIRCRAFT_TO_HANGAR);
return;
}
- veh = AiChooseAircraftToReplaceWith(p, v);
+ veh = AiChooseAircraftToReplaceWith(c, v);
if (veh != INVALID_ENGINE) {
TileIndex tile;
@@ -413,12 +413,12 @@ static void AiHandleReplaceAircraft(Player *p)
}
}
-static void AiHandleReplaceShip(Player *p)
+static void AiHandleReplaceShip(Company *c)
{
/* Ships are not implemented in this (broken) AI */
}
-typedef EngineID CheckReplaceProc(const Player* p, const Vehicle* v);
+typedef EngineID CheckReplaceProc(const Company *c, const Vehicle* v);
static CheckReplaceProc* const _veh_check_replace_proc[] = {
AiChooseTrainToReplaceWith,
@@ -427,7 +427,7 @@ static CheckReplaceProc* const _veh_check_replace_proc[] = {
AiChooseAircraftToReplaceWith,
};
-typedef void DoReplaceProc(Player *p);
+typedef void DoReplaceProc(Company *c);
static DoReplaceProc* const _veh_do_replace_proc[] = {
AiHandleReplaceTrain,
AiHandleReplaceRoadVeh,
@@ -435,29 +435,29 @@ static DoReplaceProc* const _veh_do_replace_proc[] = {
AiHandleReplaceAircraft
};
-static void AiStateCheckReplaceVehicle(Player *p)
+static void AiStateCheckReplaceVehicle(Company *c)
{
- const Vehicle* v = _players_ai[p->index].cur_veh;
+ const Vehicle* v = _companies_ai[c->index].cur_veh;
if (!v->IsValid() ||
- v->owner != _current_player ||
+ v->owner != _current_company ||
v->type > VEH_SHIP ||
- _veh_check_replace_proc[v->type - VEH_TRAIN](p, v) == INVALID_ENGINE) {
- _players_ai[p->index].state = AIS_VEH_LOOP;
+ _veh_check_replace_proc[v->type - VEH_TRAIN](c, v) == INVALID_ENGINE) {
+ _companies_ai[c->index].state = AIS_VEH_LOOP;
} else {
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].state = AIS_VEH_DO_REPLACE_VEHICLE;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].state = AIS_VEH_DO_REPLACE_VEHICLE;
}
}
-static void AiStateDoReplaceVehicle(Player *p)
+static void AiStateDoReplaceVehicle(Company *c)
{
- const Vehicle* v = _players_ai[p->index].cur_veh;
+ const Vehicle* v = _companies_ai[c->index].cur_veh;
- _players_ai[p->index].state = AIS_VEH_LOOP;
- // vehicle is not owned by the player anymore, something went very wrong.
- if (!v->IsValid() || v->owner != _current_player) return;
- _veh_do_replace_proc[v->type - VEH_TRAIN](p);
+ _companies_ai[c->index].state = AIS_VEH_LOOP;
+ // vehicle is not owned by the company anymore, something went very wrong.
+ if (!v->IsValid() || v->owner != _current_company) return;
+ _veh_do_replace_proc[v->type - VEH_TRAIN](c);
}
struct FoundRoute {
@@ -620,7 +620,7 @@ static void AiFindRandomPassengerRoute(FoundRoute *fr)
// Warn: depends on 'xy' being the first element in both Town and Industry
#define GET_TOWN_OR_INDUSTRY_TILE(p) (((Town*)(p))->xy)
-static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
+static bool AiCheckIfRouteIsGood(Company *c, FoundRoute *fr, byte bitmask)
{
TileIndex from_tile, to_tile;
Station *st;
@@ -634,7 +634,7 @@ static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
FOR_ALL_STATIONS(st) {
int cur;
- if (st->owner != _current_player) continue;
+ if (st->owner != _current_company) continue;
cur = DistanceMax(from_tile, st->xy);
if (cur < dist) dist = cur;
cur = DistanceMax(to_tile, st->xy);
@@ -664,8 +664,8 @@ static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
/* Make sure distance to closest station is < min_distance tiles. */
if (dist != 0xFFFF && dist > min_distance) return false;
- if (_players_ai[p->index].route_type_mask != 0 &&
- !(_players_ai[p->index].route_type_mask & bitmask) &&
+ if (_companies_ai[c->index].route_type_mask != 0 &&
+ !(_companies_ai[c->index].route_type_mask & bitmask) &&
!Chance16(1, 5)) {
return false;
}
@@ -680,8 +680,8 @@ static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
}
// Make sure it has a reasonably good rating
- if (from->ratings[_current_player] < -100 ||
- to->ratings[_current_player] < -100) {
+ if (from->ratings[_current_company] < -100 ||
+ to->ratings[_current_company] < -100) {
return false;
}
} else {
@@ -693,7 +693,7 @@ static bool AiCheckIfRouteIsGood(Player *p, FoundRoute *fr, byte bitmask)
}
}
- _players_ai[p->index].route_type_mask |= bitmask;
+ _companies_ai[c->index].route_type_mask |= bitmask;
return true;
}
@@ -712,7 +712,7 @@ static TileIndex AiGetPctTileBetween(TileIndex a, TileIndex b, byte pct)
);
}
-static void AiWantLongIndustryRoute(Player *p)
+static void AiWantLongIndustryRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -731,91 +731,91 @@ static void AiWantLongIndustryRoute(Player *p)
if (--i == 0) return;
}
- if (!AiCheckIfRouteIsGood(p, &fr, 1)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 1)) return;
// Fill the source field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
-
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 9;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.unk6 = 1;
- _players_ai[p->index].src.unk7 = 0;
- _players_ai[p->index].src.buildcmd_a = 0x24;
- _players_ai[p->index].src.buildcmd_b = 0xFF;
- _players_ai[p->index].src.direction = AiGetDirectionBetweenTiles(
- _players_ai[p->index].src.spec_tile,
- _players_ai[p->index].dst.spec_tile
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 9;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.unk6 = 1;
+ _companies_ai[c->index].src.unk7 = 0;
+ _companies_ai[c->index].src.buildcmd_a = 0x24;
+ _companies_ai[c->index].src.buildcmd_b = 0xFF;
+ _companies_ai[c->index].src.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].src.spec_tile,
+ _companies_ai[c->index].dst.spec_tile
);
- _players_ai[p->index].src.cargo = fr.cargo | 0x80;
+ _companies_ai[c->index].src.cargo = fr.cargo | 0x80;
// Fill the dest field
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 9;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.unk6 = 1;
- _players_ai[p->index].dst.unk7 = 0;
- _players_ai[p->index].dst.buildcmd_a = 0x34;
- _players_ai[p->index].dst.buildcmd_b = 0xFF;
- _players_ai[p->index].dst.direction = AiGetDirectionBetweenTiles(
- _players_ai[p->index].dst.spec_tile,
- _players_ai[p->index].src.spec_tile
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 9;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.unk6 = 1;
+ _companies_ai[c->index].dst.unk7 = 0;
+ _companies_ai[c->index].dst.buildcmd_a = 0x34;
+ _companies_ai[c->index].dst.buildcmd_b = 0xFF;
+ _companies_ai[c->index].dst.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].dst.spec_tile,
+ _companies_ai[c->index].src.spec_tile
);
- _players_ai[p->index].dst.cargo = fr.cargo;
+ _companies_ai[c->index].dst.cargo = fr.cargo;
// Fill middle field 1
- _players_ai[p->index].mid1.spec_tile = AiGetPctTileBetween(
- _players_ai[p->index].src.spec_tile,
- _players_ai[p->index].dst.spec_tile,
+ _companies_ai[c->index].mid1.spec_tile = AiGetPctTileBetween(
+ _companies_ai[c->index].src.spec_tile,
+ _companies_ai[c->index].dst.spec_tile,
0x55
);
- _players_ai[p->index].mid1.use_tile = 0;
- _players_ai[p->index].mid1.rand_rng = 6;
- _players_ai[p->index].mid1.cur_building_rule = 0xFF;
- _players_ai[p->index].mid1.unk6 = 2;
- _players_ai[p->index].mid1.unk7 = 1;
- _players_ai[p->index].mid1.buildcmd_a = 0x30;
- _players_ai[p->index].mid1.buildcmd_b = 0xFF;
- _players_ai[p->index].mid1.direction = _players_ai[p->index].src.direction;
- _players_ai[p->index].mid1.cargo = fr.cargo;
+ _companies_ai[c->index].mid1.use_tile = 0;
+ _companies_ai[c->index].mid1.rand_rng = 6;
+ _companies_ai[c->index].mid1.cur_building_rule = 0xFF;
+ _companies_ai[c->index].mid1.unk6 = 2;
+ _companies_ai[c->index].mid1.unk7 = 1;
+ _companies_ai[c->index].mid1.buildcmd_a = 0x30;
+ _companies_ai[c->index].mid1.buildcmd_b = 0xFF;
+ _companies_ai[c->index].mid1.direction = _companies_ai[c->index].src.direction;
+ _companies_ai[c->index].mid1.cargo = fr.cargo;
// Fill middle field 2
- _players_ai[p->index].mid2.spec_tile = AiGetPctTileBetween(
- _players_ai[p->index].src.spec_tile,
- _players_ai[p->index].dst.spec_tile,
+ _companies_ai[c->index].mid2.spec_tile = AiGetPctTileBetween(
+ _companies_ai[c->index].src.spec_tile,
+ _companies_ai[c->index].dst.spec_tile,
0xAA
);
- _players_ai[p->index].mid2.use_tile = 0;
- _players_ai[p->index].mid2.rand_rng = 6;
- _players_ai[p->index].mid2.cur_building_rule = 0xFF;
- _players_ai[p->index].mid2.unk6 = 2;
- _players_ai[p->index].mid2.unk7 = 1;
- _players_ai[p->index].mid2.buildcmd_a = 0xFF;
- _players_ai[p->index].mid2.buildcmd_b = 0xFF;
- _players_ai[p->index].mid2.direction = _players_ai[p->index].dst.direction;
- _players_ai[p->index].mid2.cargo = fr.cargo;
+ _companies_ai[c->index].mid2.use_tile = 0;
+ _companies_ai[c->index].mid2.rand_rng = 6;
+ _companies_ai[c->index].mid2.cur_building_rule = 0xFF;
+ _companies_ai[c->index].mid2.unk6 = 2;
+ _companies_ai[c->index].mid2.unk7 = 1;
+ _companies_ai[c->index].mid2.buildcmd_a = 0xFF;
+ _companies_ai[c->index].mid2.buildcmd_b = 0xFF;
+ _companies_ai[c->index].mid2.direction = _companies_ai[c->index].dst.direction;
+ _companies_ai[c->index].mid2.cargo = fr.cargo;
// Fill common fields
- _players_ai[p->index].cargo_type = fr.cargo;
- _players_ai[p->index].num_wagons = 3;
- _players_ai[p->index].build_kind = 2;
- _players_ai[p->index].num_build_rec = 4;
- _players_ai[p->index].num_loco_to_build = 2;
- _players_ai[p->index].num_want_fullload = 2;
- _players_ai[p->index].wagon_list[0] = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
-
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = fr.cargo;
+ _companies_ai[c->index].num_wagons = 3;
+ _companies_ai[c->index].build_kind = 2;
+ _companies_ai[c->index].num_build_rec = 4;
+ _companies_ai[c->index].num_loco_to_build = 2;
+ _companies_ai[c->index].num_want_fullload = 2;
+ _companies_ai[c->index].wagon_list[0] = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantMediumIndustryRoute(Player *p)
+static void AiWantMediumIndustryRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -834,56 +834,56 @@ static void AiWantMediumIndustryRoute(Player *p)
if (--i == 0) return;
}
- if (!AiCheckIfRouteIsGood(p, &fr, 1)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 1)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 9;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.unk6 = 1;
- _players_ai[p->index].src.unk7 = 0;
- _players_ai[p->index].src.buildcmd_a = 0x10;
- _players_ai[p->index].src.buildcmd_b = 0xFF;
- _players_ai[p->index].src.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 9;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.unk6 = 1;
+ _companies_ai[c->index].src.unk7 = 0;
+ _companies_ai[c->index].src.buildcmd_a = 0x10;
+ _companies_ai[c->index].src.buildcmd_b = 0xFF;
+ _companies_ai[c->index].src.direction = AiGetDirectionBetweenTiles(
GET_TOWN_OR_INDUSTRY_TILE(fr.from),
GET_TOWN_OR_INDUSTRY_TILE(fr.to)
);
- _players_ai[p->index].src.cargo = fr.cargo | 0x80;
+ _companies_ai[c->index].src.cargo = fr.cargo | 0x80;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 9;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.unk6 = 1;
- _players_ai[p->index].dst.unk7 = 0;
- _players_ai[p->index].dst.buildcmd_a = 0xFF;
- _players_ai[p->index].dst.buildcmd_b = 0xFF;
- _players_ai[p->index].dst.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 9;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.unk6 = 1;
+ _companies_ai[c->index].dst.unk7 = 0;
+ _companies_ai[c->index].dst.buildcmd_a = 0xFF;
+ _companies_ai[c->index].dst.buildcmd_b = 0xFF;
+ _companies_ai[c->index].dst.direction = AiGetDirectionBetweenTiles(
GET_TOWN_OR_INDUSTRY_TILE(fr.to),
GET_TOWN_OR_INDUSTRY_TILE(fr.from)
);
- _players_ai[p->index].dst.cargo = fr.cargo;
+ _companies_ai[c->index].dst.cargo = fr.cargo;
// Fill common fields
- _players_ai[p->index].cargo_type = fr.cargo;
- _players_ai[p->index].num_wagons = 3;
- _players_ai[p->index].build_kind = 1;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 1;
- _players_ai[p->index].num_want_fullload = 1;
- _players_ai[p->index].wagon_list[0] = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = fr.cargo;
+ _companies_ai[c->index].num_wagons = 3;
+ _companies_ai[c->index].build_kind = 1;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 1;
+ _companies_ai[c->index].num_want_fullload = 1;
+ _companies_ai[c->index].wagon_list[0] = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantShortIndustryRoute(Player *p)
+static void AiWantShortIndustryRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -902,56 +902,56 @@ static void AiWantShortIndustryRoute(Player *p)
if (--i == 0) return;
}
- if (!AiCheckIfRouteIsGood(p, &fr, 1)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 1)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 9;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.unk6 = 1;
- _players_ai[p->index].src.unk7 = 0;
- _players_ai[p->index].src.buildcmd_a = 0x10;
- _players_ai[p->index].src.buildcmd_b = 0xFF;
- _players_ai[p->index].src.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 9;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.unk6 = 1;
+ _companies_ai[c->index].src.unk7 = 0;
+ _companies_ai[c->index].src.buildcmd_a = 0x10;
+ _companies_ai[c->index].src.buildcmd_b = 0xFF;
+ _companies_ai[c->index].src.direction = AiGetDirectionBetweenTiles(
GET_TOWN_OR_INDUSTRY_TILE(fr.from),
GET_TOWN_OR_INDUSTRY_TILE(fr.to)
);
- _players_ai[p->index].src.cargo = fr.cargo | 0x80;
+ _companies_ai[c->index].src.cargo = fr.cargo | 0x80;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 9;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.unk6 = 1;
- _players_ai[p->index].dst.unk7 = 0;
- _players_ai[p->index].dst.buildcmd_a = 0xFF;
- _players_ai[p->index].dst.buildcmd_b = 0xFF;
- _players_ai[p->index].dst.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 9;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.unk6 = 1;
+ _companies_ai[c->index].dst.unk7 = 0;
+ _companies_ai[c->index].dst.buildcmd_a = 0xFF;
+ _companies_ai[c->index].dst.buildcmd_b = 0xFF;
+ _companies_ai[c->index].dst.direction = AiGetDirectionBetweenTiles(
GET_TOWN_OR_INDUSTRY_TILE(fr.to),
GET_TOWN_OR_INDUSTRY_TILE(fr.from)
);
- _players_ai[p->index].dst.cargo = fr.cargo;
+ _companies_ai[c->index].dst.cargo = fr.cargo;
// Fill common fields
- _players_ai[p->index].cargo_type = fr.cargo;
- _players_ai[p->index].num_wagons = 2;
- _players_ai[p->index].build_kind = 1;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 1;
- _players_ai[p->index].num_want_fullload = 1;
- _players_ai[p->index].wagon_list[0] = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = fr.cargo;
+ _companies_ai[c->index].num_wagons = 2;
+ _companies_ai[c->index].build_kind = 1;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 1;
+ _companies_ai[c->index].num_want_fullload = 1;
+ _companies_ai[c->index].wagon_list[0] = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantMailRoute(Player *p)
+static void AiWantMailRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -971,88 +971,88 @@ static void AiWantMailRoute(Player *p)
}
fr.cargo = CT_MAIL;
- if (!AiCheckIfRouteIsGood(p, &fr, 1)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 1)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 7;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.unk6 = 1;
- _players_ai[p->index].src.unk7 = 0;
- _players_ai[p->index].src.buildcmd_a = 0x24;
- _players_ai[p->index].src.buildcmd_b = 0xFF;
- _players_ai[p->index].src.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 7;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.unk6 = 1;
+ _companies_ai[c->index].src.unk7 = 0;
+ _companies_ai[c->index].src.buildcmd_a = 0x24;
+ _companies_ai[c->index].src.buildcmd_b = 0xFF;
+ _companies_ai[c->index].src.direction = AiGetDirectionBetweenTiles(
GET_TOWN_OR_INDUSTRY_TILE(fr.from),
GET_TOWN_OR_INDUSTRY_TILE(fr.to)
);
- _players_ai[p->index].src.cargo = fr.cargo;
+ _companies_ai[c->index].src.cargo = fr.cargo;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 7;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.unk6 = 1;
- _players_ai[p->index].dst.unk7 = 0;
- _players_ai[p->index].dst.buildcmd_a = 0x34;
- _players_ai[p->index].dst.buildcmd_b = 0xFF;
- _players_ai[p->index].dst.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 7;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.unk6 = 1;
+ _companies_ai[c->index].dst.unk7 = 0;
+ _companies_ai[c->index].dst.buildcmd_a = 0x34;
+ _companies_ai[c->index].dst.buildcmd_b = 0xFF;
+ _companies_ai[c->index].dst.direction = AiGetDirectionBetweenTiles(
GET_TOWN_OR_INDUSTRY_TILE(fr.to),
GET_TOWN_OR_INDUSTRY_TILE(fr.from)
);
- _players_ai[p->index].dst.cargo = fr.cargo;
+ _companies_ai[c->index].dst.cargo = fr.cargo;
// Fill middle field 1
- _players_ai[p->index].mid1.spec_tile = AiGetPctTileBetween(
+ _companies_ai[c->index].mid1.spec_tile = AiGetPctTileBetween(
GET_TOWN_OR_INDUSTRY_TILE(fr.from),
GET_TOWN_OR_INDUSTRY_TILE(fr.to),
0x55
);
- _players_ai[p->index].mid1.use_tile = 0;
- _players_ai[p->index].mid1.rand_rng = 6;
- _players_ai[p->index].mid1.cur_building_rule = 0xFF;
- _players_ai[p->index].mid1.unk6 = 2;
- _players_ai[p->index].mid1.unk7 = 1;
- _players_ai[p->index].mid1.buildcmd_a = 0x30;
- _players_ai[p->index].mid1.buildcmd_b = 0xFF;
- _players_ai[p->index].mid1.direction = _players_ai[p->index].src.direction;
- _players_ai[p->index].mid1.cargo = fr.cargo;
+ _companies_ai[c->index].mid1.use_tile = 0;
+ _companies_ai[c->index].mid1.rand_rng = 6;
+ _companies_ai[c->index].mid1.cur_building_rule = 0xFF;
+ _companies_ai[c->index].mid1.unk6 = 2;
+ _companies_ai[c->index].mid1.unk7 = 1;
+ _companies_ai[c->index].mid1.buildcmd_a = 0x30;
+ _companies_ai[c->index].mid1.buildcmd_b = 0xFF;
+ _companies_ai[c->index].mid1.direction = _companies_ai[c->index].src.direction;
+ _companies_ai[c->index].mid1.cargo = fr.cargo;
// Fill middle field 2
- _players_ai[p->index].mid2.spec_tile = AiGetPctTileBetween(
+ _companies_ai[c->index].mid2.spec_tile = AiGetPctTileBetween(
GET_TOWN_OR_INDUSTRY_TILE(fr.from),
GET_TOWN_OR_INDUSTRY_TILE(fr.to),
0xAA
);
- _players_ai[p->index].mid2.use_tile = 0;
- _players_ai[p->index].mid2.rand_rng = 6;
- _players_ai[p->index].mid2.cur_building_rule = 0xFF;
- _players_ai[p->index].mid2.unk6 = 2;
- _players_ai[p->index].mid2.unk7 = 1;
- _players_ai[p->index].mid2.buildcmd_a = 0xFF;
- _players_ai[p->index].mid2.buildcmd_b = 0xFF;
- _players_ai[p->index].mid2.direction = _players_ai[p->index].dst.direction;
- _players_ai[p->index].mid2.cargo = fr.cargo;
+ _companies_ai[c->index].mid2.use_tile = 0;
+ _companies_ai[c->index].mid2.rand_rng = 6;
+ _companies_ai[c->index].mid2.cur_building_rule = 0xFF;
+ _companies_ai[c->index].mid2.unk6 = 2;
+ _companies_ai[c->index].mid2.unk7 = 1;
+ _companies_ai[c->index].mid2.buildcmd_a = 0xFF;
+ _companies_ai[c->index].mid2.buildcmd_b = 0xFF;
+ _companies_ai[c->index].mid2.direction = _companies_ai[c->index].dst.direction;
+ _companies_ai[c->index].mid2.cargo = fr.cargo;
// Fill common fields
- _players_ai[p->index].cargo_type = fr.cargo;
- _players_ai[p->index].num_wagons = 3;
- _players_ai[p->index].build_kind = 2;
- _players_ai[p->index].num_build_rec = 4;
- _players_ai[p->index].num_loco_to_build = 2;
- _players_ai[p->index].num_want_fullload = 0;
- _players_ai[p->index].wagon_list[0] = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = fr.cargo;
+ _companies_ai[c->index].num_wagons = 3;
+ _companies_ai[c->index].build_kind = 2;
+ _companies_ai[c->index].num_build_rec = 4;
+ _companies_ai[c->index].num_loco_to_build = 2;
+ _companies_ai[c->index].num_want_fullload = 0;
+ _companies_ai[c->index].wagon_list[0] = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantPassengerRoute(Player *p)
+static void AiWantPassengerRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -1072,75 +1072,75 @@ static void AiWantPassengerRoute(Player *p)
}
fr.cargo = CT_PASSENGERS;
- if (!AiCheckIfRouteIsGood(p, &fr, 1)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 1)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 7;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.unk6 = 1;
- _players_ai[p->index].src.unk7 = 0;
- _players_ai[p->index].src.buildcmd_a = 0x10;
- _players_ai[p->index].src.buildcmd_b = 0xFF;
- _players_ai[p->index].src.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 7;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.unk6 = 1;
+ _companies_ai[c->index].src.unk7 = 0;
+ _companies_ai[c->index].src.buildcmd_a = 0x10;
+ _companies_ai[c->index].src.buildcmd_b = 0xFF;
+ _companies_ai[c->index].src.direction = AiGetDirectionBetweenTiles(
GET_TOWN_OR_INDUSTRY_TILE(fr.from),
GET_TOWN_OR_INDUSTRY_TILE(fr.to)
);
- _players_ai[p->index].src.cargo = fr.cargo;
+ _companies_ai[c->index].src.cargo = fr.cargo;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 7;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.unk6 = 1;
- _players_ai[p->index].dst.unk7 = 0;
- _players_ai[p->index].dst.buildcmd_a = 0xFF;
- _players_ai[p->index].dst.buildcmd_b = 0xFF;
- _players_ai[p->index].dst.direction = AiGetDirectionBetweenTiles(
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 7;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.unk6 = 1;
+ _companies_ai[c->index].dst.unk7 = 0;
+ _companies_ai[c->index].dst.buildcmd_a = 0xFF;
+ _companies_ai[c->index].dst.buildcmd_b = 0xFF;
+ _companies_ai[c->index].dst.direction = AiGetDirectionBetweenTiles(
GET_TOWN_OR_INDUSTRY_TILE(fr.to),
GET_TOWN_OR_INDUSTRY_TILE(fr.from)
);
- _players_ai[p->index].dst.cargo = fr.cargo;
+ _companies_ai[c->index].dst.cargo = fr.cargo;
// Fill common fields
- _players_ai[p->index].cargo_type = fr.cargo;
- _players_ai[p->index].num_wagons = 2;
- _players_ai[p->index].build_kind = 1;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 1;
- _players_ai[p->index].num_want_fullload = 0;
- _players_ai[p->index].wagon_list[0] = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = fr.cargo;
+ _companies_ai[c->index].num_wagons = 2;
+ _companies_ai[c->index].build_kind = 1;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 1;
+ _companies_ai[c->index].num_want_fullload = 0;
+ _companies_ai[c->index].wagon_list[0] = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_RAIL_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantTrainRoute(Player *p)
+static void AiWantTrainRoute(Company *c)
{
uint16 r = GB(Random(), 0, 16);
- _players_ai[p->index].railtype_to_use = GetBestRailtype(p->index);
+ _companies_ai[c->index].railtype_to_use = GetBestRailtype(c->index);
if (r > 0xD000) {
- AiWantLongIndustryRoute(p);
+ AiWantLongIndustryRoute(c);
} else if (r > 0x6000) {
- AiWantMediumIndustryRoute(p);
+ AiWantMediumIndustryRoute(c);
} else if (r > 0x1000) {
- AiWantShortIndustryRoute(p);
+ AiWantShortIndustryRoute(c);
} else if (r > 0x800) {
- AiWantPassengerRoute(p);
+ AiWantPassengerRoute(c);
} else {
- AiWantMailRoute(p);
+ AiWantMailRoute(c);
}
}
-static void AiWantLongRoadIndustryRoute(Player *p)
+static void AiWantLongRoadIndustryRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -1159,44 +1159,44 @@ static void AiWantLongRoadIndustryRoute(Player *p)
if (--i == 0) return;
}
- if (!AiCheckIfRouteIsGood(p, &fr, 2)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 2)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 9;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.buildcmd_a = 1;
- _players_ai[p->index].src.direction = 0;
- _players_ai[p->index].src.cargo = fr.cargo | 0x80;
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 9;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.buildcmd_a = 1;
+ _companies_ai[c->index].src.direction = 0;
+ _companies_ai[c->index].src.cargo = fr.cargo | 0x80;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 9;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.buildcmd_a = 0xFF;
- _players_ai[p->index].dst.direction = 0;
- _players_ai[p->index].dst.cargo = fr.cargo;
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 9;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.buildcmd_a = 0xFF;
+ _companies_ai[c->index].dst.direction = 0;
+ _companies_ai[c->index].dst.cargo = fr.cargo;
// Fill common fields
- _players_ai[p->index].cargo_type = fr.cargo;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 5;
- _players_ai[p->index].num_want_fullload = 5;
-
-// _players_ai[p->index].loco_id = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
-
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_ROAD_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = fr.cargo;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 5;
+ _companies_ai[c->index].num_want_fullload = 5;
+
+// _companies_ai[c->index].loco_id = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_ROAD_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantMediumRoadIndustryRoute(Player *p)
+static void AiWantMediumRoadIndustryRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -1215,44 +1215,44 @@ static void AiWantMediumRoadIndustryRoute(Player *p)
if (--i == 0) return;
}
- if (!AiCheckIfRouteIsGood(p, &fr, 2)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 2)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 9;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.buildcmd_a = 1;
- _players_ai[p->index].src.direction = 0;
- _players_ai[p->index].src.cargo = fr.cargo | 0x80;
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 9;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.buildcmd_a = 1;
+ _companies_ai[c->index].src.direction = 0;
+ _companies_ai[c->index].src.cargo = fr.cargo | 0x80;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 9;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.buildcmd_a = 0xFF;
- _players_ai[p->index].dst.direction = 0;
- _players_ai[p->index].dst.cargo = fr.cargo;
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 9;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.buildcmd_a = 0xFF;
+ _companies_ai[c->index].dst.direction = 0;
+ _companies_ai[c->index].dst.cargo = fr.cargo;
// Fill common fields
- _players_ai[p->index].cargo_type = fr.cargo;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 3;
- _players_ai[p->index].num_want_fullload = 3;
-
-// _players_ai[p->index].loco_id = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
-
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_ROAD_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = fr.cargo;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 3;
+ _companies_ai[c->index].num_want_fullload = 3;
+
+// _companies_ai[c->index].loco_id = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_ROAD_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantLongRoadPassengerRoute(Player *p)
+static void AiWantLongRoadPassengerRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -1273,44 +1273,44 @@ static void AiWantLongRoadPassengerRoute(Player *p)
fr.cargo = CT_PASSENGERS;
- if (!AiCheckIfRouteIsGood(p, &fr, 2)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 2)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 10;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.buildcmd_a = 1;
- _players_ai[p->index].src.direction = 0;
- _players_ai[p->index].src.cargo = CT_PASSENGERS;
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 10;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.buildcmd_a = 1;
+ _companies_ai[c->index].src.direction = 0;
+ _companies_ai[c->index].src.cargo = CT_PASSENGERS;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 10;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.buildcmd_a = 0xFF;
- _players_ai[p->index].dst.direction = 0;
- _players_ai[p->index].dst.cargo = CT_PASSENGERS;
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 10;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.buildcmd_a = 0xFF;
+ _companies_ai[c->index].dst.direction = 0;
+ _companies_ai[c->index].dst.cargo = CT_PASSENGERS;
// Fill common fields
- _players_ai[p->index].cargo_type = CT_PASSENGERS;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 4;
- _players_ai[p->index].num_want_fullload = 0;
-
-// _players_ai[p->index].loco_id = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
-
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_ROAD_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = CT_PASSENGERS;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 4;
+ _companies_ai[c->index].num_want_fullload = 0;
+
+// _companies_ai[c->index].loco_id = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_ROAD_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantPassengerRouteInsideTown(Player *p)
+static void AiWantPassengerRouteInsideTown(Company *c)
{
int i;
FoundRoute fr;
@@ -1329,59 +1329,59 @@ static void AiWantPassengerRouteInsideTown(Player *p)
fr.cargo = CT_PASSENGERS;
fr.from = fr.to = t;
- if (!AiCheckIfRouteIsGood(p, &fr, 2)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 2)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = t->xy;
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 10;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.buildcmd_a = 1;
- _players_ai[p->index].src.direction = 0;
- _players_ai[p->index].src.cargo = CT_PASSENGERS;
+ _companies_ai[c->index].src.spec_tile = t->xy;
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 10;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.buildcmd_a = 1;
+ _companies_ai[c->index].src.direction = 0;
+ _companies_ai[c->index].src.cargo = CT_PASSENGERS;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = t->xy;
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 10;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.buildcmd_a = 0xFF;
- _players_ai[p->index].dst.direction = 0;
- _players_ai[p->index].dst.cargo = CT_PASSENGERS;
+ _companies_ai[c->index].dst.spec_tile = t->xy;
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 10;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.buildcmd_a = 0xFF;
+ _companies_ai[c->index].dst.direction = 0;
+ _companies_ai[c->index].dst.cargo = CT_PASSENGERS;
// Fill common fields
- _players_ai[p->index].cargo_type = CT_PASSENGERS;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 2;
- _players_ai[p->index].num_want_fullload = 0;
-
-// _players_ai[p->index].loco_id = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
-
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_ROAD_BLOCKS;
- _players_ai[p->index].state_mode = UCHAR_MAX;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = CT_PASSENGERS;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 2;
+ _companies_ai[c->index].num_want_fullload = 0;
+
+// _companies_ai[c->index].loco_id = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_ROAD_BLOCKS;
+ _companies_ai[c->index].state_mode = UCHAR_MAX;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantRoadRoute(Player *p)
+static void AiWantRoadRoute(Company *c)
{
uint16 r = GB(Random(), 0, 16);
if (r > 0x4000) {
- AiWantLongRoadIndustryRoute(p);
+ AiWantLongRoadIndustryRoute(c);
} else if (r > 0x2000) {
- AiWantMediumRoadIndustryRoute(p);
+ AiWantMediumRoadIndustryRoute(c);
} else if (r > 0x1000) {
- AiWantLongRoadPassengerRoute(p);
+ AiWantLongRoadPassengerRoute(c);
} else {
- AiWantPassengerRouteInsideTown(p);
+ AiWantPassengerRouteInsideTown(c);
}
}
-static void AiWantPassengerAircraftRoute(Player *p)
+static void AiWantPassengerAircraftRoute(Company *c)
{
FoundRoute fr;
int i;
@@ -1389,7 +1389,7 @@ static void AiWantPassengerAircraftRoute(Player *p)
/* Get aircraft that would be bought for this route
* (probably, as conditions may change before the route is fully built,
* like running out of money and having to select different aircraft, etc ...) */
- EngineID veh = AiChooseAircraftToBuild(p->player_money, _players_ai[p->index].build_kind != 0 ? AIR_CTOL : 0);
+ EngineID veh = AiChooseAircraftToBuild(c->money, _companies_ai[c->index].build_kind != 0 ? AIR_CTOL : 0);
/* No aircraft buildable mean no aircraft route */
if (veh == INVALID_ENGINE) return;
@@ -1441,28 +1441,28 @@ static void AiWantPassengerAircraftRoute(Player *p)
}
fr.cargo = CT_PASSENGERS;
- if (!AiCheckIfRouteIsGood(p, &fr, 4)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 4)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 12;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.cargo = fr.cargo;
+ _companies_ai[c->index].src.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.to);
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 12;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.cargo = fr.cargo;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 12;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.cargo = fr.cargo;
+ _companies_ai[c->index].dst.spec_tile = GET_TOWN_OR_INDUSTRY_TILE(fr.from);
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 12;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.cargo = fr.cargo;
// Fill common fields
- _players_ai[p->index].cargo_type = fr.cargo;
- _players_ai[p->index].build_kind = 0;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 1;
+ _companies_ai[c->index].cargo_type = fr.cargo;
+ _companies_ai[c->index].build_kind = 0;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 1;
/* Using full load always may not be the best.
* Pick random value and rely on selling the vehicle & route
* afterwards if the choice was utterly wrong (or maybe altering the value if AI is improved)
@@ -1475,17 +1475,17 @@ static void AiWantPassengerAircraftRoute(Player *p)
* Also, non-full load is more resistant against starving (by building better stations
* or using exclusive rights)
*/
- _players_ai[p->index].num_want_fullload = Chance16(1, 5); // 20% chance
-// _players_ai[p->index].loco_id = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
-
- _players_ai[p->index].state = AIS_AIRPORT_STUFF;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].num_want_fullload = Chance16(1, 5); // 20% chance
+// _companies_ai[c->index].loco_id = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+
+ _companies_ai[c->index].state = AIS_AIRPORT_STUFF;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantOilRigAircraftRoute(Player *p)
+static void AiWantOilRigAircraftRoute(Company *c)
{
int i;
FoundRoute fr;
@@ -1512,57 +1512,57 @@ static void AiWantOilRigAircraftRoute(Player *p)
fr.cargo = CT_PASSENGERS;
fr.from = fr.to = t;
- if (!AiCheckIfRouteIsGood(p, &fr, 4)) return;
+ if (!AiCheckIfRouteIsGood(c, &fr, 4)) return;
// Fill the source field
- _players_ai[p->index].src.spec_tile = t->xy;
- _players_ai[p->index].src.use_tile = 0;
- _players_ai[p->index].src.rand_rng = 12;
- _players_ai[p->index].src.cur_building_rule = 0xFF;
- _players_ai[p->index].src.cargo = CT_PASSENGERS;
+ _companies_ai[c->index].src.spec_tile = t->xy;
+ _companies_ai[c->index].src.use_tile = 0;
+ _companies_ai[c->index].src.rand_rng = 12;
+ _companies_ai[c->index].src.cur_building_rule = 0xFF;
+ _companies_ai[c->index].src.cargo = CT_PASSENGERS;
// Fill the dest field
- _players_ai[p->index].dst.spec_tile = in->xy;
- _players_ai[p->index].dst.use_tile = 0;
- _players_ai[p->index].dst.rand_rng = 5;
- _players_ai[p->index].dst.cur_building_rule = 0xFF;
- _players_ai[p->index].dst.cargo = CT_PASSENGERS;
+ _companies_ai[c->index].dst.spec_tile = in->xy;
+ _companies_ai[c->index].dst.use_tile = 0;
+ _companies_ai[c->index].dst.rand_rng = 5;
+ _companies_ai[c->index].dst.cur_building_rule = 0xFF;
+ _companies_ai[c->index].dst.cargo = CT_PASSENGERS;
// Fill common fields
- _players_ai[p->index].cargo_type = CT_PASSENGERS;
- _players_ai[p->index].build_kind = 1;
- _players_ai[p->index].num_build_rec = 2;
- _players_ai[p->index].num_loco_to_build = 1;
- _players_ai[p->index].num_want_fullload = 0;
-// _players_ai[p->index].loco_id = INVALID_VEHICLE;
- _players_ai[p->index].order_list_blocks[0] = 0;
- _players_ai[p->index].order_list_blocks[1] = 1;
- _players_ai[p->index].order_list_blocks[2] = 255;
-
- _players_ai[p->index].state = AIS_AIRPORT_STUFF;
- _players_ai[p->index].timeout_counter = 0;
+ _companies_ai[c->index].cargo_type = CT_PASSENGERS;
+ _companies_ai[c->index].build_kind = 1;
+ _companies_ai[c->index].num_build_rec = 2;
+ _companies_ai[c->index].num_loco_to_build = 1;
+ _companies_ai[c->index].num_want_fullload = 0;
+// _companies_ai[c->index].loco_id = INVALID_VEHICLE;
+ _companies_ai[c->index].order_list_blocks[0] = 0;
+ _companies_ai[c->index].order_list_blocks[1] = 1;
+ _companies_ai[c->index].order_list_blocks[2] = 255;
+
+ _companies_ai[c->index].state = AIS_AIRPORT_STUFF;
+ _companies_ai[c->index].timeout_counter = 0;
}
-static void AiWantAircraftRoute(Player *p)
+static void AiWantAircraftRoute(Company *c)
{
uint16 r = (uint16)Random();
if (r >= 0x2AAA || _date < 0x3912 + DAYS_TILL_ORIGINAL_BASE_YEAR) {
- AiWantPassengerAircraftRoute(p);
+ AiWantPassengerAircraftRoute(c);
} else {
- AiWantOilRigAircraftRoute(p);
+ AiWantOilRigAircraftRoute(c);
}
}
-static void AiStateWantNewRoute(Player *p)
+static void AiStateWantNewRoute(Company *c)
{
uint16 r;
int i;
- if (p->player_money < AiGetBasePrice(p) * 500) {
- _players_ai[p->index].state = AIS_0;
+ if (c->money < AiGetBasePrice(c) * 500) {
+ _companies_ai[c->index].state = AIS_0;
return;
}
@@ -1579,23 +1579,23 @@ static void AiStateWantNewRoute(Player *p)
if (r < 0x7626) {
if (_settings_game.ai.ai_disable_veh_train) continue;
- AiWantTrainRoute(p);
+ AiWantTrainRoute(c);
} else if (r < 0xC4EA) {
if (_settings_game.ai.ai_disable_veh_roadveh) continue;
- AiWantRoadRoute(p);
+ AiWantRoadRoute(c);
} else if (r < 0xD89B) {
if (_settings_game.ai.ai_disable_veh_aircraft) continue;
- AiWantAircraftRoute(p);
+ AiWantAircraftRoute(c);
} else {
/* Ships are not implemented in this (broken) AI */
}
// got a route?
- if (_players_ai[p->index].state != AIS_WANT_NEW_ROUTE) break;
+ if (_companies_ai[c->index].state != AIS_WANT_NEW_ROUTE) break;
// time out?
if (--i == 0) {
- if (++_players_ai[p->index].state_counter == 556) _players_ai[p->index].state = AIS_0;
+ if (++_companies_ai[c->index].state_counter == 556) _companies_ai[c->index].state = AIS_0;
break;
}
}
@@ -1725,7 +1725,7 @@ clear_town_stuff:;
}
if (!(flag & DC_EXEC)) {
- if (t != NULL && rating > t->ratings[_current_player]) {
+ if (t != NULL && rating > t->ratings[_current_company]) {
return CMD_ERROR;
}
}
@@ -1775,13 +1775,13 @@ static const byte _terraform_down_flags[] = {
static void AiDoTerraformLand(TileIndex tile, DiagDirection dir, int unk, int mode)
{
- PlayerID old_player;
+ CompanyID old_company;
uint32 r;
Slope slope;
uint h;
- old_player = _current_player;
- _current_player = OWNER_NONE;
+ old_company = _current_company;
+ _current_company = OWNER_NONE;
r = Random();
@@ -1810,10 +1810,10 @@ static void AiDoTerraformLand(TileIndex tile, DiagDirection dir, int unk, int mo
}
}
- _current_player = old_player;
+ _current_company = old_company;
}
-static void AiStateBuildDefaultRailBlocks(Player *p)
+static void AiStateBuildDefaultRailBlocks(Company *c)
{
uint i;
int j;
@@ -1822,16 +1822,16 @@ static void AiStateBuildDefaultRailBlocks(Player *p)
CommandCost cost;
// time out?
- if (++_players_ai[p->index].timeout_counter == 1388) {
- _players_ai[p->index].state = AIS_DELETE_RAIL_BLOCKS;
+ if (++_companies_ai[c->index].timeout_counter == 1388) {
+ _companies_ai[c->index].state = AIS_DELETE_RAIL_BLOCKS;
return;
}
// do the following 8 times
for (i = 0; i < 8; i++) {
// check if we can build the default track
- aib = &_players_ai[p->index].src;
- j = _players_ai[p->index].num_build_rec;
+ aib = &_companies_ai[c->index].src;
+ j = _companies_ai[c->index].num_build_rec;
do {
// this item has already been built?
if (aib->cur_building_rule != 255) continue;
@@ -1842,31 +1842,31 @@ static void AiStateBuildDefaultRailBlocks(Player *p)
// check if the track can be build there.
rule = AiBuildDefaultRailTrack(aib->use_tile,
- _players_ai[p->index].build_kind, _players_ai[p->index].num_wagons,
+ _companies_ai[c->index].build_kind, _companies_ai[c->index].num_wagons,
aib->unk6, aib->unk7,
aib->direction, aib->cargo,
- _players_ai[p->index].railtype_to_use,
+ _companies_ai[c->index].railtype_to_use,
&cost
);
if (rule == -1) {
// cannot build, terraform after a while
- if (_players_ai[p->index].state_counter >= 600) {
- AiDoTerraformLand(aib->use_tile, (DiagDirection)(Random() & 3), 3, (int8)_players_ai[p->index].state_mode);
+ if (_companies_ai[c->index].state_counter >= 600) {
+ AiDoTerraformLand(aib->use_tile, (DiagDirection)(Random() & 3), 3, (int8)_companies_ai[c->index].state_mode);
}
// also try the other terraform direction
- if (++_players_ai[p->index].state_counter >= 1000) {
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].state_mode = -_players_ai[p->index].state_mode;
+ if (++_companies_ai[c->index].state_counter >= 1000) {
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].state_mode = -_companies_ai[c->index].state_mode;
}
- } else if (CheckPlayerHasMoney(cost)) {
- // player has money, build it.
+ } else if (CheckCompanyHasMoney(cost)) {
+ // company has money, build it.
aib->cur_building_rule = rule;
AiDoBuildDefaultRailTrack(
aib->use_tile,
_default_rail_track_data[rule]->data,
- _players_ai[p->index].railtype_to_use,
+ _companies_ai[c->index].railtype_to_use,
DC_EXEC | DC_NO_TOWN_RATING
);
}
@@ -1874,15 +1874,15 @@ static void AiStateBuildDefaultRailBlocks(Player *p)
}
// check if we're done with all of them
- aib = &_players_ai[p->index].src;
- j = _players_ai[p->index].num_build_rec;
+ aib = &_companies_ai[c->index].src;
+ j = _companies_ai[c->index].num_build_rec;
do {
if (aib->cur_building_rule == 255) return;
} while (++aib, --j);
// yep, all are done. switch state to the rail building state.
- _players_ai[p->index].state = AIS_BUILD_RAIL;
- _players_ai[p->index].state_mode = 255;
+ _companies_ai[c->index].state = AIS_BUILD_RAIL;
+ _companies_ai[c->index].state_mode = 255;
}
static TileIndex AiGetEdgeOfDefaultRailBlock(byte rule, TileIndex tile, byte cmd, DiagDirection *dir)
@@ -1915,15 +1915,15 @@ static bool AiEnumFollowTrack(TileIndex tile, AiRailPathFindData *a, int track,
return false;
}
-static bool AiDoFollowTrack(const Player* p)
+static bool AiDoFollowTrack(const Company *c)
{
AiRailPathFindData arpfd;
- arpfd.tile = _players_ai[p->index].start_tile_a;
- arpfd.tile2 = _players_ai[p->index].cur_tile_a;
+ arpfd.tile = _companies_ai[c->index].start_tile_a;
+ arpfd.tile2 = _companies_ai[c->index].cur_tile_a;
arpfd.flag = false;
arpfd.count = 0;
- FollowTrack(_players_ai[p->index].cur_tile_a + TileOffsByDiagDir(_players_ai[p->index].cur_dir_a), PATHFIND_FLAGS_NONE, TRANSPORT_RAIL, 0, ReverseDiagDir(_players_ai[p->index].cur_dir_a),
+ FollowTrack(_companies_ai[c->index].cur_tile_a + TileOffsByDiagDir(_companies_ai[c->index].cur_dir_a), PATHFIND_FLAGS_NONE, TRANSPORT_RAIL, 0, ReverseDiagDir(_companies_ai[c->index].cur_dir_a),
(TPFEnumProc*)AiEnumFollowTrack, NULL, &arpfd);
return arpfd.count > 8;
}
@@ -1942,7 +1942,7 @@ struct AiRailFinder {
uint best_dist;
TileIndex cur_best_tile, best_tile;
TileIndex bridge_end_tile;
- Player *player;
+ Company *company;
};
static const byte _ai_table_15[4][8] = {
@@ -1953,32 +1953,32 @@ static const byte _ai_table_15[4][8] = {
};
-static bool AiIsTileBanned(const Player* p, TileIndex tile, byte val)
+static bool AiIsTileBanned(const Company *c, TileIndex tile, byte val)
{
int i;
- for (i = 0; i != _players_ai[p->index].banned_tile_count; i++) {
- if (_players_ai[p->index].banned_tiles[i] == tile && _players_ai[p->index].banned_val[i] == val) {
+ for (i = 0; i != _companies_ai[c->index].banned_tile_count; i++) {
+ if (_companies_ai[c->index].banned_tiles[i] == tile && _companies_ai[c->index].banned_val[i] == val) {
return true;
}
}
return false;
}
-static void AiBanTile(Player* p, TileIndex tile, byte val)
+static void AiBanTile(Company *c, TileIndex tile, byte val)
{
uint i;
- for (i = lengthof(_players_ai[p->index].banned_tiles) - 1; i != 0; i--) {
- _players_ai[p->index].banned_tiles[i] = _players_ai[p->index].banned_tiles[i - 1];
- _players_ai[p->index].banned_val[i] = _players_ai[p->index].banned_val[i - 1];
+ for (i = lengthof(_companies_ai[c->index].banned_tiles) - 1; i != 0; i--) {
+ _companies_ai[c->index].banned_tiles[i] = _companies_ai[c->index].banned_tiles[i - 1];
+ _companies_ai[c->index].banned_val[i] = _companies_ai[c->index].banned_val[i - 1];
}
- _players_ai[p->index].banned_tiles[0] = tile;
- _players_ai[p->index].banned_val[0] = val;
+ _companies_ai[c->index].banned_tiles[0] = tile;
+ _companies_ai[c->index].banned_val[0] = val;
- if (_players_ai[p->index].banned_tile_count != lengthof(_players_ai[p->index].banned_tiles)) {
- _players_ai[p->index].banned_tile_count++;
+ if (_companies_ai[c->index].banned_tile_count != lengthof(_companies_ai[c->index].banned_tiles)) {
+ _companies_ai[c->index].banned_tile_count++;
}
}
@@ -2045,7 +2045,7 @@ static inline void AiCheckBuildRailBridgeHere(AiRailFinder *arf, TileIndex tile,
}
// Is building a (rail)bridge possible at this place (type doesn't matter)?
- if (CmdFailed(DoCommand(tile_new, tile, _players_ai[arf->player->index].railtype_to_use << 8 | TRANSPORT_RAIL << 15, DC_AUTO, CMD_BUILD_BRIDGE))) {
+ if (CmdFailed(DoCommand(tile_new, tile, _companies_ai[arf->company->index].railtype_to_use << 8 | TRANSPORT_RAIL << 15, DC_AUTO, CMD_BUILD_BRIDGE))) {
return;
}
AiBuildRailRecursive(arf, tile_new, dir2);
@@ -2062,9 +2062,9 @@ static inline void AiCheckBuildRailTunnelHere(AiRailFinder *arf, TileIndex tile,
uint z;
if (GetTileSlope(tile, &z) == InclinedSlope((DiagDirection)(p[0] & 3)) && z != 0) {
- CommandCost cost = DoCommand(tile, _players_ai[arf->player->index].railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL);
+ CommandCost cost = DoCommand(tile, _companies_ai[arf->company->index].railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL);
- if (CmdSucceeded(cost) && cost.GetCost() <= (arf->player->player_money >> 4)) {
+ if (CmdSucceeded(cost) && cost.GetCost() <= (arf->company->money >> 4)) {
AiBuildRailRecursive(arf, _build_tunnel_endtile, (DiagDirection)(p[0] & 3));
if (arf->depth == 1) AiCheckRailPathBetter(arf, p);
}
@@ -2117,8 +2117,8 @@ static void AiBuildRailRecursive(AiRailFinder *arf, TileIndex tile, DiagDirectio
} else {
do {
// Make sure the tile is not in the list of banned tiles and that a rail can be built here.
- if (!AiIsTileBanned(arf->player, tile, p[0]) &&
- CmdSucceeded(DoCommand(tile, _players_ai[arf->player->index].railtype_to_use, p[0], DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL))) {
+ if (!AiIsTileBanned(arf->company, tile, p[0]) &&
+ CmdSucceeded(DoCommand(tile, _companies_ai[arf->company->index].railtype_to_use, p[0], DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL))) {
AiBuildRailRecursive(arf, tile, (DiagDirection)p[1]);
}
@@ -2136,25 +2136,25 @@ static void AiBuildRailRecursive(AiRailFinder *arf, TileIndex tile, DiagDirectio
}
-static void AiBuildRailConstruct(Player *p)
+static void AiBuildRailConstruct(Company *c)
{
AiRailFinder arf;
int i;
// Check too much lookahead?
- if (AiDoFollowTrack(p)) {
- _players_ai[p->index].state_counter = (Random()&0xE)+6; // Destruct this amount of blocks
- _players_ai[p->index].state_mode = 1; // Start destruct
+ if (AiDoFollowTrack(c)) {
+ _companies_ai[c->index].state_counter = (Random()&0xE)+6; // Destruct this amount of blocks
+ _companies_ai[c->index].state_mode = 1; // Start destruct
// Ban this tile and don't reach it for a while.
- AiBanTile(p, _players_ai[p->index].cur_tile_a, FindFirstBit(GetRailTrackStatus(_players_ai[p->index].cur_tile_a)));
+ AiBanTile(c, _companies_ai[c->index].cur_tile_a, FindFirstBit(GetRailTrackStatus(_companies_ai[c->index].cur_tile_a)));
return;
}
// Setup recursive finder and call it.
- arf.player = p;
- arf.final_tile = _players_ai[p->index].cur_tile_b;
- arf.final_dir = _players_ai[p->index].cur_dir_b;
+ arf.company = c;
+ arf.final_tile = _companies_ai[c->index].cur_tile_b;
+ arf.final_dir = _companies_ai[c->index].cur_dir_b;
arf.depth = 0;
arf.recursive_mode = 0;
arf.best_ptr = NULL;
@@ -2164,11 +2164,11 @@ static void AiBuildRailConstruct(Player *p)
arf.best_depth = 0xff;
arf.cur_best_tile = 0;
arf.best_tile = 0;
- AiBuildRailRecursive(&arf, _players_ai[p->index].cur_tile_a, _players_ai[p->index].cur_dir_a);
+ AiBuildRailRecursive(&arf, _companies_ai[c->index].cur_tile_a, _companies_ai[c->index].cur_dir_a);
// Reached destination?
if (arf.recursive_mode == 2 && arf.cur_best_depth == 0) {
- _players_ai[p->index].state_mode = 255;
+ _companies_ai[c->index].state_mode = 255;
return;
}
@@ -2176,23 +2176,23 @@ static void AiBuildRailConstruct(Player *p)
if (arf.best_ptr == NULL) {
// Terraform some
for (i = 0; i != 5; i++) {
- AiDoTerraformLand(_players_ai[p->index].cur_tile_a, _players_ai[p->index].cur_dir_a, 3, 0);
+ AiDoTerraformLand(_companies_ai[c->index].cur_tile_a, _companies_ai[c->index].cur_dir_a, 3, 0);
}
- if (++_players_ai[p->index].state_counter == 21) {
- _players_ai[p->index].state_counter = 40;
- _players_ai[p->index].state_mode = 1;
+ if (++_companies_ai[c->index].state_counter == 21) {
+ _companies_ai[c->index].state_counter = 40;
+ _companies_ai[c->index].state_mode = 1;
// Ban this tile
- AiBanTile(p, _players_ai[p->index].cur_tile_a, FindFirstBit(GetRailTrackStatus(_players_ai[p->index].cur_tile_a)));
+ AiBanTile(c, _companies_ai[c->index].cur_tile_a, FindFirstBit(GetRailTrackStatus(_companies_ai[c->index].cur_tile_a)));
}
return;
}
- _players_ai[p->index].cur_tile_a += TileOffsByDiagDir(_players_ai[p->index].cur_dir_a);
+ _companies_ai[c->index].cur_tile_a += TileOffsByDiagDir(_companies_ai[c->index].cur_dir_a);
if (arf.best_ptr[0] & 0x80) {
- TileIndex t1 = _players_ai[p->index].cur_tile_a;
+ TileIndex t1 = _companies_ai[c->index].cur_tile_a;
TileIndex t2 = arf.bridge_end_tile;
int32 bridge_len = GetTunnelBridgeLength(t1, t2);
@@ -2209,7 +2209,7 @@ static void AiBuildRailConstruct(Player *p)
/* try to build one rail on each tile - can't use CMD_BUILD_RAILROAD_TRACK now, it can build one part of track without failing */
do {
- cost = DoCommand(t, _players_ai[p->index].railtype_to_use, track, DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
+ cost = DoCommand(t, _companies_ai[c->index].railtype_to_use, track, DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
/* do not allow building over existing track */
if (CmdFailed(cost) || IsTileType(t, MP_RAILWAY)) {
fail = true;
@@ -2219,10 +2219,10 @@ static void AiBuildRailConstruct(Player *p)
} while (t != t2);
/* can we build long track? */
- if (!fail) cost = DoCommand(t1, t2, _players_ai[p->index].railtype_to_use | (track << 4), DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_TRACK);
+ if (!fail) cost = DoCommand(t1, t2, _companies_ai[c->index].railtype_to_use | (track << 4), DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_TRACK);
- if (!fail && CmdSucceeded(cost) && cost.GetCost() <= p->player_money) {
- DoCommand(t1, t2, _players_ai[p->index].railtype_to_use | (track << 4), DC_AUTO | DC_NO_WATER | DC_EXEC, CMD_BUILD_RAILROAD_TRACK);
+ if (!fail && CmdSucceeded(cost) && cost.GetCost() <= c->money) {
+ DoCommand(t1, t2, _companies_ai[c->index].railtype_to_use | (track << 4), DC_AUTO | DC_NO_WATER | DC_EXEC, CMD_BUILD_RAILROAD_TRACK);
} else {
/* Figure out which (rail)bridge type to build
@@ -2231,28 +2231,28 @@ static void AiBuildRailConstruct(Player *p)
int i;
for (i = MAX_BRIDGES - 1; i != 0; i--) {
if (CheckBridge_Stuff(i, bridge_len)) {
- CommandCost cost = DoCommand(t1, t2, i | _players_ai[p->index].railtype_to_use << 8 | TRANSPORT_RAIL << 15, DC_AUTO, CMD_BUILD_BRIDGE);
- if (CmdSucceeded(cost) && cost.GetCost() < (p->player_money >> 1) && cost.GetCost() < ((p->player_money + _economy.max_loan - p->current_loan) >> 5)) break;
+ CommandCost cost = DoCommand(t1, t2, i | _companies_ai[c->index].railtype_to_use << 8 | TRANSPORT_RAIL << 15, DC_AUTO, CMD_BUILD_BRIDGE);
+ if (CmdSucceeded(cost) && cost.GetCost() < (c->money >> 1) && cost.GetCost() < ((c->money + _economy.max_loan - c->current_loan) >> 5)) break;
}
}
/* Build it */
- DoCommand(t1, t2, i | _players_ai[p->index].railtype_to_use << 8 | TRANSPORT_RAIL << 15, DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
+ DoCommand(t1, t2, i | _companies_ai[c->index].railtype_to_use << 8 | TRANSPORT_RAIL << 15, DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
}
- _players_ai[p->index].cur_tile_a = t2;
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].cur_tile_a = t2;
+ _companies_ai[c->index].state_counter = 0;
} else if (arf.best_ptr[0] & 0x40) {
// tunnel
- DoCommand(_players_ai[p->index].cur_tile_a, _players_ai[p->index].railtype_to_use, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
- _players_ai[p->index].cur_tile_a = _build_tunnel_endtile;
- _players_ai[p->index].state_counter = 0;
+ DoCommand(_companies_ai[c->index].cur_tile_a, _companies_ai[c->index].railtype_to_use, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
+ _companies_ai[c->index].cur_tile_a = _build_tunnel_endtile;
+ _companies_ai[c->index].state_counter = 0;
} else {
// rail
- _players_ai[p->index].cur_dir_a = (DiagDirection)(arf.best_ptr[1] & 3);
- DoCommand(_players_ai[p->index].cur_tile_a, _players_ai[p->index].railtype_to_use, arf.best_ptr[0],
+ _companies_ai[c->index].cur_dir_a = (DiagDirection)(arf.best_ptr[1] & 3);
+ DoCommand(_companies_ai[c->index].cur_tile_a, _companies_ai[c->index].railtype_to_use, arf.best_ptr[0],
DC_EXEC | DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL);
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].state_counter = 0;
}
if (arf.best_tile != 0) {
@@ -2262,10 +2262,10 @@ static void AiBuildRailConstruct(Player *p)
}
}
-static bool AiRemoveTileAndGoForward(Player *p)
+static bool AiRemoveTileAndGoForward(Company *c)
{
const byte *ptr;
- TileIndex tile = _players_ai[p->index].cur_tile_a;
+ TileIndex tile = _companies_ai[c->index].cur_tile_a;
TileIndex tilenew;
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
@@ -2273,26 +2273,26 @@ static bool AiRemoveTileAndGoForward(Player *p)
// Clear the tunnel and continue at the other side of it.
if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR)))
return false;
- _players_ai[p->index].cur_tile_a = TILE_MASK(_build_tunnel_endtile - TileOffsByDiagDir(_players_ai[p->index].cur_dir_a));
+ _companies_ai[c->index].cur_tile_a = TILE_MASK(_build_tunnel_endtile - TileOffsByDiagDir(_companies_ai[c->index].cur_dir_a));
return true;
} else { // IsBridge(tile)
// Check if the bridge points in the right direction.
// This is not really needed the first place AiRemoveTileAndGoForward is called.
- if (DiagDirToAxis(GetTunnelBridgeDirection(tile)) != (_players_ai[p->index].cur_dir_a & 1)) return false;
+ if (DiagDirToAxis(GetTunnelBridgeDirection(tile)) != (_companies_ai[c->index].cur_dir_a & 1)) return false;
tile = GetOtherBridgeEnd(tile);
- tilenew = TILE_MASK(tile - TileOffsByDiagDir(_players_ai[p->index].cur_dir_a));
+ tilenew = TILE_MASK(tile - TileOffsByDiagDir(_companies_ai[c->index].cur_dir_a));
// And clear the bridge.
if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR)))
return false;
- _players_ai[p->index].cur_tile_a = tilenew;
+ _companies_ai[c->index].cur_tile_a = tilenew;
return true;
}
}
// Find the railtype at the position. Quit if no rail there.
- TrackBits bits = GetRailTrackStatus(tile) & DiagdirReachesTracks(ReverseDiagDir(_players_ai[p->index].cur_dir_a));
+ TrackBits bits = GetRailTrackStatus(tile) & DiagdirReachesTracks(ReverseDiagDir(_companies_ai[c->index].cur_dir_a));
if (bits == TRACK_BIT_NONE) return false;
// Convert into a bit position that CMD_REMOVE_SINGLE_RAIL expects.
@@ -2309,41 +2309,41 @@ static bool AiRemoveTileAndGoForward(Player *p)
return false;
// Find the direction at the other edge of the rail.
- ptr = _ai_table_15[ReverseDiagDir(_players_ai[p->index].cur_dir_a)];
+ ptr = _ai_table_15[ReverseDiagDir(_companies_ai[c->index].cur_dir_a)];
while (ptr[0] != track) ptr += 2;
- _players_ai[p->index].cur_dir_a = ReverseDiagDir((DiagDirection)ptr[1]);
+ _companies_ai[c->index].cur_dir_a = ReverseDiagDir((DiagDirection)ptr[1]);
// And then also switch tile.
- _players_ai[p->index].cur_tile_a = TILE_MASK(_players_ai[p->index].cur_tile_a - TileOffsByDiagDir(_players_ai[p->index].cur_dir_a));
+ _companies_ai[c->index].cur_tile_a = TILE_MASK(_companies_ai[c->index].cur_tile_a - TileOffsByDiagDir(_companies_ai[c->index].cur_dir_a));
return true;
}
-static void AiBuildRailDestruct(Player *p)
+static void AiBuildRailDestruct(Company *c)
{
// Decrease timeout.
- if (!--_players_ai[p->index].state_counter) {
- _players_ai[p->index].state_mode = 2;
- _players_ai[p->index].state_counter = 0;
+ if (!--_companies_ai[c->index].state_counter) {
+ _companies_ai[c->index].state_mode = 2;
+ _companies_ai[c->index].state_counter = 0;
}
// Don't do anything if the destination is already reached.
- if (_players_ai[p->index].cur_tile_a == _players_ai[p->index].start_tile_a) return;
+ if (_companies_ai[c->index].cur_tile_a == _companies_ai[c->index].start_tile_a) return;
- AiRemoveTileAndGoForward(p);
+ AiRemoveTileAndGoForward(c);
}
-static void AiBuildRail(Player *p)
+static void AiBuildRail(Company *c)
{
- switch (_players_ai[p->index].state_mode) {
+ switch (_companies_ai[c->index].state_mode) {
case 0: // Construct mode, build new rail.
- AiBuildRailConstruct(p);
+ AiBuildRailConstruct(c);
break;
case 1: // Destruct mode, destroy the rail currently built.
- AiBuildRailDestruct(p);
+ AiBuildRailDestruct(c);
break;
case 2: {
@@ -2351,12 +2351,12 @@ static void AiBuildRail(Player *p)
// Terraform some and then try building again.
for (i = 0; i != 4; i++) {
- AiDoTerraformLand(_players_ai[p->index].cur_tile_a, _players_ai[p->index].cur_dir_a, 3, 0);
+ AiDoTerraformLand(_companies_ai[c->index].cur_tile_a, _companies_ai[c->index].cur_dir_a, 3, 0);
}
- if (++_players_ai[p->index].state_counter == 4) {
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].state_mode = 0;
+ if (++_companies_ai[c->index].state_counter == 4) {
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].state_mode = 0;
}
}
@@ -2364,7 +2364,7 @@ static void AiBuildRail(Player *p)
}
}
-static void AiStateBuildRail(Player *p)
+static void AiStateBuildRail(Company *c)
{
int num;
AiBuildRec *aib;
@@ -2373,26 +2373,26 @@ static void AiStateBuildRail(Player *p)
DiagDirection dir;
// time out?
- if (++_players_ai[p->index].timeout_counter == 1388) {
- _players_ai[p->index].state = AIS_DELETE_RAIL_BLOCKS;
+ if (++_companies_ai[c->index].timeout_counter == 1388) {
+ _companies_ai[c->index].state = AIS_DELETE_RAIL_BLOCKS;
return;
}
// Currently building a rail between two points?
- if (_players_ai[p->index].state_mode != 255) {
- AiBuildRail(p);
+ if (_companies_ai[c->index].state_mode != 255) {
+ AiBuildRail(c);
// Alternate between edges
- Swap(_players_ai[p->index].start_tile_a, _players_ai[p->index].start_tile_b);
- Swap(_players_ai[p->index].cur_tile_a, _players_ai[p->index].cur_tile_b);
- Swap(_players_ai[p->index].start_dir_a, _players_ai[p->index].start_dir_b);
- Swap(_players_ai[p->index].cur_dir_a, _players_ai[p->index].cur_dir_b);
+ Swap(_companies_ai[c->index].start_tile_a, _companies_ai[c->index].start_tile_b);
+ Swap(_companies_ai[c->index].cur_tile_a, _companies_ai[c->index].cur_tile_b);
+ Swap(_companies_ai[c->index].start_dir_a, _companies_ai[c->index].start_dir_b);
+ Swap(_companies_ai[c->index].cur_dir_a, _companies_ai[c->index].cur_dir_b);
return;
}
// Now, find two new points to build between
- num = _players_ai[p->index].num_build_rec;
- aib = &_players_ai[p->index].src;
+ num = _companies_ai[c->index].num_build_rec;
+ aib = &_companies_ai[c->index].src;
for (;;) {
cmd = aib->buildcmd_a;
@@ -2405,37 +2405,37 @@ static void AiStateBuildRail(Player *p)
aib++;
if (--num == 0) {
- _players_ai[p->index].state = AIS_BUILD_RAIL_VEH;
- _players_ai[p->index].state_counter = 0; // timeout
+ _companies_ai[c->index].state = AIS_BUILD_RAIL_VEH;
+ _companies_ai[c->index].state_counter = 0; // timeout
return;
}
}
// Find first edge to build from.
tile = AiGetEdgeOfDefaultRailBlock(aib->cur_building_rule, aib->use_tile, cmd & 3, &dir);
- _players_ai[p->index].start_tile_a = tile;
- _players_ai[p->index].cur_tile_a = tile;
- _players_ai[p->index].start_dir_a = dir;
- _players_ai[p->index].cur_dir_a = dir;
+ _companies_ai[c->index].start_tile_a = tile;
+ _companies_ai[c->index].cur_tile_a = tile;
+ _companies_ai[c->index].start_dir_a = dir;
+ _companies_ai[c->index].cur_dir_a = dir;
DoCommand(TILE_MASK(tile + TileOffsByDiagDir(dir)), 0, (dir & 1) ? 1 : 0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL);
assert(TILE_MASK(tile) != 0xFF00);
// Find second edge to build to
- aib = (&_players_ai[p->index].src) + ((cmd >> 4) & 0xF);
+ aib = (&_companies_ai[c->index].src) + ((cmd >> 4) & 0xF);
tile = AiGetEdgeOfDefaultRailBlock(aib->cur_building_rule, aib->use_tile, (cmd >> 2) & 3, &dir);
- _players_ai[p->index].start_tile_b = tile;
- _players_ai[p->index].cur_tile_b = tile;
- _players_ai[p->index].start_dir_b = dir;
- _players_ai[p->index].cur_dir_b = dir;
+ _companies_ai[c->index].start_tile_b = tile;
+ _companies_ai[c->index].cur_tile_b = tile;
+ _companies_ai[c->index].start_dir_b = dir;
+ _companies_ai[c->index].cur_dir_b = dir;
DoCommand(TILE_MASK(tile + TileOffsByDiagDir(dir)), 0, (dir & 1) ? 1 : 0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL);
assert(TILE_MASK(tile) != 0xFF00);
// And setup state.
- _players_ai[p->index].state_mode = 2;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].banned_tile_count = 0;
+ _companies_ai[c->index].state_mode = 2;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].banned_tile_count = 0;
}
static StationID AiGetStationIdByDef(TileIndex tile, int id)
@@ -2459,7 +2459,7 @@ static EngineID AiFindBestWagon(CargoID cargo, RailType railtype)
if (!IsCompatibleRail(rvi->railtype, railtype) ||
rvi->railveh_type != RAILVEH_WAGON ||
- !HasBit(e->player_avail, _current_player)) {
+ !HasBit(e->company_avail, _current_company)) {
continue;
}
@@ -2478,7 +2478,7 @@ static EngineID AiFindBestWagon(CargoID cargo, RailType railtype)
return best_veh_index;
}
-static void AiStateBuildRailVeh(Player *p)
+static void AiStateBuildRailVeh(Company *c)
{
const AiDefaultBlockData *ptr;
TileIndex tile;
@@ -2489,40 +2489,40 @@ static void AiStateBuildRailVeh(Player *p)
Vehicle *v;
VehicleID loco_id;
- ptr = _default_rail_track_data[_players_ai[p->index].src.cur_building_rule]->data;
+ ptr = _default_rail_track_data[_companies_ai[c->index].src.cur_building_rule]->data;
while (ptr->mode != 0) ptr++;
- tile = TILE_ADD(_players_ai[p->index].src.use_tile, ToTileIndexDiff(ptr->tileoffs));
+ tile = TILE_ADD(_companies_ai[c->index].src.use_tile, ToTileIndexDiff(ptr->tileoffs));
- cargo = _players_ai[p->index].cargo_type;
+ cargo = _companies_ai[c->index].cargo_type;
for (i = 0;;) {
- if (_players_ai[p->index].wagon_list[i] == INVALID_VEHICLE) {
- veh = AiFindBestWagon(cargo, _players_ai[p->index].railtype_to_use);
+ if (_companies_ai[c->index].wagon_list[i] == INVALID_VEHICLE) {
+ veh = AiFindBestWagon(cargo, _companies_ai[c->index].railtype_to_use);
/* veh will return INVALID_ENGINE if no suitable wagon is available.
* We shall treat this in the same way as having no money */
if (veh == INVALID_ENGINE) goto handle_nocash;
cost = DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE);
if (CmdFailed(cost)) goto handle_nocash;
- _players_ai[p->index].wagon_list[i] = _new_vehicle_id;
- _players_ai[p->index].wagon_list[i + 1] = INVALID_VEHICLE;
+ _companies_ai[c->index].wagon_list[i] = _new_vehicle_id;
+ _companies_ai[c->index].wagon_list[i + 1] = INVALID_VEHICLE;
return;
}
if (cargo == CT_MAIL) cargo = CT_PASSENGERS;
- if (++i == _players_ai[p->index].num_wagons * 2 - 1) break;
+ if (++i == _companies_ai[c->index].num_wagons * 2 - 1) break;
}
// Which locomotive to build?
- veh = AiChooseTrainToBuild(_players_ai[p->index].railtype_to_use, p->player_money, cargo != CT_PASSENGERS ? 1 : 0, tile);
+ veh = AiChooseTrainToBuild(_companies_ai[c->index].railtype_to_use, c->money, cargo != CT_PASSENGERS ? 1 : 0, tile);
if (veh == INVALID_ENGINE) {
handle_nocash:
// after a while, if AI still doesn't have cash, get out of this block by selling the wagons.
- if (++_players_ai[p->index].state_counter == 1000) {
- for (i = 0; _players_ai[p->index].wagon_list[i] != INVALID_VEHICLE; i++) {
- cost = DoCommand(tile, _players_ai[p->index].wagon_list[i], 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
+ if (++_companies_ai[c->index].state_counter == 1000) {
+ for (i = 0; _companies_ai[c->index].wagon_list[i] != INVALID_VEHICLE; i++) {
+ cost = DoCommand(tile, _companies_ai[c->index].wagon_list[i], 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
assert(CmdSucceeded(cost));
}
- _players_ai[p->index].state = AIS_0;
+ _companies_ai[c->index].state = AIS_0;
}
return;
}
@@ -2535,29 +2535,29 @@ handle_nocash:
// Sell a vehicle if the train is double headed.
v = GetVehicle(loco_id);
if (v->Next() != NULL) {
- i = _players_ai[p->index].wagon_list[_players_ai[p->index].num_wagons * 2 - 2];
- _players_ai[p->index].wagon_list[_players_ai[p->index].num_wagons * 2 - 2] = INVALID_VEHICLE;
+ i = _companies_ai[c->index].wagon_list[_companies_ai[c->index].num_wagons * 2 - 2];
+ _companies_ai[c->index].wagon_list[_companies_ai[c->index].num_wagons * 2 - 2] = INVALID_VEHICLE;
DoCommand(tile, i, 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
}
// Move the wagons onto the train
- for (i = 0; _players_ai[p->index].wagon_list[i] != INVALID_VEHICLE; i++) {
- DoCommand(tile, _players_ai[p->index].wagon_list[i] | (loco_id << 16), 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ for (i = 0; _companies_ai[c->index].wagon_list[i] != INVALID_VEHICLE; i++) {
+ DoCommand(tile, _companies_ai[c->index].wagon_list[i] | (loco_id << 16), 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
}
- for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) {
- const AiBuildRec* aib = &_players_ai[p->index].src + _players_ai[p->index].order_list_blocks[i];
+ for (i = 0; _companies_ai[c->index].order_list_blocks[i] != 0xFF; i++) {
+ const AiBuildRec* aib = &_companies_ai[c->index].src + _companies_ai[c->index].order_list_blocks[i];
bool is_pass = (
- _players_ai[p->index].cargo_type == CT_PASSENGERS ||
- _players_ai[p->index].cargo_type == CT_MAIL ||
- (_settings_game.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES)
+ _companies_ai[c->index].cargo_type == CT_PASSENGERS ||
+ _companies_ai[c->index].cargo_type == CT_MAIL ||
+ (_settings_game.game_creation.landscape == LT_TEMPERATE && _companies_ai[c->index].cargo_type == CT_VALUABLES)
);
Order order;
order.MakeGoToStation(AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule));
if (!is_pass && i == 1) order.SetUnloadType(OUFB_UNLOAD);
- if (_players_ai[p->index].num_want_fullload != 0 && (is_pass || i == 0))
+ if (_companies_ai[c->index].num_want_fullload != 0 && (is_pass || i == 0))
order.SetLoadType(OLFB_FULL_LOAD);
DoCommand(0, loco_id + (i << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
@@ -2567,20 +2567,20 @@ handle_nocash:
DoCommand(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
- if (_players_ai[p->index].num_want_fullload != 0) _players_ai[p->index].num_want_fullload--;
+ if (_companies_ai[c->index].num_want_fullload != 0) _companies_ai[c->index].num_want_fullload--;
- if (--_players_ai[p->index].num_loco_to_build != 0) {
-// _players_ai[p->index].loco_id = INVALID_VEHICLE;
- _players_ai[p->index].wagon_list[0] = INVALID_VEHICLE;
+ if (--_companies_ai[c->index].num_loco_to_build != 0) {
+// _companies_ai[c->index].loco_id = INVALID_VEHICLE;
+ _companies_ai[c->index].wagon_list[0] = INVALID_VEHICLE;
} else {
- _players_ai[p->index].state = AIS_0;
+ _companies_ai[c->index].state = AIS_0;
}
}
-static void AiStateDeleteRailBlocks(Player *p)
+static void AiStateDeleteRailBlocks(Company *c)
{
- const AiBuildRec* aib = &_players_ai[p->index].src;
- uint num = _players_ai[p->index].num_build_rec;
+ const AiBuildRec* aib = &_companies_ai[c->index].src;
+ uint num = _companies_ai[c->index].num_build_rec;
do {
const AiDefaultBlockData* b;
@@ -2591,7 +2591,7 @@ static void AiStateDeleteRailBlocks(Player *p)
}
} while (++aib, --num);
- _players_ai[p->index].state = AIS_0;
+ _companies_ai[c->index].state = AIS_0;
}
static bool AiCheckRoadResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo)
@@ -2711,16 +2711,16 @@ clear_town_stuff:;
if (!_want_road_truck_station && !(roadflag & 2)) return CMD_ERROR;
if (!(flag & DC_EXEC)) {
- if (t != NULL && rating > t->ratings[_current_player]) return CMD_ERROR;
+ if (t != NULL && rating > t->ratings[_current_company]) return CMD_ERROR;
}
return total_cost;
}
// Make sure the blocks are not too close to each other
-static bool AiCheckBlockDistances(Player *p, TileIndex tile)
+static bool AiCheckBlockDistances(Company *c, TileIndex tile)
{
- const AiBuildRec* aib = &_players_ai[p->index].src;
- uint num = _players_ai[p->index].num_build_rec;
+ const AiBuildRec* aib = &_companies_ai[c->index].src;
+ uint num = _companies_ai[c->index].num_build_rec;
do {
if (aib->cur_building_rule != 255) {
@@ -2732,7 +2732,7 @@ static bool AiCheckBlockDistances(Player *p, TileIndex tile)
}
-static void AiStateBuildDefaultRoadBlocks(Player *p)
+static void AiStateBuildDefaultRoadBlocks(Company *c)
{
uint i;
int j;
@@ -2741,16 +2741,16 @@ static void AiStateBuildDefaultRoadBlocks(Player *p)
CommandCost cost;
// time out?
- if (++_players_ai[p->index].timeout_counter == 1388) {
- _players_ai[p->index].state = AIS_DELETE_RAIL_BLOCKS;
+ if (++_companies_ai[c->index].timeout_counter == 1388) {
+ _companies_ai[c->index].state = AIS_DELETE_RAIL_BLOCKS;
return;
}
// do the following 8 times
for (i = 0; i != 8; i++) {
// check if we can build the default track
- aib = &_players_ai[p->index].src;
- j = _players_ai[p->index].num_build_rec;
+ aib = &_companies_ai[c->index].src;
+ j = _companies_ai[c->index].num_build_rec;
do {
// this item has already been built?
if (aib->cur_building_rule != 255) continue;
@@ -2766,18 +2766,18 @@ static void AiStateBuildDefaultRoadBlocks(Player *p)
if (rule == -1) {
// cannot build, terraform after a while
- if (_players_ai[p->index].state_counter >= 600) {
- AiDoTerraformLand(aib->use_tile, (DiagDirection)(Random() & 3), 3, (int8)_players_ai[p->index].state_mode);
+ if (_companies_ai[c->index].state_counter >= 600) {
+ AiDoTerraformLand(aib->use_tile, (DiagDirection)(Random() & 3), 3, (int8)_companies_ai[c->index].state_mode);
}
// also try the other terraform direction
- if (++_players_ai[p->index].state_counter >= 1000) {
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].state_mode = -_players_ai[p->index].state_mode;
+ if (++_companies_ai[c->index].state_counter >= 1000) {
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].state_mode = -_companies_ai[c->index].state_mode;
}
- } else if (CheckPlayerHasMoney(cost) && AiCheckBlockDistances(p, aib->use_tile)) {
+ } else if (CheckCompanyHasMoney(cost) && AiCheckBlockDistances(c, aib->use_tile)) {
CommandCost r;
- // player has money, build it.
+ // company has money, build it.
aib->cur_building_rule = rule;
r = AiDoBuildDefaultRoadBlock(
@@ -2791,15 +2791,15 @@ static void AiStateBuildDefaultRoadBlocks(Player *p)
}
// check if we're done with all of them
- aib = &_players_ai[p->index].src;
- j = _players_ai[p->index].num_build_rec;
+ aib = &_companies_ai[c->index].src;
+ j = _companies_ai[c->index].num_build_rec;
do {
if (aib->cur_building_rule == 255) return;
} while (++aib, --j);
// yep, all are done. switch state to the rail building state.
- _players_ai[p->index].state = AIS_BUILD_ROAD;
- _players_ai[p->index].state_mode = 255;
+ _companies_ai[c->index].state = AIS_BUILD_ROAD;
+ _companies_ai[c->index].state_mode = 255;
}
struct AiRoadFinder {
@@ -2816,7 +2816,7 @@ struct AiRoadFinder {
uint best_dist;
TileIndex cur_best_tile, best_tile;
TileIndex bridge_end_tile;
- Player *player;
+ Company *company;
};
struct AiRoadEnum {
@@ -2879,14 +2879,14 @@ static bool AiEnumFollowRoad(TileIndex tile, AiRoadEnum *a, Trackdir track, uint
return false;
}
-static bool AiCheckRoadFinished(Player *p)
+static bool AiCheckRoadFinished(Company *c)
{
AiRoadEnum are;
TileIndex tile;
- DiagDirection dir = _players_ai[p->index].cur_dir_a;
+ DiagDirection dir = _companies_ai[c->index].cur_dir_a;
- are.dest = _players_ai[p->index].cur_tile_b;
- tile = TILE_MASK(_players_ai[p->index].cur_tile_a + TileOffsByDiagDir(dir));
+ are.dest = _companies_ai[c->index].cur_tile_b;
+ tile = TILE_MASK(_companies_ai[c->index].cur_tile_a + TileOffsByDiagDir(dir));
if (IsRoadStopTile(tile) || IsRoadDepotTile(tile)) return false;
TrackdirBits bits = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ROADTYPES_ROAD)) & DiagdirReachesTrackdirs(dir);
@@ -2903,8 +2903,8 @@ static bool AiCheckRoadFinished(Player *p)
if (are.best_dist == 0) return true;
- _players_ai[p->index].cur_tile_a = are.best_tile;
- _players_ai[p->index].cur_dir_a = TrackdirToExitdir(are.best_track);
+ _companies_ai[c->index].cur_tile_a = are.best_tile;
+ _companies_ai[c->index].cur_dir_a = TrackdirToExitdir(are.best_track);
return false;
}
@@ -2972,7 +2972,7 @@ static inline void AiCheckBuildRoadTunnelHere(AiRoadFinder *arf, TileIndex tile,
if (GetTileSlope(tile, &z) == InclinedSlope((DiagDirection)(p[0] & 3)) && z != 0) {
CommandCost cost = DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
- if (CmdSucceeded(cost) && cost.GetCost() <= (arf->player->player_money >> 4)) {
+ if (CmdSucceeded(cost) && cost.GetCost() <= (arf->company->money >> 4)) {
AiBuildRoadRecursive(arf, _build_tunnel_endtile, (DiagDirection)(p[0] & 3));
if (arf->depth == 1) AiCheckRoadPathBetter(arf, p);
}
@@ -3039,22 +3039,22 @@ static void AiBuildRoadRecursive(AiRoadFinder *arf, TileIndex tile, DiagDirectio
}
-static void AiBuildRoadConstruct(Player *p)
+static void AiBuildRoadConstruct(Company *c)
{
AiRoadFinder arf;
int i;
TileIndex tile;
// Reached destination?
- if (AiCheckRoadFinished(p)) {
- _players_ai[p->index].state_mode = 255;
+ if (AiCheckRoadFinished(c)) {
+ _companies_ai[c->index].state_mode = 255;
return;
}
// Setup recursive finder and call it.
- arf.player = p;
- arf.final_tile = _players_ai[p->index].cur_tile_b;
- arf.final_dir = _players_ai[p->index].cur_dir_b;
+ arf.company = c;
+ arf.final_tile = _companies_ai[c->index].cur_tile_b;
+ arf.final_dir = _companies_ai[c->index].cur_dir_b;
arf.depth = 0;
arf.recursive_mode = 0;
arf.best_ptr = NULL;
@@ -3064,11 +3064,11 @@ static void AiBuildRoadConstruct(Player *p)
arf.best_depth = 0xff;
arf.cur_best_tile = 0;
arf.best_tile = 0;
- AiBuildRoadRecursive(&arf, _players_ai[p->index].cur_tile_a, _players_ai[p->index].cur_dir_a);
+ AiBuildRoadRecursive(&arf, _companies_ai[c->index].cur_tile_a, _companies_ai[c->index].cur_dir_a);
// Reached destination?
if (arf.recursive_mode == 2 && arf.cur_best_depth == 0) {
- _players_ai[p->index].state_mode = 255;
+ _companies_ai[c->index].state_mode = 255;
return;
}
@@ -3077,19 +3077,19 @@ static void AiBuildRoadConstruct(Player *p)
// Terraform some
do_some_terraform:
for (i = 0; i != 5; i++)
- AiDoTerraformLand(_players_ai[p->index].cur_tile_a, _players_ai[p->index].cur_dir_a, 3, 0);
+ AiDoTerraformLand(_companies_ai[c->index].cur_tile_a, _companies_ai[c->index].cur_dir_a, 3, 0);
- if (++_players_ai[p->index].state_counter == 21) {
- _players_ai[p->index].state_mode = 1;
+ if (++_companies_ai[c->index].state_counter == 21) {
+ _companies_ai[c->index].state_mode = 1;
- _players_ai[p->index].cur_tile_a = TILE_MASK(_players_ai[p->index].cur_tile_a + TileOffsByDiagDir(_players_ai[p->index].cur_dir_a));
- _players_ai[p->index].cur_dir_a = ReverseDiagDir(_players_ai[p->index].cur_dir_a);
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].cur_tile_a = TILE_MASK(_companies_ai[c->index].cur_tile_a + TileOffsByDiagDir(_companies_ai[c->index].cur_dir_a));
+ _companies_ai[c->index].cur_dir_a = ReverseDiagDir(_companies_ai[c->index].cur_dir_a);
+ _companies_ai[c->index].state_counter = 0;
}
return;
}
- tile = TILE_MASK(_players_ai[p->index].cur_tile_a + TileOffsByDiagDir(_players_ai[p->index].cur_dir_a));
+ tile = TILE_MASK(_companies_ai[c->index].cur_tile_a + TileOffsByDiagDir(_companies_ai[c->index].cur_dir_a));
if (arf.best_ptr[0] & 0x80) {
TileIndex t1 = tile;
@@ -3102,7 +3102,7 @@ do_some_terraform:
/* try to build a long road instead of bridge - CMD_BUILD_LONG_ROAD has to fail if it couldn't build at least one piece! */
CommandCost cost = DoCommand(t2, t1, (t2 < t1 ? 1 : 2) | (axis << 2) | (ROADTYPE_ROAD << 3), DC_AUTO | DC_NO_WATER, CMD_BUILD_LONG_ROAD);
- if (CmdSucceeded(cost) && cost.GetCost() <= p->player_money) {
+ if (CmdSucceeded(cost) && cost.GetCost() <= c->money) {
DoCommand(t2, t1, (t2 < t1 ? 1 : 2) | (axis << 2) | (ROADTYPE_ROAD << 3), DC_AUTO | DC_EXEC | DC_NO_WATER, CMD_BUILD_LONG_ROAD);
} else {
int i;
@@ -3113,7 +3113,7 @@ do_some_terraform:
for (i = MAX_BRIDGES - 1; i != 0; i--) {
if (CheckBridge_Stuff(i, bridge_len)) {
CommandCost cost = DoCommand(t1, t2, i | ROADTYPES_ROAD << 8 | TRANSPORT_ROAD << 15, DC_AUTO, CMD_BUILD_BRIDGE);
- if (CmdSucceeded(cost) && cost.GetCost() < (p->player_money >> 1) && cost.GetCost() < ((p->player_money + _economy.max_loan - p->current_loan) >> 5)) break;
+ if (CmdSucceeded(cost) && cost.GetCost() < (c->money >> 1) && cost.GetCost() < ((c->money + _economy.max_loan - c->current_loan) >> 5)) break;
}
}
@@ -3121,21 +3121,21 @@ do_some_terraform:
DoCommand(t1, t2, i | ROADTYPES_ROAD << 8 | TRANSPORT_ROAD << 15, DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
}
- _players_ai[p->index].cur_tile_a = t2;
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].cur_tile_a = t2;
+ _companies_ai[c->index].state_counter = 0;
} else if (arf.best_ptr[0] & 0x40) {
// tunnel
DoCommand(tile, 0x200, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
- _players_ai[p->index].cur_tile_a = _build_tunnel_endtile;
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].cur_tile_a = _build_tunnel_endtile;
+ _companies_ai[c->index].state_counter = 0;
} else {
// road
if (!AiBuildRoadHelper(tile, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, arf.best_ptr[0]))
goto do_some_terraform;
- _players_ai[p->index].cur_dir_a = (DiagDirection)(arf.best_ptr[1] & 3);
- _players_ai[p->index].cur_tile_a = tile;
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].cur_dir_a = (DiagDirection)(arf.best_ptr[1] & 3);
+ _companies_ai[c->index].cur_tile_a = tile;
+ _companies_ai[c->index].state_counter = 0;
}
if (arf.best_tile != 0) {
@@ -3145,26 +3145,26 @@ do_some_terraform:
}
-static void AiBuildRoad(Player *p)
+static void AiBuildRoad(Company *c)
{
- if (_players_ai[p->index].state_mode < 1) {
+ if (_companies_ai[c->index].state_mode < 1) {
// Construct mode, build new road.
- AiBuildRoadConstruct(p);
- } else if (_players_ai[p->index].state_mode == 1) {
+ AiBuildRoadConstruct(c);
+ } else if (_companies_ai[c->index].state_mode == 1) {
// Destruct mode, not implemented for roads.
- _players_ai[p->index].state_mode = 2;
- _players_ai[p->index].state_counter = 0;
- } else if (_players_ai[p->index].state_mode == 2) {
+ _companies_ai[c->index].state_mode = 2;
+ _companies_ai[c->index].state_counter = 0;
+ } else if (_companies_ai[c->index].state_mode == 2) {
uint i;
// Terraform some and then try building again.
for (i = 0; i != 4; i++) {
- AiDoTerraformLand(_players_ai[p->index].cur_tile_a, _players_ai[p->index].cur_dir_a, 3, 0);
+ AiDoTerraformLand(_companies_ai[c->index].cur_tile_a, _companies_ai[c->index].cur_dir_a, 3, 0);
}
- if (++_players_ai[p->index].state_counter == 4) {
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].state_mode = 0;
+ if (++_companies_ai[c->index].state_counter == 4) {
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].state_mode = 0;
}
}
}
@@ -3178,7 +3178,7 @@ static TileIndex AiGetRoadBlockEdge(byte rule, TileIndex tile, DiagDirection *di
}
-static void AiStateBuildRoad(Player *p)
+static void AiStateBuildRoad(Company *c)
{
int num;
AiBuildRec *aib;
@@ -3187,27 +3187,27 @@ static void AiStateBuildRoad(Player *p)
DiagDirection dir;
// time out?
- if (++_players_ai[p->index].timeout_counter == 1388) {
- _players_ai[p->index].state = AIS_DELETE_ROAD_BLOCKS;
+ if (++_companies_ai[c->index].timeout_counter == 1388) {
+ _companies_ai[c->index].state = AIS_DELETE_ROAD_BLOCKS;
return;
}
// Currently building a road between two points?
- if (_players_ai[p->index].state_mode != 255) {
- AiBuildRoad(p);
+ if (_companies_ai[c->index].state_mode != 255) {
+ AiBuildRoad(c);
// Alternate between edges
- Swap(_players_ai[p->index].start_tile_a, _players_ai[p->index].start_tile_b);
- Swap(_players_ai[p->index].cur_tile_a, _players_ai[p->index].cur_tile_b);
- Swap(_players_ai[p->index].start_dir_a, _players_ai[p->index].start_dir_b);
- Swap(_players_ai[p->index].cur_dir_a, _players_ai[p->index].cur_dir_b);
+ Swap(_companies_ai[c->index].start_tile_a, _companies_ai[c->index].start_tile_b);
+ Swap(_companies_ai[c->index].cur_tile_a, _companies_ai[c->index].cur_tile_b);
+ Swap(_companies_ai[c->index].start_dir_a, _companies_ai[c->index].start_dir_b);
+ Swap(_companies_ai[c->index].cur_dir_a, _companies_ai[c->index].cur_dir_b);
return;
}
// Now, find two new points to build between
- num = _players_ai[p->index].num_build_rec;
- aib = &_players_ai[p->index].src;
+ num = _companies_ai[c->index].num_build_rec;
+ aib = &_companies_ai[c->index].src;
for (;;) {
cmd = aib->buildcmd_a;
@@ -3216,30 +3216,30 @@ static void AiStateBuildRoad(Player *p)
aib++;
if (--num == 0) {
- _players_ai[p->index].state = AIS_BUILD_ROAD_VEHICLES;
+ _companies_ai[c->index].state = AIS_BUILD_ROAD_VEHICLES;
return;
}
}
// Find first edge to build from.
tile = AiGetRoadBlockEdge(aib->cur_building_rule, aib->use_tile, &dir);
- _players_ai[p->index].start_tile_a = tile;
- _players_ai[p->index].cur_tile_a = tile;
- _players_ai[p->index].start_dir_a = dir;
- _players_ai[p->index].cur_dir_a = dir;
+ _companies_ai[c->index].start_tile_a = tile;
+ _companies_ai[c->index].cur_tile_a = tile;
+ _companies_ai[c->index].start_dir_a = dir;
+ _companies_ai[c->index].cur_dir_a = dir;
// Find second edge to build to
- aib = (&_players_ai[p->index].src) + (cmd & 0xF);
+ aib = (&_companies_ai[c->index].src) + (cmd & 0xF);
tile = AiGetRoadBlockEdge(aib->cur_building_rule, aib->use_tile, &dir);
- _players_ai[p->index].start_tile_b = tile;
- _players_ai[p->index].cur_tile_b = tile;
- _players_ai[p->index].start_dir_b = dir;
- _players_ai[p->index].cur_dir_b = dir;
+ _companies_ai[c->index].start_tile_b = tile;
+ _companies_ai[c->index].cur_tile_b = tile;
+ _companies_ai[c->index].start_dir_b = dir;
+ _companies_ai[c->index].cur_dir_b = dir;
// And setup state.
- _players_ai[p->index].state_mode = 2;
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].banned_tile_count = 0;
+ _companies_ai[c->index].state_mode = 2;
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].banned_tile_count = 0;
}
static StationID AiGetStationIdFromRoadBlock(TileIndex tile, int id)
@@ -3249,7 +3249,7 @@ static StationID AiGetStationIdFromRoadBlock(TileIndex tile, int id)
return GetStationIndex(TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)));
}
-static void AiStateBuildRoadVehicles(Player *p)
+static void AiStateBuildRoadVehicles(Company *c)
{
const AiDefaultBlockData *ptr;
TileIndex tile;
@@ -3257,13 +3257,13 @@ static void AiStateBuildRoadVehicles(Player *p)
EngineID veh;
uint i;
- ptr = _road_default_block_data[_players_ai[p->index].src.cur_building_rule]->data;
+ ptr = _road_default_block_data[_companies_ai[c->index].src.cur_building_rule]->data;
for (; ptr->mode != 0; ptr++) {}
- tile = TILE_ADD(_players_ai[p->index].src.use_tile, ToTileIndexDiff(ptr->tileoffs));
+ tile = TILE_ADD(_companies_ai[c->index].src.use_tile, ToTileIndexDiff(ptr->tileoffs));
- veh = AiChooseRoadVehToBuild(_players_ai[p->index].cargo_type, p->player_money, tile);
+ veh = AiChooseRoadVehToBuild(_companies_ai[c->index].cargo_type, c->money, tile);
if (veh == INVALID_ENGINE) {
- _players_ai[p->index].state = AIS_0;
+ _companies_ai[c->index].state = AIS_0;
return;
}
@@ -3271,28 +3271,28 @@ static void AiStateBuildRoadVehicles(Player *p)
loco_id = _new_vehicle_id;
- if (GetVehicle(loco_id)->cargo_type != _players_ai[p->index].cargo_type) {
+ if (GetVehicle(loco_id)->cargo_type != _companies_ai[c->index].cargo_type) {
/* Cargo type doesn't match, so refit it */
- if (CmdFailed(DoCommand(tile, loco_id, _players_ai[p->index].cargo_type, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
+ if (CmdFailed(DoCommand(tile, loco_id, _companies_ai[c->index].cargo_type, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
/* Refit failed... sell the vehicle */
DoCommand(tile, loco_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
return;
}
}
- for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) {
- const AiBuildRec* aib = &_players_ai[p->index].src + _players_ai[p->index].order_list_blocks[i];
+ for (i = 0; _companies_ai[c->index].order_list_blocks[i] != 0xFF; i++) {
+ const AiBuildRec* aib = &_companies_ai[c->index].src + _companies_ai[c->index].order_list_blocks[i];
bool is_pass = (
- _players_ai[p->index].cargo_type == CT_PASSENGERS ||
- _players_ai[p->index].cargo_type == CT_MAIL ||
- (_settings_game.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES)
+ _companies_ai[c->index].cargo_type == CT_PASSENGERS ||
+ _companies_ai[c->index].cargo_type == CT_MAIL ||
+ (_settings_game.game_creation.landscape == LT_TEMPERATE && _companies_ai[c->index].cargo_type == CT_VALUABLES)
);
Order order;
order.MakeGoToStation(AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule));
if (!is_pass && i == 1) order.SetUnloadType(OUFB_UNLOAD);
- if (_players_ai[p->index].num_want_fullload != 0 && (is_pass || i == 0))
+ if (_companies_ai[c->index].num_want_fullload != 0 && (is_pass || i == 0))
order.SetLoadType(OLFB_FULL_LOAD);
DoCommand(0, loco_id + (i << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
@@ -3301,14 +3301,14 @@ static void AiStateBuildRoadVehicles(Player *p)
DoCommand(0, loco_id, 0, DC_EXEC, CMD_START_STOP_VEHICLE);
DoCommand(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
- if (_players_ai[p->index].num_want_fullload != 0) _players_ai[p->index].num_want_fullload--;
- if (--_players_ai[p->index].num_loco_to_build == 0) _players_ai[p->index].state = AIS_0;
+ if (_companies_ai[c->index].num_want_fullload != 0) _companies_ai[c->index].num_want_fullload--;
+ if (--_companies_ai[c->index].num_loco_to_build == 0) _companies_ai[c->index].state = AIS_0;
}
-static void AiStateDeleteRoadBlocks(Player *p)
+static void AiStateDeleteRoadBlocks(Company *c)
{
- const AiBuildRec* aib = &_players_ai[p->index].src;
- uint num = _players_ai[p->index].num_build_rec;
+ const AiBuildRec* aib = &_companies_ai[c->index].src;
+ uint num = _companies_ai[c->index].num_build_rec;
do {
const AiDefaultBlockData* b;
@@ -3320,11 +3320,11 @@ static void AiStateDeleteRoadBlocks(Player *p)
}
} while (++aib, --num);
- _players_ai[p->index].state = AIS_0;
+ _companies_ai[c->index].state = AIS_0;
}
-static void AiStateAirportStuff(Player *p)
+static void AiStateAirportStuff(Company *c)
{
const Station* st;
int i;
@@ -3341,19 +3341,19 @@ static void AiStateAirportStuff(Player *p)
// We do this all twice - once for the source (town in the case
// of oilrig route) and then for the destination (oilrig in the
// case of oilrig route).
- aib = &_players_ai[p->index].src + i;
+ aib = &_companies_ai[c->index].src + i;
FOR_ALL_STATIONS(st) {
// Is this an airport?
if (!(st->facilities & FACIL_AIRPORT)) continue;
// Do we own the airport? (Oilrigs aren't owned, though.)
- if (st->owner != OWNER_NONE && st->owner != _current_player) continue;
+ if (st->owner != OWNER_NONE && st->owner != _current_company) continue;
AirportFTAClass::Flags flags = st->Airport()->flags;
/* if airport doesn't accept our kind of plane, dismiss it */
- if (!(flags & (_players_ai[p->index].build_kind == 1 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) {
+ if (!(flags & (_companies_ai[c->index].build_kind == 1 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) {
continue;
}
@@ -3392,11 +3392,11 @@ static void AiStateAirportStuff(Player *p)
aib->use_tile = st->airport_tile;
break;
}
- } while (++i != _players_ai[p->index].num_build_rec);
+ } while (++i != _companies_ai[c->index].num_build_rec);
- _players_ai[p->index].state = AIS_BUILD_DEFAULT_AIRPORT_BLOCKS;
- _players_ai[p->index].state_mode = 255;
- _players_ai[p->index].state_counter = 0;
+ _companies_ai[c->index].state = AIS_BUILD_DEFAULT_AIRPORT_BLOCKS;
+ _companies_ai[c->index].state_mode = 255;
+ _companies_ai[c->index].state_counter = 0;
}
static CommandCost AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockData *p, byte flag)
@@ -3470,7 +3470,7 @@ static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli,
return -1;
}
-static void AiStateBuildDefaultAirportBlocks(Player *p)
+static void AiStateBuildDefaultAirportBlocks(Company *c)
{
int i, j;
AiBuildRec *aib;
@@ -3478,8 +3478,8 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
CommandCost cost;
// time out?
- if (++_players_ai[p->index].timeout_counter == 1388) {
- _players_ai[p->index].state = AIS_0;
+ if (++_companies_ai[c->index].timeout_counter == 1388) {
+ _companies_ai[c->index].state = AIS_0;
return;
}
@@ -3487,8 +3487,8 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
i = 8;
do {
// check if we can build the default
- aib = &_players_ai[p->index].src;
- j = _players_ai[p->index].num_build_rec;
+ aib = &_companies_ai[c->index].src;
+ j = _companies_ai[c->index].num_build_rec;
do {
// this item has already been built?
if (aib->cur_building_rule != 255) continue;
@@ -3498,22 +3498,22 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
aib->use_tile = AdjustTileCoordRandomly(aib->spec_tile, aib->rand_rng);
// check if the aircraft stuff can be built there.
- rule = AiFindBestDefaultAirportBlock(aib->use_tile, aib->cargo, _players_ai[p->index].build_kind, &cost);
+ rule = AiFindBestDefaultAirportBlock(aib->use_tile, aib->cargo, _companies_ai[c->index].build_kind, &cost);
// SetRedErrorSquare(aib->use_tile);
if (rule == -1) {
// cannot build, terraform after a while
- if (_players_ai[p->index].state_counter >= 600) {
- AiDoTerraformLand(aib->use_tile, (DiagDirection)(Random() & 3), 3, (int8)_players_ai[p->index].state_mode);
+ if (_companies_ai[c->index].state_counter >= 600) {
+ AiDoTerraformLand(aib->use_tile, (DiagDirection)(Random() & 3), 3, (int8)_companies_ai[c->index].state_mode);
}
// also try the other terraform direction
- if (++_players_ai[p->index].state_counter >= 1000) {
- _players_ai[p->index].state_counter = 0;
- _players_ai[p->index].state_mode = -_players_ai[p->index].state_mode;
+ if (++_companies_ai[c->index].state_counter >= 1000) {
+ _companies_ai[c->index].state_counter = 0;
+ _companies_ai[c->index].state_mode = -_companies_ai[c->index].state_mode;
}
- } else if (CheckPlayerHasMoney(cost) && AiCheckBlockDistances(p, aib->use_tile)) {
- // player has money, build it.
+ } else if (CheckCompanyHasMoney(cost) && AiCheckBlockDistances(c, aib->use_tile)) {
+ // company has money, build it.
CommandCost r;
aib->cur_building_rule = rule;
@@ -3529,14 +3529,14 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
} while (--i);
// check if we're done with all of them
- aib = &_players_ai[p->index].src;
- j = _players_ai[p->index].num_build_rec;
+ aib = &_companies_ai[c->index].src;
+ j = _companies_ai[c->index].num_build_rec;
do {
if (aib->cur_building_rule == 255) return;
} while (++aib, --j);
// yep, all are done. switch state.
- _players_ai[p->index].state = AIS_BUILD_AIRCRAFT_VEHICLES;
+ _companies_ai[c->index].state = AIS_BUILD_AIRCRAFT_VEHICLES;
}
static StationID AiGetStationIdFromAircraftBlock(TileIndex tile, int id)
@@ -3546,7 +3546,7 @@ static StationID AiGetStationIdFromAircraftBlock(TileIndex tile, int id)
return GetStationIndex(TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)));
}
-static void AiStateBuildAircraftVehicles(Player *p)
+static void AiStateBuildAircraftVehicles(Company *c)
{
const AiDefaultBlockData *ptr;
TileIndex tile;
@@ -3554,15 +3554,15 @@ static void AiStateBuildAircraftVehicles(Player *p)
int i;
VehicleID loco_id;
- ptr = _airport_default_block_data[_players_ai[p->index].src.cur_building_rule];
+ ptr = _airport_default_block_data[_companies_ai[c->index].src.cur_building_rule];
for (; ptr->mode != 0; ptr++) {}
- tile = TILE_ADD(_players_ai[p->index].src.use_tile, ToTileIndexDiff(ptr->tileoffs));
+ tile = TILE_ADD(_companies_ai[c->index].src.use_tile, ToTileIndexDiff(ptr->tileoffs));
/* determine forbidden aircraft bits */
byte forbidden = 0;
- for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) {
- const AiBuildRec *aib = (&_players_ai[p->index].src) + _players_ai[p->index].order_list_blocks[i];
+ for (i = 0; _companies_ai[c->index].order_list_blocks[i] != 0xFF; i++) {
+ const AiBuildRec *aib = (&_companies_ai[c->index].src) + _companies_ai[c->index].order_list_blocks[i];
const Station *st = GetStationByTile(aib->use_tile);
if (st == NULL || !(st->facilities & FACIL_AIRPORT)) continue;
@@ -3572,7 +3572,7 @@ static void AiStateBuildAircraftVehicles(Player *p)
if (flags & AirportFTAClass::SHORT_STRIP) forbidden |= AIR_FAST; // no fast planes for small airports
}
- veh = AiChooseAircraftToBuild(p->player_money, forbidden);
+ veh = AiChooseAircraftToBuild(c->money, forbidden);
if (veh == INVALID_ENGINE) return;
if (GetStationByTile(tile)->Airport()->nof_depots == 0) return;
@@ -3582,15 +3582,15 @@ static void AiStateBuildAircraftVehicles(Player *p)
if (CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return;
loco_id = _new_vehicle_id;
- for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) {
- AiBuildRec *aib = (&_players_ai[p->index].src) + _players_ai[p->index].order_list_blocks[i];
- bool is_pass = (_players_ai[p->index].cargo_type == CT_PASSENGERS || _players_ai[p->index].cargo_type == CT_MAIL);
+ for (i = 0; _companies_ai[c->index].order_list_blocks[i] != 0xFF; i++) {
+ AiBuildRec *aib = (&_companies_ai[c->index].src) + _companies_ai[c->index].order_list_blocks[i];
+ bool is_pass = (_companies_ai[c->index].cargo_type == CT_PASSENGERS || _companies_ai[c->index].cargo_type == CT_MAIL);
Order order;
order.MakeGoToStation(AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule));
if (!is_pass && i == 1) order.SetUnloadType(OUFB_UNLOAD);
- if (_players_ai[p->index].num_want_fullload != 0 && (is_pass || i == 0))
+ if (_companies_ai[c->index].num_want_fullload != 0 && (is_pass || i == 0))
order.SetLoadType(OLFB_FULL_LOAD);
DoCommand(0, loco_id + (i << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
@@ -3600,31 +3600,31 @@ static void AiStateBuildAircraftVehicles(Player *p)
DoCommand(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
- if (_players_ai[p->index].num_want_fullload != 0) _players_ai[p->index].num_want_fullload--;
+ if (_companies_ai[c->index].num_want_fullload != 0) _companies_ai[c->index].num_want_fullload--;
- if (--_players_ai[p->index].num_loco_to_build == 0) _players_ai[p->index].state = AIS_0;
+ if (--_companies_ai[c->index].num_loco_to_build == 0) _companies_ai[c->index].state = AIS_0;
}
-static void AiStateCheckShipStuff(Player *p)
+static void AiStateCheckShipStuff(Company *c)
{
/* Ships are not implemented in this (broken) AI */
}
-static void AiStateBuildDefaultShipBlocks(Player *p)
+static void AiStateBuildDefaultShipBlocks(Company *c)
{
/* Ships are not implemented in this (broken) AI */
}
-static void AiStateDoShipStuff(Player *p)
+static void AiStateDoShipStuff(Company *c)
{
/* Ships are not implemented in this (broken) AI */
}
-static void AiStateSellVeh(Player *p)
+static void AiStateSellVeh(Company *c)
{
- Vehicle *v = _players_ai[p->index].cur_veh;
+ Vehicle *v = _companies_ai[c->index].cur_veh;
- if (v->owner == _current_player) {
+ if (v->owner == _current_company) {
if (v->type == VEH_TRAIN) {
if (!IsRailDepotTile(v->tile) || v->u.rail.track != TRACK_BIT_DEPOT || !(v->vehstatus & VS_STOPPED)) {
@@ -3659,17 +3659,17 @@ static void AiStateSellVeh(Player *p)
goto return_to_loop;
going_to_depot:;
- if (++_players_ai[p->index].state_counter <= 832) return;
+ if (++_companies_ai[c->index].state_counter <= 832) return;
if (v->current_order.IsType(OT_GOTO_DEPOT)) {
v->current_order.MakeDummy();
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
}
return_to_loop:;
- _players_ai[p->index].state = AIS_VEH_LOOP;
+ _companies_ai[c->index].state = AIS_VEH_LOOP;
}
-static void AiStateRemoveStation(Player *p)
+static void AiStateRemoveStation(Company *c)
{
// Remove stations that aren't in use by any vehicle
const Order *ord;
@@ -3677,7 +3677,7 @@ static void AiStateRemoveStation(Player *p)
TileIndex tile;
// Go to this state when we're done.
- _players_ai[p->index].state = AIS_1;
+ _companies_ai[c->index].state = AIS_1;
// Get a list of all stations that are in use by a vehicle
byte *in_use = MallocT<byte>(GetMaxStationIndex() + 1);
@@ -3688,7 +3688,7 @@ static void AiStateRemoveStation(Player *p)
// Go through all stations and delete those that aren't in use
FOR_ALL_STATIONS(st) {
- if (st->owner == _current_player && !in_use[st->index] &&
+ if (st->owner == _current_company && !in_use[st->index] &&
( (st->bus_stops != NULL && (tile = st->bus_stops->xy) != 0) ||
(st->truck_stops != NULL && (tile = st->truck_stops->xy)) != 0 ||
(tile = st->train_tile) != 0 ||
@@ -3701,12 +3701,12 @@ static void AiStateRemoveStation(Player *p)
free(in_use);
}
-static void AiRemovePlayerRailOrRoad(Player *p, TileIndex tile)
+static void AiRemoveCompanyRailOrRoad(Company *c, TileIndex tile)
{
TrackBits rails;
if (IsTileType(tile, MP_RAILWAY)) {
- if (!IsTileOwner(tile, _current_player)) return;
+ if (!IsTileOwner(tile, _current_company)) return;
if (IsPlainRailTile(tile)) {
is_rail_crossing:;
@@ -3717,9 +3717,9 @@ is_rail_crossing:;
if (rails & TRACK_BIT_3WAY_NE) {
pos_0:
if ((GetRailTrackStatus(TILE_MASK(tile - TileDiffXY(1, 0))) & TRACK_BIT_3WAY_SW) == 0) {
- _players_ai[p->index].cur_dir_a = DIAGDIR_NE;
- _players_ai[p->index].cur_tile_a = tile;
- _players_ai[p->index].state = AIS_REMOVE_SINGLE_RAIL_TILE;
+ _companies_ai[c->index].cur_dir_a = DIAGDIR_NE;
+ _companies_ai[c->index].cur_tile_a = tile;
+ _companies_ai[c->index].state = AIS_REMOVE_SINGLE_RAIL_TILE;
return;
}
}
@@ -3727,9 +3727,9 @@ pos_0:
if (rails & TRACK_BIT_3WAY_SE) {
pos_1:
if ((GetRailTrackStatus(TILE_MASK(tile + TileDiffXY(0, 1))) & TRACK_BIT_3WAY_NW) == 0) {
- _players_ai[p->index].cur_dir_a = DIAGDIR_SE;
- _players_ai[p->index].cur_tile_a = tile;
- _players_ai[p->index].state = AIS_REMOVE_SINGLE_RAIL_TILE;
+ _companies_ai[c->index].cur_dir_a = DIAGDIR_SE;
+ _companies_ai[c->index].cur_tile_a = tile;
+ _companies_ai[c->index].state = AIS_REMOVE_SINGLE_RAIL_TILE;
return;
}
}
@@ -3737,9 +3737,9 @@ pos_1:
if (rails & TRACK_BIT_3WAY_SW) {
pos_2:
if ((GetRailTrackStatus(TILE_MASK(tile + TileDiffXY(1, 0))) & TRACK_BIT_3WAY_NE) == 0) {
- _players_ai[p->index].cur_dir_a = DIAGDIR_SW;
- _players_ai[p->index].cur_tile_a = tile;
- _players_ai[p->index].state = AIS_REMOVE_SINGLE_RAIL_TILE;
+ _companies_ai[c->index].cur_dir_a = DIAGDIR_SW;
+ _companies_ai[c->index].cur_tile_a = tile;
+ _companies_ai[c->index].state = AIS_REMOVE_SINGLE_RAIL_TILE;
return;
}
}
@@ -3747,9 +3747,9 @@ pos_2:
if (rails & TRACK_BIT_3WAY_NW) {
pos_3:
if ((GetRailTrackStatus(TILE_MASK(tile - TileDiffXY(0, 1))) & TRACK_BIT_3WAY_SE) == 0) {
- _players_ai[p->index].cur_dir_a = DIAGDIR_NW;
- _players_ai[p->index].cur_tile_a = tile;
- _players_ai[p->index].state = AIS_REMOVE_SINGLE_RAIL_TILE;
+ _companies_ai[c->index].cur_dir_a = DIAGDIR_NW;
+ _companies_ai[c->index].cur_tile_a = tile;
+ _companies_ai[c->index].state = AIS_REMOVE_SINGLE_RAIL_TILE;
return;
}
}
@@ -3767,23 +3767,23 @@ pos_3:
if (IsLevelCrossing(tile)) goto is_rail_crossing;
if (IsRoadDepot(tile)) {
- if (!IsTileOwner(tile, _current_player)) return;
+ if (!IsTileOwner(tile, _current_company)) return;
DiagDirection dir;
TileIndex t;
// Check if there are any stations around.
t = tile + TileDiffXY(-1, 0);
- if (IsTileType(t, MP_STATION) && IsTileOwner(t, _current_player)) return;
+ if (IsTileType(t, MP_STATION) && IsTileOwner(t, _current_company)) return;
t = tile + TileDiffXY(1, 0);
- if (IsTileType(t, MP_STATION) && IsTileOwner(t, _current_player)) return;
+ if (IsTileType(t, MP_STATION) && IsTileOwner(t, _current_company)) return;
t = tile + TileDiffXY(0, -1);
- if (IsTileType(t, MP_STATION) && IsTileOwner(t, _current_player)) return;
+ if (IsTileType(t, MP_STATION) && IsTileOwner(t, _current_company)) return;
t = tile + TileDiffXY(0, 1);
- if (IsTileType(t, MP_STATION) && IsTileOwner(t, _current_player)) return;
+ if (IsTileType(t, MP_STATION) && IsTileOwner(t, _current_company)) return;
dir = GetRoadDepotDirection(tile);
@@ -3796,7 +3796,7 @@ pos_3:
CMD_REMOVE_ROAD);
}
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
- if (!IsTileOwner(tile, _current_player) ||
+ if (!IsTileOwner(tile, _current_company) ||
!IsBridge(tile) ||
GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) {
return;
@@ -3814,30 +3814,30 @@ pos_3:
}
}
-static void AiStateRemoveTrack(Player *p)
+static void AiStateRemoveTrack(Company *c)
{
/* Was 1000 for standard 8x8 maps. */
int num = MapSizeX() * 4;
do {
- TileIndex tile = ++_players_ai[p->index].state_counter;
+ TileIndex tile = ++_companies_ai[c->index].state_counter;
// Iterated all tiles?
if (tile >= MapSize()) {
- _players_ai[p->index].state = AIS_REMOVE_STATION;
+ _companies_ai[c->index].state = AIS_REMOVE_STATION;
return;
}
- // Remove player stuff in that tile
- AiRemovePlayerRailOrRoad(p, tile);
- if (_players_ai[p->index].state != AIS_REMOVE_TRACK) return;
+ // Remove company stuff in that tile
+ AiRemoveCompanyRailOrRoad(c, tile);
+ if (_companies_ai[c->index].state != AIS_REMOVE_TRACK) return;
} while (--num);
}
-static void AiStateRemoveSingleRailTile(Player *p)
+static void AiStateRemoveSingleRailTile(Company *c)
{
// Remove until we can't remove more.
- if (!AiRemoveTileAndGoForward(p)) _players_ai[p->index].state = AIS_REMOVE_TRACK;
+ if (!AiRemoveTileAndGoForward(c)) _companies_ai[c->index].state = AIS_REMOVE_TRACK;
}
static AiStateAction * const _ai_actions[] = {
@@ -3873,101 +3873,101 @@ static AiStateAction * const _ai_actions[] = {
AiStateRemoveSingleRailTile
};
-extern void ShowBuyCompanyDialog(uint player);
+extern void ShowBuyCompanyDialog(CompanyID company);
-static void AiHandleTakeover(Player *p)
+static void AiHandleTakeover(Company *c)
{
- if (p->bankrupt_timeout != 0) {
- p->bankrupt_timeout -= 8;
- if (p->bankrupt_timeout > 0) return;
- p->bankrupt_timeout = 0;
- DeleteWindowById(WC_BUY_COMPANY, _current_player);
- if (IsLocalPlayer()) {
+ if (c->bankrupt_timeout != 0) {
+ c->bankrupt_timeout -= 8;
+ if (c->bankrupt_timeout > 0) return;
+ c->bankrupt_timeout = 0;
+ DeleteWindowById(WC_BUY_COMPANY, _current_company);
+ if (IsLocalCompany()) {
AskExitToGameMenu();
return;
}
- if (IsHumanPlayer(_current_player)) return;
+ if (IsHumanCompany(_current_company)) return;
}
- if (p->bankrupt_asked == 255) return;
+ if (c->bankrupt_asked == 255) return;
{
- uint asked = p->bankrupt_asked;
- Player *pp, *best_pl = NULL;
+ uint asked = c->bankrupt_asked;
+ Company *company, *best_company = NULL;
int32 best_val = -1;
// Ask the guy with the highest performance hist.
- FOR_ALL_PLAYERS(pp) {
+ FOR_ALL_COMPANIES(company) {
if (!(asked & 1) &&
- pp->bankrupt_asked == 0 &&
- best_val < pp->old_economy[1].performance_history) {
- best_val = pp->old_economy[1].performance_history;
- best_pl = pp;
+ company->bankrupt_asked == 0 &&
+ best_val < company->old_economy[1].performance_history) {
+ best_val = company->old_economy[1].performance_history;
+ best_company = company;
}
asked >>= 1;
}
- // Asked all players?
+ // Asked all companies?
if (best_val == -1) {
- p->bankrupt_asked = 255;
+ c->bankrupt_asked = 255;
return;
}
- SetBit(p->bankrupt_asked, best_pl->index);
+ SetBit(c->bankrupt_asked, best_company->index);
- if (best_pl->index == _local_player) {
- p->bankrupt_timeout = 4440;
- ShowBuyCompanyDialog(_current_player);
+ if (best_company->index == _local_company) {
+ c->bankrupt_timeout = 4440;
+ ShowBuyCompanyDialog(_current_company);
return;
}
- if (IsHumanPlayer(best_pl->index)) return;
+ if (IsHumanCompany(best_company->index)) return;
// Too little money for computer to buy it?
- if (best_pl->player_money >> 1 >= p->bankrupt_value) {
+ if (best_company->money >> 1 >= c->bankrupt_value) {
// Computer wants to buy it.
- PlayerID old_p = _current_player;
- _current_player = best_pl->index;
- DoCommand(0, old_p, 0, DC_EXEC, CMD_BUY_COMPANY);
- _current_player = old_p;
+ CompanyID old_company = _current_company;
+ _current_company = best_company->index;
+ DoCommand(0, old_company, 0, DC_EXEC, CMD_BUY_COMPANY);
+ _current_company = old_company;
}
}
}
-static void AiAdjustLoan(const Player* p)
+static void AiAdjustLoan(const Company *c)
{
- Money base = AiGetBasePrice(p);
+ Money base = AiGetBasePrice(c);
- if (p->player_money > base * 1400) {
+ if (c->money > base * 1400) {
// Decrease loan
- if (p->current_loan != 0) {
+ if (c->current_loan != 0) {
DoCommand(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
}
- } else if (p->player_money < base * 500) {
+ } else if (c->money < base * 500) {
// Increase loan
- if (p->current_loan < _economy.max_loan &&
- p->num_valid_stat_ent >= 2 &&
- -(p->old_economy[0].expenses + p->old_economy[1].expenses) < base * 60) {
+ if (c->current_loan < _economy.max_loan &&
+ c->num_valid_stat_ent >= 2 &&
+ -(c->old_economy[0].expenses + c->old_economy[1].expenses) < base * 60) {
DoCommand(0, 0, 0, DC_EXEC, CMD_INCREASE_LOAN);
}
}
}
-static void AiBuildCompanyHQ(Player *p)
+static void AiBuildCompanyHQ(Company *c)
{
TileIndex tile;
- if (p->location_of_HQ == 0 &&
- p->last_build_coordinate != 0) {
- tile = AdjustTileCoordRandomly(p->last_build_coordinate, 8);
+ if (c->location_of_HQ == 0 &&
+ c->last_build_coordinate != 0) {
+ tile = AdjustTileCoordRandomly(c->last_build_coordinate, 8);
DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
}
}
-void AiDoGameLoop(Player *p)
+void AiDoGameLoop(Company *c)
{
- if (p->bankrupt_asked != 0) {
- AiHandleTakeover(p);
+ if (c->bankrupt_asked != 0) {
+ AiHandleTakeover(c);
return;
}
@@ -3977,10 +3977,10 @@ void AiDoGameLoop(Player *p)
// or in %
_ai_service_interval = _settings_game.vehicle.servint_ispercent ? 80 : 180;
- if (IsHumanPlayer(_current_player)) return;
+ if (IsHumanCompany(_current_company)) return;
- AiAdjustLoan(p);
- AiBuildCompanyHQ(p);
+ AiAdjustLoan(c);
+ AiBuildCompanyHQ(c);
#if 0
{
@@ -4013,11 +4013,11 @@ void AiDoGameLoop(Player *p)
"AiStateRemoveSingleRailTile"
};
- if (_players_ai[p->index].state != old_state) {
+ if (_companies_ai[c->index].state != old_state) {
if (hasdots)
printf("\n");
hasdots = false;
- printf("AiState: %s\n", _ai_state_names[old_state=_players_ai[p->index].state]);
+ printf("AiState: %s\n", _ai_state_names[old_state=_companies_ai[c->index].state]);
} else {
printf(".");
hasdots = true;
@@ -4025,55 +4025,55 @@ void AiDoGameLoop(Player *p)
}
#endif
- _ai_actions[_players_ai[p->index].state](p);
+ _ai_actions[_companies_ai[c->index].state](c);
}
-static const SaveLoad _player_ai_desc[] = {
- SLE_VAR(PlayerAI, state, SLE_UINT8),
- SLE_VAR(PlayerAI, tick, SLE_UINT8),
- SLE_CONDVAR(PlayerAI, state_counter, SLE_FILE_U16 | SLE_VAR_U32, 0, 12),
- SLE_CONDVAR(PlayerAI, state_counter, SLE_UINT32, 13, SL_MAX_VERSION),
- SLE_VAR(PlayerAI, timeout_counter, SLE_UINT16),
+static const SaveLoad _company_ai_desc[] = {
+ SLE_VAR(CompanyAI, state, SLE_UINT8),
+ SLE_VAR(CompanyAI, tick, SLE_UINT8),
+ SLE_CONDVAR(CompanyAI, state_counter, SLE_FILE_U16 | SLE_VAR_U32, 0, 12),
+ SLE_CONDVAR(CompanyAI, state_counter, SLE_UINT32, 13, SL_MAX_VERSION),
+ SLE_VAR(CompanyAI, timeout_counter, SLE_UINT16),
- SLE_VAR(PlayerAI, state_mode, SLE_UINT8),
- SLE_VAR(PlayerAI, banned_tile_count, SLE_UINT8),
- SLE_VAR(PlayerAI, railtype_to_use, SLE_UINT8),
+ SLE_VAR(CompanyAI, state_mode, SLE_UINT8),
+ SLE_VAR(CompanyAI, banned_tile_count, SLE_UINT8),
+ SLE_VAR(CompanyAI, railtype_to_use, SLE_UINT8),
- SLE_VAR(PlayerAI, cargo_type, SLE_UINT8),
- SLE_VAR(PlayerAI, num_wagons, SLE_UINT8),
- SLE_VAR(PlayerAI, build_kind, SLE_UINT8),
- SLE_VAR(PlayerAI, num_build_rec, SLE_UINT8),
- SLE_VAR(PlayerAI, num_loco_to_build, SLE_UINT8),
- SLE_VAR(PlayerAI, num_want_fullload, SLE_UINT8),
+ SLE_VAR(CompanyAI, cargo_type, SLE_UINT8),
+ SLE_VAR(CompanyAI, num_wagons, SLE_UINT8),
+ SLE_VAR(CompanyAI, build_kind, SLE_UINT8),
+ SLE_VAR(CompanyAI, num_build_rec, SLE_UINT8),
+ SLE_VAR(CompanyAI, num_loco_to_build, SLE_UINT8),
+ SLE_VAR(CompanyAI, num_want_fullload, SLE_UINT8),
- SLE_VAR(PlayerAI, route_type_mask, SLE_UINT8),
+ SLE_VAR(CompanyAI, route_type_mask, SLE_UINT8),
- SLE_CONDVAR(PlayerAI, start_tile_a, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(PlayerAI, start_tile_a, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(PlayerAI, cur_tile_a, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(PlayerAI, cur_tile_a, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_VAR(PlayerAI, start_dir_a, SLE_UINT8),
- SLE_VAR(PlayerAI, cur_dir_a, SLE_UINT8),
+ SLE_CONDVAR(CompanyAI, start_tile_a, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
+ SLE_CONDVAR(CompanyAI, start_tile_a, SLE_UINT32, 6, SL_MAX_VERSION),
+ SLE_CONDVAR(CompanyAI, cur_tile_a, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
+ SLE_CONDVAR(CompanyAI, cur_tile_a, SLE_UINT32, 6, SL_MAX_VERSION),
+ SLE_VAR(CompanyAI, start_dir_a, SLE_UINT8),
+ SLE_VAR(CompanyAI, cur_dir_a, SLE_UINT8),
- SLE_CONDVAR(PlayerAI, start_tile_b, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(PlayerAI, start_tile_b, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(PlayerAI, cur_tile_b, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(PlayerAI, cur_tile_b, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_VAR(PlayerAI, start_dir_b, SLE_UINT8),
- SLE_VAR(PlayerAI, cur_dir_b, SLE_UINT8),
+ SLE_CONDVAR(CompanyAI, start_tile_b, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
+ SLE_CONDVAR(CompanyAI, start_tile_b, SLE_UINT32, 6, SL_MAX_VERSION),
+ SLE_CONDVAR(CompanyAI, cur_tile_b, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
+ SLE_CONDVAR(CompanyAI, cur_tile_b, SLE_UINT32, 6, SL_MAX_VERSION),
+ SLE_VAR(CompanyAI, start_dir_b, SLE_UINT8),
+ SLE_VAR(CompanyAI, cur_dir_b, SLE_UINT8),
- SLE_REF(PlayerAI, cur_veh, REF_VEHICLE),
+ SLE_REF(CompanyAI, cur_veh, REF_VEHICLE),
- SLE_ARR(PlayerAI, wagon_list, SLE_UINT16, 9),
- SLE_ARR(PlayerAI, order_list_blocks, SLE_UINT8, 20),
- SLE_ARR(PlayerAI, banned_tiles, SLE_UINT16, 16),
+ SLE_ARR(CompanyAI, wagon_list, SLE_UINT16, 9),
+ SLE_ARR(CompanyAI, order_list_blocks, SLE_UINT8, 20),
+ SLE_ARR(CompanyAI, banned_tiles, SLE_UINT16, 16),
SLE_CONDNULL(64, 2, SL_MAX_VERSION),
SLE_END()
};
-static const SaveLoad _player_ai_build_rec_desc[] = {
+static const SaveLoad _company_ai_build_rec_desc[] = {
SLE_CONDVAR(AiBuildRec, spec_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(AiBuildRec, spec_tile, SLE_UINT32, 6, SL_MAX_VERSION),
SLE_CONDVAR(AiBuildRec, use_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
@@ -4090,11 +4090,11 @@ static const SaveLoad _player_ai_build_rec_desc[] = {
};
-void SaveLoad_AI(PlayerID id)
+void SaveLoad_AI(CompanyID company)
{
- PlayerAI *pai = &_players_ai[id];
- SlObject(pai, _player_ai_desc);
- for (int i = 0; i != pai->num_build_rec; i++) {
- SlObject(&pai->src + i, _player_ai_build_rec_desc);
+ CompanyAI *cai = &_companies_ai[company];
+ SlObject(cai, _company_ai_desc);
+ for (int i = 0; i != cai->num_build_rec; i++) {
+ SlObject(&cai->src + i, _company_ai_build_rec_desc);
}
}
diff --git a/src/ai/default/default.h b/src/ai/default/default.h
index b0a4163be..69d65a396 100644
--- a/src/ai/default/default.h
+++ b/src/ai/default/default.h
@@ -9,8 +9,8 @@
#include "../../vehicle_type.h"
#include "../../rail_type.h"
-void AiDoGameLoop(Player*);
-void SaveLoad_AI(PlayerID id);
+void AiDoGameLoop(Company *c);
+void SaveLoad_AI(CompanyID company);
struct AiBuildRec {
TileIndex spec_tile;
@@ -25,7 +25,7 @@ struct AiBuildRec {
CargoID cargo;
};
-struct PlayerAI {
+struct CompanyAI {
byte state;
byte tick; ///< Used to determine how often to move
uint32 state_counter; ///< Can hold tile index!
@@ -65,6 +65,6 @@ struct PlayerAI {
byte banned_val[16];
};
-extern PlayerAI _players_ai[MAX_PLAYERS];
+extern CompanyAI _companies_ai[MAX_COMPANIES];
#endif
diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp
index ac35b0251..311ca71f2 100644
--- a/src/ai/trolly/build.cpp
+++ b/src/ai/trolly/build.cpp
@@ -23,7 +23,7 @@
// Build HQ
// Params:
// tile : tile where HQ is going to be build
-bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile)
+bool AiNew_Build_CompanyHQ(Company *c, TileIndex tile)
{
if (CmdFailed(AI_DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ)))
return false;
@@ -40,7 +40,7 @@ bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile)
// numtracks : in case of AI_TRAIN: tracks of station
// direction : the direction of the station
// flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
-CommandCost AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
+CommandCost AiNew_Build_Station(Company *c, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
{
if (type == AI_TRAIN)
return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
@@ -52,12 +52,12 @@ CommandCost AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte lengt
}
-// Builds a brdige. The second best out of the ones available for this player
+// Builds a brdige. The second best out of the ones available for this company
// Params:
// tile_a : starting point
// tile_b : end point
// flag : flag passed to DoCommand
-CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
+CommandCost AiNew_Build_Bridge(Company *c, TileIndex tile_a, TileIndex tile_b, byte flag)
{
int bridge_type, bridge_len, type, type2;
@@ -76,7 +76,7 @@ CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, by
if (type2 == 0 && type != 0) type2 = type;
// Now, simply, build the bridge!
- if (_players_ainew[p->index].tbt == AI_TRAIN) {
+ if (_companies_ainew[c->index].tbt == AI_TRAIN) {
return AI_DoCommand(tile_a, tile_b, type2 | RAILTYPE_RAIL << 8 | TRANSPORT_RAIL << 15, flag | DC_AUTO, CMD_BUILD_BRIDGE);
} else {
return AI_DoCommand(tile_a, tile_b, type2 | ROADTYPES_ROAD << 8 | TRANSPORT_ROAD << 15, flag | DC_AUTO, CMD_BUILD_BRIDGE);
@@ -94,7 +94,7 @@ CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, by
// part : Which part we need to build
//
// TODO: skip already builded road-pieces (e.g.: cityroad)
-CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag)
+CommandCost AiNew_Build_RoutePart(Company *c, Ai_PathFinderInfo *PathFinderInfo, byte flag)
{
int part = PathFinderInfo->position;
byte *route_extra = PathFinderInfo->route_extra;
@@ -127,7 +127,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
}
// Bridge code
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
- cost.AddCost(AiNew_Build_Bridge(p, route[part], route[part - 1], flag));
+ cost.AddCost(AiNew_Build_Bridge(c, route[part], route[part - 1], flag));
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
@@ -150,7 +150,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
res = AI_DoCommand(route[part], 0, dir, flag, CMD_BUILD_SINGLE_RAIL);
if (CmdFailed(res)) {
// Problem.. let's just abort it all!
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return CommandCost();
}
cost.AddCost(res);
@@ -177,7 +177,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
}
// Bridge code
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
- cost.AddCost(AiNew_Build_Bridge(p, route[part], route[part + 1], flag));
+ cost.AddCost(AiNew_Build_Bridge(c, route[part], route[part + 1], flag));
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
@@ -206,7 +206,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_ROAD) && !EnsureNoVehicleOnGround(route[part])) {
// Problem.. let's just abort it all!
DEBUG(ai, 0, "[BuidPath] route building failed at tile 0x%X, aborting", route[part]);
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return CommandCost();
}
@@ -230,9 +230,9 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
// This functions tries to find the best vehicle for this type of cargo
// It returns INVALID_ENGINE if not suitable engine is found
-EngineID AiNew_PickVehicle(Player *p)
+EngineID AiNew_PickVehicle(Company *c)
{
- if (_players_ainew[p->index].tbt == AI_TRAIN) {
+ if (_companies_ainew[c->index].tbt == AI_TRAIN) {
// Not supported yet
return INVALID_ENGINE;
} else {
@@ -246,14 +246,14 @@ EngineID AiNew_PickVehicle(Player *p)
const RoadVehicleInfo *rvi = &e->u.road;
/* Skip vehicles which can't take our cargo type */
- if (rvi->cargo_type != _players_ainew[p->index].cargo && !CanRefitTo(i, _players_ainew[p->index].cargo)) continue;
+ if (rvi->cargo_type != _companies_ainew[c->index].cargo && !CanRefitTo(i, _companies_ainew[c->index].cargo)) continue;
/* Skip trams */
if (HasBit(EngInfo(i)->misc_flags, EF_ROAD_TRAM)) continue;
// Is it availiable?
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
- if (!HasBit(e->player_avail, _current_player) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
+ if (!HasBit(e->company_avail, _current_company) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
/* Rate and compare the engine by speed & capacity */
int rating = rvi->max_speed * rvi->capacity;
@@ -274,34 +274,34 @@ EngineID AiNew_PickVehicle(Player *p)
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
- Player* p = GetPlayer(_current_player);
+ Company *c = GetCompany(_current_company);
if (success) {
- _players_ainew[p->index].state = AI_STATE_GIVE_ORDERS;
- _players_ainew[p->index].veh_id = _new_vehicle_id;
+ _companies_ainew[c->index].state = AI_STATE_GIVE_ORDERS;
+ _companies_ainew[c->index].veh_id = _new_vehicle_id;
- if (GetVehicle(_players_ainew[p->index].veh_id)->cargo_type != _players_ainew[p->index].cargo) {
+ if (GetVehicle(_companies_ainew[c->index].veh_id)->cargo_type != _companies_ainew[c->index].cargo) {
/* Cargo type doesn't match, so refit it */
- if (CmdFailed(DoCommand(tile, _players_ainew[p->index].veh_id, _players_ainew[p->index].cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
+ if (CmdFailed(DoCommand(tile, _companies_ainew[c->index].veh_id, _companies_ainew[c->index].cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
/* Refit failed, so sell the vehicle */
- DoCommand(tile, _players_ainew[p->index].veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ DoCommand(tile, _companies_ainew[c->index].veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
}
}
} else {
/* XXX this should be handled more gracefully */
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
}
}
// Builds the best vehicle possible
-CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
+CommandCost AiNew_Build_Vehicle(Company *c, TileIndex tile, byte flag)
{
- EngineID i = AiNew_PickVehicle(p);
+ EngineID i = AiNew_PickVehicle(c);
if (i == INVALID_ENGINE) return CMD_ERROR;
- if (_players_ainew[p->index].tbt == AI_TRAIN) return CMD_ERROR;
+ if (_companies_ainew[c->index].tbt == AI_TRAIN) return CMD_ERROR;
if (flag & DC_EXEC) {
return AI_DoCommandCc(tile, i, 0, flag, CMD_BUILD_ROAD_VEH, CcAI);
@@ -310,10 +310,10 @@ CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
}
}
-CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
+CommandCost AiNew_Build_Depot(Company *c, TileIndex tile, DiagDirection direction, byte flag)
{
CommandCost ret, ret2;
- if (_players_ainew[p->index].tbt == AI_TRAIN) {
+ if (_companies_ainew[c->index].tbt == AI_TRAIN) {
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
} else {
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp
index dbb43fc55..258243f23 100644
--- a/src/ai/trolly/pathfinder.cpp
+++ b/src/ai/trolly/pathfinder.cpp
@@ -24,21 +24,21 @@
// TODO: make it train compatible
static bool TestCanBuildStationHere(TileIndex tile, byte dir)
{
- Player *p = GetPlayer(_current_player);
+ Company *c = GetCompany(_current_company);
if (dir == TEST_STATION_NO_DIR) {
CommandCost ret;
// TODO: currently we only allow spots that can be access from al 4 directions...
// should be fixed!!!
for (dir = 0; dir < 4; dir++) {
- ret = AiNew_Build_Station(p, _players_ainew[p->index].tbt, tile, 1, 1, dir, DC_QUERY_COST);
+ ret = AiNew_Build_Station(c, _companies_ainew[c->index].tbt, tile, 1, 1, dir, DC_QUERY_COST);
if (CmdSucceeded(ret)) return true;
}
return false;
}
// return true if command succeeded, so the inverse of CmdFailed()
- return CmdSucceeded(AiNew_Build_Station(p, _players_ainew[p->index].tbt, tile, 1, 1, dir, DC_QUERY_COST));
+ return CmdSucceeded(AiNew_Build_Station(c, _companies_ainew[c->index].tbt, tile, 1, 1, dir, DC_QUERY_COST));
}
diff --git a/src/ai/trolly/shared.cpp b/src/ai/trolly/shared.cpp
index 9f990b554..d08bfd723 100644
--- a/src/ai/trolly/shared.cpp
+++ b/src/ai/trolly/shared.cpp
@@ -78,13 +78,13 @@ DiagDirection AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
// This functions looks up if this vehicle is special for this AI
// and returns his flag
-uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
+uint AiNew_GetSpecialVehicleFlag(Company *c, Vehicle *v)
{
uint i;
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
- if (_players_ainew[p->index].special_vehicles[i].veh_id == v->index) {
- return _players_ainew[p->index].special_vehicles[i].flag;
+ if (_companies_ainew[c->index].special_vehicles[i].veh_id == v->index) {
+ return _companies_ainew[c->index].special_vehicles[i].flag;
}
}
@@ -93,19 +93,19 @@ uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
}
-bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
+bool AiNew_SetSpecialVehicleFlag(Company *c, Vehicle *v, uint flag)
{
int new_id = -1;
uint i;
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
- if (_players_ainew[p->index].special_vehicles[i].veh_id == v->index) {
- _players_ainew[p->index].special_vehicles[i].flag |= flag;
+ if (_companies_ainew[c->index].special_vehicles[i].veh_id == v->index) {
+ _companies_ainew[c->index].special_vehicles[i].flag |= flag;
return true;
}
if (new_id == -1 &&
- _players_ainew[p->index].special_vehicles[i].veh_id == 0 &&
- _players_ainew[p->index].special_vehicles[i].flag == 0) {
+ _companies_ainew[c->index].special_vehicles[i].veh_id == 0 &&
+ _companies_ainew[c->index].special_vehicles[i].flag == 0) {
new_id = i;
}
}
@@ -115,7 +115,7 @@ bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
DEBUG(ai, 1, "special_vehicles list is too small");
return false;
}
- _players_ainew[p->index].special_vehicles[new_id].veh_id = v->index;
- _players_ainew[p->index].special_vehicles[new_id].flag = flag;
+ _companies_ainew[c->index].special_vehicles[new_id].veh_id = v->index;
+ _companies_ainew[c->index].special_vehicles[new_id].flag = flag;
return true;
}
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index bbd630673..9ec6b937d 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -43,37 +43,37 @@
#include "table/strings.h"
-PlayerAiNew _players_ainew[MAX_PLAYERS];
+CompanyAiNew _companies_ainew[MAX_COMPANIES];
// This function is called after StartUp. It is the init of an AI
-static void AiNew_State_FirstTime(Player *p)
+static void AiNew_State_FirstTime(Company *c)
{
// This assert is used to protect those function from misuse
// You have quickly a small mistake in the state-array
// With that, everything would go wrong. Finding that, is almost impossible
// With this assert, that problem can never happen.
- assert(_players_ainew[p->index].state == AI_STATE_FIRST_TIME);
+ assert(_companies_ainew[c->index].state == AI_STATE_FIRST_TIME);
// We first have to init some things
- if (_current_player == 1) ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_IN_PROGRESS, 0, 0);
+ if (_current_company == 1) ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_IN_PROGRESS, 0, 0);
// The PathFinder (AyStar)
// TODO: Maybe when an AI goes bankrupt, this is de-init
// or when coming from a savegame.. should be checked out!
- _players_ainew[p->index].path_info.start_tile_tl = 0;
- _players_ainew[p->index].path_info.start_tile_br = 0;
- _players_ainew[p->index].path_info.end_tile_tl = 0;
- _players_ainew[p->index].path_info.end_tile_br = 0;
- _players_ainew[p->index].pathfinder = new_AyStar_AiPathFinder(12, &_players_ainew[p->index].path_info);
+ _companies_ainew[c->index].path_info.start_tile_tl = 0;
+ _companies_ainew[c->index].path_info.start_tile_br = 0;
+ _companies_ainew[c->index].path_info.end_tile_tl = 0;
+ _companies_ainew[c->index].path_info.end_tile_br = 0;
+ _companies_ainew[c->index].pathfinder = new_AyStar_AiPathFinder(12, &_companies_ainew[c->index].path_info);
- _players_ainew[p->index].idle = 0;
- _players_ainew[p->index].last_vehiclecheck_date = _date;
+ _companies_ainew[c->index].idle = 0;
+ _companies_ainew[c->index].last_vehiclecheck_date = _date;
// We ALWAYS start with a bus route.. just some basic money ;)
- _players_ainew[p->index].action = AI_ACTION_BUS_ROUTE;
+ _companies_ainew[c->index].action = AI_ACTION_BUS_ROUTE;
// Let's popup the news, and after that, start building..
- _players_ainew[p->index].state = AI_STATE_WAKE_UP;
+ _companies_ainew[c->index].state = AI_STATE_WAKE_UP;
}
@@ -84,15 +84,15 @@ static void AiNew_State_FirstTime(Player *p)
//
// Let's say, we sleep between one and three days if the AI is put on Very Fast.
// This means that on Very Slow it will be between 16 and 48 days.. slow enough?
-static void AiNew_State_Nothing(Player *p)
+static void AiNew_State_Nothing(Company *c)
{
- assert(_players_ainew[p->index].state == AI_STATE_NOTHING);
+ assert(_companies_ainew[c->index].state == AI_STATE_NOTHING);
// If we are done idling, start over again
- if (_players_ainew[p->index].idle == 0) _players_ainew[p->index].idle = AI_RandomRange(DAY_TICKS * 2) + DAY_TICKS;
- if (--_players_ainew[p->index].idle == 0) {
+ if (_companies_ainew[c->index].idle == 0) _companies_ainew[c->index].idle = AI_RandomRange(DAY_TICKS * 2) + DAY_TICKS;
+ if (--_companies_ainew[c->index].idle == 0) {
// We are done idling.. what you say? Let's do something!
// I mean.. the next tick ;)
- _players_ainew[p->index].state = AI_STATE_WAKE_UP;
+ _companies_ainew[c->index].state = AI_STATE_WAKE_UP;
}
}
@@ -102,118 +102,117 @@ static void AiNew_State_Nothing(Player *p)
// - Make new route
// - Check route
// - Build HQ
-static void AiNew_State_WakeUp(Player *p)
+static void AiNew_State_WakeUp(Company *c)
{
- int c;
- assert(_players_ainew[p->index].state == AI_STATE_WAKE_UP);
+ assert(_companies_ainew[c->index].state == AI_STATE_WAKE_UP);
// First, check if we have a HQ
- if (p->location_of_HQ == 0) {
+ if (c->location_of_HQ == 0) {
// We have no HQ yet, build one on a random place
// Random till we found a place for it!
// TODO: this should not be on a random place..
- AiNew_Build_CompanyHQ(p, AI_Random() % MapSize());
+ AiNew_Build_CompanyHQ(c, AI_Random() % MapSize());
// Enough for now, but we want to come back here the next time
// so we do not change any status
return;
}
- Money money = p->player_money - AI_MINIMUM_MONEY;
+ Money money = c->money - AI_MINIMUM_MONEY;
// Let's pick an action!
- if (_players_ainew[p->index].action == AI_ACTION_NONE) {
- c = AI_Random() & 0xFF;
- if (p->current_loan > 0 &&
- p->old_economy[1].income > AI_MINIMUM_INCOME_FOR_LOAN &&
- c < 10) {
- _players_ainew[p->index].action = AI_ACTION_REPAY_LOAN;
- } else if (_players_ainew[p->index].last_vehiclecheck_date + AI_DAYS_BETWEEN_VEHICLE_CHECKS < _date) {
+ if (_companies_ainew[c->index].action == AI_ACTION_NONE) {
+ int r = AI_Random() & 0xFF;
+ if (c->current_loan > 0 &&
+ c->old_economy[1].income > AI_MINIMUM_INCOME_FOR_LOAN &&
+ r < 10) {
+ _companies_ainew[c->index].action = AI_ACTION_REPAY_LOAN;
+ } else if (_companies_ainew[c->index].last_vehiclecheck_date + AI_DAYS_BETWEEN_VEHICLE_CHECKS < _date) {
// Check all vehicles once in a while
- _players_ainew[p->index].action = AI_ACTION_CHECK_ALL_VEHICLES;
- _players_ainew[p->index].last_vehiclecheck_date = _date;
- } else if (c < 100 && !_settings_game.ai.ai_disable_veh_roadveh) {
+ _companies_ainew[c->index].action = AI_ACTION_CHECK_ALL_VEHICLES;
+ _companies_ainew[c->index].last_vehiclecheck_date = _date;
+ } else if (r < 100 && !_settings_game.ai.ai_disable_veh_roadveh) {
// Do we have any spots for road-vehicles left open?
if (GetFreeUnitNumber(VEH_ROAD) <= _settings_game.vehicle.max_roadveh) {
- if (c < 85) {
- _players_ainew[p->index].action = AI_ACTION_TRUCK_ROUTE;
+ if (r < 85) {
+ _companies_ainew[c->index].action = AI_ACTION_TRUCK_ROUTE;
} else {
- _players_ainew[p->index].action = AI_ACTION_BUS_ROUTE;
+ _companies_ainew[c->index].action = AI_ACTION_BUS_ROUTE;
}
}
#if 0
- } else if (c < 200 && !_settings_game.ai.ai_disable_veh_train) {
+ } else if (r < 200 && !_settings_game.ai.ai_disable_veh_train) {
if (GetFreeUnitNumber(VEH_TRAIN) <= _settings_game.vehicle.max_trains) {
- _players_ainew[p->index].action = AI_ACTION_TRAIN_ROUTE;
+ _companies_ainew[c->index].action = AI_ACTION_TRAIN_ROUTE;
}
#endif
}
- _players_ainew[p->index].counter = 0;
+ _companies_ainew[c->index].counter = 0;
}
- if (_players_ainew[p->index].counter++ > AI_MAX_TRIES_FOR_SAME_ROUTE) {
- _players_ainew[p->index].action = AI_ACTION_NONE;
+ if (_companies_ainew[c->index].counter++ > AI_MAX_TRIES_FOR_SAME_ROUTE) {
+ _companies_ainew[c->index].action = AI_ACTION_NONE;
return;
}
if (_settings_game.ai.ai_disable_veh_roadveh && (
- _players_ainew[p->index].action == AI_ACTION_BUS_ROUTE ||
- _players_ainew[p->index].action == AI_ACTION_TRUCK_ROUTE
+ _companies_ainew[c->index].action == AI_ACTION_BUS_ROUTE ||
+ _companies_ainew[c->index].action == AI_ACTION_TRUCK_ROUTE
)) {
- _players_ainew[p->index].action = AI_ACTION_NONE;
+ _companies_ainew[c->index].action = AI_ACTION_NONE;
return;
}
- if (_players_ainew[p->index].action == AI_ACTION_REPAY_LOAN &&
+ if (_companies_ainew[c->index].action == AI_ACTION_REPAY_LOAN &&
money > AI_MINIMUM_LOAN_REPAY_MONEY) {
// We start repaying some money..
- _players_ainew[p->index].state = AI_STATE_REPAY_MONEY;
+ _companies_ainew[c->index].state = AI_STATE_REPAY_MONEY;
return;
}
- if (_players_ainew[p->index].action == AI_ACTION_CHECK_ALL_VEHICLES) {
- _players_ainew[p->index].state = AI_STATE_CHECK_ALL_VEHICLES;
+ if (_companies_ainew[c->index].action == AI_ACTION_CHECK_ALL_VEHICLES) {
+ _companies_ainew[c->index].state = AI_STATE_CHECK_ALL_VEHICLES;
return;
}
// It is useless to start finding a route if we don't have enough money
// to build the route anyway..
- if (_players_ainew[p->index].action == AI_ACTION_BUS_ROUTE &&
+ if (_companies_ainew[c->index].action == AI_ACTION_BUS_ROUTE &&
money > AI_MINIMUM_BUS_ROUTE_MONEY) {
if (GetFreeUnitNumber(VEH_ROAD) > _settings_game.vehicle.max_roadveh) {
- _players_ainew[p->index].action = AI_ACTION_NONE;
+ _companies_ainew[c->index].action = AI_ACTION_NONE;
return;
}
- _players_ainew[p->index].cargo = AI_NEED_CARGO;
- _players_ainew[p->index].state = AI_STATE_LOCATE_ROUTE;
- _players_ainew[p->index].tbt = AI_BUS; // Bus-route
+ _companies_ainew[c->index].cargo = AI_NEED_CARGO;
+ _companies_ainew[c->index].state = AI_STATE_LOCATE_ROUTE;
+ _companies_ainew[c->index].tbt = AI_BUS; // Bus-route
return;
}
- if (_players_ainew[p->index].action == AI_ACTION_TRUCK_ROUTE &&
+ if (_companies_ainew[c->index].action == AI_ACTION_TRUCK_ROUTE &&
money > AI_MINIMUM_TRUCK_ROUTE_MONEY) {
if (GetFreeUnitNumber(VEH_ROAD) > _settings_game.vehicle.max_roadveh) {
- _players_ainew[p->index].action = AI_ACTION_NONE;
+ _companies_ainew[c->index].action = AI_ACTION_NONE;
return;
}
- _players_ainew[p->index].cargo = AI_NEED_CARGO;
- _players_ainew[p->index].last_id = 0;
- _players_ainew[p->index].state = AI_STATE_LOCATE_ROUTE;
- _players_ainew[p->index].tbt = AI_TRUCK;
+ _companies_ainew[c->index].cargo = AI_NEED_CARGO;
+ _companies_ainew[c->index].last_id = 0;
+ _companies_ainew[c->index].state = AI_STATE_LOCATE_ROUTE;
+ _companies_ainew[c->index].tbt = AI_TRUCK;
return;
}
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
}
-static void AiNew_State_ActionDone(Player *p)
+static void AiNew_State_ActionDone(Company *c)
{
- _players_ainew[p->index].action = AI_ACTION_NONE;
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].action = AI_ACTION_NONE;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
}
// Check if a city or industry is good enough to start a route there
-static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
+static bool AiNew_Check_City_or_Industry(Company *c, int ic, byte type)
{
if (type == AI_CITY) {
const Town* t = GetTown(ic);
@@ -226,7 +225,7 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// Check if the rating in a city is high enough
// If not, take a chance if we want to continue
- if (t->ratings[_current_player] < 0 && AI_CHANCE16(1, 4)) return false;
+ if (t->ratings[_current_company] < 0 && AI_CHANCE16(1, 4)) return false;
if (t->max_pass - t->act_pass < AI_CHECKCITY_NEEDED_CARGO && !AI_CHANCE16(1, AI_CHECKCITY_CITY_CHANCE)) return false;
@@ -236,9 +235,9 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// This way we don't get 12 busstations in one city of 100 population ;)
FOR_ALL_STATIONS(st) {
// Do we own it?
- if (st->owner == _current_player) {
+ if (st->owner == _current_company) {
// Are we talking busses?
- if (_players_ainew[p->index].tbt == AI_BUS && (FACIL_BUS_STOP & st->facilities) != FACIL_BUS_STOP) continue;
+ if (_companies_ainew[c->index].tbt == AI_BUS && (FACIL_BUS_STOP & st->facilities) != FACIL_BUS_STOP) continue;
// Is it the same city as we are in now?
if (st->town != t) continue;
// When was this station build?
@@ -281,7 +280,7 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
int count = 0;
int j = 0;
- if (i->town != NULL && i->town->ratings[_current_player] < 0 && AI_CHANCE16(1, 4)) return false;
+ if (i->town != NULL && i->town->ratings[_current_company] < 0 && AI_CHANCE16(1, 4)) return false;
// No limits on delevering stations!
// Or for industry that does not give anything yet
@@ -294,9 +293,9 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// and sometimes it takes up to 4 months before the stats are corectly.
FOR_ALL_STATIONS(st) {
// Do we own it?
- if (st->owner == _current_player) {
+ if (st->owner == _current_company) {
// Are we talking trucks?
- if (_players_ainew[p->index].tbt == AI_TRUCK && (FACIL_TRUCK_STOP & st->facilities) != FACIL_TRUCK_STOP) continue;
+ if (_companies_ainew[c->index].tbt == AI_TRUCK && (FACIL_TRUCK_STOP & st->facilities) != FACIL_TRUCK_STOP) continue;
// Is it the same city as we are in now?
if (st->town != i->town) continue;
// When was this station build?
@@ -338,32 +337,32 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// This functions tries to locate a good route
-static void AiNew_State_LocateRoute(Player *p)
+static void AiNew_State_LocateRoute(Company *c)
{
- assert(_players_ainew[p->index].state == AI_STATE_LOCATE_ROUTE);
+ assert(_companies_ainew[c->index].state == AI_STATE_LOCATE_ROUTE);
// For now, we only support PASSENGERS, CITY and BUSSES
// We don't have a route yet
- if (_players_ainew[p->index].cargo == AI_NEED_CARGO) {
- _players_ainew[p->index].new_cost = 0; // No cost yet
- _players_ainew[p->index].temp = -1;
+ if (_companies_ainew[c->index].cargo == AI_NEED_CARGO) {
+ _companies_ainew[c->index].new_cost = 0; // No cost yet
+ _companies_ainew[c->index].temp = -1;
// Reset the counter
- _players_ainew[p->index].counter = 0;
+ _companies_ainew[c->index].counter = 0;
- _players_ainew[p->index].from_ic = -1;
- _players_ainew[p->index].to_ic = -1;
- if (_players_ainew[p->index].tbt == AI_BUS) {
+ _companies_ainew[c->index].from_ic = -1;
+ _companies_ainew[c->index].to_ic = -1;
+ if (_companies_ainew[c->index].tbt == AI_BUS) {
// For now we only have a passenger route
- _players_ainew[p->index].cargo = CT_PASSENGERS;
+ _companies_ainew[c->index].cargo = CT_PASSENGERS;
// Find a route to cities
- _players_ainew[p->index].from_type = AI_CITY;
- _players_ainew[p->index].to_type = AI_CITY;
- } else if (_players_ainew[p->index].tbt == AI_TRUCK) {
- _players_ainew[p->index].cargo = AI_NO_CARGO;
+ _companies_ainew[c->index].from_type = AI_CITY;
+ _companies_ainew[c->index].to_type = AI_CITY;
+ } else if (_companies_ainew[c->index].tbt == AI_TRUCK) {
+ _companies_ainew[c->index].cargo = AI_NO_CARGO;
- _players_ainew[p->index].from_type = AI_INDUSTRY;
- _players_ainew[p->index].to_type = AI_INDUSTRY;
+ _companies_ainew[c->index].from_type = AI_INDUSTRY;
+ _companies_ainew[c->index].to_type = AI_INDUSTRY;
}
// Now we are doing initing, we wait one tick
@@ -371,63 +370,63 @@ static void AiNew_State_LocateRoute(Player *p)
}
// Increase the counter and abort if it is taking too long!
- _players_ainew[p->index].counter++;
- if (_players_ainew[p->index].counter > AI_LOCATE_ROUTE_MAX_COUNTER) {
+ _companies_ainew[c->index].counter++;
+ if (_companies_ainew[c->index].counter > AI_LOCATE_ROUTE_MAX_COUNTER) {
// Switch back to doing nothing!
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
// We are going to locate a city from where we are going to connect
- if (_players_ainew[p->index].from_ic == -1) {
- if (_players_ainew[p->index].temp == -1) {
+ if (_companies_ainew[c->index].from_ic == -1) {
+ if (_companies_ainew[c->index].temp == -1) {
// First, we pick a random spot to search from
- if (_players_ainew[p->index].from_type == AI_CITY) {
- _players_ainew[p->index].temp = AI_RandomRange(GetMaxTownIndex() + 1);
+ if (_companies_ainew[c->index].from_type == AI_CITY) {
+ _companies_ainew[c->index].temp = AI_RandomRange(GetMaxTownIndex() + 1);
} else {
- _players_ainew[p->index].temp = AI_RandomRange(GetMaxIndustryIndex() + 1);
+ _companies_ainew[c->index].temp = AI_RandomRange(GetMaxIndustryIndex() + 1);
}
}
- if (!AiNew_Check_City_or_Industry(p, _players_ainew[p->index].temp, _players_ainew[p->index].from_type)) {
+ if (!AiNew_Check_City_or_Industry(c, _companies_ainew[c->index].temp, _companies_ainew[c->index].from_type)) {
// It was not a valid city
// increase the temp with one, and return. We will come back later here
// to try again
- _players_ainew[p->index].temp++;
- if (_players_ainew[p->index].from_type == AI_CITY) {
- if (_players_ainew[p->index].temp > GetMaxTownIndex()) _players_ainew[p->index].temp = 0;
+ _companies_ainew[c->index].temp++;
+ if (_companies_ainew[c->index].from_type == AI_CITY) {
+ if (_companies_ainew[c->index].temp > GetMaxTownIndex()) _companies_ainew[c->index].temp = 0;
} else {
- if (_players_ainew[p->index].temp > GetMaxIndustryIndex()) _players_ainew[p->index].temp = 0;
+ if (_companies_ainew[c->index].temp > GetMaxIndustryIndex()) _companies_ainew[c->index].temp = 0;
}
// Don't do an attempt if we are trying the same id as the last time...
- if (_players_ainew[p->index].last_id == _players_ainew[p->index].temp) return;
- _players_ainew[p->index].last_id = _players_ainew[p->index].temp;
+ if (_companies_ainew[c->index].last_id == _companies_ainew[c->index].temp) return;
+ _companies_ainew[c->index].last_id = _companies_ainew[c->index].temp;
return;
}
// We found a good city/industry, save the data of it
- _players_ainew[p->index].from_ic = _players_ainew[p->index].temp;
+ _companies_ainew[c->index].from_ic = _companies_ainew[c->index].temp;
// Start the next tick with finding a to-city
- _players_ainew[p->index].temp = -1;
+ _companies_ainew[c->index].temp = -1;
return;
}
// Find a to-city
- if (_players_ainew[p->index].temp == -1) {
+ if (_companies_ainew[c->index].temp == -1) {
// First, we pick a random spot to search to
- if (_players_ainew[p->index].to_type == AI_CITY) {
- _players_ainew[p->index].temp = AI_RandomRange(GetMaxTownIndex() + 1);
+ if (_companies_ainew[c->index].to_type == AI_CITY) {
+ _companies_ainew[c->index].temp = AI_RandomRange(GetMaxTownIndex() + 1);
} else {
- _players_ainew[p->index].temp = AI_RandomRange(GetMaxIndustryIndex() + 1);
+ _companies_ainew[c->index].temp = AI_RandomRange(GetMaxIndustryIndex() + 1);
}
}
// The same city is not allowed
// Also check if the city is valid
- if (_players_ainew[p->index].temp != _players_ainew[p->index].from_ic && AiNew_Check_City_or_Industry(p, _players_ainew[p->index].temp, _players_ainew[p->index].to_type)) {
+ if (_companies_ainew[c->index].temp != _companies_ainew[c->index].from_ic && AiNew_Check_City_or_Industry(c, _companies_ainew[c->index].temp, _companies_ainew[c->index].to_type)) {
// Maybe it is valid..
/* We need to know if they are not to far apart from eachother..
@@ -435,9 +434,9 @@ static void AiNew_State_LocateRoute(Player *p)
* route is.
*/
- if (_players_ainew[p->index].from_type == AI_CITY && _players_ainew[p->index].tbt == AI_BUS) {
- const Town* town_from = GetTown(_players_ainew[p->index].from_ic);
- const Town* town_temp = GetTown(_players_ainew[p->index].temp);
+ if (_companies_ainew[c->index].from_type == AI_CITY && _companies_ainew[c->index].tbt == AI_BUS) {
+ const Town* town_from = GetTown(_companies_ainew[c->index].from_ic);
+ const Town* town_temp = GetTown(_companies_ainew[c->index].temp);
uint distance = DistanceManhattan(town_from->xy, town_temp->xy);
int max_cargo;
@@ -448,23 +447,23 @@ static void AiNew_State_LocateRoute(Player *p)
// If it is more than the distance, we allow it
if (distance <= max_cargo * AI_LOCATEROUTE_BUS_CARGO_DISTANCE) {
// We found a good city/industry, save the data of it
- _players_ainew[p->index].to_ic = _players_ainew[p->index].temp;
- _players_ainew[p->index].state = AI_STATE_FIND_STATION;
+ _companies_ainew[c->index].to_ic = _companies_ainew[c->index].temp;
+ _companies_ainew[c->index].state = AI_STATE_FIND_STATION;
DEBUG(ai, 1, "[LocateRoute] found bus-route of %d tiles long (from %d to %d)",
distance,
- _players_ainew[p->index].from_ic,
- _players_ainew[p->index].temp
+ _companies_ainew[c->index].from_ic,
+ _companies_ainew[c->index].temp
);
- _players_ainew[p->index].from_tile = 0;
- _players_ainew[p->index].to_tile = 0;
+ _companies_ainew[c->index].from_tile = 0;
+ _companies_ainew[c->index].to_tile = 0;
return;
}
- } else if (_players_ainew[p->index].tbt == AI_TRUCK) {
- const Industry* ind_from = GetIndustry(_players_ainew[p->index].from_ic);
- const Industry* ind_temp = GetIndustry(_players_ainew[p->index].temp);
+ } else if (_companies_ainew[c->index].tbt == AI_TRUCK) {
+ const Industry* ind_from = GetIndustry(_companies_ainew[c->index].from_ic);
+ const Industry* ind_temp = GetIndustry(_companies_ainew[c->index].temp);
bool found = false;
int max_cargo = 0;
uint i;
@@ -478,8 +477,8 @@ static void AiNew_State_LocateRoute(Player *p)
// Found a compatible industry
max_cargo = ind_from->last_month_production[0] - ind_from->last_month_transported[0];
found = true;
- _players_ainew[p->index].from_deliver = true;
- _players_ainew[p->index].to_deliver = false;
+ _companies_ainew[c->index].from_deliver = true;
+ _companies_ainew[c->index].to_deliver = false;
break;
}
}
@@ -492,8 +491,8 @@ static void AiNew_State_LocateRoute(Player *p)
// Found a compatbiel industry
found = true;
max_cargo = ind_temp->last_month_production[0] - ind_temp->last_month_transported[0];
- _players_ainew[p->index].from_deliver = false;
- _players_ainew[p->index].to_deliver = true;
+ _companies_ainew[c->index].from_deliver = false;
+ _companies_ainew[c->index].to_deliver = true;
break;
}
}
@@ -505,22 +504,22 @@ static void AiNew_State_LocateRoute(Player *p)
if (distance > AI_LOCATEROUTE_TRUCK_MIN_DISTANCE &&
distance <= max_cargo * AI_LOCATEROUTE_TRUCK_CARGO_DISTANCE) {
- _players_ainew[p->index].to_ic = _players_ainew[p->index].temp;
- if (_players_ainew[p->index].from_deliver) {
- _players_ainew[p->index].cargo = ind_from->produced_cargo[0];
+ _companies_ainew[c->index].to_ic = _companies_ainew[c->index].temp;
+ if (_companies_ainew[c->index].from_deliver) {
+ _companies_ainew[c->index].cargo = ind_from->produced_cargo[0];
} else {
- _players_ainew[p->index].cargo = ind_temp->produced_cargo[0];
+ _companies_ainew[c->index].cargo = ind_temp->produced_cargo[0];
}
- _players_ainew[p->index].state = AI_STATE_FIND_STATION;
+ _companies_ainew[c->index].state = AI_STATE_FIND_STATION;
DEBUG(ai, 1, "[LocateRoute] found truck-route of %d tiles long (from %d to %d)",
distance,
- _players_ainew[p->index].from_ic,
- _players_ainew[p->index].temp
+ _companies_ainew[c->index].from_ic,
+ _companies_ainew[c->index].temp
);
- _players_ainew[p->index].from_tile = 0;
- _players_ainew[p->index].to_tile = 0;
+ _companies_ainew[c->index].from_tile = 0;
+ _companies_ainew[c->index].to_tile = 0;
return;
}
@@ -531,29 +530,29 @@ static void AiNew_State_LocateRoute(Player *p)
// It was not a valid city
// increase the temp with one, and return. We will come back later here
// to try again
- _players_ainew[p->index].temp++;
- if (_players_ainew[p->index].to_type == AI_CITY) {
- if (_players_ainew[p->index].temp > GetMaxTownIndex()) _players_ainew[p->index].temp = 0;
+ _companies_ainew[c->index].temp++;
+ if (_companies_ainew[c->index].to_type == AI_CITY) {
+ if (_companies_ainew[c->index].temp > GetMaxTownIndex()) _companies_ainew[c->index].temp = 0;
} else {
- if (_players_ainew[p->index].temp > GetMaxIndustryIndex()) _players_ainew[p->index].temp = 0;
+ if (_companies_ainew[c->index].temp > GetMaxIndustryIndex()) _companies_ainew[c->index].temp = 0;
}
// Don't do an attempt if we are trying the same id as the last time...
- if (_players_ainew[p->index].last_id == _players_ainew[p->index].temp) return;
- _players_ainew[p->index].last_id = _players_ainew[p->index].temp;
+ if (_companies_ainew[c->index].last_id == _companies_ainew[c->index].temp) return;
+ _companies_ainew[c->index].last_id = _companies_ainew[c->index].temp;
}
// Check if there are not more than a certain amount of vehicles pointed to a certain
// station. This to prevent 10 busses going to one station, which gives... problems ;)
-static bool AiNew_CheckVehicleStation(Player *p, Station *st)
+static bool AiNew_CheckVehicleStation(Company *c, Station *st)
{
int count = 0;
Vehicle *v;
// Also check if we don't have already a lot of busses to this city...
FOR_ALL_VEHICLES(v) {
- if (v->owner == _current_player) {
+ if (v->owner == _current_company) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
@@ -570,7 +569,7 @@ static bool AiNew_CheckVehicleStation(Player *p, Station *st)
}
// This function finds a good spot for a station
-static void AiNew_State_FindStation(Player *p)
+static void AiNew_State_FindStation(Company *c)
{
TileIndex tile;
Station *st;
@@ -579,50 +578,50 @@ static void AiNew_State_FindStation(Player *p)
TileIndex new_tile = 0;
DiagDirection direction = DIAGDIR_NE;
Town *town = NULL;
- assert(_players_ainew[p->index].state == AI_STATE_FIND_STATION);
+ assert(_companies_ainew[c->index].state == AI_STATE_FIND_STATION);
- if (_players_ainew[p->index].from_tile == 0) {
+ if (_companies_ainew[c->index].from_tile == 0) {
// First we scan for a station in the from-city
- if (_players_ainew[p->index].from_type == AI_CITY) {
- town = GetTown(_players_ainew[p->index].from_ic);
+ if (_companies_ainew[c->index].from_type == AI_CITY) {
+ town = GetTown(_companies_ainew[c->index].from_ic);
tile = town->xy;
} else {
- tile = GetIndustry(_players_ainew[p->index].from_ic)->xy;
+ tile = GetIndustry(_companies_ainew[c->index].from_ic)->xy;
}
- } else if (_players_ainew[p->index].to_tile == 0) {
+ } else if (_companies_ainew[c->index].to_tile == 0) {
// Second we scan for a station in the to-city
- if (_players_ainew[p->index].to_type == AI_CITY) {
- town = GetTown(_players_ainew[p->index].to_ic);
+ if (_companies_ainew[c->index].to_type == AI_CITY) {
+ town = GetTown(_companies_ainew[c->index].to_ic);
tile = town->xy;
} else {
- tile = GetIndustry(_players_ainew[p->index].to_ic)->xy;
+ tile = GetIndustry(_companies_ainew[c->index].to_ic)->xy;
}
} else {
// Unsupported request
// Go to FIND_PATH
- _players_ainew[p->index].temp = -1;
- _players_ainew[p->index].state = AI_STATE_FIND_PATH;
+ _companies_ainew[c->index].temp = -1;
+ _companies_ainew[c->index].state = AI_STATE_FIND_PATH;
return;
}
// First, we are going to look at the stations that already exist inside the city
// If there is enough cargo left in the station, we take that station
// If that is not possible, and there are more than 2 stations in the city, abort
- i = AiNew_PickVehicle(p);
+ i = AiNew_PickVehicle(c);
// Euhmz, this should not happen _EVER_
// Quit finding a route...
if (i == INVALID_ENGINE) {
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
FOR_ALL_STATIONS(st) {
- if (st->owner == _current_player) {
- if (_players_ainew[p->index].tbt == AI_BUS && (FACIL_BUS_STOP & st->facilities) == FACIL_BUS_STOP) {
+ if (st->owner == _current_company) {
+ if (_companies_ainew[c->index].tbt == AI_BUS && (FACIL_BUS_STOP & st->facilities) == FACIL_BUS_STOP) {
if (st->town == town) {
// Check how much cargo there is left in the station
- if ((int)st->goods[_players_ainew[p->index].cargo].cargo.Count() > RoadVehInfo(i)->capacity * AI_STATION_REUSE_MULTIPLER) {
- if (AiNew_CheckVehicleStation(p, st)) {
+ if ((int)st->goods[_companies_ainew[c->index].cargo].cargo.Count() > RoadVehInfo(i)->capacity * AI_STATION_REUSE_MULTIPLER) {
+ if (AiNew_CheckVehicleStation(c, st)) {
// We did found a station that was good enough!
new_tile = st->xy;
direction = GetRoadStopDir(st->xy);
@@ -639,11 +638,11 @@ static void AiNew_State_FindStation(Player *p)
// No more than 2 stations allowed in a city
// This is because only the best 2 stations of one cargo do get any cargo
if (count > 2) {
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
- if (new_tile == 0 && _players_ainew[p->index].tbt == AI_BUS) {
+ if (new_tile == 0 && _companies_ainew[c->index].tbt == AI_BUS) {
uint x, y, i = 0;
CommandCost r;
uint best;
@@ -663,20 +662,20 @@ static void AiNew_State_FindStation(Player *p)
// XXX - Get the catchment area
GetAcceptanceAroundTiles(accepts, new_tile, 1, 1, 4);
// >> 3 == 0 means no cargo
- if (accepts[_players_ainew[p->index].cargo] >> 3 == 0) continue;
+ if (accepts[_companies_ainew[c->index].cargo] >> 3 == 0) continue;
// See if we can build the station
- r = AiNew_Build_Station(p, _players_ainew[p->index].tbt, new_tile, 0, 0, 0, DC_QUERY_COST);
+ r = AiNew_Build_Station(c, _companies_ainew[c->index].tbt, new_tile, 0, 0, 0, DC_QUERY_COST);
if (CmdFailed(r)) continue;
// We can build it, so add it to found_spot
found_spot[i] = new_tile;
- found_best[i++] = accepts[_players_ainew[p->index].cargo];
+ found_best[i++] = accepts[_companies_ainew[c->index].cargo];
}
}
}
// If i is still zero, we did not find anything
if (i == 0) {
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
@@ -693,11 +692,11 @@ static void AiNew_State_FindStation(Player *p)
}
// See how much it is going to cost us...
- r = AiNew_Build_Station(p, _players_ainew[p->index].tbt, new_tile, 0, 0, 0, DC_QUERY_COST);
- _players_ainew[p->index].new_cost += r.GetCost();
+ r = AiNew_Build_Station(c, _companies_ainew[c->index].tbt, new_tile, 0, 0, 0, DC_QUERY_COST);
+ _companies_ainew[c->index].new_cost += r.GetCost();
direction = (DiagDirection)AI_PATHFINDER_NO_DIRECTION;
- } else if (new_tile == 0 && _players_ainew[p->index].tbt == AI_TRUCK) {
+ } else if (new_tile == 0 && _companies_ainew[c->index].tbt == AI_TRUCK) {
// Truck station locater works differently.. a station can be on any place
// as long as it is in range. So we give back code AI_STATION_RANGE
// so the pathfinder routine can work it out!
@@ -705,76 +704,76 @@ static void AiNew_State_FindStation(Player *p)
direction = (DiagDirection)AI_PATHFINDER_NO_DIRECTION;
}
- if (_players_ainew[p->index].from_tile == 0) {
- _players_ainew[p->index].from_tile = new_tile;
- _players_ainew[p->index].from_direction = direction;
+ if (_companies_ainew[c->index].from_tile == 0) {
+ _companies_ainew[c->index].from_tile = new_tile;
+ _companies_ainew[c->index].from_direction = direction;
// Now we found thisone, go in for to_tile
return;
- } else if (_players_ainew[p->index].to_tile == 0) {
- _players_ainew[p->index].to_tile = new_tile;
- _players_ainew[p->index].to_direction = direction;
+ } else if (_companies_ainew[c->index].to_tile == 0) {
+ _companies_ainew[c->index].to_tile = new_tile;
+ _companies_ainew[c->index].to_direction = direction;
// K, done placing stations!
- _players_ainew[p->index].temp = -1;
- _players_ainew[p->index].state = AI_STATE_FIND_PATH;
+ _companies_ainew[c->index].temp = -1;
+ _companies_ainew[c->index].state = AI_STATE_FIND_PATH;
return;
}
}
// We try to find a path between 2 points
-static void AiNew_State_FindPath(Player *p)
+static void AiNew_State_FindPath(Company *c)
{
int r;
- assert(_players_ainew[p->index].state == AI_STATE_FIND_PATH);
+ assert(_companies_ainew[c->index].state == AI_STATE_FIND_PATH);
// First time, init some data
- if (_players_ainew[p->index].temp == -1) {
+ if (_companies_ainew[c->index].temp == -1) {
// Init path_info
- if (_players_ainew[p->index].from_tile == AI_STATION_RANGE) {
- const Industry* i = GetIndustry(_players_ainew[p->index].from_ic);
+ if (_companies_ainew[c->index].from_tile == AI_STATION_RANGE) {
+ const Industry* i = GetIndustry(_companies_ainew[c->index].from_ic);
// For truck routes we take a range around the industry
- _players_ainew[p->index].path_info.start_tile_tl = i->xy - TileDiffXY(1, 1);
- _players_ainew[p->index].path_info.start_tile_br = i->xy + TileDiffXY(i->width + 1, i->height + 1);
- _players_ainew[p->index].path_info.start_direction = _players_ainew[p->index].from_direction;
+ _companies_ainew[c->index].path_info.start_tile_tl = i->xy - TileDiffXY(1, 1);
+ _companies_ainew[c->index].path_info.start_tile_br = i->xy + TileDiffXY(i->width + 1, i->height + 1);
+ _companies_ainew[c->index].path_info.start_direction = _companies_ainew[c->index].from_direction;
} else {
- _players_ainew[p->index].path_info.start_tile_tl = _players_ainew[p->index].from_tile;
- _players_ainew[p->index].path_info.start_tile_br = _players_ainew[p->index].from_tile;
- _players_ainew[p->index].path_info.start_direction = _players_ainew[p->index].from_direction;
+ _companies_ainew[c->index].path_info.start_tile_tl = _companies_ainew[c->index].from_tile;
+ _companies_ainew[c->index].path_info.start_tile_br = _companies_ainew[c->index].from_tile;
+ _companies_ainew[c->index].path_info.start_direction = _companies_ainew[c->index].from_direction;
}
- if (_players_ainew[p->index].to_tile == AI_STATION_RANGE) {
- const Industry* i = GetIndustry(_players_ainew[p->index].to_ic);
+ if (_companies_ainew[c->index].to_tile == AI_STATION_RANGE) {
+ const Industry* i = GetIndustry(_companies_ainew[c->index].to_ic);
- _players_ainew[p->index].path_info.end_tile_tl = i->xy - TileDiffXY(1, 1);
- _players_ainew[p->index].path_info.end_tile_br = i->xy + TileDiffXY(i->width + 1, i->height + 1);
- _players_ainew[p->index].path_info.end_direction = _players_ainew[p->index].to_direction;
+ _companies_ainew[c->index].path_info.end_tile_tl = i->xy - TileDiffXY(1, 1);
+ _companies_ainew[c->index].path_info.end_tile_br = i->xy + TileDiffXY(i->width + 1, i->height + 1);
+ _companies_ainew[c->index].path_info.end_direction = _companies_ainew[c->index].to_direction;
} else {
- _players_ainew[p->index].path_info.end_tile_tl = _players_ainew[p->index].to_tile;
- _players_ainew[p->index].path_info.end_tile_br = _players_ainew[p->index].to_tile;
- _players_ainew[p->index].path_info.end_direction = _players_ainew[p->index].to_direction;
+ _companies_ainew[c->index].path_info.end_tile_tl = _companies_ainew[c->index].to_tile;
+ _companies_ainew[c->index].path_info.end_tile_br = _companies_ainew[c->index].to_tile;
+ _companies_ainew[c->index].path_info.end_direction = _companies_ainew[c->index].to_direction;
}
- _players_ainew[p->index].path_info.rail_or_road = (_players_ainew[p->index].tbt == AI_TRAIN);
+ _companies_ainew[c->index].path_info.rail_or_road = (_companies_ainew[c->index].tbt == AI_TRAIN);
// First, clean the pathfinder with our new begin and endpoints
- clean_AyStar_AiPathFinder(_players_ainew[p->index].pathfinder, &_players_ainew[p->index].path_info);
+ clean_AyStar_AiPathFinder(_companies_ainew[c->index].pathfinder, &_companies_ainew[c->index].path_info);
- _players_ainew[p->index].temp = 0;
+ _companies_ainew[c->index].temp = 0;
}
// Start the pathfinder
- r = _players_ainew[p->index].pathfinder->main(_players_ainew[p->index].pathfinder);
+ r = _companies_ainew[c->index].pathfinder->main(_companies_ainew[c->index].pathfinder);
switch (r) {
case AYSTAR_NO_PATH:
DEBUG(ai, 1, "No route found by pathfinder");
// Start all over again
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
break;
case AYSTAR_FOUND_END_NODE: // We found the end-point
- _players_ainew[p->index].temp = -1;
- _players_ainew[p->index].state = AI_STATE_FIND_DEPOT;
+ _companies_ainew[c->index].temp = -1;
+ _companies_ainew[c->index].state = AI_STATE_FIND_DEPOT;
break;
// In any other case, we are still busy finding the route
@@ -784,7 +783,7 @@ static void AiNew_State_FindPath(Player *p)
// This function tries to locate a good place for a depot!
-static void AiNew_State_FindDepot(Player *p)
+static void AiNew_State_FindDepot(Company *c)
{
// To place the depot, we walk through the route, and if we find a lovely spot (MP_CLEAR, MP_TREES), we place it there..
// Simple, easy, works!
@@ -795,21 +794,21 @@ static void AiNew_State_FindDepot(Player *p)
CommandCost r;
DiagDirection j;
TileIndex tile;
- assert(_players_ainew[p->index].state == AI_STATE_FIND_DEPOT);
+ assert(_companies_ainew[c->index].state == AI_STATE_FIND_DEPOT);
- _players_ainew[p->index].depot_tile = 0;
+ _companies_ainew[c->index].depot_tile = 0;
- for (i = 2; i < _players_ainew[p->index].path_info.route_length - 2; i++) {
- tile = _players_ainew[p->index].path_info.route[i];
+ for (i = 2; i < _companies_ainew[c->index].path_info.route_length - 2; i++) {
+ tile = _companies_ainew[c->index].path_info.route[i];
for (j = DIAGDIR_BEGIN; j < DIAGDIR_END; j++) {
TileIndex t = tile + TileOffsByDiagDir(j);
if (IsRoadDepotTile(t) &&
- IsTileOwner(t, _current_player) &&
+ IsTileOwner(t, _current_company) &&
GetRoadDepotDirection(t) == ReverseDiagDir(j)) {
- _players_ainew[p->index].depot_tile = t;
- _players_ainew[p->index].depot_direction = ReverseDiagDir(j);
- _players_ainew[p->index].state = AI_STATE_VERIFY_ROUTE;
+ _companies_ainew[c->index].depot_tile = t;
+ _companies_ainew[c->index].depot_direction = ReverseDiagDir(j);
+ _companies_ainew[c->index].state = AI_STATE_VERIFY_ROUTE;
return;
}
}
@@ -817,19 +816,19 @@ static void AiNew_State_FindDepot(Player *p)
// This routine let depot finding start in the middle, and work his way to the stations
// It makes depot placing nicer :)
- i = _players_ainew[p->index].path_info.route_length / 2;
+ i = _companies_ainew[c->index].path_info.route_length / 2;
g = 1;
- while (i > 1 && i < _players_ainew[p->index].path_info.route_length - 2) {
+ while (i > 1 && i < _companies_ainew[c->index].path_info.route_length - 2) {
i += g;
g *= -1;
(g < 0 ? g-- : g++);
- if (_players_ainew[p->index].path_info.route_extra[i] != 0 || _players_ainew[p->index].path_info.route_extra[i + 1] != 0) {
+ if (_companies_ainew[c->index].path_info.route_extra[i] != 0 || _companies_ainew[c->index].path_info.route_extra[i + 1] != 0) {
// Bridge or tunnel.. we can't place a depot there
continue;
}
- tile = _players_ainew[p->index].path_info.route[i];
+ tile = _companies_ainew[c->index].path_info.route[i];
for (j = DIAGDIR_BEGIN; j < DIAGDIR_END; j++) {
TileIndex t = tile + TileOffsByDiagDir(j);
@@ -837,32 +836,32 @@ static void AiNew_State_FindDepot(Player *p)
// It may not be placed on the road/rail itself
// And because it is not build yet, we can't see it on the tile..
// So check the surrounding tiles :)
- if (t == _players_ainew[p->index].path_info.route[i - 1] ||
- t == _players_ainew[p->index].path_info.route[i + 1]) {
+ if (t == _companies_ainew[c->index].path_info.route[i - 1] ||
+ t == _companies_ainew[c->index].path_info.route[i + 1]) {
continue;
}
// Not around a bridge?
- if (_players_ainew[p->index].path_info.route_extra[i] != 0) continue;
+ if (_companies_ainew[c->index].path_info.route_extra[i] != 0) continue;
if (IsTileType(tile, MP_TUNNELBRIDGE)) continue;
// Is the terrain clear?
if (IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)) {
// If the current tile is on a slope then we do not allow this
if (GetTileSlope(tile, NULL) != SLOPE_FLAT) continue;
// Check if everything went okay..
- r = AiNew_Build_Depot(p, t, ReverseDiagDir(j), 0);
+ r = AiNew_Build_Depot(c, t, ReverseDiagDir(j), 0);
if (CmdFailed(r)) continue;
// Found a spot!
- _players_ainew[p->index].new_cost += r.GetCost();
- _players_ainew[p->index].depot_tile = t;
- _players_ainew[p->index].depot_direction = ReverseDiagDir(j); // Reverse direction
- _players_ainew[p->index].state = AI_STATE_VERIFY_ROUTE;
+ _companies_ainew[c->index].new_cost += r.GetCost();
+ _companies_ainew[c->index].depot_tile = t;
+ _companies_ainew[c->index].depot_direction = ReverseDiagDir(j); // Reverse direction
+ _companies_ainew[c->index].state = AI_STATE_VERIFY_ROUTE;
return;
}
}
}
// Failed to find a depot?
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
}
@@ -871,17 +870,17 @@ static void AiNew_State_FindDepot(Player *p)
// It works pretty simple: get the length, see how much we move around
// and hussle that, and you know how many vehicles there are needed.
// It returns the cost for the vehicles
-static int AiNew_HowManyVehicles(Player *p)
+static int AiNew_HowManyVehicles(Company *c)
{
- if (_players_ainew[p->index].tbt == AI_BUS) {
+ if (_companies_ainew[c->index].tbt == AI_BUS) {
// For bus-routes we look at the time before we are back in the station
EngineID i;
int length, tiles_a_day;
int amount;
- i = AiNew_PickVehicle(p);
+ i = AiNew_PickVehicle(c);
if (i == INVALID_ENGINE) return 0;
// Passenger run.. how long is the route?
- length = _players_ainew[p->index].path_info.route_length;
+ length = _companies_ainew[c->index].path_info.route_length;
// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
tiles_a_day = RoadVehInfo(i)->max_speed * DAY_TICKS / 256 / 16;
if (tiles_a_day == 0) tiles_a_day = 1;
@@ -890,22 +889,22 @@ static int AiNew_HowManyVehicles(Player *p)
amount = length * 2 * 2 / tiles_a_day / 30;
if (amount == 0) amount = 1;
return amount;
- } else if (_players_ainew[p->index].tbt == AI_TRUCK) {
+ } else if (_companies_ainew[c->index].tbt == AI_TRUCK) {
// For truck-routes we look at the cargo
EngineID i;
int length, amount, tiles_a_day;
int max_cargo;
- i = AiNew_PickVehicle(p);
+ i = AiNew_PickVehicle(c);
if (i == INVALID_ENGINE) return 0;
// Passenger run.. how long is the route?
- length = _players_ainew[p->index].path_info.route_length;
+ length = _companies_ainew[c->index].path_info.route_length;
// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
tiles_a_day = RoadVehInfo(i)->max_speed * DAY_TICKS / 256 / 16;
if (tiles_a_day == 0) tiles_a_day = 1;
- if (_players_ainew[p->index].from_deliver) {
- max_cargo = GetIndustry(_players_ainew[p->index].from_ic)->last_month_production[0];
+ if (_companies_ainew[c->index].from_deliver) {
+ max_cargo = GetIndustry(_companies_ainew[c->index].from_ic)->last_month_production[0];
} else {
- max_cargo = GetIndustry(_players_ainew[p->index].to_ic)->last_month_production[0];
+ max_cargo = GetIndustry(_companies_ainew[c->index].to_ic)->last_month_production[0];
}
// This is because moving 60% is more than we can dream of!
@@ -928,116 +927,116 @@ static int AiNew_HowManyVehicles(Player *p)
// - If the route went okay
// - Calculates the amount of money needed to build the route
// - Calculates how much vehicles needed for the route
-static void AiNew_State_VerifyRoute(Player *p)
+static void AiNew_State_VerifyRoute(Company *c)
{
int res, i;
- assert(_players_ainew[p->index].state == AI_STATE_VERIFY_ROUTE);
+ assert(_companies_ainew[c->index].state == AI_STATE_VERIFY_ROUTE);
// Let's calculate the cost of the path..
// new_cost already contains the cost of the stations
- _players_ainew[p->index].path_info.position = -1;
+ _companies_ainew[c->index].path_info.position = -1;
do {
- _players_ainew[p->index].path_info.position++;
- _players_ainew[p->index].new_cost += AiNew_Build_RoutePart(p, &_players_ainew[p->index].path_info, DC_QUERY_COST).GetCost();
- } while (_players_ainew[p->index].path_info.position != -2);
+ _companies_ainew[c->index].path_info.position++;
+ _companies_ainew[c->index].new_cost += AiNew_Build_RoutePart(c, &_companies_ainew[c->index].path_info, DC_QUERY_COST).GetCost();
+ } while (_companies_ainew[c->index].path_info.position != -2);
// Now we know the price of build station + path. Now check how many vehicles
// we need and what the price for that will be
- res = AiNew_HowManyVehicles(p);
+ res = AiNew_HowManyVehicles(c);
// If res == 0, no vehicle was found, or an other problem did occour
if (res == 0) {
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
- _players_ainew[p->index].amount_veh = res;
- _players_ainew[p->index].cur_veh = 0;
+ _companies_ainew[c->index].amount_veh = res;
+ _companies_ainew[c->index].cur_veh = 0;
// Check how much it it going to cost us..
for (i = 0; i < res; i++) {
- _players_ainew[p->index].new_cost += AiNew_Build_Vehicle(p, 0, DC_QUERY_COST).GetCost();
+ _companies_ainew[c->index].new_cost += AiNew_Build_Vehicle(c, 0, DC_QUERY_COST).GetCost();
}
// Now we know how much the route is going to cost us
// Check if we have enough money for it!
- if (_players_ainew[p->index].new_cost > p->player_money - AI_MINIMUM_MONEY) {
+ if (_companies_ainew[c->index].new_cost > c->money - AI_MINIMUM_MONEY) {
// Too bad..
- DEBUG(ai, 1, "Insufficient funds to build route (%" OTTD_PRINTF64 "d)", (int64)_players_ainew[p->index].new_cost);
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ DEBUG(ai, 1, "Insufficient funds to build route (%" OTTD_PRINTF64 "d)", (int64)_companies_ainew[c->index].new_cost);
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
// Now we can build the route, check the direction of the stations!
- if (_players_ainew[p->index].from_direction == AI_PATHFINDER_NO_DIRECTION) {
- _players_ainew[p->index].from_direction = AiNew_GetDirection(_players_ainew[p->index].path_info.route[_players_ainew[p->index].path_info.route_length - 1], _players_ainew[p->index].path_info.route[_players_ainew[p->index].path_info.route_length - 2]);
+ if (_companies_ainew[c->index].from_direction == AI_PATHFINDER_NO_DIRECTION) {
+ _companies_ainew[c->index].from_direction = AiNew_GetDirection(_companies_ainew[c->index].path_info.route[_companies_ainew[c->index].path_info.route_length - 1], _companies_ainew[c->index].path_info.route[_companies_ainew[c->index].path_info.route_length - 2]);
}
- if (_players_ainew[p->index].to_direction == AI_PATHFINDER_NO_DIRECTION) {
- _players_ainew[p->index].to_direction = AiNew_GetDirection(_players_ainew[p->index].path_info.route[0], _players_ainew[p->index].path_info.route[1]);
+ if (_companies_ainew[c->index].to_direction == AI_PATHFINDER_NO_DIRECTION) {
+ _companies_ainew[c->index].to_direction = AiNew_GetDirection(_companies_ainew[c->index].path_info.route[0], _companies_ainew[c->index].path_info.route[1]);
}
- if (_players_ainew[p->index].from_tile == AI_STATION_RANGE)
- _players_ainew[p->index].from_tile = _players_ainew[p->index].path_info.route[_players_ainew[p->index].path_info.route_length - 1];
- if (_players_ainew[p->index].to_tile == AI_STATION_RANGE)
- _players_ainew[p->index].to_tile = _players_ainew[p->index].path_info.route[0];
+ if (_companies_ainew[c->index].from_tile == AI_STATION_RANGE)
+ _companies_ainew[c->index].from_tile = _companies_ainew[c->index].path_info.route[_companies_ainew[c->index].path_info.route_length - 1];
+ if (_companies_ainew[c->index].to_tile == AI_STATION_RANGE)
+ _companies_ainew[c->index].to_tile = _companies_ainew[c->index].path_info.route[0];
- _players_ainew[p->index].state = AI_STATE_BUILD_STATION;
- _players_ainew[p->index].temp = 0;
+ _companies_ainew[c->index].state = AI_STATE_BUILD_STATION;
+ _companies_ainew[c->index].temp = 0;
- DEBUG(ai, 1, "The route is set and buildable, building 0x%X to 0x%X...", _players_ainew[p->index].from_tile, _players_ainew[p->index].to_tile);
+ DEBUG(ai, 1, "The route is set and buildable, building 0x%X to 0x%X...", _companies_ainew[c->index].from_tile, _companies_ainew[c->index].to_tile);
}
// Build the stations
-static void AiNew_State_BuildStation(Player *p)
+static void AiNew_State_BuildStation(Company *c)
{
CommandCost res;
- assert(_players_ainew[p->index].state == AI_STATE_BUILD_STATION);
- if (_players_ainew[p->index].temp == 0) {
- if (!IsTileType(_players_ainew[p->index].from_tile, MP_STATION))
- res = AiNew_Build_Station(p, _players_ainew[p->index].tbt, _players_ainew[p->index].from_tile, 0, 0, _players_ainew[p->index].from_direction, DC_EXEC);
+ assert(_companies_ainew[c->index].state == AI_STATE_BUILD_STATION);
+ if (_companies_ainew[c->index].temp == 0) {
+ if (!IsTileType(_companies_ainew[c->index].from_tile, MP_STATION))
+ res = AiNew_Build_Station(c, _companies_ainew[c->index].tbt, _companies_ainew[c->index].from_tile, 0, 0, _companies_ainew[c->index].from_direction, DC_EXEC);
} else {
- if (!IsTileType(_players_ainew[p->index].to_tile, MP_STATION))
- res = AiNew_Build_Station(p, _players_ainew[p->index].tbt, _players_ainew[p->index].to_tile, 0, 0, _players_ainew[p->index].to_direction, DC_EXEC);
- _players_ainew[p->index].state = AI_STATE_BUILD_PATH;
+ if (!IsTileType(_companies_ainew[c->index].to_tile, MP_STATION))
+ res = AiNew_Build_Station(c, _companies_ainew[c->index].tbt, _companies_ainew[c->index].to_tile, 0, 0, _companies_ainew[c->index].to_direction, DC_EXEC);
+ _companies_ainew[c->index].state = AI_STATE_BUILD_PATH;
}
if (CmdFailed(res)) {
- DEBUG(ai, 0, "[BuildStation] station could not be built (0x%X)", _players_ainew[p->index].to_tile);
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ DEBUG(ai, 0, "[BuildStation] station could not be built (0x%X)", _companies_ainew[c->index].to_tile);
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
// If the first station _was_ build, destroy it
- if (_players_ainew[p->index].temp != 0)
- AI_DoCommand(_players_ainew[p->index].from_tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ if (_companies_ainew[c->index].temp != 0)
+ AI_DoCommand(_companies_ainew[c->index].from_tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
return;
}
- _players_ainew[p->index].temp++;
+ _companies_ainew[c->index].temp++;
}
// Build the path
-static void AiNew_State_BuildPath(Player *p)
+static void AiNew_State_BuildPath(Company *c)
{
- assert(_players_ainew[p->index].state == AI_STATE_BUILD_PATH);
- // _players_ainew[p->index].temp is set to -1 when this function is called for the first time
- if (_players_ainew[p->index].temp == -1) {
+ assert(_companies_ainew[c->index].state == AI_STATE_BUILD_PATH);
+ // _companies_ainew[c->index].temp is set to -1 when this function is called for the first time
+ if (_companies_ainew[c->index].temp == -1) {
DEBUG(ai, 1, "Starting to build new path");
// Init the counter
- _players_ainew[p->index].counter = (4 - _settings_game.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1;
+ _companies_ainew[c->index].counter = (4 - _settings_game.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1;
// Set the position to the startingplace (-1 because in a minute we do ++)
- _players_ainew[p->index].path_info.position = -1;
+ _companies_ainew[c->index].path_info.position = -1;
// And don't do this again
- _players_ainew[p->index].temp = 0;
+ _companies_ainew[c->index].temp = 0;
}
// Building goes very fast on normal rate, so we are going to slow it down..
// By let the counter count from AI_BUILDPATH_PAUSE to 0, we have a nice way :)
- if (--_players_ainew[p->index].counter != 0) return;
- _players_ainew[p->index].counter = (4 - _settings_game.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1;
+ if (--_companies_ainew[c->index].counter != 0) return;
+ _companies_ainew[c->index].counter = (4 - _settings_game.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1;
// Increase the building position
- _players_ainew[p->index].path_info.position++;
+ _companies_ainew[c->index].path_info.position++;
// Build route
- AiNew_Build_RoutePart(p, &_players_ainew[p->index].path_info, DC_EXEC);
- if (_players_ainew[p->index].path_info.position == -2) {
+ AiNew_Build_RoutePart(c, &_companies_ainew[c->index].path_info, DC_EXEC);
+ if (_companies_ainew[c->index].path_info.position == -2) {
// This means we are done building!
- if (_players_ainew[p->index].tbt == AI_TRUCK && !_settings_game.pf.roadveh_queue) {
+ if (_companies_ainew[c->index].tbt == AI_TRUCK && !_settings_game.pf.roadveh_queue) {
// If they not queue, they have to go up and down to try again at a station...
// We don't want that, so try building some road left or right of the station
DiagDirection dir1, dir2, dir3;
@@ -1045,15 +1044,15 @@ static void AiNew_State_BuildPath(Player *p)
CommandCost ret;
for (int i = 0; i < 2; i++) {
if (i == 0) {
- tile = _players_ainew[p->index].from_tile + TileOffsByDiagDir(_players_ainew[p->index].from_direction);
- dir1 = ChangeDiagDir(_players_ainew[p->index].from_direction, DIAGDIRDIFF_90LEFT);
- dir2 = ChangeDiagDir(_players_ainew[p->index].from_direction, DIAGDIRDIFF_90RIGHT);
- dir3 = _players_ainew[p->index].from_direction;
+ tile = _companies_ainew[c->index].from_tile + TileOffsByDiagDir(_companies_ainew[c->index].from_direction);
+ dir1 = ChangeDiagDir(_companies_ainew[c->index].from_direction, DIAGDIRDIFF_90LEFT);
+ dir2 = ChangeDiagDir(_companies_ainew[c->index].from_direction, DIAGDIRDIFF_90RIGHT);
+ dir3 = _companies_ainew[c->index].from_direction;
} else {
- tile = _players_ainew[p->index].to_tile + TileOffsByDiagDir(_players_ainew[p->index].to_direction);
- dir1 = ChangeDiagDir(_players_ainew[p->index].to_direction, DIAGDIRDIFF_90LEFT);
- dir2 = ChangeDiagDir(_players_ainew[p->index].to_direction, DIAGDIRDIFF_90RIGHT);
- dir3 = _players_ainew[p->index].to_direction;
+ tile = _companies_ainew[c->index].to_tile + TileOffsByDiagDir(_companies_ainew[c->index].to_direction);
+ dir1 = ChangeDiagDir(_companies_ainew[c->index].to_direction, DIAGDIRDIFF_90LEFT);
+ dir2 = ChangeDiagDir(_companies_ainew[c->index].to_direction, DIAGDIRDIFF_90RIGHT);
+ dir3 = _companies_ainew[c->index].to_direction;
}
ret = AI_DoCommand(tile, DiagDirToRoadBits(ReverseDiagDir(dir1)), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
@@ -1094,152 +1093,152 @@ static void AiNew_State_BuildPath(Player *p)
}
}
- DEBUG(ai, 1, "Finished building path, cost: %" OTTD_PRINTF64 "d", (int64)_players_ainew[p->index].new_cost);
- _players_ainew[p->index].state = AI_STATE_BUILD_DEPOT;
+ DEBUG(ai, 1, "Finished building path, cost: %" OTTD_PRINTF64 "d", (int64)_companies_ainew[c->index].new_cost);
+ _companies_ainew[c->index].state = AI_STATE_BUILD_DEPOT;
}
}
// Builds the depot
-static void AiNew_State_BuildDepot(Player *p)
+static void AiNew_State_BuildDepot(Company *c)
{
CommandCost res;
- assert(_players_ainew[p->index].state == AI_STATE_BUILD_DEPOT);
+ assert(_companies_ainew[c->index].state == AI_STATE_BUILD_DEPOT);
- if (IsRoadDepotTile(_players_ainew[p->index].depot_tile)) {
- if (IsTileOwner(_players_ainew[p->index].depot_tile, _current_player)) {
+ if (IsRoadDepotTile(_companies_ainew[c->index].depot_tile)) {
+ if (IsTileOwner(_companies_ainew[c->index].depot_tile, _current_company)) {
// The depot is already built
- _players_ainew[p->index].state = AI_STATE_BUILD_VEHICLE;
+ _companies_ainew[c->index].state = AI_STATE_BUILD_VEHICLE;
return;
} else {
// There is a depot, but not of our team! :(
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
}
// There is a bus on the tile we want to build road on... idle till he is gone! (BAD PERSON! :p)
- if (!EnsureNoVehicleOnGround(_players_ainew[p->index].depot_tile + TileOffsByDiagDir(_players_ainew[p->index].depot_direction)))
+ if (!EnsureNoVehicleOnGround(_companies_ainew[c->index].depot_tile + TileOffsByDiagDir(_companies_ainew[c->index].depot_direction)))
return;
- res = AiNew_Build_Depot(p, _players_ainew[p->index].depot_tile, _players_ainew[p->index].depot_direction, DC_EXEC);
+ res = AiNew_Build_Depot(c, _companies_ainew[c->index].depot_tile, _companies_ainew[c->index].depot_direction, DC_EXEC);
if (CmdFailed(res)) {
- DEBUG(ai, 0, "[BuildDepot] depot could not be built (0x%X)", _players_ainew[p->index].depot_tile);
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ DEBUG(ai, 0, "[BuildDepot] depot could not be built (0x%X)", _companies_ainew[c->index].depot_tile);
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
- _players_ainew[p->index].state = AI_STATE_BUILD_VEHICLE;
- _players_ainew[p->index].idle = 10;
- _players_ainew[p->index].veh_main_id = INVALID_VEHICLE;
+ _companies_ainew[c->index].state = AI_STATE_BUILD_VEHICLE;
+ _companies_ainew[c->index].idle = 10;
+ _companies_ainew[c->index].veh_main_id = INVALID_VEHICLE;
}
// Build vehicles
-static void AiNew_State_BuildVehicle(Player *p)
+static void AiNew_State_BuildVehicle(Company *c)
{
CommandCost res;
- assert(_players_ainew[p->index].state == AI_STATE_BUILD_VEHICLE);
+ assert(_companies_ainew[c->index].state == AI_STATE_BUILD_VEHICLE);
// Check if we need to build a vehicle
- if (_players_ainew[p->index].amount_veh == 0) {
+ if (_companies_ainew[c->index].amount_veh == 0) {
// Nope, we are done!
// This means: we are all done! The route is open.. go back to NOTHING
// He will idle some time and it will all start over again.. :)
- _players_ainew[p->index].state = AI_STATE_ACTION_DONE;
+ _companies_ainew[c->index].state = AI_STATE_ACTION_DONE;
return;
}
- if (--_players_ainew[p->index].idle != 0) return;
+ if (--_companies_ainew[c->index].idle != 0) return;
// It is realistic that the AI can only build 1 vehicle a day..
// This makes sure of that!
- _players_ainew[p->index].idle = AI_BUILD_VEHICLE_TIME_BETWEEN;
+ _companies_ainew[c->index].idle = AI_BUILD_VEHICLE_TIME_BETWEEN;
// Build the vehicle
- res = AiNew_Build_Vehicle(p, _players_ainew[p->index].depot_tile, DC_EXEC);
+ res = AiNew_Build_Vehicle(c, _companies_ainew[c->index].depot_tile, DC_EXEC);
if (CmdFailed(res)) {
// This happens when the AI can't build any more vehicles!
- _players_ainew[p->index].state = AI_STATE_NOTHING;
+ _companies_ainew[c->index].state = AI_STATE_NOTHING;
return;
}
// Increase the current counter
- _players_ainew[p->index].cur_veh++;
+ _companies_ainew[c->index].cur_veh++;
// Decrease the total counter
- _players_ainew[p->index].amount_veh--;
+ _companies_ainew[c->index].amount_veh--;
// Go give some orders!
- _players_ainew[p->index].state = AI_STATE_WAIT_FOR_BUILD;
+ _companies_ainew[c->index].state = AI_STATE_WAIT_FOR_BUILD;
}
// Put the stations in the order list
-static void AiNew_State_GiveOrders(Player *p)
+static void AiNew_State_GiveOrders(Company *c)
{
int idx;
Order order;
- assert(_players_ainew[p->index].state == AI_STATE_GIVE_ORDERS);
+ assert(_companies_ainew[c->index].state == AI_STATE_GIVE_ORDERS);
- if (_players_ainew[p->index].veh_main_id != INVALID_VEHICLE) {
- AI_DoCommand(0, _players_ainew[p->index].veh_id + (_players_ainew[p->index].veh_main_id << 16), CO_SHARE, DC_EXEC, CMD_CLONE_ORDER);
+ if (_companies_ainew[c->index].veh_main_id != INVALID_VEHICLE) {
+ AI_DoCommand(0, _companies_ainew[c->index].veh_id + (_companies_ainew[c->index].veh_main_id << 16), CO_SHARE, DC_EXEC, CMD_CLONE_ORDER);
- _players_ainew[p->index].state = AI_STATE_START_VEHICLE;
+ _companies_ainew[c->index].state = AI_STATE_START_VEHICLE;
return;
} else {
- _players_ainew[p->index].veh_main_id = _players_ainew[p->index].veh_id;
+ _companies_ainew[c->index].veh_main_id = _companies_ainew[c->index].veh_id;
}
// Very handy for AI, goto depot.. but yeah, it needs to be activated ;)
if (_settings_game.order.gotodepot) {
idx = 0;
- order.MakeGoToDepot(GetDepotByTile(_players_ainew[p->index].depot_tile)->index, ODTFB_PART_OF_ORDERS);
- AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
+ order.MakeGoToDepot(GetDepotByTile(_companies_ainew[c->index].depot_tile)->index, ODTFB_PART_OF_ORDERS);
+ AI_DoCommand(0, _companies_ainew[c->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
}
idx = 0;
- order.MakeGoToStation(GetStationIndex(_players_ainew[p->index].to_tile));
- if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].to_deliver) order.SetLoadType(OLFB_FULL_LOAD);
- AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
+ order.MakeGoToStation(GetStationIndex(_companies_ainew[c->index].to_tile));
+ if (_companies_ainew[c->index].tbt == AI_TRUCK && _companies_ainew[c->index].to_deliver) order.SetLoadType(OLFB_FULL_LOAD);
+ AI_DoCommand(0, _companies_ainew[c->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
idx = 0;
- order.MakeGoToStation(GetStationIndex(_players_ainew[p->index].from_tile));
- if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].from_deliver) order.SetLoadType(OLFB_FULL_LOAD);
- AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
+ order.MakeGoToStation(GetStationIndex(_companies_ainew[c->index].from_tile));
+ if (_companies_ainew[c->index].tbt == AI_TRUCK && _companies_ainew[c->index].from_deliver) order.SetLoadType(OLFB_FULL_LOAD);
+ AI_DoCommand(0, _companies_ainew[c->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
// Start the engines!
- _players_ainew[p->index].state = AI_STATE_START_VEHICLE;
+ _companies_ainew[c->index].state = AI_STATE_START_VEHICLE;
}
// Start the vehicle
-static void AiNew_State_StartVehicle(Player *p)
+static void AiNew_State_StartVehicle(Company *c)
{
- assert(_players_ainew[p->index].state == AI_STATE_START_VEHICLE);
+ assert(_companies_ainew[c->index].state == AI_STATE_START_VEHICLE);
// Skip the first order if it is a second vehicle
// This to make vehicles go different ways..
- if (_players_ainew[p->index].cur_veh & 1)
- AI_DoCommand(0, _players_ainew[p->index].veh_id, 1, DC_EXEC, CMD_SKIP_TO_ORDER);
+ if (_companies_ainew[c->index].cur_veh & 1)
+ AI_DoCommand(0, _companies_ainew[c->index].veh_id, 1, DC_EXEC, CMD_SKIP_TO_ORDER);
// 3, 2, 1... go! (give START_STOP command ;))
- AI_DoCommand(0, _players_ainew[p->index].veh_id, 0, DC_EXEC, CMD_START_STOP_VEHICLE);
+ AI_DoCommand(0, _companies_ainew[c->index].veh_id, 0, DC_EXEC, CMD_START_STOP_VEHICLE);
// Try to build an other vehicle (that function will stop building when needed)
- _players_ainew[p->index].idle = 10;
- _players_ainew[p->index].state = AI_STATE_BUILD_VEHICLE;
+ _companies_ainew[c->index].idle = 10;
+ _companies_ainew[c->index].state = AI_STATE_BUILD_VEHICLE;
}
// Repays money
-static void AiNew_State_RepayMoney(Player *p)
+static void AiNew_State_RepayMoney(Company *c)
{
uint i;
for (i = 0; i < AI_LOAN_REPAY; i++) {
AI_DoCommand(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
}
- _players_ainew[p->index].state = AI_STATE_ACTION_DONE;
+ _companies_ainew[c->index].state = AI_STATE_ACTION_DONE;
}
-static void AiNew_CheckVehicle(Player *p, Vehicle *v)
+static void AiNew_CheckVehicle(Company *c, Vehicle *v)
{
// When a vehicle is under the 6 months, we don't check for anything
if (v->age < 180) return;
@@ -1259,7 +1258,7 @@ static void AiNew_CheckVehicle(Player *p, Vehicle *v)
// We are already sending him back
- if (AiNew_GetSpecialVehicleFlag(p, v) & AI_VEHICLEFLAG_SELL) {
+ if (AiNew_GetSpecialVehicleFlag(c, v) & AI_VEHICLEFLAG_SELL) {
if (v->type == VEH_ROAD && IsRoadDepotTile(v->tile) &&
(v->vehstatus & VS_STOPPED)) {
// We are at the depot, sell the vehicle
@@ -1268,7 +1267,7 @@ static void AiNew_CheckVehicle(Player *p, Vehicle *v)
return;
}
- if (!AiNew_SetSpecialVehicleFlag(p, v, AI_VEHICLEFLAG_SELL)) return;
+ if (!AiNew_SetSpecialVehicleFlag(c, v, AI_VEHICLEFLAG_SELL)) return;
{
CommandCost ret;
if (v->type == VEH_ROAD)
@@ -1282,19 +1281,19 @@ static void AiNew_CheckVehicle(Player *p, Vehicle *v)
// Checks all vehicles if they are still valid and make money and stuff
-static void AiNew_State_CheckAllVehicles(Player *p)
+static void AiNew_State_CheckAllVehicles(Company *c)
{
Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (v->owner != p->index) continue;
+ if (v->owner != c->index) continue;
// Currently, we only know how to handle road-vehicles
if (v->type != VEH_ROAD) continue;
- AiNew_CheckVehicle(p, v);
+ AiNew_CheckVehicle(c, v);
}
- _players_ainew[p->index].state = AI_STATE_ACTION_DONE;
+ _companies_ainew[c->index].state = AI_STATE_ACTION_DONE;
}
@@ -1324,27 +1323,27 @@ static AiNew_StateFunction* const _ainew_state[] = {
NULL,
};
-static void AiNew_OnTick(Player *p)
+static void AiNew_OnTick(Company *c)
{
- if (_ainew_state[_players_ainew[p->index].state] != NULL)
- _ainew_state[_players_ainew[p->index].state](p);
+ if (_ainew_state[_companies_ainew[c->index].state] != NULL)
+ _ainew_state[_companies_ainew[c->index].state](c);
}
-void AiNewDoGameLoop(Player *p)
+void AiNewDoGameLoop(Company *c)
{
- if (_players_ainew[p->index].state == AI_STATE_STARTUP) {
+ if (_companies_ainew[c->index].state == AI_STATE_STARTUP) {
// The AI just got alive!
- _players_ainew[p->index].state = AI_STATE_FIRST_TIME;
- _players_ainew[p->index].tick = 0;
+ _companies_ainew[c->index].state = AI_STATE_FIRST_TIME;
+ _companies_ainew[c->index].tick = 0;
// Only startup the AI
return;
}
// We keep a ticker. We use it for competitor_speed
- _players_ainew[p->index].tick++;
+ _companies_ainew[c->index].tick++;
// If we come here, we can do a tick.. do so!
- AiNew_OnTick(p);
+ AiNew_OnTick(c);
}
diff --git a/src/ai/trolly/trolly.h b/src/ai/trolly/trolly.h
index ac81dcdff..2b11623e9 100644
--- a/src/ai/trolly/trolly.h
+++ b/src/ai/trolly/trolly.h
@@ -120,7 +120,7 @@
// Minimum % of reliabilty a vehicle has to have before the AI buys it
#define AI_VEHICLE_MIN_RELIABILTY 60
-// The minimum amount of money a player should always have
+// The minimum amount of money a company should always have
#define AI_MINIMUM_MONEY 15000
// If the most cheap route is build, how much is it going to cost..
@@ -148,7 +148,7 @@
// How many days must there between vehicle checks
// The more often, the less non-money-making lines there will be
-// but the unfair it may seem to a human player
+// but the unfair it may seem to a human company
#define AI_DAYS_BETWEEN_VEHICLE_CHECKS 30
// How money profit does a vehicle needs to make to stay in order
@@ -239,10 +239,10 @@ enum {
#define AI_PATHFINDER_FLAG_BRIDGE 1
#define AI_PATHFINDER_FLAG_TUNNEL 2
-typedef void AiNew_StateFunction(Player *p);
+typedef void AiNew_StateFunction(Company *c);
// ai_new.c
-void AiNewDoGameLoop(Player *p);
+void AiNewDoGameLoop(Company *c);
struct Ai_PathFinderInfo {
TileIndex start_tile_tl; ///< tl = top-left
@@ -268,17 +268,17 @@ void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
DiagDirection AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b);
-bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag);
-uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v);
+bool AiNew_SetSpecialVehicleFlag(Company *c, Vehicle *v, uint flag);
+uint AiNew_GetSpecialVehicleFlag(Company *c, Vehicle *v);
// ai_build.c
-bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile);
-CommandCost AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
-CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag);
-CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
-EngineID AiNew_PickVehicle(Player *p);
-CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
-CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag);
+bool AiNew_Build_CompanyHQ(Company *c, TileIndex tile);
+CommandCost AiNew_Build_Station(Company *c, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
+CommandCost AiNew_Build_Bridge(Company *c, TileIndex tile_a, TileIndex tile_b, byte flag);
+CommandCost AiNew_Build_RoutePart(Company *c, Ai_PathFinderInfo *PathFinderInfo, byte flag);
+EngineID AiNew_PickVehicle(Company *c);
+CommandCost AiNew_Build_Vehicle(Company *c, TileIndex tile, byte flag);
+CommandCost AiNew_Build_Depot(Company *c, TileIndex tile, DiagDirection direction, byte flag);
/* The amount of memory reserved for the AI-special-vehicles */
#define AI_MAX_SPECIAL_VEHICLES 100
@@ -288,7 +288,7 @@ struct Ai_SpecialVehicle {
uint32 flag;
};
-struct PlayerAiNew {
+struct CompanyAiNew {
uint8 state;
uint tick;
uint idle;
@@ -338,6 +338,6 @@ struct PlayerAiNew {
int to_ic;
byte to_type;
};
-extern PlayerAiNew _players_ainew[MAX_PLAYERS];
+extern CompanyAiNew _companies_ainew[MAX_COMPANIES];
#endif /* AI_TROLLY_H */
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index ebabe544d..16cce3252 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -104,7 +104,7 @@ enum HelicopterRotorStates {
};
/** Find the nearest hangar to v
- * INVALID_STATION is returned, if the player does not have any suitable
+ * INVALID_STATION is returned, if the company does not have any suitable
* airports (like helipads only)
* @param v vehicle looking for a hangar
* @return the StationID if one is found, otherwise, INVALID_STATION
@@ -266,7 +266,7 @@ uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi)
*/
CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_player)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE);
+ if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_company)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE);
const AircraftVehicleInfo *avi = AircraftVehInfo(p1);
CommandCost value = EstimateAircraftCost(p1, avi);
@@ -274,7 +274,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* to just query the cost, it is not neccessary to have a valid tile (automation/AI) */
if (flags & DC_QUERY_COST) return value;
- if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
+ if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
/* Prevent building aircraft types at places which can't handle them */
if (!CanAircraftUseStation(p1, tile)) return CMD_ERROR;
@@ -299,7 +299,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->unitnumber = unit_num;
v->direction = DIR_SE;
- v->owner = u->owner = _current_player;
+ v->owner = u->owner = _current_company;
v->tile = tile;
// u->tile = 0;
@@ -428,7 +428,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
w = new (w) Aircraft();
w->direction = DIR_N;
- w->owner = _current_player;
+ w->owner = _current_company;
w->x_pos = v->x_pos;
w->y_pos = v->y_pos;
w->z_pos = v->z_pos + 5;
@@ -448,10 +448,10 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
InvalidateWindow(WC_COMPANY, v->owner);
- if (IsLocalPlayer())
+ if (IsLocalCompany())
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); //updates the replace Aircraft window
- GetPlayer(_current_player)->num_engines[p1]++;
+ GetCompany(_current_company)->num_engines[p1]++;
}
return value;
@@ -529,7 +529,7 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
if (p2 & DEPOT_MASS_SEND) {
/* Mass goto depot requested */
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
- return SendAllVehiclesToDepot(VEH_AIRCRAFT, flags, p2 & DEPOT_SERVICE, _current_player, (p2 & VLW_MASK), p1);
+ return SendAllVehiclesToDepot(VEH_AIRCRAFT, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
}
if (!IsValidVehicleID(p1)) return CMD_ERROR;
@@ -597,7 +597,7 @@ CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
_returned_refit_capacity = pass;
CommandCost cost;
- if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
+ if (IsHumanCompany(v->owner) && new_cid != v->cargo_type) {
cost = GetRefitCost(v->engine_type);
}
@@ -660,7 +660,7 @@ void Aircraft::OnNewDay()
this->profit_this_year -= cost.GetCost();
this->running_ticks = 0;
- SubtractMoneyFromPlayerFract(this->owner, cost);
+ SubtractMoneyFromCompanyFract(this->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
InvalidateWindowClasses(WC_AIRCRAFT_LIST);
@@ -1312,11 +1312,11 @@ void HandleMissingAircraftOrders(Vehicle *v)
const Station *st = GetTargetAirportIfValid(v);
if (st == NULL) {
CommandCost ret;
- PlayerID old_player = _current_player;
+ CompanyID old_company = _current_company;
- _current_player = v->owner;
+ _current_company = v->owner;
ret = DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
- _current_player = old_player;
+ _current_company = old_company;
if (CmdFailed(ret)) CrashAirplane(v);
} else if (!v->current_order.IsType(OT_GOTO_DEPOT)) {
@@ -1413,7 +1413,7 @@ static void AircraftEntersTerminal(Vehicle *v)
/* show newsitem of celebrating citizens */
AddNewsItem(
STR_A033_CITIZENS_CELEBRATE_FIRST,
- (v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
+ (v->owner == _local_company) ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
v->index,
st->index
);
@@ -1477,28 +1477,28 @@ static void AircraftLeaveHangar(Vehicle *v)
static inline bool CheckSendAircraftToHangarForReplacement(const Vehicle *v)
{
EngineID new_engine;
- Player *p = GetPlayer(v->owner);
+ Company *c = GetCompany(v->owner);
if (VehicleHasDepotOrders(v)) return false; // The aircraft will end up in the hangar eventually on it's own
- new_engine = EngineReplacementForPlayer(p, v->engine_type, v->group_id);
+ new_engine = EngineReplacementForCompany(c, v->engine_type, v->group_id);
if (new_engine == INVALID_ENGINE) {
/* There is no autoreplace assigned to this EngineID so we will set it to renew to the same type if needed */
new_engine = v->engine_type;
- if (!v->NeedsAutorenewing(p)) {
+ if (!v->NeedsAutorenewing(c)) {
/* No need to replace the aircraft */
return false;
}
}
- if (!HasBit(GetEngine(new_engine)->player_avail, v->owner)) {
+ if (!HasBit(GetEngine(new_engine)->company_avail, v->owner)) {
/* Engine is not buildable anymore */
return false;
}
- if (p->player_money < (p->engine_renew_money + (2 * DoCommand(0, new_engine, 0, DC_QUERY_COST, CMD_BUILD_AIRCRAFT).GetCost()))) {
+ if (c->money < (c->engine_renew_money + (2 * DoCommand(0, new_engine, 0, DC_QUERY_COST, CMD_BUILD_AIRCRAFT).GetCost()))) {
/* We lack enough money to request the replacement right away.
* We want 2*(the price of the new vehicle) and not looking at the value of the vehicle we are going to sell.
* The reason is that we don't want to send a whole lot of vehicles to the hangars when we only have enough money to replace a single one.
@@ -1652,9 +1652,9 @@ static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass *
/* Send the helicopter to a hangar if needed for replacement */
if (CheckSendAircraftToHangarForReplacement(v)) {
- _current_player = v->owner;
+ _current_company = v->owner;
DoCommand(v->tile, v->index, DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
}
}
@@ -1704,9 +1704,9 @@ static void AircraftEventHandler_Landing(Vehicle *v, const AirportFTAClass *apc)
/* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
if (CheckSendAircraftToHangarForReplacement(v)) {
- _current_player = v->owner;
+ _current_company = v->owner;
DoCommand(v->tile, v->index, DEPOT_SERVICE, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
}
}
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 538fd7b71..da6e11664 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -146,7 +146,7 @@ static const WindowDesc _air_toolbar_desc = {
void ShowBuildAirToolbar()
{
- if (!IsValidPlayerID(_current_player)) return;
+ if (!IsValidCompanyID(_current_company)) return;
DeleteWindowByClass(WC_BUILD_TOOLBAR);
AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index f162f0d3f..b7df99acb 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -39,10 +39,10 @@ static bool EnginesGotCargoInCommon(EngineID engine_a, EngineID engine_b, Vehicl
* Checks some basic properties whether autoreplace is allowed
* @param from Origin engine
* @param to Destination engine
- * @param player Player to check for
+ * @param company Company to check for
* @return true if autoreplace is allowed
*/
-bool CheckAutoreplaceValidity(EngineID from, EngineID to, PlayerID player)
+bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
{
/* First we make sure that it's a valid type the user requested
* check that it's an engine that is in the engine array */
@@ -53,8 +53,8 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, PlayerID player)
VehicleType type = GetEngine(from)->type;
- /* check that the new vehicle type is available to the player and its type is the same as the original one */
- if (!IsEngineBuildable(to, type, player)) return false;
+ /* check that the new vehicle type is available to the company and its type is the same as the original one */
+ if (!IsEngineBuildable(to, type, company)) return false;
switch (type) {
case VEH_TRAIN: {
@@ -213,10 +213,10 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
/** Get the EngineID of the replacement for a vehicle
* @param v The vehicle to find a replacement for
- * @param p The vehicle's owner (it's faster to forward the pointer than refinding it)
+ * @param c The vehicle's owner (it's faster to forward the pointer than refinding it)
* @return the EngineID of the replacement. INVALID_ENGINE if no buildable replacement is found
*/
-static EngineID GetNewEngineType(const Vehicle *v, const Player *p)
+static EngineID GetNewEngineType(const Vehicle *v, const Company *c)
{
assert(v->type != VEH_TRAIN || !IsArticulatedPart(v));
@@ -225,14 +225,14 @@ static EngineID GetNewEngineType(const Vehicle *v, const Player *p)
return INVALID_ENGINE;
}
- EngineID e = EngineReplacementForPlayer(p, v->engine_type, v->group_id);
+ EngineID e = EngineReplacementForCompany(c, v->engine_type, v->group_id);
- if (e != INVALID_ENGINE && IsEngineBuildable(e, v->type, _current_player)) {
+ if (e != INVALID_ENGINE && IsEngineBuildable(e, v->type, _current_company)) {
return e;
}
- if (v->NeedsAutorenewing(p) && // replace if engine is too old
- IsEngineBuildable(v->engine_type, v->type, _current_player)) { // engine can still be build
+ if (v->NeedsAutorenewing(c) && // replace if engine is too old
+ IsEngineBuildable(v->engine_type, v->type, _current_company)) { // engine can still be build
return v->engine_type;
}
@@ -251,8 +251,8 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
*new_vehicle = NULL;
/* Shall the vehicle be replaced? */
- const Player *p = GetPlayer(_current_player);
- EngineID e = GetNewEngineType(old_veh, p);
+ const Company *c = GetCompany(_current_company);
+ EngineID e = GetNewEngineType(old_veh, c);
if (e == INVALID_ENGINE) return CommandCost(); // neither autoreplace is set, nor autorenew is triggered
/* Does it need to be refitted */
@@ -627,14 +627,14 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, uint32 flags, uint32 p1, uint3
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
}
- const Player *p = GetPlayer(_current_player);
- bool wagon_removal = p->renew_keep_length;
+ const Company *c = GetCompany(_current_company);
+ bool wagon_removal = c->renew_keep_length;
/* Test whether any replacement is set, before issuing a whole lot of commands that would end in nothing changed */
Vehicle *w = v;
bool any_replacements = false;
while (w != NULL && !any_replacements) {
- any_replacements = (GetNewEngineType(w, p) != INVALID_ENGINE);
+ any_replacements = (GetNewEngineType(w, c) != INVALID_ENGINE);
w = (!free_wagon && w->type == VEH_TRAIN ? GetNextUnit(w) : NULL);
}
diff --git a/src/autoreplace_func.h b/src/autoreplace_func.h
index 0b5129818..6ca44fde0 100644
--- a/src/autoreplace_func.h
+++ b/src/autoreplace_func.h
@@ -9,9 +9,9 @@
#include "player_base.h"
/**
- * Remove all engine replacement settings for the player.
- * @param erl The renewlist for a given player.
- * @return The new renewlist for the player.
+ * Remove all engine replacement settings for the company.
+ * @param erl The renewlist for a given company.
+ * @return The new renewlist for the company.
*/
void RemoveAllEngineReplacement(EngineRenewList *erl);
@@ -44,62 +44,62 @@ CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, Engi
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags);
/**
- * Remove all engine replacement settings for the given player.
- * @param p Player.
+ * Remove all engine replacement settings for the given company.
+ * @param c the company.
*/
-static inline void RemoveAllEngineReplacementForPlayer(Player *p)
+static inline void RemoveAllEngineReplacementForCompany(Company *c)
{
- RemoveAllEngineReplacement(&p->engine_renew_list);
+ RemoveAllEngineReplacement(&c->engine_renew_list);
}
/**
- * Retrieve the engine replacement for the given player and original engine type.
- * @param p Player.
+ * Retrieve the engine replacement for the given company and original engine type.
+ * @param c company.
* @param engine Engine type.
* @return The engine type to replace with, or INVALID_ENGINE if no
* replacement is in the list.
*/
-static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
+static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group)
{
- return EngineReplacement(p->engine_renew_list, engine, group);
+ return EngineReplacement(c->engine_renew_list, engine, group);
}
/**
- * Check if a player has a replacement set up for the given engine.
- * @param p Player.
+ * Check if a company has a replacement set up for the given engine.
+ * @param c Company.
* @param engine Engine type to be replaced.
* @return true if a replacement was set up, false otherwise.
*/
-static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
+static inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
{
- return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE;
+ return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
}
/**
- * Add an engine replacement for the player.
- * @param p Player.
+ * Add an engine replacement for the company.
+ * @param c Company.
* @param old_engine The original engine type.
* @param new_engine The replacement engine type.
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
-static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
+static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
{
- return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags);
+ return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, flags);
}
/**
- * Remove an engine replacement for the player.
- * @param p Player.
+ * Remove an engine replacement for the company.
+ * @param c Company.
* @param engine The original engine type.
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
-static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags)
+static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, uint32 flags)
{
- return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags);
+ return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
}
-bool CheckAutoreplaceValidity(EngineID from, EngineID to, PlayerID player);
+bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company);
#endif /* AUTOREPLACE_FUNC_H */
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 7b6645e66..71100f271 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -71,10 +71,10 @@ static int CDECL EngineNumberSorter(const void *a, const void *b)
*/
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
{
- Player *p = GetPlayer(_local_player);
- uint num_engines = GetGroupNumEngines(_local_player, id_g, e);
+ Company *c = GetCompany(_local_company);
+ uint num_engines = GetGroupNumEngines(_local_company, id_g, e);
- if (num_engines == 0 || p->num_engines[e] == 0) {
+ if (num_engines == 0 || c->num_engines[e] == 0) {
/* We don't have any of this engine type.
* Either we just sold the last one, we build a new one or we stopped replacing it.
* In all cases, we need to update the left list */
@@ -147,12 +147,12 @@ class ReplaceVehicleWindow : public Window {
if (draw_left) {
const GroupID selected_group = this->sel_group;
- const uint num_engines = GetGroupNumEngines(_local_player, selected_group, eid);
+ const uint num_engines = GetGroupNumEngines(_local_company, selected_group, eid);
/* Skip drawing the engines we don't have any of and haven't set for replacement */
- if (num_engines == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), eid, selected_group) == INVALID_ENGINE) continue;
+ if (num_engines == 0 && EngineReplacementForCompany(GetCompany(_local_company), eid, selected_group) == INVALID_ENGINE) continue;
} else {
- if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_player)) continue;
+ if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
}
*list->Append() = eid;
@@ -244,7 +244,7 @@ public:
this->resize.width = this->width;
this->resize.height = this->height;
- this->caption_color = _local_player;
+ this->caption_color = _local_company;
this->sel_group = id_g;
this->vscroll2.cap = this->vscroll.cap; // these two are always the same
@@ -262,7 +262,7 @@ public:
if (this->update_left || this->update_right) this->GenerateLists();
- Player *p = GetPlayer(_local_player);
+ Company *c = GetCompany(_local_company);
EngineID selected_id[2];
const GroupID selected_group = this->sel_group;
@@ -276,29 +276,29 @@ public:
this->SetWidgetDisabledState(RVW_WIDGET_START_REPLACE,
selected_id[0] == INVALID_ENGINE ||
selected_id[1] == INVALID_ENGINE ||
- EngineReplacementForPlayer(p, selected_id[1], selected_group) != INVALID_ENGINE ||
- EngineReplacementForPlayer(p, selected_id[0], selected_group) == selected_id[1]);
+ EngineReplacementForCompany(c, selected_id[1], selected_group) != INVALID_ENGINE ||
+ EngineReplacementForCompany(c, selected_id[0], selected_group) == selected_id[1]);
/* Disable the "Stop Replacing" button if:
* The left list (existing vehicle) is empty
* or The selected vehicle has no replacement set up */
this->SetWidgetDisabledState(RVW_WIDGET_STOP_REPLACE,
selected_id[0] == INVALID_ENGINE ||
- !EngineHasReplacementForPlayer(p, selected_id[0], selected_group));
+ !EngineHasReplacementForCompany(c, selected_id[0], selected_group));
/* now the actual drawing of the window itself takes place */
SetDParam(0, _vehicle_type_names[this->window_number]);
if (this->window_number == VEH_TRAIN) {
/* set on/off for renew_keep_length */
- SetDParam(1, p->renew_keep_length ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
+ SetDParam(1, c->renew_keep_length ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
/* set wagon/engine button */
SetDParam(2, this->wagon_btnstate ? STR_ENGINES : STR_WAGONS);
/* sets the colour of that art thing */
- this->widget[RVW_WIDGET_TRAIN_FLUFF_LEFT].color = _player_colors[_local_player];
- this->widget[RVW_WIDGET_TRAIN_FLUFF_RIGHT].color = _player_colors[_local_player];
+ this->widget[RVW_WIDGET_TRAIN_FLUFF_LEFT].color = _company_colours[_local_company];
+ this->widget[RVW_WIDGET_TRAIN_FLUFF_RIGHT].color = _company_colours[_local_company];
}
if (this->window_number == VEH_TRAIN) {
@@ -311,11 +311,11 @@ public:
/* sets up the string for the vehicle that is being replaced to */
if (selected_id[0] != INVALID_ENGINE) {
- if (!EngineHasReplacementForPlayer(p, selected_id[0], selected_group)) {
+ if (!EngineHasReplacementForCompany(c, selected_id[0], selected_group)) {
SetDParam(0, STR_NOT_REPLACING);
} else {
SetDParam(0, STR_ENGINE_NAME);
- SetDParam(1, EngineReplacementForPlayer(p, selected_id[0], selected_group));
+ SetDParam(1, EngineReplacementForCompany(c, selected_id[0], selected_group));
}
} else {
SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);
@@ -358,19 +358,19 @@ public:
break;
case RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: { /* Railtype selection dropdown menu */
- const Player *p = GetPlayer(_local_player);
+ const Company *c = GetCompany(_local_company);
DropDownList *list = new DropDownList();
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
const RailtypeInfo *rti = GetRailTypeInfo(rt);
- list->push_back(new DropDownListStringItem(rti->strings.replace_text, rt, !HasBit(p->avail_railtypes, rt)));
+ list->push_back(new DropDownListStringItem(rti->strings.replace_text, rt, !HasBit(c->avail_railtypes, rt)));
}
ShowDropDownList(this, list, sel_railtype, RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN);
break;
}
case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: /* toggle renew_keep_length */
- DoCommandP(0, 5, GetPlayer(_local_player)->renew_keep_length ? 0 : 1, NULL, CMD_SET_AUTOREPLACE);
+ DoCommandP(0, 5, GetCompany(_local_company)->renew_keep_length ? 0 : 1, NULL, CMD_SET_AUTOREPLACE);
break;
case RVW_WIDGET_START_REPLACE: { /* Start replacing */
diff --git a/src/autoreplace_type.h b/src/autoreplace_type.h
index 6dbdd5299..d66c12587 100644
--- a/src/autoreplace_type.h
+++ b/src/autoreplace_type.h
@@ -8,8 +8,8 @@
struct EngineRenew;
/**
- * A list to group EngineRenew directives together (such as per-player).
+ * A list to group EngineRenew directives together (such as per-company).
*/
-typedef EngineRenew* EngineRenewList;
+typedef EngineRenew *EngineRenewList;
#endif /* AUTOREPLACE_TYPE_H */
diff --git a/src/autoslope.h b/src/autoslope.h
index 9b5766c09..b5ae320f0 100644
--- a/src/autoslope.h
+++ b/src/autoslope.h
@@ -30,17 +30,17 @@ static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slo
}
/**
- * Tests if autoslope is enabled for _current_player.
+ * Tests if autoslope is enabled for _current_company.
*
- * Autoslope is disabled for town/industry construction and old ai players.
+ * Autoslope is disabled for town/industry construction and old ai companies.
*
* @return true iff autoslope is enabled.
*/
static inline bool AutoslopeEnabled()
{
return (_settings_game.construction.autoslope &&
- ((_current_player < MAX_PLAYERS && !_is_old_ai_player) ||
- (_current_player == OWNER_NONE && _game_mode == GM_EDITOR)));
+ ((_current_company < MAX_COMPANIES && !_is_old_ai_company) ||
+ (_current_company == OWNER_NONE && _game_mode == GM_EDITOR)));
}
#endif /* AUTOSLOPE_H */
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index d668e98f0..995cf8857 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -776,12 +776,12 @@ void DrawEngineList(VehicleType type, int x, int r, int y, const GUIEngineList *
for (; min < max; min++, y += step_size) {
const EngineID engine = (*eng_list)[min];
- /* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_player here. */
- const uint num_engines = GetGroupNumEngines(_local_player, selected_group, engine);
+ /* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_company here. */
+ const uint num_engines = GetGroupNumEngines(_local_company, selected_group, engine);
SetDParam(0, engine);
DrawStringTruncated(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK, maxw);
- DrawVehicleEngine(type, x, y + y_offset, engine, (count_location != 0 && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_player));
+ DrawVehicleEngine(type, x, y + y_offset, engine, (count_location != 0 && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_company));
if (count_location != 0) {
SetDParam(0, num_engines);
DrawStringRightAligned(count_location, y + (GetVehicleListHeight(type) == 14 ? 3 : 8), STR_TINY_BLACK, TC_FROMSTRING);
@@ -818,7 +818,7 @@ struct BuildVehicleWindow : Window {
this->resize.width = this->width;
this->resize.height = this->height;
- this->caption_color = (tile != 0) ? GetTileOwner(tile) : _local_player;
+ this->caption_color = (tile != 0) ? GetTileOwner(tile) : _local_company;
this->sel_engine = INVALID_ENGINE;
this->regenerate_list = false;
@@ -925,7 +925,7 @@ struct BuildVehicleWindow : Window {
const RailVehicleInfo *rvi = &e->u.rail;
if (this->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, this->filter.railtype)) continue;
- if (!IsEngineBuildable(eid, VEH_TRAIN, _local_player)) continue;
+ if (!IsEngineBuildable(eid, VEH_TRAIN, _local_company)) continue;
*this->eng_list.Append() = eid;
@@ -962,7 +962,7 @@ struct BuildVehicleWindow : Window {
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
EngineID eid = e->index;
- if (!IsEngineBuildable(eid, VEH_ROAD, _local_player)) continue;
+ if (!IsEngineBuildable(eid, VEH_ROAD, _local_company)) continue;
if (!HasBit(this->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
*this->eng_list.Append() = eid;
@@ -980,7 +980,7 @@ struct BuildVehicleWindow : Window {
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_SHIP) {
EngineID eid = e->index;
- if (!IsEngineBuildable(eid, VEH_SHIP, _local_player)) continue;
+ if (!IsEngineBuildable(eid, VEH_SHIP, _local_company)) continue;
*this->eng_list.Append() = eid;
if (eid == this->sel_engine) sel_id = eid;
@@ -1002,7 +1002,7 @@ struct BuildVehicleWindow : Window {
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_AIRCRAFT) {
EngineID eid = e->index;
- if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
+ if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_company)) continue;
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
if (!this->listview_mode && !CanAircraftUseStation(eid, this->window_number)) continue;
@@ -1207,7 +1207,7 @@ void ShowBuildVehicleWindow(TileIndex tile, VehicleType type)
* number. */
uint num = (tile == 0) ? (int)type : tile;
- assert(IsPlayerBuildableVehicleType(type));
+ assert(IsCompanyBuildableVehicleType(type));
DeleteWindowById(WC_BUILD_VEHICLE, num);
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index fd0e90eeb..7c6e5a696 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -39,22 +39,22 @@ static int32 ClickMoneyCheat(int32 p1, int32 p2)
}
/**
- * @param p1 player to set to
+ * @param p1 company to set to
* @param p2 is -1 or +1 (down/up)
*/
-static int32 ClickChangePlayerCheat(int32 p1, int32 p2)
+static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
{
- while ((uint)p1 < GetPlayerPoolSize()) {
- if (IsValidPlayerID((PlayerID)p1)) {
- SetLocalPlayer((PlayerID)p1);
+ while ((uint)p1 < GetCompanyPoolSize()) {
+ if (IsValidCompanyID((CompanyID)p1)) {
+ SetLocalCompany((CompanyID)p1);
MarkWholeScreenDirty();
- return _local_player;
+ return _local_company;
}
p1 += p2;
}
- return _local_player;
+ return _local_company;
}
/**
@@ -106,15 +106,15 @@ struct CheatEntry {
};
static const CheatEntry _cheats_ui[] = {
- {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
- {SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat },
- {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL },
- {SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_settings_game.game_creation.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat},
- {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
+ {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
+ {SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
+ {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL },
+ {SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_settings_game.game_creation.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat },
+ {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
};
@@ -163,11 +163,11 @@ struct CheatWindow : Window {
/* Display date for change date cheat */
case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break;
- /* Draw colored flag for change player cheat */
+ /* Draw colored flag for change company cheat */
case STR_CHEAT_CHANGE_PLAYER:
SetDParam(0, val);
GetString(buf, STR_CHEAT_CHANGE_PLAYER, lastof(buf));
- DrawPlayerIcon(_current_player, 60 + GetStringBoundingBox(buf).width, y + 2);
+ DrawCompanyIcon(_current_company, 60 + GetStringBoundingBox(buf).width, y + 2);
break;
/* Set correct string for switch climate cheat */
diff --git a/src/cheat_type.h b/src/cheat_type.h
index 4fd802017..5dbf08106 100644
--- a/src/cheat_type.h
+++ b/src/cheat_type.h
@@ -20,7 +20,7 @@ struct Cheat {
*/
struct Cheats {
Cheat magic_bulldozer; ///< dynamite industries, unmovables
- Cheat switch_player; ///< change to another player
+ Cheat switch_company; ///< change to another company
Cheat money; ///< get rich or poor
Cheat crossing_tunnels; ///< allow tunnels that cross each other
Cheat build_in_pause; ///< build while in pause mode
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index c5eb652a5..74687f5f0 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -339,7 +339,7 @@ static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
td->owner[0] = GetTileOwner(tile);
}
-static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Clear(TileIndex tile, Owner old_owner, Owner new_owner)
{
return;
}
diff --git a/src/command.cpp b/src/command.cpp
index 034848271..ad5a9cf12 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -105,8 +105,8 @@ DEF_COMMAND(CmdRestoreOrderIndex);
DEF_COMMAND(CmdBuildIndustry);
DEF_COMMAND(CmdBuildCompanyHQ);
-DEF_COMMAND(CmdSetPlayerFace);
-DEF_COMMAND(CmdSetPlayerColor);
+DEF_COMMAND(CmdSetCompanyManagerFace);
+DEF_COMMAND(CmdSetCompanyColor);
DEF_COMMAND(CmdIncreaseLoan);
DEF_COMMAND(CmdDecreaseLoan);
@@ -165,7 +165,7 @@ DEF_COMMAND(CmdMoneyCheat);
DEF_COMMAND(CmdBuildCanal);
DEF_COMMAND(CmdBuildLock);
-DEF_COMMAND(CmdPlayerCtrl);
+DEF_COMMAND(CmdCompanyCtrl);
DEF_COMMAND(CmdLevelLand);
@@ -255,8 +255,8 @@ static const Command _command_proc_table[] = {
{CmdBuildIndustry, 0}, /* CMD_BUILD_INDUSTRY */
{CmdBuildCompanyHQ, CMD_AUTO}, /* CMD_BUILD_COMPANY_HQ */
- {CmdSetPlayerFace, 0}, /* CMD_SET_PLAYER_FACE */
- {CmdSetPlayerColor, 0}, /* CMD_SET_PLAYER_COLOR */
+ {CmdSetCompanyManagerFace, 0}, /* CMD_SET_COMPANY_MANAGER_FACE */
+ {CmdSetCompanyColor, 0}, /* CMD_SET_COMPANY_COLOR */
{CmdIncreaseLoan, 0}, /* CMD_INCREASE_LOAN */
{CmdDecreaseLoan, 0}, /* CMD_DECREASE_LOAN */
@@ -310,7 +310,7 @@ static const Command _command_proc_table[] = {
{CmdMoneyCheat, CMD_OFFLINE}, /* CMD_MONEY_CHEAT */
{CmdBuildCanal, CMD_AUTO}, /* CMD_BUILD_CANAL */
- {CmdPlayerCtrl, 0}, /* CMD_PLAYER_CTRL */
+ {CmdCompanyCtrl, 0}, /* CMD_COMPANY_CTRL */
{CmdLevelLand, CMD_AUTO}, /* CMD_LEVEL_LAND */
@@ -417,7 +417,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32
!(flags & DC_QUERY_COST) &&
!(flags & DC_BANKRUPT) &&
res.GetCost() != 0 &&
- !CheckPlayerHasMoney(res)) {
+ !CheckCompanyHasMoney(res)) {
goto error;
}
@@ -441,10 +441,10 @@ error:
/* if toplevel, subtract the money. */
if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) {
- SubtractMoneyFromPlayer(res);
- /* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player */
- if (tile != 0 && IsValidPlayerID(_current_player)) {
- GetPlayer(_current_player)->last_build_coordinate = tile;
+ SubtractMoneyFromCompany(res);
+ /* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of company */
+ if (tile != 0 && IsValidCompanyID(_current_company)) {
+ GetCompany(_current_company)->last_build_coordinate = tile;
}
}
@@ -454,30 +454,30 @@ error:
/*!
* This functions returns the money which can be used to execute a command.
- * This is either the money of the current player or INT64_MAX if there
- * is no such a player "at the moment" like the server itself.
+ * This is either the money of the current company or INT64_MAX if there
+ * is no such a company "at the moment" like the server itself.
*
- * @return The available money of a player or INT64_MAX
+ * @return The available money of a company or INT64_MAX
*/
Money GetAvailableMoneyForCommand()
{
- PlayerID pid = _current_player;
- if (!IsValidPlayerID(pid)) return INT64_MAX;
- return GetPlayer(pid)->player_money;
+ CompanyID company = _current_company;
+ if (!IsValidCompanyID(company)) return INT64_MAX;
+ return GetCompany(company)->money;
}
/*!
- * Toplevel network safe docommand function for the current player. Must not be called recursively.
+ * Toplevel network safe docommand function for the current company. Must not be called recursively.
* The callback is called when the command succeeded or failed. The parameters
* tile, p1 and p2 are from the #CommandProc function. The paramater cmd is the command to execute.
- * The parameter my_cmd is used to indicate if the command is from a player or the server.
+ * The parameter my_cmd is used to indicate if the command is from a company or the server.
*
* @param tile The tile to perform a command on (see #CommandProc)
* @param p1 Additional data for the command (see #CommandProc)
* @param p2 Additional data for the command (see #CommandProc)
* @param callback A callback function to call after the command is finished
* @param cmd The command to execute (a CMD_* value)
- * @param my_cmd indicator if the command is from a player or server (to display error messages for a user)
+ * @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
* @return true if the command succeeded, else false
*/
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd)
@@ -505,7 +505,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/** Spectator has no rights except for the (dedicated) server which
* is/can be a spectator but as the server it can do anything */
- if (_current_player == PLAYER_SPECTATOR && !_network_server) {
+ if (_current_company == COMPANY_SPECTATOR && !_network_server) {
if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y);
_cmd_text = NULL;
return false;
@@ -547,7 +547,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/* cost estimation only? */
if (!IsGeneratingWorld() &&
_shift_pressed &&
- IsLocalPlayer() &&
+ IsLocalCompany() &&
!(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR)) &&
(cmd & 0xFF) != CMD_PAUSE) {
/* estimate the cost. */
@@ -578,33 +578,33 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
goto show_error;
}
/* no money? Only check if notest is off */
- if (!notest && res.GetCost() != 0 && !CheckPlayerHasMoney(res)) goto show_error;
+ if (!notest && res.GetCost() != 0 && !CheckCompanyHasMoney(res)) goto show_error;
}
#ifdef ENABLE_NETWORK
/** If we are in network, and the command is not from the network
* send it to the command-queue and abort execution
- * If we are a dedicated server temporarily switch local player, otherwise
+ * If we are a dedicated server temporarily switch local company, otherwise
* the other parties won't be able to execute our command and will desync.
* We also need to do this if the server's company has gone bankrupt
* @todo Rewrite (dedicated) server to something more than a dirty hack!
*/
if (_networking && !(cmd & CMD_NETWORK_COMMAND)) {
- PlayerID pbck = _local_player;
- if (_network_dedicated || (_network_server && pbck == PLAYER_SPECTATOR)) _local_player = PLAYER_FIRST;
+ CompanyID pbck = _local_company;
+ if (_network_dedicated || (_network_server && pbck == COMPANY_SPECTATOR)) _local_company = COMPANY_FIRST;
NetworkSend_Command(tile, p1, p2, cmd, callback);
- if (_network_dedicated || (_network_server && pbck == PLAYER_SPECTATOR)) _local_player = pbck;
+ if (_network_dedicated || (_network_server && pbck == COMPANY_SPECTATOR)) _local_company = pbck;
_docommand_recursive = 0;
_cmd_text = NULL;
ClearStorageChanges(false);
return true;
}
#endif /* ENABLE_NETWORK */
- DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text);
+ DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd, _cmd_text);
- /* update last build coordinate of player. */
- if (tile != 0 && IsValidPlayerID(_current_player)) {
- GetPlayer(_current_player)->last_build_coordinate = tile;
+ /* update last build coordinate of company. */
+ if (tile != 0 && IsValidCompanyID(_current_company)) {
+ GetCompany(_current_company)->last_build_coordinate = tile;
}
/* Actually try and execute the command. If no cost-type is given
@@ -622,12 +622,12 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
}
}
- SubtractMoneyFromPlayer(res2);
+ SubtractMoneyFromCompany(res2);
/* update signals if needed */
UpdateSignalsInBuffer();
- if (IsLocalPlayer() && _game_mode != GM_EDITOR) {
+ if (IsLocalCompany() && _game_mode != GM_EDITOR) {
if (res2.GetCost() != 0 && tile != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2.GetCost());
if (_additional_cash_required != 0) {
SetDParam(0, _additional_cash_required);
@@ -645,7 +645,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
show_error:
/* show error message if the command fails? */
- if (IsLocalPlayer() && error_part1 != 0 && my_cmd) {
+ if (IsLocalCompany() && error_part1 != 0 && my_cmd) {
ShowErrorMessage(_error_message, error_part1, x, y);
}
diff --git a/src/command_type.h b/src/command_type.h
index 0e75187d5..c990f1a2c 100644
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -201,8 +201,8 @@ enum {
CMD_BUILD_INDUSTRY, ///< build a new industry
CMD_BUILD_COMPANY_HQ, ///< build the company headquarter
- CMD_SET_PLAYER_FACE, ///< set the face of the player/company
- CMD_SET_PLAYER_COLOR, ///< set the color of the player/company
+ CMD_SET_COMPANY_MANAGER_FACE, ///< set the manager's face of the company
+ CMD_SET_COMPANY_COLOR, ///< set the color of the company
CMD_INCREASE_LOAN, ///< increase the loan from the bank
CMD_DECREASE_LOAN, ///< decrease the loan from the bank
@@ -254,7 +254,7 @@ enum {
CMD_MONEY_CHEAT, ///< do the money cheat
CMD_BUILD_CANAL, ///< build a canal
- CMD_PLAYER_CTRL, ///< used in multiplayer to create a new player etc.
+ CMD_COMPANY_CTRL, ///< used in multiplayer to create a new companies etc.
CMD_LEVEL_LAND, ///< level land
CMD_REFIT_RAIL_VEHICLE, ///< refit the cargo space of a train
@@ -264,7 +264,7 @@ enum {
CMD_BUILD_SIGNAL_TRACK, ///< add signals along a track (by dragging)
CMD_REMOVE_SIGNAL_TRACK, ///< remove signals along a track (by dragging)
- CMD_GIVE_MONEY, ///< give money to an other player
+ CMD_GIVE_MONEY, ///< give money to another company
CMD_CHANGE_PATCH_SETTING, ///< change a patch setting
CMD_SET_AUTOREPLACE, ///< set an autoreplace entry
diff --git a/src/console.cpp b/src/console.cpp
index 48bb2f941..60851cc2f 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -79,7 +79,7 @@ void IConsoleFree()
/**
* Handle the printing of text entered into the console or redirected there
- * by any other means. Text can be redirected to other players in a network game
+ * by any other means. Text can be redirected to other clients in a network game
* as well as to a logfile. If the network server is a dedicated server, all activities
* are also logged. All lines to print are added to a temporary buffer which can be
* used as a history to print them onscreen
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index c0a7b1c7d..d2eb3db4f 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -375,7 +375,7 @@ DEF_CONSOLE_CMD(ConBan)
uint32 index;
if (argc == 0) {
- IConsoleHelp("Ban a player from a network game. Usage: 'ban <ip | client-id>'");
+ IConsoleHelp("Ban a client from a network game. Usage: 'ban <ip | client-id>'");
IConsoleHelp("For client-id's, see the command 'clients'");
IConsoleHelp("If the client is no longer online, you can still ban his/her IP");
return true;
@@ -408,7 +408,7 @@ DEF_CONSOLE_CMD(ConBan)
if (ci != NULL) {
IConsolePrint(CC_DEFAULT, "Client banned");
- banip = GetPlayerIP(ci);
+ banip = GetClientIP(ci);
NetworkServerSendError(index, NETWORK_ERROR_KICKED);
} else {
IConsolePrint(CC_DEFAULT, "Client not online, banned IP");
@@ -430,7 +430,7 @@ DEF_CONSOLE_CMD(ConUnBan)
uint i, index;
if (argc == 0) {
- IConsoleHelp("Unban a player from a network game. Usage: 'unban <ip | client-id>'");
+ IConsoleHelp("Unban a client from a network game. Usage: 'unban <ip | client-id>'");
IConsoleHelp("For a list of banned IP's, see the command 'banlist'");
return true;
}
@@ -540,13 +540,13 @@ DEF_CONSOLE_CMD(ConStatus)
DEF_CONSOLE_CMD(ConServerInfo)
{
if (argc == 0) {
- IConsoleHelp("List current and maximum client/player limits. Usage 'server_info'");
+ IConsoleHelp("List current and maximum client/company limits. Usage 'server_info'");
IConsoleHelp("You can change these values by setting the variables 'max_clients', 'max_companies' and 'max_spectators'");
return true;
}
IConsolePrintF(CC_DEFAULT, "Current/maximum clients: %2d/%2d", _network_game_info.clients_on, _settings_client.network.max_clients);
- IConsolePrintF(CC_DEFAULT, "Current/maximum companies: %2d/%2d", ActivePlayerCount(), _settings_client.network.max_companies);
+ IConsolePrintF(CC_DEFAULT, "Current/maximum companies: %2d/%2d", ActiveCompanyCount(), _settings_client.network.max_companies);
IConsolePrintF(CC_DEFAULT, "Current/maximum spectators: %2d/%2d", NetworkSpectatorCount(), _settings_client.network.max_spectators);
return true;
@@ -558,7 +558,7 @@ DEF_CONSOLE_CMD(ConKick)
uint32 index;
if (argc == 0) {
- IConsoleHelp("Kick a player from a network game. Usage: 'kick <ip | client-id>'");
+ IConsoleHelp("Kick a client from a network game. Usage: 'kick <ip | client-id>'");
IConsoleHelp("For client-id's, see the command 'clients'");
return true;
}
@@ -594,32 +594,32 @@ DEF_CONSOLE_CMD(ConKick)
DEF_CONSOLE_CMD(ConResetCompany)
{
- PlayerID index;
+ CompanyID index;
if (argc == 0) {
IConsoleHelp("Remove an idle company from the game. Usage: 'reset_company <company-id>'");
- IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Player 1 is 1, etc.");
+ IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
return true;
}
if (argc != 2) return false;
- index = (PlayerID)(atoi(argv[1]) - 1);
+ index = (CompanyID)(atoi(argv[1]) - 1);
/* Check valid range */
- if (!IsValidPlayerID(index)) {
- IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_PLAYERS);
+ if (!IsValidCompanyID(index)) {
+ IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
return true;
}
- const Player *p = GetPlayer(index);
+ const Company *c = GetCompany(index);
- if (p->is_ai) {
+ if (c->is_ai) {
IConsoleError("Company is owned by an AI.");
return true;
}
- if (NetworkCompanyHasPlayers(index)) {
+ if (NetworkCompanyHasClients(index)) {
IConsoleError("Cannot remove company: a client is connected to that company.");
return false;
}
@@ -630,7 +630,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
}
/* It is safe to remove this company */
- DoCommandP(0, 2, index, NULL, CMD_PLAYER_CTRL);
+ DoCommandP(0, 2, index, NULL, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "Company deleted.");
return true;
@@ -648,8 +648,8 @@ DEF_CONSOLE_CMD(ConNetworkClients)
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
IConsolePrintF(CC_INFO, "Client #%1d name: '%s' company: %1d IP: %s",
ci->client_index, ci->client_name,
- ci->client_playas + (IsValidPlayerID(ci->client_playas) ? 1 : 0),
- GetPlayerIP(ci));
+ ci->client_playas + (IsValidCompanyID(ci->client_playas) ? 1 : 0),
+ GetClientIP(ci));
}
return true;
@@ -659,13 +659,13 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
{
char *ip;
const char *port = NULL;
- const char *player = NULL;
+ const char *company = NULL;
uint16 rport;
if (argc == 0) {
IConsoleHelp("Connect to a remote OTTD server and join the game. Usage: 'connect <ip>'");
- IConsoleHelp("IP can contain port and player: 'IP[[#Player]:Port]', eg: 'server.ottd.org#2:443'");
- IConsoleHelp("Player #255 is spectator all others are a certain company with Company 1 being #1");
+ IConsoleHelp("IP can contain port and company: 'IP[[#Company]:Port]', eg: 'server.ottd.org#2:443'");
+ IConsoleHelp("Company #255 is spectator all others are a certain company with Company 1 being #1");
return true;
}
@@ -675,20 +675,20 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
ip = argv[1];
/* Default settings: default port and new company */
rport = NETWORK_DEFAULT_PORT;
- _network_playas = PLAYER_NEW_COMPANY;
+ _network_playas = COMPANY_NEW_COMPANY;
- ParseConnectionString(&player, &port, ip);
+ ParseConnectionString(&company, &port, ip);
IConsolePrintF(CC_DEFAULT, "Connecting to %s...", ip);
- if (player != NULL) {
- _network_playas = (PlayerID)atoi(player);
- IConsolePrintF(CC_DEFAULT, " player-no: %d", _network_playas);
+ if (company != NULL) {
+ _network_playas = (CompanyID)atoi(company);
+ IConsolePrintF(CC_DEFAULT, " company-no: %d", _network_playas);
- /* From a user pov 0 is a new player, internally it's different and all
- * players are offset by one to ease up on users (eg players 1-8 not 0-7) */
- if (_network_playas != PLAYER_SPECTATOR) {
+ /* From a user pov 0 is a new company, internally it's different and all
+ * companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
+ if (_network_playas != COMPANY_SPECTATOR) {
_network_playas--;
- if (!IsValidPlayerID(_network_playas)) return false;
+ if (!IsValidCompanyID(_network_playas)) return false;
}
}
if (port != NULL) {
@@ -1138,24 +1138,24 @@ DEF_CONSOLE_CMD(ConSay)
return true;
}
-DEF_CONSOLE_CMD(ConPlayers)
+DEF_CONSOLE_CMD(ConCompanies)
{
- Player *p;
+ Company *c;
if (argc == 0) {
- IConsoleHelp("List the in-game details of all clients connected to the server. Usage 'players'");
+ IConsoleHelp("List the in-game details of all clients connected to the server. Usage 'companies'");
return true;
}
NetworkPopulateCompanyInfo();
- FOR_ALL_PLAYERS(p) {
+ FOR_ALL_COMPANIES(c) {
char buffer[512];
- const NetworkPlayerInfo *npi = &_network_player_info[p->index];
+ const NetworkCompanyInfo *npi = &_network_company_info[c->index];
- GetString(buffer, STR_00D1_DARK_BLUE + _player_colors[p->index], lastof(buffer));
+ GetString(buffer, STR_00D1_DARK_BLUE + _company_colours[c->index], lastof(buffer));
IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: %" OTTD_PRINTF64 "d Loan: %" OTTD_PRINTF64 "d Value: %" OTTD_PRINTF64 "d (T:%d, R:%d, P:%d, S:%d) %sprotected",
- p->index + 1, buffer, npi->company_name, p->inaugurated_year, (int64)p->player_money, (int64)p->current_loan, (int64)CalculateCompanyValue(p),
+ c->index + 1, buffer, npi->company_name, c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
/* trains */ npi->num_vehicle[0],
/* lorry + bus */ npi->num_vehicle[1] + npi->num_vehicle[2],
/* planes */ npi->num_vehicle[3],
@@ -1166,26 +1166,26 @@ DEF_CONSOLE_CMD(ConPlayers)
return true;
}
-DEF_CONSOLE_CMD(ConSayPlayer)
+DEF_CONSOLE_CMD(ConSayCompany)
{
if (argc == 0) {
- IConsoleHelp("Chat to a certain player in a multiplayer game. Usage: 'say_player <player-no> \"<msg>\"'");
- IConsoleHelp("PlayerNo is the player that plays as company <playerno>, 1 through max_players");
+ IConsoleHelp("Chat to a certain company in a multiplayer game. Usage: 'say_company <company-no> \"<msg>\"'");
+ IConsoleHelp("CompanyNo is the company that plays as company <companyno>, 1 through max_companies");
return true;
}
if (argc != 3) return false;
- PlayerID player_id = (PlayerID)(atoi(argv[1]) - 1);
- if (!IsValidPlayerID(player_id)) {
- IConsolePrintF(CC_DEFAULT, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS);
+ CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
+ if (!IsValidCompanyID(company_id)) {
+ IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
return true;
}
if (!_network_server) {
- NetworkClientSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, player_id, argv[2]);
+ NetworkClientSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2]);
} else {
- NetworkServerSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, player_id, argv[2], NETWORK_SERVER_INDEX);
+ NetworkServerSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2], NETWORK_SERVER_INDEX);
}
return true;
@@ -1194,7 +1194,7 @@ DEF_CONSOLE_CMD(ConSayPlayer)
DEF_CONSOLE_CMD(ConSayClient)
{
if (argc == 0) {
- IConsoleHelp("Chat to a certain player in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'");
+ IConsoleHelp("Chat to a certain client in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'");
IConsoleHelp("For client-id's, see the command 'clients'");
return true;
}
@@ -1212,16 +1212,16 @@ DEF_CONSOLE_CMD(ConSayClient)
extern void HashCurrentCompanyPassword();
-/* Also use from within player_gui to change the password graphically */
+/* Also use from within company_gui to change the password graphically */
bool NetworkChangeCompanyPassword(byte argc, char *argv[])
{
if (argc == 0) {
- if (!IsValidPlayerID(_local_player)) return true; // dedicated server
- IConsolePrintF(CC_WARNING, "Current value for 'company_pw': %s", _network_player_info[_local_player].password);
+ if (!IsValidCompanyID(_local_company)) return true; // dedicated server
+ IConsolePrintF(CC_WARNING, "Current value for 'company_pw': %s", _network_company_info[_local_company].password);
return true;
}
- if (!IsValidPlayerID(_local_player)) {
+ if (!IsValidCompanyID(_local_company)) {
IConsoleError("You have to own a company to make use of this command.");
return false;
}
@@ -1230,7 +1230,7 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
if (strcmp(argv[0], "*") == 0) argv[0][0] = '\0';
- ttd_strlcpy(_network_player_info[_local_player].password, argv[0], sizeof(_network_player_info[_local_player].password));
+ ttd_strlcpy(_network_company_info[_local_company].password, argv[0], sizeof(_network_company_info[_local_company].password));
if (!_network_server) {
NetworkClientSetPassword();
@@ -1238,7 +1238,7 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
HashCurrentCompanyPassword();
}
- IConsolePrintF(CC_WARNING, "'company_pw' changed to: %s", _network_player_info[_local_player].password);
+ IConsolePrintF(CC_WARNING, "'company_pw' changed to: %s", _network_company_info[_local_company].password);
return true;
}
@@ -1248,7 +1248,7 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
DEF_CONSOLE_CMD(ConPatch)
{
if (argc == 0) {
- IConsoleHelp("Change patch variables for all players. Usage: 'patch <name> [<value>]'");
+ IConsoleHelp("Change patch variables for all clients. Usage: 'patch <name> [<value>]'");
IConsoleHelp("Omitting <value> will print out the current value of the patch-setting.");
return true;
}
@@ -1384,10 +1384,12 @@ void IConsoleStdLibRegister()
/*** Networking commands ***/
IConsoleCmdRegister("say", ConSay);
IConsoleCmdHookAdd("say", ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork);
- IConsoleCmdRegister("players", ConPlayers);
- IConsoleCmdHookAdd("players", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
- IConsoleCmdRegister("say_player", ConSayPlayer);
- IConsoleCmdHookAdd("say_player", ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork);
+ IConsoleCmdRegister("companies", ConCompanies);
+ IConsoleCmdHookAdd("companies", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
+ IConsoleAliasRegister("players", "companies");
+ IConsoleCmdRegister("say_company", ConSayCompany);
+ IConsoleCmdHookAdd("say_company", ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork);
+ IConsoleAliasRegister("say_player", "say_company %+");
IConsoleCmdRegister("say_client", ConSayClient);
IConsoleCmdHookAdd("say_client", ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork);
@@ -1433,7 +1435,7 @@ void IConsoleStdLibRegister()
IConsoleAliasRegister("server_password", "patch server_password %+");
IConsoleAliasRegister("rcon_pw", "patch rcon_password %+");
IConsoleAliasRegister("rcon_password", "patch rcon_password %+");
- IConsoleAliasRegister("name", "patch player_name %+");
+ IConsoleAliasRegister("name", "patch client_name %+");
IConsoleAliasRegister("server_name", "patch server_name %+");
IConsoleAliasRegister("server_port", "patch server_port %+");
IConsoleAliasRegister("server_ip", "patch server_bind_ip %+");
@@ -1450,7 +1452,7 @@ void IConsoleStdLibRegister()
IConsoleAliasRegister("autoclean_protected", "patch autoclean_protected %+");
IConsoleAliasRegister("autoclean_unprotected", "patch autoclean_unprotected %+");
IConsoleAliasRegister("restart_game_year", "patch restart_game_year %+");
- IConsoleAliasRegister("min_players", "patch min_players %+");
+ IConsoleAliasRegister("min_players", "patch min_clients %+");
IConsoleAliasRegister("reload_cfg", "patch reload_cfg %+");
#endif /* ENABLE_NETWORK */
diff --git a/src/console_gui.cpp b/src/console_gui.cpp
index 295d461d7..ebca6f9bf 100644
--- a/src/console_gui.cpp
+++ b/src/console_gui.cpp
@@ -436,7 +436,7 @@ static void IConsoleHistoryNavigate(int direction)
/**
* Handle the printing of text entered into the console or redirected there
- * by any other means. Text can be redirected to other players in a network game
+ * by any other means. Text can be redirected to other clients in a network game
* as well as to a logfile. If the network server is a dedicated server, all activities
* are also logged. All lines to print are added to a temporary buffer which can be
* used as a history to print them onscreen
diff --git a/src/core/random_func.cpp b/src/core/random_func.cpp
index c2ff9d49e..d47be6a4f 100644
--- a/src/core/random_func.cpp
+++ b/src/core/random_func.cpp
@@ -42,7 +42,7 @@ void SetRandomSeed(uint32 seed)
uint32 DoRandom(int line, const char *file)
{
if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server)) {
- printf("Random [%d/%d] %s:%d\n",_frame_counter, (byte)_current_player, file, line);
+ printf("Random [%d/%d] %s:%d\n",_frame_counter, (byte)_current_company, file, line);
}
return _random.Next();
diff --git a/src/date.cpp b/src/date.cpp
index 180781ce5..d477b7359 100644
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -160,13 +160,13 @@ extern void WaypointsDailyLoop();
extern void EnginesDailyLoop();
extern void DisasterDailyLoop();
extern void IndustryDailyLoop();
-extern void PlayersMonthlyLoop();
+extern void CompaniesMonthlyLoop();
extern void EnginesMonthlyLoop();
extern void TownsMonthlyLoop();
extern void IndustryMonthlyLoop();
extern void StationMonthlyLoop();
-extern void PlayersYearlyLoop();
+extern void CompaniesYearlyLoop();
extern void TrainsYearlyLoop();
extern void RoadVehiclesYearlyLoop();
extern void AircraftYearlyLoop();
@@ -255,7 +255,7 @@ void IncreaseDate()
}
InvalidateWindowClasses(WC_CHEATS);
- PlayersMonthlyLoop();
+ CompaniesMonthlyLoop();
EnginesMonthlyLoop();
TownsMonthlyLoop();
IndustryMonthlyLoop();
@@ -270,7 +270,7 @@ void IncreaseDate()
_cur_year = ymd.year;
/* yes, call various yearly loops */
- PlayersYearlyLoop();
+ CompaniesYearlyLoop();
TrainsYearlyLoop();
RoadVehiclesYearlyLoop();
AircraftYearlyLoop();
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index f09386a3a..12cc79f25 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -314,7 +314,7 @@ struct DepotWindow : Window {
uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
/* setup disabled buttons */
- this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_player),
+ this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_company),
DEPOT_WIDGET_STOP_ALL,
DEPOT_WIDGET_START_ALL,
DEPOT_WIDGET_SELL,
@@ -702,7 +702,7 @@ struct DepotWindow : Window {
this->type = type;
_backup_orders_tile = 0;
- assert(IsPlayerBuildableVehicleType(type)); // ensure that we make the call with a valid type
+ assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type
/* Resize the window according to the vehicle type */
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index fba812766..81d7bfaa6 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -69,11 +69,11 @@ static void DisasterClearSquare(TileIndex tile)
switch (GetTileType(tile)) {
case MP_RAILWAY:
- if (IsHumanPlayer(GetTileOwner(tile)) && !IsRailWaypoint(tile)) {
- PlayerID p = _current_player;
- _current_player = OWNER_WATER;
+ if (IsHumanCompany(GetTileOwner(tile)) && !IsRailWaypoint(tile)) {
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_WATER;
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
- _current_player = p;
+ _current_company = old_company;
/* update signals in buffer */
UpdateSignalsInBuffer();
@@ -81,10 +81,10 @@ static void DisasterClearSquare(TileIndex tile)
break;
case MP_HOUSE: {
- PlayerID p = _current_player;
- _current_player = OWNER_NONE;
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_NONE;
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
- _current_player = p;
+ _current_company = old_company;
break;
}
@@ -229,7 +229,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
IsAirport(tile) &&
- IsHumanPlayer(GetTileOwner(tile))) {
+ IsHumanCompany(GetTileOwner(tile))) {
v->current_order.SetDestination(1);
v->age = 0;
@@ -253,7 +253,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
IsAirport(tile) &&
- IsHumanPlayer(GetTileOwner(tile))) {
+ IsHumanCompany(GetTileOwner(tile))) {
st = GetStationByTile(tile);
CLRBITS(st->airport_flags, RUNWAY_IN_block);
}
@@ -294,7 +294,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
IsAirport(tile) &&
- IsHumanPlayer(GetTileOwner(tile))) {
+ IsHumanCompany(GetTileOwner(tile))) {
st = GetStationByTile(tile);
SETBITS(st->airport_flags, RUNWAY_IN_block);
}
@@ -331,7 +331,7 @@ static void DisasterTick_Ufo(Vehicle *v)
v->current_order.SetDestination(1);
FOR_ALL_VEHICLES(u) {
- if (u->type == VEH_ROAD && IsRoadVehFront(u) && IsHumanPlayer(u->owner)) {
+ if (u->type == VEH_ROAD && IsRoadVehFront(u) && IsHumanCompany(u->owner)) {
v->dest_tile = u->index;
v->age = 0;
return;
@@ -644,7 +644,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
do {
if (IsTileType(tile, MP_RAILWAY) &&
IsPlainRailTile(tile) &&
- IsHumanPlayer(GetTileOwner(tile))) {
+ IsHumanCompany(GetTileOwner(tile))) {
break;
}
tile = TILE_MASK(tile + 1);
@@ -773,7 +773,7 @@ static void Disaster_Zeppeliner_Init()
FOR_ALL_STATIONS(st) {
if (st->airport_tile != 0 &&
st->airport_type <= 1 &&
- IsHumanPlayer(st->owner)) {
+ IsHumanCompany(st->owner)) {
x = (TileX(st->xy) + 2) * TILE_SIZE;
break;
}
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 001813828..b8a785162 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -278,7 +278,7 @@ static const WindowDesc _build_docks_toolbar_desc = {
void ShowBuildDocksToolbar()
{
- if (!IsValidPlayerID(_current_player)) return;
+ if (!IsValidCompanyID(_current_company)) return;
DeleteWindowByClass(WC_BUILD_TOOLBAR);
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
diff --git a/src/dummy_land.cpp b/src/dummy_land.cpp
index 423d7db41..67eac6214 100644
--- a/src/dummy_land.cpp
+++ b/src/dummy_land.cpp
@@ -59,7 +59,7 @@ static void ClickTile_Dummy(TileIndex tile)
/* not used */
}
-static void ChangeTileOwner_Dummy(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Dummy(TileIndex tile, Owner old_owner, Owner new_owner)
{
/* not used */
}
diff --git a/src/economy.cpp b/src/economy.cpp
index 8629fc270..7523d4d5d 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -96,18 +96,18 @@ const ScoreInfo _score_info[] = {
{ SCORE_TOTAL, 0, 0 }
};
-int _score_part[MAX_PLAYERS][SCORE_END];
+int _score_part[MAX_COMPANIES][SCORE_END];
Economy _economy;
-Subsidy _subsidies[MAX_PLAYERS];
+Subsidy _subsidies[MAX_COMPANIES];
Prices _price;
uint16 _price_frac[NUM_PRICES];
Money _cargo_payment_rates[NUM_CARGO];
uint16 _cargo_payment_rates_frac[NUM_CARGO];
Money _additional_cash_required;
-Money CalculateCompanyValue(const Player* p)
+Money CalculateCompanyValue(const Company *c)
{
- PlayerID owner = p->index;
+ Owner owner = c->index;
Money value = 0;
Station *st;
@@ -132,8 +132,8 @@ Money CalculateCompanyValue(const Player* p)
}
/* Add real money value */
- value -= p->current_loan;
- value += p->player_money;
+ value -= c->current_loan;
+ value += c->money;
return max(value, (Money)1);
}
@@ -141,17 +141,17 @@ Money CalculateCompanyValue(const Player* p)
/** if update is set to true, the economy is updated with this score
* (also the house is updated, should only be true in the on-tick event)
* @param update the economy with calculated score
- * @param p player been evaluated
- * @return actual score of this player
+ * @param c company been evaluated
+ * @return actual score of this company
* */
-int UpdateCompanyRatingAndValue(Player *p, bool update)
+int UpdateCompanyRatingAndValue(Company *c, bool update)
{
- byte owner = p->index;
+ Owner owner = c->index;
int score = 0;
memset(_score_part[owner], 0, sizeof(_score_part[owner]));
-/* Count vehicles */
+ /* Count vehicles */
{
Vehicle *v;
Money min_profit = 0;
@@ -160,7 +160,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
FOR_ALL_VEHICLES(v) {
if (v->owner != owner) continue;
- if (IsPlayerBuildableVehicleType(v->type) && v->IsPrimaryVehicle()) {
+ if (IsCompanyBuildableVehicleType(v->type) && v->IsPrimaryVehicle()) {
num++;
if (v->age > 730) {
/* Find the vehicle with the lowest amount of profit */
@@ -180,7 +180,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
_score_part[owner][SCORE_MIN_PROFIT] = ClampToI32(min_profit);
}
-/* Count stations */
+ /* Count stations */
{
uint num = 0;
const Station* st;
@@ -191,61 +191,62 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
_score_part[owner][SCORE_STATIONS] = num;
}
-/* Generate statistics depending on recent income statistics */
+ /* Generate statistics depending on recent income statistics */
{
- int numec = min(p->num_valid_stat_ent, 12);
+ int numec = min(c->num_valid_stat_ent, 12);
if (numec != 0) {
- const PlayerEconomyEntry *pee = p->old_economy;
- Money min_income = pee->income + pee->expenses;
- Money max_income = pee->income + pee->expenses;
+ const CompanyEconomyEntry *cee = c->old_economy;
+ Money min_income = cee->income + cee->expenses;
+ Money max_income = cee->income + cee->expenses;
do {
- min_income = min(min_income, pee->income + pee->expenses);
- max_income = max(max_income, pee->income + pee->expenses);
- } while (++pee,--numec);
+ min_income = min(min_income, cee->income + cee->expenses);
+ max_income = max(max_income, cee->income + cee->expenses);
+ } while (++cee,--numec);
- if (min_income > 0)
+ if (min_income > 0) {
_score_part[owner][SCORE_MIN_INCOME] = ClampToI32(min_income);
+ }
_score_part[owner][SCORE_MAX_INCOME] = ClampToI32(max_income);
}
}
-/* Generate score depending on amount of transported cargo */
+ /* Generate score depending on amount of transported cargo */
{
- const PlayerEconomyEntry* pee;
+ const CompanyEconomyEntry *cee;
int numec;
uint32 total_delivered;
- numec = min(p->num_valid_stat_ent, 4);
+ numec = min(c->num_valid_stat_ent, 4);
if (numec != 0) {
- pee = p->old_economy;
+ cee = c->old_economy;
total_delivered = 0;
do {
- total_delivered += pee->delivered_cargo;
- } while (++pee,--numec);
+ total_delivered += cee->delivered_cargo;
+ } while (++cee,--numec);
_score_part[owner][SCORE_DELIVERED] = total_delivered;
}
}
-/* Generate score for variety of cargo */
+ /* Generate score for variety of cargo */
{
- uint num = CountBits(p->cargo_types);
+ uint num = CountBits(c->cargo_types);
_score_part[owner][SCORE_CARGO] = num;
- if (update) p->cargo_types = 0;
+ if (update) c->cargo_types = 0;
}
-/* Generate score for player money */
+ /* Generate score for company's money */
{
- if (p->player_money > 0) {
- _score_part[owner][SCORE_MONEY] = ClampToI32(p->player_money);
+ if (c->money > 0) {
+ _score_part[owner][SCORE_MONEY] = ClampToI32(c->money);
}
}
-/* Generate score for loan */
+ /* Generate score for loan */
{
- _score_part[owner][SCORE_LOAN] = ClampToI32(_score_info[SCORE_LOAN].needed - p->current_loan);
+ _score_part[owner][SCORE_LOAN] = ClampToI32(_score_info[SCORE_LOAN].needed - c->current_loan);
}
/* Now we calculate the score for each item.. */
@@ -269,92 +270,92 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
}
if (update) {
- p->old_economy[0].performance_history = score;
- UpdateCompanyHQ(p, score);
- p->old_economy[0].company_value = CalculateCompanyValue(p);
+ c->old_economy[0].performance_history = score;
+ UpdateCompanyHQ(c, score);
+ c->old_economy[0].company_value = CalculateCompanyValue(c);
}
InvalidateWindow(WC_PERFORMANCE_DETAIL, 0);
return score;
}
-/* use PLAYER_SPECTATOR as new_player to delete the player. */
-void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
+/* use INVALID_OWNER as new_owner to delete the company. */
+void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
{
Town *t;
- PlayerID old = _current_player;
+ CompanyID old = _current_company;
- assert(old_player != new_player);
+ assert(old_owner != new_owner);
{
- Player *p;
+ Company *c;
uint i;
- /* See if the old_player had shares in other companies */
- _current_player = old_player;
- FOR_ALL_PLAYERS(p) {
+ /* See if the old_owner had shares in other companies */
+ _current_company = old_owner;
+ FOR_ALL_COMPANIES(c) {
for (i = 0; i < 4; i++) {
- if (p->share_owners[i] == old_player) {
+ if (c->share_owners[i] == old_owner) {
/* Sell his shares */
- CommandCost res = DoCommand(0, p->index, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
+ CommandCost res = DoCommand(0, c->index, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
/* Because we are in a DoCommand, we can't just execute an other one and
* expect the money to be removed. We need to do it ourself! */
- SubtractMoneyFromPlayer(res);
+ SubtractMoneyFromCompany(res);
}
}
}
/* Sell all the shares that people have on this company */
- p = GetPlayer(old_player);
+ c = GetCompany(old_owner);
for (i = 0; i < 4; i++) {
- _current_player = p->share_owners[i];
- if (_current_player != PLAYER_SPECTATOR) {
+ _current_company = c->share_owners[i];
+ if (_current_company != INVALID_OWNER) {
/* Sell the shares */
- CommandCost res = DoCommand(0, old_player, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
+ CommandCost res = DoCommand(0, old_owner, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
/* Because we are in a DoCommand, we can't just execute an other one and
* expect the money to be removed. We need to do it ourself! */
- SubtractMoneyFromPlayer(res);
+ SubtractMoneyFromCompany(res);
}
}
}
- _current_player = old_player;
+ _current_company = old_owner;
- /* Temporarily increase the player's money, to be sure that
+ /* Temporarily increase the company's money, to be sure that
* removing his/her property doesn't fail because of lack of money.
* Not too drastically though, because it could overflow */
- if (new_player == PLAYER_SPECTATOR) {
- GetPlayer(old_player)->player_money = UINT64_MAX >> 2; // jackpot ;p
+ if (new_owner == INVALID_OWNER) {
+ GetCompany(old_owner)->money = UINT64_MAX >> 2; // jackpot ;p
}
- if (new_player == PLAYER_SPECTATOR) {
+ if (new_owner == INVALID_OWNER) {
Subsidy *s;
for (s = _subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != CT_INVALID && s->age >= 12) {
- if (GetStation(s->to)->owner == old_player) s->cargo_type = CT_INVALID;
+ if (GetStation(s->to)->owner == old_owner) s->cargo_type = CT_INVALID;
}
}
}
/* Take care of rating in towns */
FOR_ALL_TOWNS(t) {
- /* If a player takes over, give the ratings to that player. */
- if (new_player != PLAYER_SPECTATOR) {
- if (HasBit(t->have_ratings, old_player)) {
- if (HasBit(t->have_ratings, new_player)) {
+ /* If a company takes over, give the ratings to that company. */
+ if (new_owner != INVALID_OWNER) {
+ if (HasBit(t->have_ratings, old_owner)) {
+ if (HasBit(t->have_ratings, new_owner)) {
// use max of the two ratings.
- t->ratings[new_player] = max(t->ratings[new_player], t->ratings[old_player]);
+ t->ratings[new_owner] = max(t->ratings[new_owner], t->ratings[old_owner]);
} else {
- SetBit(t->have_ratings, new_player);
- t->ratings[new_player] = t->ratings[old_player];
+ SetBit(t->have_ratings, new_owner);
+ t->ratings[new_owner] = t->ratings[old_owner];
}
}
}
- /* Reset the ratings for the old player */
- t->ratings[old_player] = RATING_INITIAL;
- ClrBit(t->have_ratings, old_player);
+ /* Reset the ratings for the old owner */
+ t->ratings[old_owner] = RATING_INITIAL;
+ ClrBit(t->have_ratings, old_owner);
}
{
@@ -366,7 +367,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
/* Determine Ids for the new vehicles */
FOR_ALL_VEHICLES(v) {
- if (v->owner == new_player) {
+ if (v->owner == new_owner) {
switch (v->type) {
case VEH_TRAIN: if (IsFrontEngine(v)) num_train++; break;
case VEH_ROAD: if (IsRoadVehFront(v)) num_road++; break;
@@ -378,8 +379,8 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
}
FOR_ALL_VEHICLES(v) {
- if (v->owner == old_player && IsInsideMM(v->type, VEH_TRAIN, VEH_AIRCRAFT + 1)) {
- if (new_player == PLAYER_SPECTATOR) {
+ if (v->owner == old_owner && IsInsideMM(v->type, VEH_TRAIN, VEH_AIRCRAFT + 1)) {
+ if (new_owner == INVALID_OWNER) {
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
@@ -408,10 +409,10 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
}
}
} else {
- v->owner = new_player;
+ v->owner = new_owner;
v->colormap = PAL_NONE;
v->group_id = DEFAULT_GROUP;
- if (IsEngineCountable(v)) GetPlayer(new_player)->num_engines[v->engine_type]++;
+ if (IsEngineCountable(v)) GetCompany(new_owner)->num_engines[v->engine_type]++;
switch (v->type) {
case VEH_TRAIN: if (IsFrontEngine(v)) v->unitnumber = ++num_train; break;
case VEH_ROAD: if (IsRoadVehFront(v)) v->unitnumber = ++num_road; break;
@@ -428,24 +429,24 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
{
TileIndex tile = 0;
do {
- ChangeTileOwner(tile, old_player, new_player);
+ ChangeTileOwner(tile, old_owner, new_owner);
} while (++tile != MapSize());
- if (new_player != PLAYER_SPECTATOR) {
- /* Update all signals because there can be new segment that was owned by two players
+ if (new_owner != INVALID_OWNER) {
+ /* Update all signals because there can be new segment that was owned by two companies
* and signals were not propagated
* Similiar with crossings - it is needed to bar crossings that weren't before
* because of different owner of crossing and approaching train */
tile = 0;
do {
- if (IsTileType(tile, MP_RAILWAY) && IsTileOwner(tile, new_player) && HasSignals(tile)) {
+ if (IsTileType(tile, MP_RAILWAY) && IsTileOwner(tile, new_owner) && HasSignals(tile)) {
TrackBits tracks = GetTrackBits(tile);
do { // there may be two tracks with signals for TRACK_BIT_HORZ and TRACK_BIT_VERT
Track track = RemoveFirstTrack(&tracks);
- if (HasSignalOnTrack(tile, track)) AddTrackToSignalBuffer(tile, track, new_player);
+ if (HasSignalOnTrack(tile, track)) AddTrackToSignalBuffer(tile, track, new_owner);
} while (tracks != TRACK_BIT_NONE);
- } else if (IsLevelCrossingTile(tile) && IsTileOwner(tile, new_player)) {
+ } else if (IsLevelCrossingTile(tile) && IsTileOwner(tile, new_owner)) {
UpdateLevelCrossing(tile);
}
} while (++tile != MapSize());
@@ -457,60 +458,60 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
/* In all cases clear replace engine rules.
* Even if it was copied, it could interfere with new owner's rules */
- RemoveAllEngineReplacementForPlayer(GetPlayer(old_player));
+ RemoveAllEngineReplacementForCompany(GetCompany(old_owner));
- if (new_player == PLAYER_SPECTATOR) {
- RemoveAllGroupsForPlayer(old_player);
+ if (new_owner == INVALID_OWNER) {
+ RemoveAllGroupsForCompany(old_owner);
} else {
Group *g;
FOR_ALL_GROUPS(g) {
- if (g->owner == old_player) g->owner = new_player;
+ if (g->owner == old_owner) g->owner = new_owner;
}
}
Sign *si;
FOR_ALL_SIGNS(si) {
- if (si->owner == old_player) si->owner = new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player;
+ if (si->owner == old_owner) si->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
}
/* Change color of existing windows */
- if (new_player != PLAYER_SPECTATOR) ChangeWindowOwner(old_player, new_player);
+ if (new_owner != INVALID_OWNER) ChangeWindowOwner(old_owner, new_owner);
- _current_player = old;
+ _current_company = old;
MarkWholeScreenDirty();
}
-static void ChangeNetworkOwner(PlayerID current_player, PlayerID new_player)
+static void ChangeNetworkOwner(Owner current_owner, Owner new_owner)
{
#ifdef ENABLE_NETWORK
if (!_networking) return;
- if (current_player == _local_player) {
- _network_playas = new_player;
- SetLocalPlayer(new_player);
+ if (current_owner == _local_company) {
+ _network_playas = new_owner;
+ SetLocalCompany(new_owner);
}
if (!_network_server) return;
- NetworkServerChangeOwner(current_player, new_player);
+ NetworkServerChangeOwner(current_owner, new_owner);
#endif /* ENABLE_NETWORK */
}
-static void PlayersCheckBankrupt(Player *p)
+static void CompanyCheckBankrupt(Company *c)
{
- /* If the player has money again, it does not go bankrupt */
- if (p->player_money >= 0) {
- p->quarters_of_bankrupcy = 0;
+ /* If the company has money again, it does not go bankrupt */
+ if (c->money >= 0) {
+ c->quarters_of_bankrupcy = 0;
return;
}
- p->quarters_of_bankrupcy++;
+ c->quarters_of_bankrupcy++;
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
- cni->FillData(p);
+ cni->FillData(c);
- switch (p->quarters_of_bankrupcy) {
+ switch (c->quarters_of_bankrupcy) {
default:
free(cni);
break;
@@ -522,9 +523,9 @@ static void PlayersCheckBankrupt(Player *p)
AddNewsItem(STR_02B6, NS_COMPANY_TROUBLE, 0, 0, cni);
break;
case 3: {
- /* XXX - In multiplayer, should we ask other players if it wants to take
+ /* XXX - In multiplayer, should we ask other companies if it wants to take
over when it is a human company? -- TrueLight */
- if (IsHumanPlayer(p->index)) {
+ if (IsHumanCompany(c->index)) {
SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE);
SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED);
SetDParamStr(2, cni->company_name);
@@ -534,11 +535,11 @@ static void PlayersCheckBankrupt(Player *p)
/* Check if the company has any value.. if not, declare it bankrupt
* right now */
- Money val = CalculateCompanyValue(p);
+ Money val = CalculateCompanyValue(c);
if (val > 0) {
- p->bankrupt_value = val;
- p->bankrupt_asked = 1 << p->index; // Don't ask the owner
- p->bankrupt_timeout = 0;
+ c->bankrupt_value = val;
+ c->bankrupt_asked = 1 << c->index; // Don't ask the owner
+ c->bankrupt_timeout = 0;
free(cni);
break;
}
@@ -546,7 +547,7 @@ static void PlayersCheckBankrupt(Player *p)
}
case 4: {
/* Close everything the owner has open */
- DeletePlayerWindows(p->index);
+ DeleteCompanyWindows(c->index);
/* Show bankrupt news */
SetDParam(0, STR_705C_BANKRUPT);
@@ -554,56 +555,56 @@ static void PlayersCheckBankrupt(Player *p)
SetDParamStr(2, cni->company_name);
AddNewsItem(STR_02B6, NS_COMPANY_BANKRUPT, 0, 0, cni);
- if (IsHumanPlayer(p->index)) {
- /* XXX - If we are in offline mode, leave the player playing. Eg. there
- * is no THE-END, otherwise mark the player as spectator to make sure
+ if (IsHumanCompany(c->index)) {
+ /* XXX - If we are in offline mode, leave the company playing. Eg. there
+ * is no THE-END, otherwise mark the client as spectator to make sure
* he/she is no long in control of this company */
if (!_networking) {
- p->bankrupt_asked = 0xFF;
- p->bankrupt_timeout = 0x456;
+ c->bankrupt_asked = 0xFF;
+ c->bankrupt_timeout = 0x456;
break;
}
- ChangeNetworkOwner(p->index, PLAYER_SPECTATOR);
+ ChangeNetworkOwner(c->index, COMPANY_SPECTATOR);
}
- /* Remove the player */
- ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
- /* Register the player as not-active */
+ /* Remove the company */
+ ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
+ /* Register the company as not-active */
- if (!IsHumanPlayer(p->index) && (!_networking || _network_server) && _ai.enabled)
- AI_PlayerDied(p->index);
+ if (!IsHumanCompany(c->index) && (!_networking || _network_server) && _ai.enabled)
+ AI_CompanyDied(c->index);
- delete p;
+ delete c;
}
}
}
-static void PlayersGenStatistics()
+static void CompaniesGenStatistics()
{
Station *st;
- Player *p;
+ Company *c;
FOR_ALL_STATIONS(st) {
- _current_player = st->owner;
+ _current_company = st->owner;
CommandCost cost(EXPENSES_PROPERTY, _price.station_value >> 1);
- SubtractMoneyFromPlayer(cost);
+ SubtractMoneyFromCompany(cost);
}
if (!HasBit(1 << 0 | 1 << 3 | 1 << 6 | 1 << 9, _cur_month))
return;
- FOR_ALL_PLAYERS(p) {
- memmove(&p->old_economy[1], &p->old_economy[0], sizeof(p->old_economy) - sizeof(p->old_economy[0]));
- p->old_economy[0] = p->cur_economy;
- memset(&p->cur_economy, 0, sizeof(p->cur_economy));
+ FOR_ALL_COMPANIES(c) {
+ memmove(&c->old_economy[1], &c->old_economy[0], sizeof(c->old_economy) - sizeof(c->old_economy[0]));
+ c->old_economy[0] = c->cur_economy;
+ memset(&c->cur_economy, 0, sizeof(c->cur_economy));
- if (p->num_valid_stat_ent != 24) p->num_valid_stat_ent++;
+ if (c->num_valid_stat_ent != 24) c->num_valid_stat_ent++;
- UpdateCompanyRatingAndValue(p, true);
- PlayersCheckBankrupt(p);
+ UpdateCompanyRatingAndValue(c, true);
+ CompanyCheckBankrupt(c);
- if (p->block_preview != 0) p->block_preview--;
+ if (c->block_preview != 0) c->block_preview--;
}
InvalidateWindow(WC_INCOME_GRAPH, 0);
@@ -676,17 +677,17 @@ static void AddInflation(bool check_year = true)
InvalidateWindow(WC_PAYMENT_RATES, 0);
}
-static void PlayersPayInterest()
+static void CompaniesPayInterest()
{
- const Player* p;
+ const Company *c;
int interest = _economy.interest_rate * 54;
- FOR_ALL_PLAYERS(p) {
- _current_player = p->index;
+ FOR_ALL_COMPANIES(c) {
+ _current_company = c->index;
- SubtractMoneyFromPlayer(CommandCost(EXPENSES_LOAN_INT, (Money)BigMulSU(p->current_loan, interest, 16)));
+ SubtractMoneyFromCompany(CommandCost(EXPENSES_LOAN_INT, (Money)BigMulSU(c->current_loan, interest, 16)));
- SubtractMoneyFromPlayer(CommandCost(EXPENSES_OTHER, _price.station_value >> 2));
+ SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, _price.station_value >> 2));
}
}
@@ -1097,7 +1098,7 @@ static void SubsidyMonthlyHandler()
modified = true;
} else if (s->age == 2*12-1) {
st = GetStation(s->to);
- if (st->owner == _local_player) {
+ if (st->owner == _local_company) {
pair = SetupSubsidyDecodeParam(s, 1);
AddNewsItem(STR_202F_SUBSIDY_WITHDRAWN_SERVICE, NS_SUBSIDIES, pair.a, pair.b);
}
@@ -1352,7 +1353,7 @@ static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type)
pair = SetupSubsidyDecodeParam(s, 0);
InjectDParam(1);
- SetDParam(0, _current_player);
+ SetDParam(0, _current_company);
AddNewsItem(
STR_2031_SERVICE_SUBSIDY_AWARDED + _settings_game.difficulty.subsidy_multiplier,
NS_SUBSIDIES,
@@ -1374,11 +1375,11 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source,
assert(num_pieces > 0);
- /* Update player statistics */
+ /* Update company statistics */
{
- Player *p = GetPlayer(_current_player);
- p->cur_economy.delivered_cargo += num_pieces;
- SetBit(p->cargo_types, cargo_type);
+ Company *c = GetCompany(_current_company);
+ c->cur_economy.delivered_cargo += num_pieces;
+ SetBit(c->cargo_types, cargo_type);
}
/* Get station pointers. */
@@ -1428,8 +1429,8 @@ void VehiclePayment(Vehicle *front_v)
Station *st = GetStation(last_visited);
/* The owner of the train wants to be paid */
- PlayerID old_player = _current_player;
- _current_player = front_v->owner;
+ CompanyID old_company = _current_company;
+ _current_company = front_v->owner;
/* At this moment loading cannot be finished */
ClrBit(front_v->vehicle_flags, VF_LOADING_FINISHED);
@@ -1496,16 +1497,16 @@ void VehiclePayment(Vehicle *front_v)
if (route_profit != 0) {
front_v->profit_this_year += vehicle_profit << 8;
- SubtractMoneyFromPlayer(CommandCost(front_v->GetExpenseType(true), -route_profit));
+ SubtractMoneyFromCompany(CommandCost(front_v->GetExpenseType(true), -route_profit));
- if (IsLocalPlayer() && !PlayVehicleSound(front_v, VSE_LOAD_UNLOAD)) {
+ if (IsLocalCompany() && !PlayVehicleSound(front_v, VSE_LOAD_UNLOAD)) {
SndPlayVehicleFx(SND_14_CASHTILL, front_v);
}
ShowCostOrIncomeAnimation(front_v->x_pos, front_v->y_pos, front_v->z_pos, -vehicle_profit);
}
- _current_player = old_player;
+ _current_company = old_company;
}
/**
@@ -1726,10 +1727,10 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
/* Calculate the loading indicator fill percent and display
* In the Game Menu do not display indicators
* If _settings_client.gui.loading_indicators == 2, show indicators (bool can be promoted to int as 0 or 1 - results in 2 > 0,1 )
- * if _settings_client.gui.loading_indicators == 1, _local_player must be the owner or must be a spectator to show ind., so 1 > 0
+ * if _settings_client.gui.loading_indicators == 1, _local_company must be the owner or must be a spectator to show ind., so 1 > 0
* if _settings_client.gui.loading_indicators == 0, do not display indicators ... 0 is never greater than anything
*/
- if (_game_mode != GM_MENU && (_settings_client.gui.loading_indicators > (uint)(v->owner != _local_player && _local_player != PLAYER_SPECTATOR))) {
+ if (_game_mode != GM_MENU && (_settings_client.gui.loading_indicators > (uint)(v->owner != _local_company && _local_company != COMPANY_SPECTATOR))) {
StringID percent_up_down = STR_NULL;
int percent = CalcPercentVehicleFilled(v, &percent_up_down);
if (v->fill_percent_te_id == INVALID_TE_ID) {
@@ -1774,68 +1775,68 @@ void LoadUnloadStation(Station *st)
}
}
-void PlayersMonthlyLoop()
+void CompaniesMonthlyLoop()
{
- PlayersGenStatistics();
+ CompaniesGenStatistics();
if (_settings_game.economy.inflation) AddInflation();
- PlayersPayInterest();
- /* Reset the _current_player flag */
- _current_player = OWNER_NONE;
+ CompaniesPayInterest();
+ /* Reset the _current_company flag */
+ _current_company = OWNER_NONE;
HandleEconomyFluctuations();
SubsidyMonthlyHandler();
}
-static void DoAcquireCompany(Player *p)
+static void DoAcquireCompany(Company *c)
{
- Player *owner;
+ Company *owner;
int i;
Money value;
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
- cni->FillData(p, GetPlayer(_current_player));
+ cni->FillData(c, GetCompany(_current_company));
SetDParam(0, STR_7059_TRANSPORT_COMPANY_MERGER);
- SetDParam(1, p->bankrupt_value == 0 ? STR_707F_HAS_BEEN_TAKEN_OVER_BY : STR_705A_HAS_BEEN_SOLD_TO_FOR);
+ SetDParam(1, c->bankrupt_value == 0 ? STR_707F_HAS_BEEN_TAKEN_OVER_BY : STR_705A_HAS_BEEN_SOLD_TO_FOR);
SetDParamStr(2, cni->company_name);
SetDParamStr(3, cni->other_company_name);
- SetDParam(4, p->bankrupt_value);
+ SetDParam(4, c->bankrupt_value);
AddNewsItem(STR_02B6, NS_COMPANY_MERGER, 0, 0, cni);
/* original code does this a little bit differently */
- PlayerID pi = p->index;
- ChangeNetworkOwner(pi, _current_player);
- ChangeOwnershipOfPlayerItems(pi, _current_player);
+ CompanyID ci = c->index;
+ ChangeNetworkOwner(ci, _current_company);
+ ChangeOwnershipOfCompanyItems(ci, _current_company);
- if (p->bankrupt_value == 0) {
- owner = GetPlayer(_current_player);
- owner->current_loan += p->current_loan;
+ if (c->bankrupt_value == 0) {
+ owner = GetCompany(_current_company);
+ owner->current_loan += c->current_loan;
}
- value = CalculateCompanyValue(p) >> 2;
- PlayerID old_player = _current_player;
+ value = CalculateCompanyValue(c) >> 2;
+ CompanyID old_company = _current_company;
for (i = 0; i != 4; i++) {
- if (p->share_owners[i] != PLAYER_SPECTATOR) {
- _current_player = p->share_owners[i];
- SubtractMoneyFromPlayer(CommandCost(EXPENSES_OTHER, -value));
+ if (c->share_owners[i] != COMPANY_SPECTATOR) {
+ _current_company = c->share_owners[i];
+ SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -value));
}
}
- _current_player = old_player;
+ _current_company = old_company;
- DeletePlayerWindows(pi);
+ DeleteCompanyWindows(ci);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
- delete p;
+ delete c;
}
-extern int GetAmountOwnedBy(const Player *p, PlayerID owner);
+extern int GetAmountOwnedBy(const Company *c, Owner owner);
/** Acquire shares in an opposing company.
* @param tile unused
* @param flags type of operation
- * @param p1 player to buy the shares from
+ * @param p1 company to buy the shares from
* @param p2 unused
*/
CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -1844,31 +1845,31 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32
/* Check if buying shares is allowed (protection against modified clients) */
/* Cannot buy own shares */
- if (!IsValidPlayerID((PlayerID)p1) || !_settings_game.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
+ if (!IsValidCompanyID((CompanyID)p1) || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR;
- Player *p = GetPlayer((PlayerID)p1);
+ Company *c = GetCompany((CompanyID)p1);
/* Protect new companies from hostile takeovers */
- if (_cur_year - p->inaugurated_year < 6) return_cmd_error(STR_PROTECTED);
+ if (_cur_year - c->inaugurated_year < 6) return_cmd_error(STR_PROTECTED);
/* Those lines are here for network-protection (clients can be slow) */
- if (GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0) return cost;
+ if (GetAmountOwnedBy(c, COMPANY_SPECTATOR) == 0) return cost;
- /* We can not buy out a real player (temporarily). TODO: well, enable it obviously */
- if (GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) return cost;
+ /* We can not buy out a real company (temporarily). TODO: well, enable it obviously */
+ if (GetAmountOwnedBy(c, COMPANY_SPECTATOR) == 1 && !c->is_ai) return cost;
- cost.AddCost(CalculateCompanyValue(p) >> 2);
+ cost.AddCost(CalculateCompanyValue(c) >> 2);
if (flags & DC_EXEC) {
- PlayerByte* b = p->share_owners;
+ OwnerByte *b = c->share_owners;
int i;
- while (*b != PLAYER_SPECTATOR) b++; /* share owners is guaranteed to contain at least one PLAYER_SPECTATOR */
- *b = _current_player;
+ while (*b != COMPANY_SPECTATOR) b++; /* share owners is guaranteed to contain at least one COMPANY_SPECTATOR */
+ *b = _current_company;
- for (i = 0; p->share_owners[i] == _current_player;) {
+ for (i = 0; c->share_owners[i] == _current_company;) {
if (++i == 4) {
- p->bankrupt_value = 0;
- DoAcquireCompany(p);
+ c->bankrupt_value = 0;
+ DoAcquireCompany(c);
break;
}
}
@@ -1880,28 +1881,28 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32
/** Sell shares in an opposing company.
* @param tile unused
* @param flags type of operation
- * @param p1 player to sell the shares from
+ * @param p1 company to sell the shares from
* @param p2 unused
*/
CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
/* Check if selling shares is allowed (protection against modified clients) */
/* Cannot sell own shares */
- if (!IsValidPlayerID((PlayerID)p1) || !_settings_game.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
+ if (!IsValidCompanyID((CompanyID)p1) || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR;
- Player *p = GetPlayer((PlayerID)p1);
+ Company *c = GetCompany((CompanyID)p1);
/* Those lines are here for network-protection (clients can be slow) */
- if (GetAmountOwnedBy(p, _current_player) == 0) return CommandCost();
+ if (GetAmountOwnedBy(c, _current_company) == 0) return CommandCost();
/* adjust it a little to make it less profitable to sell and buy */
- Money cost = CalculateCompanyValue(p) >> 2;
+ Money cost = CalculateCompanyValue(c) >> 2;
cost = -(cost - (cost >> 7));
if (flags & DC_EXEC) {
- PlayerByte* b = p->share_owners;
- while (*b != _current_player) b++; // share owners is guaranteed to contain player
- *b = PLAYER_SPECTATOR;
+ OwnerByte *b = c->share_owners;
+ while (*b != _current_company) b++; // share owners is guaranteed to contain company
+ *b = COMPANY_SPECTATOR;
InvalidateWindow(WC_COMPANY, p1);
}
return CommandCost(EXPENSES_OTHER, cost);
@@ -1910,30 +1911,30 @@ CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint3
/** Buy up another company.
* When a competing company is gone bankrupt you get the chance to purchase
* that company.
- * @todo currently this only works for AI players
+ * @todo currently this only works for AI companies
* @param tile unused
* @param flags type of operation
- * @param p1 player/company to buy up
+ * @param p1 company to buy up
* @param p2 unused
*/
CommandCost CmdBuyCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- PlayerID pid = (PlayerID)p1;
+ CompanyID cid = (CompanyID)p1;
/* Disable takeovers in multiplayer games */
- if (!IsValidPlayerID(pid) || _networking) return CMD_ERROR;
+ if (!IsValidCompanyID(cid) || _networking) return CMD_ERROR;
- /* Do not allow players to take over themselves */
- if (pid == _current_player) return CMD_ERROR;
+ /* Do not allow companies to take over themselves */
+ if (cid == _current_company) return CMD_ERROR;
- Player *p = GetPlayer(pid);
+ Company *c = GetCompany(cid);
- if (!p->is_ai) return CMD_ERROR;
+ if (!c->is_ai) return CMD_ERROR;
if (flags & DC_EXEC) {
- DoAcquireCompany(p);
+ DoAcquireCompany(c);
}
- return CommandCost(EXPENSES_OTHER, p->bankrupt_value);
+ return CommandCost(EXPENSES_OTHER, c->bankrupt_value);
}
/** Prices */
diff --git a/src/economy_func.h b/src/economy_func.h
index f458ad1c6..11f10207a 100644
--- a/src/economy_func.h
+++ b/src/economy_func.h
@@ -15,23 +15,21 @@
#include "player_type.h"
#include "station_type.h"
-struct Player;
-
void ResetPriceBaseMultipliers();
void SetPriceBaseMultiplier(uint price, byte factor);
void ResetEconomy();
extern const ScoreInfo _score_info[];
-extern int _score_part[MAX_PLAYERS][SCORE_END];
+extern int _score_part[MAX_COMPANIES][SCORE_END];
extern Economy _economy;
-extern Subsidy _subsidies[MAX_PLAYERS];
+extern Subsidy _subsidies[MAX_COMPANIES];
/* Prices and also the fractional part. */
extern Prices _price;
extern uint16 _price_frac[NUM_PRICES];
extern Money _cargo_payment_rates[NUM_CARGO];
extern uint16 _cargo_payment_rates_frac[NUM_CARGO];
-int UpdateCompanyRatingAndValue(Player *p, bool update);
+int UpdateCompanyRatingAndValue(Company *c, bool update);
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode);
void DeleteSubsidyWithTown(TownID index);
void DeleteSubsidyWithIndustry(IndustryID index);
diff --git a/src/elrail.cpp b/src/elrail.cpp
index 7558c9ded..627c7584c 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -465,7 +465,7 @@ void DrawCatenary(const TileInfo *ti)
int32 SettingsDisableElrail(int32 p1)
{
Vehicle *v;
- Player *p;
+ Company *c;
bool disable = (p1 != 0);
/* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/
@@ -506,7 +506,7 @@ int32 SettingsDisableElrail(int32 p1)
}
}
- FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index);
+ FOR_ALL_COMPANIES(c) c->avail_railtypes = GetCompanyRailtypes(c->index);
/* This resets the _last_built_railtype, which will be invalid for electric
* rails. It may have unintended consequences if that function is ever
diff --git a/src/engine.cpp b/src/engine.cpp
index 91d52f5cb..f6dff726d 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -114,17 +114,17 @@ Engine::~Engine()
free(this->name);
}
-/** Sets cached values in Player::num_vehicles and Group::num_vehicles
+/** Sets cached values in Company::num_vehicles and Group::num_vehicles
*/
void SetCachedEngineCounts()
{
uint engines = GetEnginePoolSize();
- /* Set up the engine count for all players */
- Player *p;
- FOR_ALL_PLAYERS(p) {
- free(p->num_engines);
- p->num_engines = CallocT<EngineID>(engines);
+ /* Set up the engine count for all companies */
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ free(c->num_engines);
+ c->num_engines = CallocT<EngineID>(engines);
}
/* Recalculate */
@@ -140,7 +140,7 @@ void SetCachedEngineCounts()
assert(v->engine_type < engines);
- GetPlayer(v->owner)->num_engines[v->engine_type]++;
+ GetCompany(v->owner)->num_engines[v->engine_type]++;
if (v->group_id == DEFAULT_GROUP) continue;
@@ -195,12 +195,12 @@ static void CalcEngineReliability(Engine *e)
uint age = e->age;
/* Check for early retirement */
- if (e->player_avail != 0 && !_settings_game.vehicle.never_expire_vehicles) {
+ if (e->company_avail != 0 && !_settings_game.vehicle.never_expire_vehicles) {
int retire_early = e->info.retire_early;
uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12);
if (retire_early != 0 && age >= retire_early_max_age) {
/* Early retirement is enabled and we're past the date... */
- e->player_avail = 0;
+ e->company_avail = 0;
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
}
}
@@ -218,7 +218,7 @@ static void CalcEngineReliability(Engine *e)
} else {
/* time's up for this engine.
* We will now completely retire this design */
- e->player_avail = 0;
+ e->company_avail = 0;
e->reliability = e->reliability_final;
/* Kick this engine out of the lists */
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
@@ -239,7 +239,7 @@ void StartupEngines()
e->age = 0;
e->flags = 0;
- e->player_avail = 0;
+ e->company_avail = 0;
/* The magic value of 729 days below comes from the NewGRF spec. If the
* base intro date is before 1922 then the random number of days is not
@@ -248,7 +248,7 @@ void StartupEngines()
e->intro_date = ei->base_intro <= ConvertYMDToDate(1922, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro;
if (e->intro_date <= _date) {
e->age = (aging_date - e->intro_date) >> 5;
- e->player_avail = (byte)-1;
+ e->company_avail = (CompanyMask)-1;
e->flags |= ENGINE_AVAILABLE;
}
@@ -275,63 +275,63 @@ void StartupEngines()
/* prevent certain engines from ever appearing. */
if (!HasBit(ei->climates, _settings_game.game_creation.landscape)) {
e->flags |= ENGINE_AVAILABLE;
- e->player_avail = 0;
+ e->company_avail = 0;
}
}
/* Update the bitmasks for the vehicle lists */
- Player *p;
- FOR_ALL_PLAYERS(p) {
- p->avail_railtypes = GetPlayerRailtypes(p->index);
- p->avail_roadtypes = GetPlayerRoadtypes(p->index);
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ c->avail_railtypes = GetCompanyRailtypes(c->index);
+ c->avail_roadtypes = GetCompanyRoadtypes(c->index);
}
}
-static void AcceptEnginePreview(EngineID eid, PlayerID player)
+static void AcceptEnginePreview(EngineID eid, CompanyID company)
{
Engine *e = GetEngine(eid);
- Player *p = GetPlayer(player);
+ Company *c = GetCompany(company);
- SetBit(e->player_avail, player);
+ SetBit(e->company_avail, company);
if (e->type == VEH_TRAIN) {
const RailVehicleInfo *rvi = RailVehInfo(eid);
assert(rvi->railtype < RAILTYPE_END);
- SetBit(p->avail_railtypes, rvi->railtype);
+ SetBit(c->avail_railtypes, rvi->railtype);
} else if (e->type == VEH_ROAD) {
- SetBit(p->avail_roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
+ SetBit(c->avail_roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
- e->preview_player_rank = 0xFF;
- if (player == _local_player) {
+ e->preview_company_rank = 0xFF;
+ if (company == _local_company) {
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
}
}
-static PlayerID GetBestPlayer(uint8 pp)
+static CompanyID GetBestCompany(uint8 pp)
{
- const Player *p;
+ const Company *c;
int32 best_hist;
- PlayerID best_player;
+ CompanyID best_company;
uint mask = 0;
do {
best_hist = -1;
- best_player = PLAYER_SPECTATOR;
- FOR_ALL_PLAYERS(p) {
- if (p->block_preview == 0 && !HasBit(mask, p->index) &&
- p->old_economy[0].performance_history > best_hist) {
- best_hist = p->old_economy[0].performance_history;
- best_player = p->index;
+ best_company = INVALID_COMPANY;
+ FOR_ALL_COMPANIES(c) {
+ if (c->block_preview == 0 && !HasBit(mask, c->index) &&
+ c->old_economy[0].performance_history > best_hist) {
+ best_hist = c->old_economy[0].performance_history;
+ best_company = c->index;
}
}
- if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR;
+ if (best_company == INVALID_COMPANY) return INVALID_COMPANY;
- SetBit(mask, best_player);
+ SetBit(mask, best_company);
} while (--pp != 0);
- return best_player;
+ return best_company;
}
void EnginesDailyLoop()
@@ -343,33 +343,33 @@ void EnginesDailyLoop()
EngineID i = e->index;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) {
if (e->flags & ENGINE_OFFER_WINDOW_OPEN) {
- if (e->preview_player_rank != 0xFF && !--e->preview_wait) {
+ if (e->preview_company_rank != 0xFF && !--e->preview_wait) {
e->flags &= ~ENGINE_OFFER_WINDOW_OPEN;
DeleteWindowById(WC_ENGINE_PREVIEW, i);
- e->preview_player_rank++;
+ e->preview_company_rank++;
}
- } else if (e->preview_player_rank != 0xFF) {
- PlayerID best_player = GetBestPlayer(e->preview_player_rank);
+ } else if (e->preview_company_rank != 0xFF) {
+ CompanyID best_company = GetBestCompany(e->preview_company_rank);
- if (best_player == PLAYER_SPECTATOR) {
- e->preview_player_rank = 0xFF;
+ if (best_company == INVALID_COMPANY) {
+ e->preview_company_rank = 0xFF;
continue;
}
- if (!IsHumanPlayer(best_player)) {
+ if (!IsHumanCompany(best_company)) {
/* XXX - TTDBUG: TTD has a bug here ???? */
- AcceptEnginePreview(i, best_player);
+ AcceptEnginePreview(i, best_company);
} else {
e->flags |= ENGINE_OFFER_WINDOW_OPEN;
e->preview_wait = 20;
- if (IsInteractivePlayer(best_player)) ShowEnginePreviewWindow(i);
+ if (IsInteractiveCompany(best_company)) ShowEnginePreviewWindow(i);
}
}
}
}
}
-/** Accept an engine prototype. XXX - it is possible that the top-player
+/** Accept an engine prototype. XXX - it is possible that the top-company
* changes while you are waiting to accept the offer? Then it becomes invalid
* @param tile unused
* @param flags operation to perfom
@@ -382,9 +382,9 @@ CommandCost CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32
if (!IsEngineIndex(p1)) return CMD_ERROR;
e = GetEngine(p1);
- if (GetBestPlayer(e->preview_player_rank) != _current_player) return CMD_ERROR;
+ if (GetBestCompany(e->preview_company_rank) != _current_company) return CMD_ERROR;
- if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_player);
+ if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company);
return CommandCost();
}
@@ -394,26 +394,26 @@ StringID GetEngineCategoryName(EngineID engine);
static void NewVehicleAvailable(Engine *e)
{
Vehicle *v;
- Player *p;
+ Company *c;
EngineID index = e->index;
- /* In case the player didn't build the vehicle during the intro period,
- * prevent that player from getting future intro periods for a while. */
+ /* In case the company didn't build the vehicle during the intro period,
+ * prevent that company from getting future intro periods for a while. */
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) {
- FOR_ALL_PLAYERS(p) {
- uint block_preview = p->block_preview;
+ FOR_ALL_COMPANIES(c) {
+ uint block_preview = c->block_preview;
- if (!HasBit(e->player_avail, p->index)) continue;
+ if (!HasBit(e->company_avail, c->index)) continue;
/* We assume the user did NOT build it.. prove me wrong ;) */
- p->block_preview = 20;
+ c->block_preview = 20;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN || v->type == VEH_ROAD || v->type == VEH_SHIP ||
(v->type == VEH_AIRCRAFT && IsNormalAircraft(v))) {
- if (v->owner == p->index && v->engine_type == index) {
+ if (v->owner == c->index && v->engine_type == index) {
/* The user did prove me wrong, so restore old value */
- p->block_preview = block_preview;
+ c->block_preview = block_preview;
break;
}
}
@@ -424,8 +424,8 @@ static void NewVehicleAvailable(Engine *e)
e->flags = (e->flags & ~ENGINE_EXCLUSIVE_PREVIEW) | ENGINE_AVAILABLE;
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
- /* Now available for all players */
- e->player_avail = (PlayerMask)-1;
+ /* Now available for all companies */
+ e->company_avail = (CompanyMask)-1;
/* Do not introduce new rail wagons */
if (IsWagon(index)) return;
@@ -434,10 +434,10 @@ static void NewVehicleAvailable(Engine *e)
/* maybe make another rail type available */
RailType railtype = e->u.rail.railtype;
assert(railtype < RAILTYPE_END);
- FOR_ALL_PLAYERS(p) SetBit(p->avail_railtypes, railtype);
+ FOR_ALL_COMPANIES(c) SetBit(c->avail_railtypes, railtype);
} else if (e->type == VEH_ROAD) {
/* maybe make another road type available */
- FOR_ALL_PLAYERS(p) SetBit(p->avail_roadtypes, HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
+ FOR_ALL_COMPANIES(c) SetBit(c->avail_roadtypes, HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
SetDParam(0, GetEngineCategoryName(index));
@@ -457,15 +457,15 @@ void EnginesMonthlyLoop()
}
if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + 365)) {
- /* Introduce it to all players */
+ /* Introduce it to all companies */
NewVehicleAvailable(e);
} else if (!(e->flags & (ENGINE_AVAILABLE|ENGINE_EXCLUSIVE_PREVIEW)) && _date >= e->intro_date) {
- /* Introduction date has passed.. show introducing dialog to one player. */
+ /* Introduction date has passed.. show introducing dialog to one companies. */
e->flags |= ENGINE_EXCLUSIVE_PREVIEW;
/* Do not introduce new rail wagons */
if (!IsWagon(e->index))
- e->preview_player_rank = 1; // Give to the player with the highest rating.
+ e->preview_company_rank = 1; // Give to the company with the highest rating.
}
}
}
@@ -529,13 +529,13 @@ CommandCost CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/** Check if an engine is buildable.
- * @param engine index of the engine to check.
- * @param type the type the engine should be.
- * @param player index of the player.
+ * @param engine index of the engine to check.
+ * @param type the type the engine should be.
+ * @param company index of the company.
* @return True if an engine is valid, of the specified type, and buildable by
- * the given player.
+ * the given company.
*/
-bool IsEngineBuildable(EngineID engine, VehicleType type, PlayerID player)
+bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
{
/* check if it's an engine that is in the engine array */
if (!IsEngineIndex(engine)) return false;
@@ -546,12 +546,12 @@ bool IsEngineBuildable(EngineID engine, VehicleType type, PlayerID player)
if (e->type != type) return false;
/* check if it's available */
- if (!HasBit(e->player_avail, player)) return false;
+ if (!HasBit(e->company_avail, company)) return false;
if (type == VEH_TRAIN) {
- /* Check if the rail type is available to this player */
- const Player *p = GetPlayer(player);
- if (!HasBit(p->avail_railtypes, RailVehInfo(engine)->railtype)) return false;
+ /* Check if the rail type is available to this company */
+ const Company *c = GetCompany(company);
+ if (!HasBit(c->avail_railtypes, RailVehInfo(engine)->railtype)) return false;
}
return true;
@@ -602,10 +602,10 @@ static const SaveLoad _engine_desc[] = {
SLE_VAR(Engine, lifelength, SLE_UINT8),
SLE_VAR(Engine, flags, SLE_UINT8),
- SLE_VAR(Engine, preview_player_rank, SLE_UINT8),
+ SLE_VAR(Engine, preview_company_rank,SLE_UINT8),
SLE_VAR(Engine, preview_wait, SLE_UINT8),
SLE_CONDNULL(1, 0, 44),
- SLE_VAR(Engine, player_avail, SLE_UINT8),
+ SLE_VAR(Engine, company_avail, SLE_UINT8),
SLE_CONDSTR(Engine, name, SLE_STR, 0, 84, SL_MAX_VERSION),
/* reserve extra space in savegame here. (currently 16 bytes) */
@@ -664,9 +664,9 @@ void CopyTempEngineData()
e->duration_phase_3 = se->duration_phase_3;
e->lifelength = se->lifelength;
e->flags = se->flags;
- e->preview_player_rank = se->preview_player_rank;
+ e->preview_company_rank= se->preview_company_rank;
e->preview_wait = se->preview_wait;
- e->player_avail = se->player_avail;
+ e->company_avail = se->company_avail;
if (se->name != NULL) e->name = strdup(se->name);
}
diff --git a/src/engine_base.h b/src/engine_base.h
index 40ece643c..aee07e81a 100644
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -20,9 +20,9 @@ struct Engine : PoolItem<Engine, EngineID, &_Engine_pool> {
uint16 duration_phase_1, duration_phase_2, duration_phase_3;
byte lifelength;
byte flags;
- uint8 preview_player_rank;
+ uint8 preview_company_rank;
byte preview_wait;
- PlayerMask player_avail;
+ CompanyMask company_avail;
uint8 image_index; ///< Original vehicle image index
VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
diff --git a/src/engine_func.h b/src/engine_func.h
index 2e5049948..595644375 100644
--- a/src/engine_func.h
+++ b/src/engine_func.h
@@ -25,7 +25,7 @@ void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal);
void LoadCustomEngineNames();
void DeleteCustomEngineNames();
-bool IsEngineBuildable(EngineID engine, VehicleType type, PlayerID player);
+bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company);
CargoID GetEngineCargoType(EngineID engine);
void SetCachedEngineCounts();
diff --git a/src/engine_type.h b/src/engine_type.h
index 5760d3ac6..cfe284367 100644
--- a/src/engine_type.h
+++ b/src/engine_type.h
@@ -134,8 +134,8 @@ enum {
*/
enum {
ENGINE_AVAILABLE = 1, ///< This vehicle is available to everyone.
- ENGINE_EXCLUSIVE_PREVIEW = 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a player.
- ENGINE_OFFER_WINDOW_OPEN = 4, ///< The exclusive offer window is currently open for a player.
+ ENGINE_EXCLUSIVE_PREVIEW = 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a company.
+ ENGINE_OFFER_WINDOW_OPEN = 4, ///< The exclusive offer window is currently open for a company.
};
enum {
diff --git a/src/functions.h b/src/functions.h
index f42eb573e..166f7accb 100644
--- a/src/functions.h
+++ b/src/functions.h
@@ -15,10 +15,10 @@ void DrawClearLandTile(const TileInfo *ti, byte set);
void DrawClearLandFence(const TileInfo *ti);
void TileLoopClearHelper(TileIndex tile);
-/* players.cpp */
-bool CheckPlayerHasMoney(CommandCost cost);
-void SubtractMoneyFromPlayer(CommandCost cost);
-void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cost);
+/* company_cmd.cpp */
+bool CheckCompanyHasMoney(CommandCost cost);
+void SubtractMoneyFromCompany(CommandCost cost);
+void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cost);
bool CheckOwnership(Owner owner);
bool CheckTileOwnership(TileIndex tile);
diff --git a/src/genworld.cpp b/src/genworld.cpp
index dcbe15dbc..edccdbfc8 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -36,7 +36,7 @@ bool GenerateTowns();
void GenerateTrees();
void StartupEconomy();
-void StartupPlayers();
+void StartupCompanies();
void StartupDisasters();
void InitializeGame(uint size_x, uint size_y, bool reset_date);
@@ -126,7 +126,7 @@ static void _GenerateWorld(void *arg)
/* These are probably pointless when inside the scenario editor. */
SetGeneratingWorldProgress(GWP_GAME_INIT, 3);
- StartupPlayers();
+ StartupCompanies();
IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
StartupEngines();
IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
@@ -145,7 +145,7 @@ static void _GenerateWorld(void *arg)
}
ResetObjectToPlace();
- _local_player = _gw.lp;
+ _local_company = _gw.lc;
SetGeneratingWorldProgress(GWP_GAME_START, 1);
/* Call any callback */
@@ -259,15 +259,15 @@ void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y)
_gw.active = true;
_gw.abort = false;
_gw.abortp = NULL;
- _gw.lp = _local_player;
+ _gw.lc = _local_company;
_gw.wait_for_draw = false;
_gw.quit_thread = false;
_gw.threaded = true;
/* This disables some commands and stuff */
- SetLocalPlayer(PLAYER_SPECTATOR);
+ SetLocalCompany(COMPANY_SPECTATOR);
/* Make sure everything is done via OWNER_NONE */
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
/* Set the date before loading sprites as some newgrfs check it */
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
diff --git a/src/genworld.h b/src/genworld.h
index c0a192333..3739db874 100644
--- a/src/genworld.h
+++ b/src/genworld.h
@@ -36,7 +36,7 @@ struct gw_info {
bool quit_thread; ///< Do we want to quit the active thread
bool threaded; ///< Whether we run _GenerateWorld threaded
GenerateWorldMode mode;///< What mode are we making a world in
- PlayerID lp; ///< The local_player before generating
+ CompanyID lc; ///< The local_company before generating
uint size_x; ///< X-size of the map
uint size_y; ///< Y-size of the map
gw_done_proc *proc; ///< Proc that is called when done (can be NULL)
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 3392fabc1..1488e9abd 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -21,8 +21,8 @@
#include "table/strings.h"
#include "table/sprites.h"
-/* Bitmasks of player and cargo indices that shouldn't be drawn. */
-static uint _legend_excluded_players;
+/* Bitmasks of company and cargo indices that shouldn't be drawn. */
+static uint _legend_excluded_companies;
static uint _legend_excluded_cargo;
/* Apparently these don't play well with enums. */
@@ -37,7 +37,7 @@ struct GraphLegendWindow : Window {
GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
for (uint i = 3; i < this->widget_count; i++) {
- if (!HasBit(_legend_excluded_players, i - 3)) this->LowerWidget(i);
+ if (!HasBit(_legend_excluded_companies, i - 3)) this->LowerWidget(i);
}
this->FindWindowPlacementAndResize(desc);
@@ -45,22 +45,22 @@ struct GraphLegendWindow : Window {
virtual void OnPaint()
{
- for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) {
- if (IsValidPlayerID(p)) continue;
+ for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
+ if (IsValidCompanyID(c)) continue;
- SetBit(_legend_excluded_players, p);
- this->RaiseWidget(p + 3);
+ SetBit(_legend_excluded_companies, c);
+ this->RaiseWidget(c + 3);
}
this->DrawWidgets();
- const Player *p;
- FOR_ALL_PLAYERS(p) {
- DrawPlayerIcon(p->index, 4, 18 + p->index * 12);
+ const Company *c;
+ FOR_ALL_COMPANIES(c) {
+ DrawCompanyIcon(c->index, 4, 18 + c->index * 12);
- SetDParam(0, p->index);
- SetDParam(1, p->index);
- DrawString(21, 17 + p->index * 12, STR_7021, HasBit(_legend_excluded_players, p->index) ? TC_BLACK : TC_WHITE);
+ SetDParam(0, c->index);
+ SetDParam(1, c->index);
+ DrawString(21, 17 + c->index * 12, STR_7021, HasBit(_legend_excluded_companies, c->index) ? TC_BLACK : TC_WHITE);
}
}
@@ -68,7 +68,7 @@ struct GraphLegendWindow : Window {
{
if (!IsInsideMM(widget, 3, 11)) return;
- ToggleBit(_legend_excluded_players, widget - 3);
+ ToggleBit(_legend_excluded_companies, widget - 3);
this->ToggleWidgetLoweredState(widget);
this->SetDirty();
InvalidateWindow(WC_INCOME_GRAPH, 0);
@@ -155,8 +155,8 @@ protected:
int x_axis_offset; ///< Distance from the top of the graph to the x axis.
/* the colors and cost array of GraphDrawer must accomodate
- * both values for cargo and players. So if any are higher, quit */
- assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_PLAYERS);
+ * both values for cargo and companies. So if any are higher, quit */
+ assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_COMPANIES);
assert(this->num_vert_lines > 0);
byte grid_colour = _colour_gradient[COLOUR_GREY][4];
@@ -354,19 +354,19 @@ public:
{
this->DrawWidgets();
- uint excluded_players = _legend_excluded_players;
+ uint excluded_companies = _legend_excluded_companies;
- /* Exclude the players which aren't valid */
- for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) {
- if (!IsValidPlayerID(p)) SetBit(excluded_players, p);
+ /* Exclude the companies which aren't valid */
+ for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
+ if (!IsValidCompanyID(c)) SetBit(excluded_companies, c);
}
- this->excluded_data = excluded_players;
+ this->excluded_data = excluded_companies;
this->num_vert_lines = 24;
byte nums = 0;
- const Player *p;
- FOR_ALL_PLAYERS(p) {
- nums = max(nums, p->num_valid_stat_ent);
+ const Company *c;
+ FOR_ALL_COMPANIES(c) {
+ nums = max(nums, c->num_valid_stat_ent);
}
this->num_on_x_axis = min(nums, 24);
@@ -381,12 +381,12 @@ public:
this->month = mo;
int numd = 0;
- for (PlayerID k = PLAYER_FIRST; k < MAX_PLAYERS; k++) {
- if (IsValidPlayerID(k)) {
- p = GetPlayer(k);
- this->colors[numd] = _colour_gradient[p->player_color][6];
+ for (CompanyID k = COMPANY_FIRST; k < MAX_COMPANIES; k++) {
+ if (IsValidCompanyID(k)) {
+ c = GetCompany(k);
+ this->colors[numd] = _colour_gradient[c->colour][6];
for (int j = this->num_on_x_axis, i = 0; --j >= 0;) {
- this->cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(p, j);
+ this->cost[numd][i] = (j >= c->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(c, j);
i++;
}
}
@@ -398,7 +398,7 @@ public:
this->DrawGraph();
}
- virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
+ virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
{
return INVALID_DATAPOINT;
}
@@ -421,9 +421,9 @@ struct OperatingProfitGraphWindow : BaseGraphWindow {
this->FindWindowPlacementAndResize(desc);
}
- virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
+ virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
{
- return p->old_economy[j].income + p->old_economy[j].expenses;
+ return c->old_economy[j].income + c->old_economy[j].expenses;
}
};
@@ -460,9 +460,9 @@ struct IncomeGraphWindow : BaseGraphWindow {
this->FindWindowPlacementAndResize(desc);
}
- virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
+ virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
{
- return p->old_economy[j].income;
+ return c->old_economy[j].income;
}
};
@@ -497,9 +497,9 @@ struct DeliveredCargoGraphWindow : BaseGraphWindow {
this->FindWindowPlacementAndResize(desc);
}
- virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
+ virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
{
- return p->old_economy[j].delivered_cargo;
+ return c->old_economy[j].delivered_cargo;
}
};
@@ -534,9 +534,9 @@ struct PerformanceHistoryGraphWindow : BaseGraphWindow {
this->FindWindowPlacementAndResize(desc);
}
- virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
+ virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
{
- return p->old_economy[j].performance_history;
+ return c->old_economy[j].performance_history;
}
virtual void OnClick(Point pt, int widget)
@@ -578,9 +578,9 @@ struct CompanyValueGraphWindow : BaseGraphWindow {
this->FindWindowPlacementAndResize(desc);
}
- virtual OverflowSafeInt64 GetGraphData(const Player *p, int j)
+ virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
{
- return p->old_economy[j].company_value;
+ return c->old_economy[j].company_value;
}
};
@@ -668,13 +668,13 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
if (!cs->IsValid()) continue;
/* Only draw labels for widgets that exist. If the widget doesn't
- * exist then the local player has used the climate cheat or
- * changed the NewGRF configuration with this window open. */
+ * exist then the local company has used the climate cheat or
+ * changed the NewGRF configuration with this window open. */
if (i + 3 < this->widget_count) {
/* Since the buttons have no text, no images,
- * both the text and the colored box have to be manually painted.
- * clk_dif will move one pixel down and one pixel to the right
- * when the button is clicked */
+ * both the text and the colored box have to be manually painted.
+ * clk_dif will move one pixel down and one pixel to the right
+ * when the button is clicked */
byte clk_dif = this->IsWidgetLowered(i + 3) ? 1 : 0;
GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
@@ -759,63 +759,63 @@ static inline StringID GetPerformanceTitleFromValue(uint value)
class CompanyLeagueWindow : public Window {
private:
- GUIList<const Player*> players;
+ GUIList<const Company*> companies;
/**
* (Re)Build the company league list
*/
- void BuildPlayerList()
+ void BuildCompanyList()
{
- if (!this->players.NeedRebuild()) return;
+ if (!this->companies.NeedRebuild()) return;
- this->players.Clear();
+ this->companies.Clear();
- const Player *p;
- FOR_ALL_PLAYERS(p) {
- *this->players.Append() = p;
+ const Company *c;
+ FOR_ALL_COMPANIES(c) {
+ *this->companies.Append() = c;
}
- this->players.Compact();
- this->players.RebuildDone();
+ this->companies.Compact();
+ this->companies.RebuildDone();
}
/** Sort the company league by performance history */
- static int CDECL PerformanceSorter(const Player* const *p1, const Player* const *p2)
+ static int CDECL PerformanceSorter(const Company* const *c1, const Company* const *c2)
{
- return (*p2)->old_economy[1].performance_history - (*p1)->old_economy[1].performance_history;
+ return (*c2)->old_economy[1].performance_history - (*c1)->old_economy[1].performance_history;
}
public:
CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- this->players.ForceRebuild();
- this->players.NeedResort();
+ this->companies.ForceRebuild();
+ this->companies.NeedResort();
this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
{
- this->BuildPlayerList();
- this->players.Sort(&PerformanceSorter);
+ this->BuildCompanyList();
+ this->companies.Sort(&PerformanceSorter);
this->DrawWidgets();
- for (uint i = 0; i != this->players.Length(); i++) {
- const Player *p = this->players[i];
+ for (uint i = 0; i != this->companies.Length(); i++) {
+ const Company *c = this->companies[i];
SetDParam(0, i + STR_01AC_1ST);
- SetDParam(1, p->index);
- SetDParam(2, p->index);
- SetDParam(3, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
+ SetDParam(1, c->index);
+ SetDParam(2, c->index);
+ SetDParam(3, GetPerformanceTitleFromValue(c->old_economy[1].performance_history));
DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, TC_FROMSTRING);
- DrawPlayerIcon(p->index, 27, 16 + i * 10);
+ DrawCompanyIcon(c->index, 27, 16 + i * 10);
}
}
virtual void OnTick()
{
- if (this->players.NeedResort()) {
+ if (this->companies.NeedResort()) {
this->SetDirty();
}
}
@@ -823,9 +823,9 @@ public:
virtual void OnInvalidateData(int data)
{
if (data == 0) {
- this->players.ForceRebuild();
+ this->companies.ForceRebuild();
} else {
- this->players.ForceResort();
+ this->companies.ForceResort();
}
}
};
@@ -858,35 +858,35 @@ void ShowCompanyLeagueTable()
struct PerformanceRatingDetailWindow : Window {
private:
enum PerformanteRatingWidgets {
- PRW_PLAYER_FIRST = 13,
- PRW_PLAYER_LAST = 20,
+ PRW_COMPANY_FIRST = 13,
+ PRW_COMPANY_LAST = 20,
};
public:
- static PlayerID player;
+ static CompanyID company;
int timeout;
PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- /* Disable the players who are not active */
- for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
- this->SetWidgetDisabledState(i + PRW_PLAYER_FIRST, !IsValidPlayerID(i));
+ /* Disable the companies who are not active */
+ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
+ this->SetWidgetDisabledState(i + PRW_COMPANY_FIRST, !IsValidCompanyID(i));
}
- this->UpdatePlayerStats();
+ this->UpdateCompanyStats();
- if (player != INVALID_PLAYER) this->LowerWidget(player + PRW_PLAYER_FIRST);
+ if (company != INVALID_COMPANY) this->LowerWidget(company + PRW_COMPANY_FIRST);
this->FindWindowPlacementAndResize(desc);
}
- void UpdatePlayerStats()
+ void UpdateCompanyStats()
{
- /* Update all player stats with the current data
+ /* Update all company stats with the current data
* (this is because _score_info is not saved to a savegame) */
- Player *p;
- FOR_ALL_PLAYERS(p) {
- UpdateCompanyRatingAndValue(p, false);
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ UpdateCompanyRatingAndValue(c, false);
}
this->timeout = DAY_TICKS * 5;
@@ -903,39 +903,39 @@ public:
/* Draw standard stuff */
this->DrawWidgets();
- /* Check if the currently selected player is still active. */
- if (player == INVALID_PLAYER || !IsValidPlayerID(player)) {
- if (player != INVALID_PLAYER) {
+ /* Check if the currently selected company is still active. */
+ if (company == INVALID_COMPANY || !IsValidCompanyID(company)) {
+ if (company != INVALID_COMPANY) {
/* Raise and disable the widget for the previous selection. */
- this->RaiseWidget(player + PRW_PLAYER_FIRST);
- this->DisableWidget(player + PRW_PLAYER_FIRST);
+ this->RaiseWidget(company + PRW_COMPANY_FIRST);
+ this->DisableWidget(company + PRW_COMPANY_FIRST);
this->SetDirty();
- player = INVALID_PLAYER;
+ company = INVALID_COMPANY;
}
- for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
- if (IsValidPlayerID(i)) {
- /* Lower the widget corresponding to this player. */
- this->LowerWidget(i + PRW_PLAYER_FIRST);
+ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
+ if (IsValidCompanyID(i)) {
+ /* Lower the widget corresponding to this company. */
+ this->LowerWidget(i + PRW_COMPANY_FIRST);
this->SetDirty();
- player = i;
+ company = i;
break;
}
}
}
- /* If there are no active players, don't display anything else. */
- if (player == INVALID_PLAYER) return;
+ /* If there are no active companies, don't display anything else. */
+ if (company == INVALID_COMPANY) return;
- /* Paint the player icons */
- for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
- if (!IsValidPlayerID(i)) {
- /* Check if we have the player as an active player */
- if (!this->IsWidgetDisabled(i + PRW_PLAYER_FIRST)) {
- /* Bah, player gone :( */
- this->DisableWidget(i + PRW_PLAYER_FIRST);
+ /* Paint the company icons */
+ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
+ if (!IsValidCompanyID(i)) {
+ /* Check if we have the company as an active company */
+ if (!this->IsWidgetDisabled(i + PRW_COMPANY_FIRST)) {
+ /* Bah, company gone :( */
+ this->DisableWidget(i + PRW_COMPANY_FIRST);
/* We need a repaint */
this->SetDirty();
@@ -943,16 +943,16 @@ public:
continue;
}
- /* Check if we have the player marked as inactive */
- if (this->IsWidgetDisabled(i + PRW_PLAYER_FIRST)) {
- /* New player! Yippie :p */
- this->EnableWidget(i + PRW_PLAYER_FIRST);
+ /* Check if we have the company marked as inactive */
+ if (this->IsWidgetDisabled(i + PRW_COMPANY_FIRST)) {
+ /* New company! Yippie :p */
+ this->EnableWidget(i + PRW_COMPANY_FIRST);
/* We need a repaint */
this->SetDirty();
}
- x = (i == player) ? 1 : 0;
- DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
+ x = (i == company) ? 1 : 0;
+ DrawCompanyIcon(i, i * 37 + 13 + x, 16 + x);
}
/* The colors used to show how the progress is going */
@@ -961,7 +961,7 @@ public:
/* Draw all the score parts */
for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) {
- int val = _score_part[player][i];
+ int val = _score_part[company][i];
int needed = _score_info[i].needed;
int score = _score_info[i].score;
@@ -1024,12 +1024,12 @@ public:
virtual void OnClick(Point pt, int widget)
{
/* Check which button is clicked */
- if (IsInsideMM(widget, PRW_PLAYER_FIRST, PRW_PLAYER_LAST + 1)) {
+ if (IsInsideMM(widget, PRW_COMPANY_FIRST, PRW_COMPANY_LAST + 1)) {
/* Is it no on disable? */
if (!this->IsWidgetDisabled(widget)) {
- this->RaiseWidget(player + PRW_PLAYER_FIRST);
- player = (PlayerID)(widget - PRW_PLAYER_FIRST);
- this->LowerWidget(player + PRW_PLAYER_FIRST);
+ this->RaiseWidget(company + PRW_COMPANY_FIRST);
+ company = (CompanyID)(widget - PRW_COMPANY_FIRST);
+ this->LowerWidget(company + PRW_COMPANY_FIRST);
this->SetDirty();
}
}
@@ -1039,15 +1039,15 @@ public:
{
if (_pause_game != 0) return;
- /* Update the player score every 5 days */
+ /* Update the company score every 5 days */
if (--this->timeout == 0) {
- this->UpdatePlayerStats();
+ this->UpdateCompanyStats();
this->SetDirty();
}
}
};
-PlayerID PerformanceRatingDetailWindow::player = INVALID_PLAYER;
+CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
static const Widget _performance_rating_detail_widgets[] = {
diff --git a/src/group.h b/src/group.h
index 39712c4ad..eccc2498b 100644
--- a/src/group.h
+++ b/src/group.h
@@ -17,13 +17,13 @@ struct Group : PoolItem<Group, GroupID, &_Group_pool> {
char *name; ///< Group Name
uint16 num_vehicle; ///< Number of vehicles wich belong to the group
- PlayerByte owner; ///< Group Owner
+ OwnerByte owner; ///< Group Owner
VehicleTypeByte vehicle_type; ///< Vehicle type of the group
bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group
- uint16 *num_engines; ///< Caches the number of engines of each type the player owns (no need to save this)
+ uint16 *num_engines; ///< Caches the number of engines of each type the company owns (no need to save this)
- Group(PlayerID owner = INVALID_PLAYER);
+ Group(CompanyID owner = INVALID_COMPANY);
virtual ~Group();
bool IsValid() const;
@@ -41,7 +41,7 @@ static inline bool IsDefaultGroupID(GroupID index)
}
/**
- * Checks if a GroupID stands for all vehicles of a player
+ * Checks if a GroupID stands for all vehicles of a company
* @param id_g The GroupID to check
* @return true is id_g is identical to ALL_GROUP
*/
@@ -73,7 +73,7 @@ static inline uint GetGroupArraySize(void)
* @param id_e The EngineID of the engine to count
* @return The number of engines with EngineID id_e in the group
*/
-uint GetGroupNumEngines(PlayerID p, GroupID id_g, EngineID id_e);
+uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e);
static inline void IncreaseGroupNumVehicle(GroupID id_g)
{
@@ -90,6 +90,6 @@ void InitializeGroup();
void SetTrainGroupID(Vehicle *v, GroupID grp);
void UpdateTrainGroupID(Vehicle *v);
void RemoveVehicleFromGroup(const Vehicle *v);
-void RemoveAllGroupsForPlayer(const PlayerID p);
+void RemoveAllGroupsForCompany(const CompanyID company);
#endif /* GROUP_H */
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index bc6018ac1..5ff58c846 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -48,7 +48,7 @@ static inline void UpdateNumEngineGroup(EngineID i, GroupID old_g, GroupID new_g
DEFINE_OLD_POOL_GENERIC(Group, Group)
-Group::Group(PlayerID owner)
+Group::Group(Owner owner)
{
this->owner = owner;
@@ -58,13 +58,13 @@ Group::Group(PlayerID owner)
Group::~Group()
{
free(this->name);
- this->owner = INVALID_PLAYER;
+ this->owner = INVALID_OWNER;
free(this->num_engines);
}
bool Group::IsValid() const
{
- return this->owner != INVALID_PLAYER;
+ return this->owner != INVALID_OWNER;
}
void InitializeGroup(void)
@@ -83,16 +83,16 @@ void InitializeGroup(void)
CommandCost CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
VehicleType vt = (VehicleType)p1;
- if (!IsPlayerBuildableVehicleType(vt)) return CMD_ERROR;
+ if (!IsCompanyBuildableVehicleType(vt)) return CMD_ERROR;
if (!Group::CanAllocateItem()) return CMD_ERROR;
if (flags & DC_EXEC) {
- Group *g = new Group(_current_player);
+ Group *g = new Group(_current_company);
g->replace_protection = false;
g->vehicle_type = vt;
- InvalidateWindowData(GetWindowClassForVehicleType(vt), (vt << 11) | VLW_GROUP_LIST | _current_player);
+ InvalidateWindowData(GetWindowClassForVehicleType(vt), (vt << 11) | VLW_GROUP_LIST | _current_company);
}
return CommandCost();
@@ -111,7 +111,7 @@ CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (!IsValidGroupID(p1)) return CMD_ERROR;
Group *g = GetGroup(p1);
- if (g->owner != _current_player) return CMD_ERROR;
+ if (g->owner != _current_company) return CMD_ERROR;
if (flags & DC_EXEC) {
Vehicle *v;
@@ -125,13 +125,13 @@ CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (_backup_orders_data.group == g->index) _backup_orders_data.group = DEFAULT_GROUP;
/* If we set an autoreplace for the group we delete, remove it. */
- if (_current_player < MAX_PLAYERS) {
- Player *p;
+ if (_current_company < MAX_COMPANIES) {
+ Company *c;
EngineRenew *er;
- p = GetPlayer(_current_player);
+ c = GetCompany(_current_company);
FOR_ALL_ENGINE_RENEWS(er) {
- if (er->group_id == g->index) RemoveEngineReplacementForPlayer(p, er->from, g->index, flags);
+ if (er->group_id == g->index) RemoveEngineReplacementForCompany(c, er->from, g->index, flags);
}
}
@@ -141,7 +141,7 @@ CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
DeleteWindowById(WC_REPLACE_VEHICLE, g->vehicle_type);
delete g;
- InvalidateWindowData(GetWindowClassForVehicleType(vt), (vt << 11) | VLW_GROUP_LIST | _current_player);
+ InvalidateWindowData(GetWindowClassForVehicleType(vt), (vt << 11) | VLW_GROUP_LIST | _current_company);
}
return CommandCost();
@@ -173,7 +173,7 @@ CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (!IsValidGroupID(p1)) return CMD_ERROR;
Group *g = GetGroup(p1);
- if (g->owner != _current_player) return CMD_ERROR;
+ if (g->owner != _current_company) return CMD_ERROR;
bool reset = StrEmpty(_cmd_text);
@@ -188,7 +188,7 @@ CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* Assign the new one */
g->name = reset ? NULL : strdup(_cmd_text);
- InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_player);
+ InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_company);
}
return CommandCost();
@@ -213,10 +213,10 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p
if (IsValidGroupID(new_g)) {
Group *g = GetGroup(new_g);
- if (g->owner != _current_player || g->vehicle_type != v->type) return CMD_ERROR;
+ if (g->owner != _current_company || g->vehicle_type != v->type) return CMD_ERROR;
}
- if (v->owner != _current_player || !v->IsPrimaryVehicle()) return CMD_ERROR;
+ if (v->owner != _current_company || !v->IsPrimaryVehicle()) return CMD_ERROR;
if (flags & DC_EXEC) {
DecreaseGroupNumVehicle(v->group_id);
@@ -237,7 +237,7 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p
/* Update the Replace Vehicle Windows */
InvalidateWindow(WC_REPLACE_VEHICLE, v->type);
- InvalidateWindowData(GetWindowClassForVehicleType(v->type), (v->type << 11) | VLW_GROUP_LIST | _current_player);
+ InvalidateWindowData(GetWindowClassForVehicleType(v->type), (v->type << 11) | VLW_GROUP_LIST | _current_company);
}
return CommandCost();
@@ -253,7 +253,7 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p
CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
VehicleType type = (VehicleType)p2;
- if (!IsValidGroupID(p1) || !IsPlayerBuildableVehicleType(type)) return CMD_ERROR;
+ if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
if (flags & DC_EXEC) {
Vehicle *v;
@@ -273,7 +273,7 @@ CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, ui
}
}
- InvalidateWindowData(GetWindowClassForVehicleType(type), (type << 11) | VLW_GROUP_LIST | _current_player);
+ InvalidateWindowData(GetWindowClassForVehicleType(type), (type << 11) | VLW_GROUP_LIST | _current_company);
}
return CommandCost();
@@ -290,10 +290,10 @@ CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, ui
CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
VehicleType type = (VehicleType)p2;
- if (!IsValidGroupID(p1) || !IsPlayerBuildableVehicleType(type)) return CMD_ERROR;
+ if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
Group *g = GetGroup(p1);
- if (g->owner != _current_player) return CMD_ERROR;
+ if (g->owner != _current_company) return CMD_ERROR;
if (flags & DC_EXEC) {
GroupID old_g = p1;
@@ -309,7 +309,7 @@ CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, u
}
}
- InvalidateWindowData(GetWindowClassForVehicleType(type), (type << 11) | VLW_GROUP_LIST | _current_player);
+ InvalidateWindowData(GetWindowClassForVehicleType(type), (type << 11) | VLW_GROUP_LIST | _current_company);
}
return CommandCost();
@@ -329,12 +329,12 @@ CommandCost CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1
if (!IsValidGroupID(p1)) return CMD_ERROR;
Group *g = GetGroup(p1);
- if (g->owner != _current_player) return CMD_ERROR;
+ if (g->owner != _current_company) return CMD_ERROR;
if (flags & DC_EXEC) {
g->replace_protection = HasBit(p2, 0);
- InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_player);
+ InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_company);
}
return CommandCost();
@@ -398,26 +398,26 @@ void UpdateTrainGroupID(Vehicle *v)
InvalidateWindow(WC_REPLACE_VEHICLE, VEH_TRAIN);
}
-uint GetGroupNumEngines(PlayerID p, GroupID id_g, EngineID id_e)
+uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e)
{
if (IsValidGroupID(id_g)) return GetGroup(id_g)->num_engines[id_e];
- uint num = GetPlayer(p)->num_engines[id_e];
+ uint num = GetCompany(company)->num_engines[id_e];
if (!IsDefaultGroupID(id_g)) return num;
const Group *g;
FOR_ALL_GROUPS(g) {
- if (g->owner == p) num -= g->num_engines[id_e];
+ if (g->owner == company) num -= g->num_engines[id_e];
}
return num;
}
-void RemoveAllGroupsForPlayer(const PlayerID p)
+void RemoveAllGroupsForCompany(const CompanyID company)
{
Group *g;
FOR_ALL_GROUPS(g) {
- if (p == g->owner) delete g;
+ if (company == g->owner) delete g;
}
}
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index b9c2abd5e..d310a4c84 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -132,7 +132,7 @@ private:
*
* @param owner The owner of the window
*/
- void BuildGroupList(PlayerID owner)
+ void BuildGroupList(Owner owner)
{
if (!this->groups.NeedRebuild()) return;
@@ -175,7 +175,7 @@ private:
public:
VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number)
{
- const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8);
+ const Owner owner = (Owner)GB(this->window_number, 0, 8);
this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
this->caption_color = owner;
@@ -286,14 +286,14 @@ public:
virtual void OnPaint()
{
- const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8);
+ const Owner owner = (Owner)GB(this->window_number, 0, 8);
int x = this->widget[GRP_WIDGET_LIST_VEHICLE].left + 2;
int y1 = PLY_WND_PRC__OFFSET_TOP_WIDGET + 2;
int max;
int i;
- /* If we select the all vehicles, this->list will contain all vehicles of the player
- * else this->list will contain all vehicles which belong to the selected group */
+ /* If we select the all vehicles, this->list will contain all vehicles of the owner
+ * else this->list will contain all vehicles which belong to the selected group */
this->BuildVehicleList(owner, this->group_sel, IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST);
this->SortVehicleList();
@@ -310,26 +310,26 @@ public:
}
/* Disable all lists management button when the list is empty */
- this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_player != owner,
+ this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != owner,
GRP_WIDGET_STOP_ALL,
GRP_WIDGET_START_ALL,
GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN,
WIDGET_LIST_END);
/* Disable the group specific function when we select the default group or all vehicles */
- this->SetWidgetsDisabledState(IsDefaultGroupID(this->group_sel) || IsAllGroupID(this->group_sel) || _local_player != owner,
+ this->SetWidgetsDisabledState(IsDefaultGroupID(this->group_sel) || IsAllGroupID(this->group_sel) || _local_company != owner,
GRP_WIDGET_DELETE_GROUP,
GRP_WIDGET_RENAME_GROUP,
GRP_WIDGET_REPLACE_PROTECTION,
WIDGET_LIST_END);
- /* Disable remaining buttons for non-local player
- * Needed while changing _local_player, eg. by cheats
- * All procedures (eg. move vehicle to another group)
- * verify, whether you are the owner of the vehicle,
- * so it doesn't have to be disabled
- */
- this->SetWidgetsDisabledState(_local_player != owner,
+ /* Disable remaining buttons for non-local companies
+ * Needed while changing _local_company, eg. by cheats
+ * All procedures (eg. move vehicle to another group)
+ * verify, whether you are the owner of the vehicle,
+ * so it doesn't have to be disabled
+ */
+ this->SetWidgetsDisabledState(_local_company != owner,
GRP_WIDGET_CREATE_GROUP,
GRP_WIDGET_AVAILABLE_VEHICLES,
WIDGET_LIST_END);
@@ -705,11 +705,11 @@ static WindowDesc _group_desc = {
_group_widgets,
};
-void ShowPlayerGroup(PlayerID player, VehicleType vehicle_type)
+void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type)
{
- if (!IsValidPlayerID(player)) return;
+ if (!IsValidCompanyID(company)) return;
_group_desc.cls = GetWindowClassForVehicleType(vehicle_type);
- WindowNumber num = (vehicle_type << 11) | VLW_GROUP_LIST | player;
+ WindowNumber num = (vehicle_type << 11) | VLW_GROUP_LIST | company;
AllocateWindowDescFront<VehicleGroupWindow>(&_group_desc, num);
}
diff --git a/src/group_gui.h b/src/group_gui.h
index a20318901..7db3ed9a1 100644
--- a/src/group_gui.h
+++ b/src/group_gui.h
@@ -7,6 +7,6 @@
#include "vehicle_type.h"
-void ShowPlayerGroup(PlayerID player, VehicleType veh);
+void ShowCompanyGroup(CompanyID company, VehicleType veh);
#endif /* GROUP_GUI_H */
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 7c78762a1..59f3cc02a 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -420,10 +420,10 @@ static CommandCost ClearTile_Industry(TileIndex tile, byte flags)
* with magic_bulldozer cheat you can destroy industries
* (area around OILRIG is water, so water shouldn't flood it
*/
- if ((_current_player != OWNER_WATER && _game_mode != GM_EDITOR &&
+ if ((_current_company != OWNER_WATER && _game_mode != GM_EDITOR &&
!_cheats.magic_bulldozer.value) ||
((flags & DC_AUTO) != 0) ||
- (_current_player == OWNER_WATER &&
+ (_current_company == OWNER_WATER &&
((indspec->behaviour & INDUSTRYBEH_BUILT_ONWATER) ||
HasBit(GetIndustryTileSpec(GetIndustryGfx(tile))->slopes_refused, 5)))) {
SetDParam(0, indspec->name);
@@ -852,11 +852,11 @@ static void GetProducedCargo_Industry(TileIndex tile, CargoID *b)
b[1] = i->produced_cargo[1];
}
-static void ChangeTileOwner_Industry(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Industry(TileIndex tile, Owner old_owner, Owner new_owner)
{
/* If the founder merges, the industry was created by the merged company */
Industry *i = GetIndustryByTile(tile);
- if (i->founder == old_player) i->founder = (new_player == PLAYER_SPECTATOR) ? OWNER_NONE : new_player;
+ if (i->founder == old_owner) i->founder = (new_owner == INVALID_OWNER) ? OWNER_NONE : new_owner;
}
static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
@@ -976,17 +976,17 @@ void PlantRandomFarmField(const Industry *i)
static bool SearchLumberMillTrees(TileIndex tile, void *user_data)
{
if (IsTileType(tile, MP_TREES) && GetTreeGrowth(tile) > 2) { ///< 3 and up means all fully grown trees
- PlayerID old_player = _current_player;
+ CompanyID old_company = _current_company;
/* found a tree */
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
_industry_sound_ctr = 1;
_industry_sound_tile = tile;
SndPlayTileFx(SND_38_CHAINSAW, tile);
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
- _current_player = old_player;
+ _current_company = old_company;
return true;
}
return false;
@@ -1361,10 +1361,10 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, uint32 flags, const
/* Check if we don't leave the map */
if (TileX(cur_tile) == 0 || TileY(cur_tile) == 0 || TileX(cur_tile) + size_x >= MapMaxX() || TileY(cur_tile) + size_y >= MapMaxY()) return false;
- /* _current_player is OWNER_NONE for randomly generated industries and in editor, or the player who funded or prospected the industry.
+ /* _current_company is OWNER_NONE for randomly generated industries and in editor, or the company who funded or prospected the industry.
* Perform terraforming as OWNER_TOWN to disable autoslope. */
- PlayerID old_player = _current_player;
- _current_player = OWNER_TOWN;
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_TOWN;
BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) {
curh = TileHeight(tile_walk);
@@ -1372,13 +1372,13 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, uint32 flags, const
/* This tile needs terraforming. Check if we can do that without
* damaging the surroundings too much. */
if (!CheckCanTerraformSurroundingTiles(tile_walk, h, 0)) {
- _current_player = old_player;
+ _current_company = old_company;
return false;
}
/* This is not 100% correct check, but the best we can do without modifying the map.
* What is missing, is if the difference in height is more than 1.. */
if (CmdFailed(DoCommand(tile_walk, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND))) {
- _current_player = old_player;
+ _current_company = old_company;
return false;
}
}
@@ -1398,7 +1398,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, uint32 flags, const
} END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile)
}
- _current_player = old_player;
+ _current_company = old_company;
return true;
}
@@ -1502,7 +1502,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
i->last_prod_year = _cur_year;
i->last_month_production[0] = i->production_rate[0] * 8;
i->last_month_production[1] = i->production_rate[1] * 8;
- i->founder = _current_player;
+ i->founder = _current_company;
if (HasBit(indspec->callback_flags, CBM_IND_DECIDE_COLOUR)) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_DECIDE_COLOUR, 0, 0, i, type, INVALID_TILE);
@@ -1734,8 +1734,8 @@ static void PlaceInitialIndustry(IndustryType type, int amount)
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
if (_settings_game.difficulty.number_industries != 0) {
- PlayerID old_player = _current_player;
- _current_player = OWNER_NONE;
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_NONE;
assert(num > 0);
do {
@@ -1748,7 +1748,7 @@ static void PlaceInitialIndustry(IndustryType type, int amount)
}
} while (--num);
- _current_player = old_player;
+ _current_company = old_company;
}
}
@@ -1959,7 +1959,7 @@ static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accept
*
* @param ind: Industry being investigated.
*
-* @return: 0 if nobody can service the industry, 2 if the local player can
+* @return: 0 if nobody can service the industry, 2 if the local company can
* service the industry, and 1 otherwise (only competitors can service the
* industry)
*/
@@ -1974,7 +1974,7 @@ int WhoCanServiceIndustry(Industry* ind)
int result = 0;
FOR_ALL_VEHICLES(v) {
/* Is it worthwhile to try this vehicle? */
- if (v->owner != _local_player && result != 0) continue;
+ if (v->owner != _local_company && result != 0) continue;
/* Check whether it accepts the right kind of cargo */
bool c_accepts = false;
@@ -2005,7 +2005,7 @@ int WhoCanServiceIndustry(Industry* ind)
if ((o->GetUnloadType() & OUFB_UNLOAD) && !c_accepts) break;
if (stations.find(st) != stations.end()) {
- if (v->owner == _local_player) return 2; // Player services industry
+ if (v->owner == _local_company) return 2; // Company services industry
result = 1; // Competitor services industry
}
}
@@ -2026,9 +2026,9 @@ static void ReportNewsProductionChangeIndustry(Industry *ind, CargoID type, int
NewsSubtype ns;
switch (WhoCanServiceIndustry(ind)) {
- case 0: ns = NS_INDUSTRY_NOBODY; break;
- case 1: ns = NS_INDUSTRY_OTHER; break;
- case 2: ns = NS_INDUSTRY_PLAYER; break;
+ case 0: ns = NS_INDUSTRY_NOBODY; break;
+ case 1: ns = NS_INDUSTRY_OTHER; break;
+ case 2: ns = NS_INDUSTRY_COMPANY; break;
default: NOT_REACHED(); break;
}
SetDParam(2, abs(percent));
@@ -2210,9 +2210,9 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
ns = NS_INDUSTRY_CLOSE;
} else {
switch (WhoCanServiceIndustry(i)) {
- case 0: ns = NS_INDUSTRY_NOBODY; break;
- case 1: ns = NS_INDUSTRY_OTHER; break;
- case 2: ns = NS_INDUSTRY_PLAYER; break;
+ case 0: ns = NS_INDUSTRY_NOBODY; break;
+ case 1: ns = NS_INDUSTRY_OTHER; break;
+ case 2: ns = NS_INDUSTRY_COMPANY; break;
default: NOT_REACHED(); break;
}
}
@@ -2256,8 +2256,8 @@ void IndustryDailyLoop()
return; // Nothing to do? get out
}
- PlayerID old_player = _current_player;
- _current_player = OWNER_NONE;
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_NONE;
/* perform the required industry changes for the day */
for (uint16 j = 0; j < change_loop; j++) {
@@ -2270,7 +2270,7 @@ void IndustryDailyLoop()
}
}
- _current_player = old_player;
+ _current_company = old_company;
/* production-change */
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, 1);
@@ -2279,8 +2279,8 @@ void IndustryDailyLoop()
void IndustryMonthlyLoop()
{
Industry *i;
- PlayerID old_player = _current_player;
- _current_player = OWNER_NONE;
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_NONE;
FOR_ALL_INDUSTRIES(i) {
UpdateIndustryStatistics(i);
@@ -2291,7 +2291,7 @@ void IndustryMonthlyLoop()
}
}
- _current_player = old_player;
+ _current_company = old_company;
/* production-change */
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, 1);
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index e81b2ccfb..58116f081 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -359,7 +359,7 @@ public:
return;
}
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
_generating_world = true;
_ignore_restrictions = true;
success = DoCommandP(tile, (InteractiveRandomRange(indsp->num_table) << 16) | this->selected_type, seed, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
@@ -420,7 +420,7 @@ public:
void ShowBuildIndustryWindow()
{
- if (_game_mode != GM_EDITOR && !IsValidPlayerID(_current_player)) return;
+ if (_game_mode != GM_EDITOR && !IsValidCompanyID(_current_company)) return;
if (BringWindowToFrontById(WC_BUILD_INDUSTRY, 0)) return;
new BuildIndustryWindow();
}
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 30a01e5dd..2e4e10c47 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -473,9 +473,9 @@ TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode
return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode, side);
}
-void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player)
+void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
{
- _tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_player, new_player);
+ _tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_owner, new_owner);
}
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac)
@@ -895,7 +895,7 @@ void OnTick_Trees();
void OnTick_Station();
void OnTick_Industry();
-void OnTick_Players();
+void OnTick_Companies();
void OnTick_Train();
void CallLandscapeTick()
@@ -905,7 +905,7 @@ void CallLandscapeTick()
OnTick_Station();
OnTick_Industry();
- OnTick_Players();
+ OnTick_Companies();
OnTick_Train();
}
diff --git a/src/livery.h b/src/livery.h
index a5f6674c4..719aeb798 100644
--- a/src/livery.h
+++ b/src/livery.h
@@ -67,10 +67,10 @@ struct Livery {
};
/**
- * Reset the livery schemes to the player's primary colour.
- * This is used on loading games without livery information and on new player start up.
- * @param p Player to reset.
+ * Reset the livery schemes to the company's primary colour.
+ * This is used on loading games without livery information and on new company start up.
+ * @param c Company to reset.
*/
-void ResetPlayerLivery(Player *p);
+void ResetCompanyLivery(Company *c);
#endif /* LIVERY_H */
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 7ac736638..414088970 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -49,7 +49,7 @@ void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
if (!success || !_settings_game.economy.give_money) return;
char msg[20];
- /* Inform the player of this action */
+ /* Inform the company of the action of one of it's clients (controllers). */
snprintf(msg, sizeof(msg), "%d", p1);
if (!_network_server) {
@@ -67,8 +67,8 @@ void HandleOnEditText(const char *str)
switch (_rename_what) {
#ifdef ENABLE_NETWORK
case 3: { // Give money, you can only give money in excess of loan
- const Player *p = GetPlayer(_current_player);
- Money money = min(p->player_money - p->current_loan, (Money)(atoi(str) / _currency->rate));
+ const Company *c = GetCompany(_current_company);
+ Money money = min(c->money - c->current_loan, (Money)(atoi(str) / _currency->rate));
uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
@@ -118,9 +118,9 @@ void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2)
}
#ifdef ENABLE_NETWORK
-void ShowNetworkGiveMoneyWindow(PlayerID player)
+void ShowNetworkGiveMoneyWindow(CompanyID company)
{
- _rename_id = player;
+ _rename_id = company;
_rename_what = 3;
ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL, QSF_NONE);
}
@@ -319,8 +319,8 @@ struct MainWindow : Window
if (cio == NULL) break;
- /* Only players actually playing can speak to team. Eg spectators cannot */
- if (_settings_client.gui.prefer_teamchat && IsValidPlayerID(cio->client_playas)) {
+ /* Only companies actually playing can speak to team. Eg spectators cannot */
+ if (_settings_client.gui.prefer_teamchat && IsValidCompanyID(cio->client_playas)) {
const NetworkClientInfo *ci;
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
if (ci->client_playas == cio->client_playas && ci != cio) {
@@ -334,7 +334,7 @@ struct MainWindow : Window
}
break;
- case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players
+ case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all clients
if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
break;
diff --git a/src/misc.cpp b/src/misc.cpp
index 6e2b5d976..3d51bf2b2 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -52,7 +52,7 @@ void InitializeTrees();
void InitializeSigns();
void InitializeStations();
void InitializeCargoPackets();
-void InitializePlayers();
+void InitializeCompanies();
void InitializeCheats();
void InitializeNPF();
void InitializeOldNames();
@@ -101,7 +101,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date)
InitializeTrains();
InitializeNPF();
- InitializePlayers();
+ InitializeCompanies();
AI_Initialize();
InitializeCheats();
@@ -151,7 +151,7 @@ static const SaveLoadGlobVarList _date_desc[] = {
SLEG_VAR(_random.state[1], SLE_UINT32),
SLEG_CONDVAR(_cur_town_ctr, SLE_FILE_U8 | SLE_VAR_U32, 0, 9),
SLEG_CONDVAR(_cur_town_ctr, SLE_UINT32, 10, SL_MAX_VERSION),
- SLEG_VAR(_cur_player_tick_index, SLE_FILE_U8 | SLE_VAR_U32),
+ SLEG_VAR(_cur_company_tick_index, SLE_FILE_U8 | SLE_VAR_U32),
SLEG_VAR(_next_competitor_start, SLE_FILE_U16 | SLE_VAR_U32),
SLEG_VAR(_trees_tick_ctr, SLE_UINT8),
SLEG_CONDVAR(_pause_game, SLE_UINT8, 4, SL_MAX_VERSION),
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index 084949a32..572cf0cef 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -25,26 +25,26 @@
#include "table/strings.h"
-/** Change the player's face.
+/** Change the company manager's face.
* @param tile unused
* @param flags operation to perform
* @param p1 unused
* @param p2 face bitmasked
*/
-CommandCost CmdSetPlayerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdSetCompanyManagerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- PlayerFace pf = (PlayerFace)p2;
+ CompanyManagerFace cmf = (CompanyManagerFace)p2;
- if (!IsValidPlayerIDFace(pf)) return CMD_ERROR;
+ if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
if (flags & DC_EXEC) {
- GetPlayer(_current_player)->face = pf;
+ GetCompany(_current_company)->face = cmf;
MarkWholeScreenDirty();
}
return CommandCost();
}
-/** Change the player's company-colour
+/** Change the company's company-colour
* @param tile unused
* @param flags operation to perform
* @param p1 bitstuffed:
@@ -52,7 +52,7 @@ CommandCost CmdSetPlayerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* p1 bits 8-9 set in use state or first/second colour
* @param p2 new colour for vehicles, property, etc.
*/
-CommandCost CmdSetPlayerColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdSetCompanyColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (p2 >= 16) return CMD_ERROR; // max 16 colours
@@ -63,35 +63,35 @@ CommandCost CmdSetPlayerColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
if (scheme >= LS_END || state >= 3) return CMD_ERROR;
- Player *p = GetPlayer(_current_player);
+ Company *c = GetCompany(_current_company);
/* Ensure no two companies have the same primary colour */
if (scheme == LS_DEFAULT && state == 0) {
- const Player *pp;
- FOR_ALL_PLAYERS(pp) {
- if (pp != p && pp->player_color == colour) return CMD_ERROR;
+ const Company *cc;
+ FOR_ALL_COMPANIES(cc) {
+ if (cc != c && cc->colour == colour) return CMD_ERROR;
}
}
if (flags & DC_EXEC) {
switch (state) {
case 0:
- p->livery[scheme].colour1 = colour;
+ c->livery[scheme].colour1 = colour;
/* If setting the first colour of the default scheme, adjust the
- * original and cached player colours too. */
+ * original and cached company colours too. */
if (scheme == LS_DEFAULT) {
- _player_colors[_current_player] = colour;
- p->player_color = colour;
+ _company_colours[_current_company] = colour;
+ c->colour = colour;
}
break;
case 1:
- p->livery[scheme].colour2 = colour;
+ c->livery[scheme].colour2 = colour;
break;
case 2:
- p->livery[scheme].in_use = colour != 0;
+ c->livery[scheme].in_use = colour != 0;
/* Now handle setting the default scheme's in_use flag.
* This is different to the other schemes, as it signifies if any
@@ -101,16 +101,16 @@ CommandCost CmdSetPlayerColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
/* If enabling a scheme, set the default scheme to be in use too */
if (colour != 0) {
- p->livery[LS_DEFAULT].in_use = true;
+ c->livery[LS_DEFAULT].in_use = true;
break;
}
/* Else loop through all schemes to see if any are left enabled.
* If not, disable the default scheme too. */
- p->livery[LS_DEFAULT].in_use = false;
+ c->livery[LS_DEFAULT].in_use = false;
for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
- if (p->livery[scheme].in_use) {
- p->livery[LS_DEFAULT].in_use = true;
+ if (c->livery[scheme].in_use) {
+ c->livery[LS_DEFAULT].in_use = true;
break;
}
}
@@ -134,9 +134,9 @@ CommandCost CmdSetPlayerColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
*/
CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- Player *p = GetPlayer(_current_player);
+ Company *c = GetCompany(_current_company);
- if (p->current_loan >= _economy.max_loan) {
+ if (c->current_loan >= _economy.max_loan) {
SetDParam(0, _economy.max_loan);
return_cmd_error(STR_702B_MAXIMUM_PERMITTED_LOAN);
}
@@ -145,20 +145,20 @@ CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
switch (p2) {
default: return CMD_ERROR; // Invalid method
case 0: // Take some extra loan
- loan = (IsHumanPlayer(_current_player) || _settings_game.ai.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI;
+ loan = (IsHumanCompany(_current_company) || _settings_game.ai.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI;
break;
case 1: // Take a loan as big as possible
- loan = _economy.max_loan - p->current_loan;
+ loan = _economy.max_loan - c->current_loan;
break;
}
/* Overflow protection */
- if (p->player_money + p->current_loan + loan < p->player_money) return CMD_ERROR;
+ if (c->money + c->current_loan + loan < c->money) return CMD_ERROR;
if (flags & DC_EXEC) {
- p->player_money += loan;
- p->current_loan += loan;
- InvalidatePlayerWindows(p);
+ c->money += loan;
+ c->current_loan += loan;
+ InvalidateCompanyWindows(c);
}
return CommandCost(EXPENSES_OTHER);
@@ -173,42 +173,42 @@ CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
*/
CommandCost CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- Player *p = GetPlayer(_current_player);
+ Company *c = GetCompany(_current_company);
- if (p->current_loan == 0) return_cmd_error(STR_702D_LOAN_ALREADY_REPAYED);
+ if (c->current_loan == 0) return_cmd_error(STR_702D_LOAN_ALREADY_REPAYED);
Money loan;
switch (p2) {
default: return CMD_ERROR; // Invalid method
case 0: // Pay back one step
- loan = min(p->current_loan, (Money)(IsHumanPlayer(_current_player) || _settings_game.ai.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI);
+ loan = min(c->current_loan, (Money)(IsHumanCompany(_current_company) || _settings_game.ai.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI);
break;
case 1: // Pay back as much as possible
- loan = max(min(p->current_loan, p->player_money), (Money)LOAN_INTERVAL);
+ loan = max(min(c->current_loan, c->money), (Money)LOAN_INTERVAL);
loan -= loan % LOAN_INTERVAL;
break;
}
- if (p->player_money < loan) {
+ if (c->money < loan) {
SetDParam(0, loan);
return_cmd_error(STR_702E_REQUIRED);
}
if (flags & DC_EXEC) {
- p->player_money -= loan;
- p->current_loan -= loan;
- InvalidatePlayerWindows(p);
+ c->money -= loan;
+ c->current_loan -= loan;
+ InvalidateCompanyWindows(c);
}
return CommandCost();
}
static bool IsUniqueCompanyName(const char *name)
{
- const Player *p;
+ const Company *c;
char buf[512];
- FOR_ALL_PLAYERS(p) {
- SetDParam(0, p->index);
+ FOR_ALL_COMPANIES(c) {
+ SetDParam(0, c->index);
GetString(buf, STR_COMPANY_NAME, lastof(buf));
if (strcmp(buf, name) == 0) return false;
}
@@ -232,9 +232,9 @@ CommandCost CmdRenameCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
if (flags & DC_EXEC) {
- Player *p = GetPlayer(_current_player);
- free(p->name);
- p->name = reset ? NULL : strdup(_cmd_text);
+ Company *c = GetCompany(_current_company);
+ free(c->name);
+ c->name = reset ? NULL : strdup(_cmd_text);
MarkWholeScreenDirty();
}
@@ -243,11 +243,11 @@ CommandCost CmdRenameCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
static bool IsUniquePresidentName(const char *name)
{
- const Player *p;
+ const Company *c;
char buf[512];
- FOR_ALL_PLAYERS(p) {
- SetDParam(0, p->index);
+ FOR_ALL_COMPANIES(c) {
+ SetDParam(0, c->index);
GetString(buf, STR_PLAYER_NAME, lastof(buf));
if (strcmp(buf, name) == 0) return false;
}
@@ -271,15 +271,15 @@ CommandCost CmdRenamePresident(TileIndex tile, uint32 flags, uint32 p1, uint32 p
}
if (flags & DC_EXEC) {
- Player *p = GetPlayer(_current_player);
- free(p->president_name);
+ Company *c = GetCompany(_current_company);
+ free(c->president_name);
if (reset) {
- p->president_name = NULL;
+ c->president_name = NULL;
} else {
- p->president_name = strdup(_cmd_text);
+ c->president_name = strdup(_cmd_text);
- if (p->name_1 == STR_SV_UNNAMED && p->name == NULL) {
+ if (c->name_1 == STR_SV_UNNAMED && c->name == NULL) {
char buf[80];
snprintf(buf, lengthof(buf), "%s Transport", _cmd_text);
@@ -358,34 +358,34 @@ CommandCost CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return CommandCost(EXPENSES_OTHER, -(int32)p1);
}
-/** Transfer funds (money) from one player to another.
+/** Transfer funds (money) from one company to another.
* To prevent abuse in multiplayer games you can only send money to other
- * players if you have paid off your loan (either explicitely, or implicitely
+ * companies if you have paid off your loan (either explicitely, or implicitely
* given the fact that you have more money than loan).
* @param tile unused
* @param flags operation to perform
* @param p1 the amount of money to transfer; max 20.000.000
- * @param p2 the player to transfer the money to
+ * @param p2 the company to transfer the money to
*/
CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (!_settings_game.economy.give_money) return CMD_ERROR;
- const Player *p = GetPlayer(_current_player);
+ const Company *c = GetCompany(_current_company);
CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
/* You can only transfer funds that is in excess of your loan */
- if (p->player_money - p->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR;
- if (!_networking || !IsValidPlayerID((PlayerID)p2)) return CMD_ERROR;
+ if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR;
+ if (!_networking || !IsValidCompanyID((CompanyID)p2)) return CMD_ERROR;
if (flags & DC_EXEC) {
- /* Add money to player */
- PlayerID old_cp = _current_player;
- _current_player = (PlayerID)p2;
- SubtractMoneyFromPlayer(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
- _current_player = old_cp;
+ /* Add money to company */
+ CompanyID old_company = _current_company;
+ _current_company = (CompanyID)p2;
+ SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
+ _current_company = old_company;
}
- /* Subtract money from local-player */
+ /* Subtract money from local-company */
return amount;
}
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 028fd9409..bda46aded 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -104,13 +104,13 @@ public:
}
LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
- Player *p = GetPlayer(IsValidPlayerID(_local_player) ? _local_player : PLAYER_FIRST);
+ Company *c = GetCompany(IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
- Money old_money = p->player_money;
- p->player_money = INT64_MAX;
+ Money old_money = c->money;
+ c->money = INT64_MAX;
CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
- p->player_money = old_money;
+ c->money = old_money;
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
TileDesc td;
@@ -423,14 +423,14 @@ private:
uint64 decode_params[20];
StringID message_1;
StringID message_2;
- bool show_player_face;
+ bool show_company_manager_face;
int y[2];
public:
- ErrmsgWindow(Point pt, int width, int height, StringID msg1, StringID msg2, const Widget *widget, bool show_player_face) :
+ ErrmsgWindow(Point pt, int width, int height, StringID msg1, StringID msg2, const Widget *widget, bool show_company_manager_face) :
Window(pt.x, pt.y, width, height, WC_ERRMSG, widget),
- show_player_face(show_player_face)
+ show_company_manager_face(show_company_manager_face)
{
this->duration = _settings_client.gui.errmsg_duration;
CopyOutDParam(this->decode_params, 0, lengthof(this->decode_params));
@@ -476,9 +476,9 @@ public:
SwitchToErrorRefStack();
RewindTextRefStack();
- if (this->show_player_face) {
- const Player *p = GetPlayer((PlayerID)GetDParamX(this->decode_params, 2));
- DrawPlayerFace(p->face, p->player_color, 2, 16);
+ if (this->show_company_manager_face) {
+ const Company *c = GetCompany((CompanyID)GetDParamX(this->decode_params, 2));
+ DrawCompanyManagerFace(c->face, c->colour, 2, 16);
}
DrawStringMultiCenter(this->width - 120, y[1], this->message_2, this->width - 2);
@@ -1419,10 +1419,10 @@ struct SaveLoadWindow : public QueryStringBaseWindow {
void GenerateFileName()
{
/* Check if we are not a spectator who wants to generate a name..
- * Let's use the name of player #0 for now. */
- const Player *p = GetPlayer(IsValidPlayerID(_local_player) ? _local_player : PLAYER_FIRST);
+ * Let's use the name of company #0 for now. */
+ const Company *c = GetCompany(IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
- SetDParam(0, p->index);
+ SetDParam(0, c->index);
SetDParam(1, _date);
GetString(this->edit_str_buf, STR_4004, &this->edit_str_buf[this->edit_str_size - 1]);
SanitizeFilename(this->edit_str_buf);
diff --git a/src/network/core/config.h b/src/network/core/config.h
index 7d9672036..c41190cce 100644
--- a/src/network/core/config.h
+++ b/src/network/core/config.h
@@ -29,8 +29,8 @@ enum {
NETWORK_UNIQUE_ID_LENGTH = 33, ///< The maximum length of the unique id of the clients, in bytes including '\0'
NETWORK_REVISION_LENGTH = 15, ///< The maximum length of the revision, in bytes including '\0'
NETWORK_PASSWORD_LENGTH = 33, ///< The maximum length of the password, in bytes including '\0' (must be >= NETWORK_UNIQUE_ID_LENGTH)
- NETWORK_PLAYERS_LENGTH = 200, ///< The maximum length for the list of players that controls a company, in bytes including '\0'
- NETWORK_CLIENT_NAME_LENGTH = 25, ///< The maximum length of a player, in bytes including '\0'
+ NETWORK_CLIENTS_LENGTH = 200, ///< The maximum length for the list of clients that controls a company, in bytes including '\0'
+ NETWORK_CLIENT_NAME_LENGTH = 25, ///< The maximum length of a client's name, in bytes including '\0'
NETWORK_RCONCOMMAND_LENGTH = 500, ///< The maximum length of a rconsole command, in bytes including '\0'
NETWORK_CHAT_LENGTH = 900, ///< The maximum length of a chat message, in bytes including '\0'
diff --git a/src/network/core/game.h b/src/network/core/game.h
index 6b8e989b3..714711fe4 100644
--- a/src/network/core/game.h
+++ b/src/network/core/game.h
@@ -17,7 +17,7 @@
/**
* This is the struct used by both client and server
* some fields will be empty on the client (like game_password) by default
- * and only filled with data a player enters.
+ * and only filled with data a client enters.
*/
struct NetworkServerGameInfo {
byte clients_on; ///< Current count of clients on server
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index 16a795e28..6af0d17f8 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -61,7 +61,7 @@ enum {
/** Packet that wraps a command */
struct CommandPacket {
CommandPacket *next; ///< the next command packet (if in queue)
- PlayerByte player; ///< player that is executing the command
+ CompanyByte company; ///< company that is executing the command
uint32 cmd; ///< command being executed
uint32 p1; ///< parameter p1
uint32 p2; ///< parameter p2
@@ -81,7 +81,7 @@ enum ClientStatus {
STATUS_MAP, ///< The client is downloading the map
STATUS_DONE_MAP, ///< The client has downloaded the map
STATUS_PRE_ACTIVE, ///< The client is catching up the delayed frames
- STATUS_ACTIVE, ///< The client is an active player in the game
+ STATUS_ACTIVE, ///< The client is active within in the game
};
/** Base socket handler for all TCP sockets */
diff --git a/src/network/network.cpp b/src/network/network.cpp
index e2b355c6f..0033f4030 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -47,7 +47,7 @@ bool _network_available; ///< is network mode available?
bool _network_dedicated; ///< are we a dedicated server?
bool _is_network_server; ///< Does this client wants to be a network-server?
NetworkServerGameInfo _network_game_info;
-NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
+NetworkCompanyInfo _network_company_info[MAX_COMPANIES];
NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
uint16 _network_own_client_index;
uint16 _redirect_console_to_client;
@@ -155,7 +155,7 @@ byte NetworkSpectatorCount()
byte count = 0;
FOR_ALL_CLIENTS(cs) {
- if (DEREF_CLIENT_INFO(cs)->client_playas == PLAYER_SPECTATOR) count++;
+ if (DEREF_CLIENT_INFO(cs)->client_playas == COMPANY_SPECTATOR) count++;
}
return count;
@@ -335,54 +335,54 @@ char* GetNetworkErrorMsg(char* buf, NetworkErrorCode err, const char* last)
}
/* Count the number of active clients connected */
-static uint NetworkCountPlayers()
+static uint NetworkCountActiveClients()
{
NetworkTCPSocketHandler *cs;
uint count = 0;
FOR_ALL_CLIENTS(cs) {
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayerID(ci->client_playas)) count++;
+ if (IsValidCompanyID(ci->client_playas)) count++;
}
return count;
}
-static bool _min_players_paused = false;
+static bool _min_active_clients_paused = false;
-/* Check if the minimum number of players has been reached and pause or unpause the game as appropriate */
-void CheckMinPlayers()
+/* Check if the minimum number of active clients has been reached and pause or unpause the game as appropriate */
+void CheckMinActiveClients()
{
if (!_network_dedicated) return;
- if (NetworkCountPlayers() < _settings_client.network.min_players) {
- if (_min_players_paused) return;
+ if (NetworkCountActiveClients() < _settings_client.network.min_active_clients) {
+ if (_min_active_clients_paused) return;
- _min_players_paused = true;
+ _min_active_clients_paused = true;
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game paused (not enough players)", NETWORK_SERVER_INDEX);
} else {
- if (!_min_players_paused) return;
+ if (!_min_active_clients_paused) return;
- _min_players_paused = false;
+ _min_active_clients_paused = false;
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (enough players)", NETWORK_SERVER_INDEX);
}
}
-/** Converts a string to ip/port/player
- * Format: IP#player:port
+/** Converts a string to ip/port/company
+ * Format: IP#company:port
*
- * connection_string will be re-terminated to seperate out the hostname, and player and port will
- * be set to the player and port strings given by the user, inside the memory area originally
+ * connection_string will be re-terminated to seperate out the hostname, and company and port will
+ * be set to the company and port strings given by the user, inside the memory area originally
* occupied by connection_string. */
-void ParseConnectionString(const char **player, const char **port, char *connection_string)
+void ParseConnectionString(const char **company, const char **port, char *connection_string)
{
char *p;
for (p = connection_string; *p != '\0'; p++) {
switch (*p) {
case '#':
- *player = p + 1;
+ *company = p + 1;
*p = '\0';
break;
case ':':
@@ -421,7 +421,7 @@ static NetworkTCPSocketHandler *NetworkAllocClient(SOCKET s)
cs->index = _network_client_index++;
ci->client_index = cs->index;
- ci->client_playas = PLAYER_INACTIVE_CLIENT;
+ ci->client_playas = COMPANY_INACTIVE_CLIENT;
ci->join_date = _date;
InvalidateWindow(WC_CLIENT_LIST, 0);
@@ -495,7 +495,7 @@ void NetworkCloseClient(NetworkTCPSocketHandler *cs)
cs->index = NETWORK_EMPTY_INDEX;
ci->client_index = NETWORK_EMPTY_INDEX;
- CheckMinPlayers();
+ CheckMinActiveClients();
}
// A client wants to connect to a server
@@ -688,7 +688,7 @@ static void NetworkInitialize()
// Clean the client_info memory
memset(&_network_client_info, 0, sizeof(_network_client_info));
- memset(&_network_player_info, 0, sizeof(_network_player_info));
+ memset(&_network_company_info, 0, sizeof(_network_company_info));
_sync_frame = 0;
_network_first_time = true;
@@ -729,7 +729,7 @@ void NetworkAddServer(const char *b)
{
if (*b != '\0') {
const char *port = NULL;
- const char *player = NULL;
+ const char *company = NULL;
char host[NETWORK_HOSTNAME_LENGTH];
uint16 rport;
@@ -738,7 +738,7 @@ void NetworkAddServer(const char *b)
ttd_strlcpy(_settings_client.network.connect_to_ip, b, lengthof(_settings_client.network.connect_to_ip));
rport = NETWORK_DEFAULT_PORT;
- ParseConnectionString(&player, &port, host);
+ ParseConnectionString(&company, &port, host);
if (port != NULL) rport = atoi(port);
NetworkUDPQueryServer(host, rport, true);
@@ -812,9 +812,9 @@ static void NetworkInitGameInfo()
memset(ci, 0, sizeof(*ci));
ci->client_index = NETWORK_SERVER_INDEX;
- ci->client_playas = _network_dedicated ? PLAYER_SPECTATOR : _local_player;
+ ci->client_playas = _network_dedicated ? COMPANY_SPECTATOR : _local_company;
- ttd_strlcpy(ci->client_name, _settings_client.network.player_name, sizeof(ci->client_name));
+ ttd_strlcpy(ci->client_name, _settings_client.network.client_name, sizeof(ci->client_name));
ttd_strlcpy(ci->unique_id, _settings_client.network.network_id, sizeof(ci->unique_id));
}
@@ -841,8 +841,8 @@ bool NetworkServerStart()
_last_sync_frame = 0;
_network_own_client_index = NETWORK_SERVER_INDEX;
- /* Non-dedicated server will always be player #1 */
- if (!_network_dedicated) _network_playas = PLAYER_FIRST;
+ /* Non-dedicated server will always be company #1 */
+ if (!_network_dedicated) _network_playas = COMPANY_FIRST;
_network_clients_connected = 0;
@@ -853,8 +853,8 @@ bool NetworkServerStart()
// if the server is dedicated ... add some other script
if (_network_dedicated) IConsoleCmdExec("exec scripts/on_dedicated.scr 0");
- _min_players_paused = false;
- CheckMinPlayers();
+ _min_active_clients_paused = false;
+ CheckMinActiveClients();
/* Try to register us to the master server */
_network_last_advertise_frame = 0;
@@ -1077,7 +1077,7 @@ void NetworkGameLoop()
while (f != NULL && !feof(f)) {
if (cp != NULL && _date == next_date && _date_fract == next_date_fract) {
- _current_player = cp->player;
+ _current_company = cp->company;
_cmd_text = cp->text;
DoCommandP(cp->tile, cp->p1, cp->p2, NULL, cp->cmd);
free(cp);
@@ -1090,9 +1090,9 @@ void NetworkGameLoop()
if (fgets(buff, lengthof(buff), f) == NULL) break;
if (strncmp(buff, "ddc:cmd:", 8) != 0) continue;
cp = MallocT<CommandPacket>(1);
- int player;
- sscanf(&buff[8], "%d;%d;%d;%d;%d;%d;%d;%s", &next_date, &next_date_fract, &player, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text);
- cp->player = (Owner)player;
+ int company;
+ sscanf(&buff[8], "%d;%d;%d;%d;%d;%d;%d;%s", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text);
+ cp->company = (CompanyID)company;
}
#endif /* DEBUG_DUMP_COMMANDS */
@@ -1238,4 +1238,4 @@ bool IsNetworkCompatibleVersion(const char *other)
#endif /* ENABLE_NETWORK */
/* NOTE: this variable needs to be always available */
-PlayerID _network_playas;
+CompanyID _network_playas;
diff --git a/src/network/network.h b/src/network/network.h
index 9c913ceb6..441378563 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -34,7 +34,7 @@ static inline void NetworkDrawChatMessage() {}
#endif /* ENABLE_NETWORK */
-/** As which player do we play? */
-extern PlayerID _network_playas;
+/** As which company do we play? */
+extern CompanyID _network_playas;
#endif /* NETWORK_H */
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index fe9a85289..552095ec9 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -27,7 +27,7 @@
#include "table/strings.h"
-/* The draw buffer must be able to contain the chat message, player name and the "[All]" message,
+/* The draw buffer must be able to contain the chat message, client name and the "[All]" message,
* some spaces and possible translations of [All] to other languages. */
assert_compile((int)DRAW_STRING_BUFFER >= (int)NETWORK_CHAT_LENGTH + NETWORK_NAME_LENGTH + 40);
@@ -99,7 +99,7 @@ void CDECL NetworkAddChatMessage(uint16 color, uint8 duration, const char *messa
ChatMessage *cmsg = &_chatmsg_list[msg_count++];
ttd_strlcpy(cmsg->message, bufp, sizeof(cmsg->message));
- /* The default colour for a message is player colour. Replace this with
+ /* The default colour for a message is company colour. Replace this with
* white for any additional lines */
cmsg->color = (bufp == buf && color & IS_PALETTE_COLOR) ? color : (0x1D - 15) | IS_PALETTE_COLOR;
cmsg->end_date = _date + duration;
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 0b07e7da0..d7eeb515b 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -77,17 +77,17 @@ static const char *GenerateCompanyPasswordHash(const char *password)
}
/**
- * Hash the current company password; used when the server 'player' sets his/her password.
+ * Hash the current company password; used when the server 'company' sets his/her password.
*/
void HashCurrentCompanyPassword()
{
- if (StrEmpty(_network_player_info[_local_player].password)) return;
+ if (StrEmpty(_network_company_info[_local_company].password)) return;
_password_game_seed = _settings_game.game_creation.generation_seed;
ttd_strlcpy(_password_server_unique_id, _settings_client.network.network_id, sizeof(_password_server_unique_id));
- const char *new_pw = GenerateCompanyPasswordHash(_network_player_info[_local_player].password);
- ttd_strlcpy(_network_player_info[_local_player].password, new_pw, sizeof(_network_player_info[_local_player].password));
+ const char *new_pw = GenerateCompanyPasswordHash(_network_company_info[_local_company].password);
+ ttd_strlcpy(_network_company_info[_local_company].password, new_pw, sizeof(_network_company_info[_local_company].password));
}
@@ -119,10 +119,10 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
// Function: Try to join the server
// Data:
// String: OpenTTD Revision (norev000 if no revision)
- // String: Player Name (max NETWORK_NAME_LENGTH)
- // uint8: Play as Player id (1..MAX_PLAYERS)
+ // String: Client Name (max NETWORK_NAME_LENGTH)
+ // uint8: Play as Company id (1..MAX_COMPANIES)
// uint8: Language ID
- // String: Unique id to find the player back in server-listing
+ // String: Unique id to find the client back in server-listing
//
Packet *p;
@@ -131,7 +131,7 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
p = NetworkSend_Init(PACKET_CLIENT_JOIN);
p->Send_string(_openttd_revision);
- p->Send_string(_settings_client.network.player_name); // Player name
+ p->Send_string(_settings_client.network.client_name); // Client name
p->Send_uint8 (_network_playas); // PlayAs
p->Send_uint8 (NETLANG_ANY); // Language
p->Send_string(_settings_client.network.network_id);
@@ -213,7 +213,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(CommandPacket *cp)
// Packet: CLIENT_COMMAND
// Function: Send a DoCommand to the Server
// Data:
- // uint8: PlayerID (0..MAX_PLAYERS-1)
+ // uint8: CompanyID (0..MAX_COMPANIES-1)
// uint32: CommandID (see command.h)
// uint32: P1 (free variables used in DoCommand)
// uint32: P2
@@ -224,7 +224,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(CommandPacket *cp)
Packet *p = NetworkSend_Init(PACKET_CLIENT_COMMAND);
- p->Send_uint8 (cp->player);
+ p->Send_uint8 (cp->company);
p->Send_uint32(cp->cmd);
p->Send_uint32(cp->p1);
p->Send_uint32(cp->p2);
@@ -244,7 +244,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_CHAT)(NetworkAction action, DestType
// Data:
// uint8: ActionID (see network_data.h, NetworkAction)
// uint8: Destination Type (see network_data.h, DestType);
- // uint16: Destination Player
+ // uint16: Destination Company/Client
// String: Message (max NETWORK_CHAT_LENGTH)
//
@@ -290,7 +290,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_SET_NAME)(const char *name)
{
//
// Packet: PACKET_CLIENT_SET_NAME
- // Function: Gives the player a new name
+ // Function: Gives the client a new name
// Data:
// String: Name
//
@@ -359,7 +359,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
if (!MY_CLIENT->has_quit && company_info_version == NETWORK_COMPANY_INFO_VERSION) {
byte total;
- PlayerID current;
+ CompanyID current;
total = p->Recv_uint8();
@@ -367,21 +367,21 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
if (total == 0) return NETWORK_RECV_STATUS_CLOSE_QUERY;
current = (Owner)p->Recv_uint8();
- if (current >= MAX_PLAYERS) return NETWORK_RECV_STATUS_CLOSE_QUERY;
-
- p->Recv_string(_network_player_info[current].company_name, sizeof(_network_player_info[current].company_name));
- _network_player_info[current].inaugurated_year = p->Recv_uint32();
- _network_player_info[current].company_value = p->Recv_uint64();
- _network_player_info[current].money = p->Recv_uint64();
- _network_player_info[current].income = p->Recv_uint64();
- _network_player_info[current].performance = p->Recv_uint16();
- _network_player_info[current].use_password = p->Recv_bool();
+ if (current >= MAX_COMPANIES) return NETWORK_RECV_STATUS_CLOSE_QUERY;
+
+ p->Recv_string(_network_company_info[current].company_name, sizeof(_network_company_info[current].company_name));
+ _network_company_info[current].inaugurated_year = p->Recv_uint32();
+ _network_company_info[current].company_value = p->Recv_uint64();
+ _network_company_info[current].money = p->Recv_uint64();
+ _network_company_info[current].income = p->Recv_uint64();
+ _network_company_info[current].performance = p->Recv_uint16();
+ _network_company_info[current].use_password = p->Recv_bool();
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++)
- _network_player_info[current].num_vehicle[i] = p->Recv_uint16();
+ _network_company_info[current].num_vehicle[i] = p->Recv_uint16();
for (i = 0; i < NETWORK_STATION_TYPES; i++)
- _network_player_info[current].num_station[i] = p->Recv_uint16();
+ _network_company_info[current].num_station[i] = p->Recv_uint16();
- p->Recv_string(_network_player_info[current].players, sizeof(_network_player_info[current].players));
+ p->Recv_string(_network_company_info[current].clients, sizeof(_network_company_info[current].clients));
InvalidateWindow(WC_NETWORK_WINDOW, 0);
@@ -398,7 +398,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
{
NetworkClientInfo *ci;
uint16 index = p->Recv_uint16();
- PlayerID playas = (Owner)p->Recv_uint8();
+ CompanyID playas = (CompanyID)p->Recv_uint8();
char name[NETWORK_NAME_LENGTH];
p->Recv_string(name, sizeof(name));
@@ -414,7 +414,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
// Client name changed, display the change
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", name);
} else if (playas != ci->client_playas) {
- // The player changed from client-player..
+ // The client changed from client-player..
// Do not display that for now
}
@@ -451,7 +451,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_ERROR)
/* We made an error in the protocol, and our connection is closed.... */
case NETWORK_ERROR_NOT_AUTHORIZED:
case NETWORK_ERROR_NOT_EXPECTED:
- case NETWORK_ERROR_PLAYER_MISMATCH:
+ case NETWORK_ERROR_COMPANY_MISMATCH:
_switch_mode_errorstr = STR_NETWORK_ERR_SERVER_ERROR;
break;
case NETWORK_ERROR_FULL:
@@ -622,21 +622,21 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
// Say we received the map and loaded it correctly!
SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
- /* New company/spectator (invalid player) or company we want to join is not active
- * Switch local player to spectator and await the server's judgement */
- if (_network_playas == PLAYER_NEW_COMPANY || !IsValidPlayerID(_network_playas)) {
- SetLocalPlayer(PLAYER_SPECTATOR);
+ /* New company/spectator (invalid company) or company we want to join is not active
+ * Switch local company to spectator and await the server's judgement */
+ if (_network_playas == COMPANY_NEW_COMPANY || !IsValidCompanyID(_network_playas)) {
+ SetLocalCompany(COMPANY_SPECTATOR);
- if (_network_playas != PLAYER_SPECTATOR) {
- /* We have arrived and ready to start playing; send a command to make a new player;
+ if (_network_playas != COMPANY_SPECTATOR) {
+ /* We have arrived and ready to start playing; send a command to make a new company;
* the server will give us a client-id and let us in */
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
ShowJoinStatusWindow();
- NetworkSend_Command(0, 0, 0, CMD_PLAYER_CTRL, NULL);
+ NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL);
}
} else {
// take control over an existing company
- SetLocalPlayer(_network_playas);
+ SetLocalCompany(_network_playas);
}
}
@@ -685,7 +685,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_SYNC)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMMAND)
{
CommandPacket *cp = MallocT<CommandPacket>(1);
- cp->player = (PlayerID)p->Recv_uint8();
+ cp->company = (CompanyID)p->Recv_uint8();
cp->cmd = p->Recv_uint32();
cp->p1 = p->Recv_uint32();
cp->p2 = p->Recv_uint32();
@@ -733,12 +733,12 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CHAT)
ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
break;
- /* For speaking to company or giving money, we need the player-name */
+ /* For speaking to company or giving money, we need the company-name */
case NETWORK_ACTION_GIVE_MONEY:
- if (!IsValidPlayerID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
+ if (!IsValidCompanyID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
/* fallthrough */
case NETWORK_ACTION_CHAT_COMPANY: {
- StringID str = IsValidPlayerID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
+ StringID str = IsValidCompanyID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);
GetString(name, str, lastof(name));
@@ -754,7 +754,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CHAT)
}
if (ci != NULL)
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), self_send, name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), self_send, name, "%s", msg);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -831,10 +831,10 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_SHUTDOWN)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEWGAME)
{
// To trottle the reconnects a bit, every clients waits
- // his _local_player value before reconnecting
- // PLAYER_SPECTATOR is currently 255, so to avoid long wait periods
+ // his _local_company value before reconnecting
+ // COMPANY_SPECTATOR is currently 255, so to avoid long wait periods
// set the max to 10.
- _network_reconnect = min(_local_player + 1, 10);
+ _network_reconnect = min(_local_company + 1, 10);
_switch_mode_errorstr = STR_NETWORK_SERVER_REBOOT;
return NETWORK_RECV_STATUS_SERVER_ERROR;
@@ -938,20 +938,20 @@ void NetworkClientSendRcon(const char *password, const char *command)
SEND_COMMAND(PACKET_CLIENT_RCON)(password, command);
}
-void NetworkUpdatePlayerName()
+void NetworkUpdateClientName()
{
NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
if (ci == NULL) return;
/* Don't change the name if it is the same as the old name */
- if (strcmp(ci->client_name, _settings_client.network.player_name) != 0) {
+ if (strcmp(ci->client_name, _settings_client.network.client_name) != 0) {
if (!_network_server) {
- SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_settings_client.network.player_name);
+ SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_settings_client.network.client_name);
} else {
- if (NetworkFindName(_settings_client.network.player_name)) {
- NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", _settings_client.network.player_name);
- ttd_strlcpy(ci->client_name, _settings_client.network.player_name, sizeof(ci->client_name));
+ if (NetworkFindName(_settings_client.network.client_name)) {
+ NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", _settings_client.network.client_name);
+ ttd_strlcpy(ci->client_name, _settings_client.network.client_name, sizeof(ci->client_name));
NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
}
}
@@ -965,7 +965,7 @@ void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const
void NetworkClientSetPassword()
{
- SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
+ SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_company_info[_local_company].password);
}
#endif /* ENABLE_NETWORK */
diff --git a/src/network/network_data.cpp b/src/network/network_data.cpp
index b24b2e498..914f6d40c 100644
--- a/src/network/network_data.cpp
+++ b/src/network/network_data.cpp
@@ -36,12 +36,12 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
{
CommandPacket c;
- c.player = _local_player;
- c.next = NULL;
- c.tile = tile;
- c.p1 = p1;
- c.p2 = p2;
- c.cmd = cmd;
+ c.company = _local_company;
+ c.next = NULL;
+ c.tile = tile;
+ c.p1 = p1;
+ c.p2 = p2;
+ c.cmd = cmd;
c.callback = 0;
while (c.callback < _callback_table_count && _callback_table[c.callback] != callback) {
@@ -95,7 +95,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
// Execute a DoCommand we received from the network
void NetworkExecuteCommand(CommandPacket *cp)
{
- _current_player = cp->player;
+ _current_company = cp->company;
_cmd_text = cp->text;
/* cp->callback is unsigned. so we don't need to do lower bounds checking. */
if (cp->callback > _callback_table_count) {
@@ -103,7 +103,7 @@ void NetworkExecuteCommand(CommandPacket *cp)
cp->callback = 0;
}
- DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->player, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text);
+ DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text);
DoCommandP(cp->tile, cp->p1, cp->p2, _callback_table[cp->callback], cp->cmd | CMD_NETWORK_COMMAND, cp->my_cmd);
}
diff --git a/src/network/network_func.h b/src/network/network_func.h
index cd1a5aa5d..fac321506 100644
--- a/src/network/network_func.h
+++ b/src/network/network_func.h
@@ -11,7 +11,7 @@
#include "../console_type.h"
extern NetworkServerGameInfo _network_game_info;
-extern NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
+extern NetworkCompanyInfo _network_company_info[MAX_COMPANIES];
extern NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
extern uint16 _network_own_client_index;
@@ -23,16 +23,16 @@ extern char *_network_host_list[10];
extern char *_network_ban_list[25];
byte NetworkSpectatorCount();
-void CheckMinPlayers();
-void NetworkUpdatePlayerName();
-bool NetworkCompanyHasPlayers(PlayerID company);
+void CheckMinActiveClients();
+void NetworkUpdateClientName();
+bool NetworkCompanyHasClients(CompanyID company);
bool NetworkChangeCompanyPassword(byte argc, char *argv[]);
void NetworkReboot();
void NetworkDisconnect();
void NetworkGameLoop();
void NetworkUDPGameLoop();
void NetworkUDPCloseAll();
-void ParseConnectionString(const char **player, const char **port, char *connection_string);
+void ParseConnectionString(const char **company, const char **port, char *connection_string);
void NetworkStartDebugLog(const char *hostname, uint16 port);
void NetworkPopulateCompanyInfo();
@@ -45,13 +45,13 @@ void NetworkClientSetPassword();
/*** Commands ran by the server ***/
void NetworkServerMonthlyLoop();
void NetworkServerYearlyLoop();
-void NetworkServerChangeOwner(PlayerID current_player, PlayerID new_player);
+void NetworkServerChangeOwner(Owner current_owner, Owner new_owner);
void NetworkServerShowStatusToConsole();
bool NetworkServerStart();
NetworkClientInfo *NetworkFindClientInfoFromIndex(uint16 client_index);
NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip);
-const char* GetPlayerIP(const NetworkClientInfo *ci);
+const char* GetClientIP(const NetworkClientInfo *ci);
void NetworkServerSendRcon(uint16 client_index, ConsoleColour colour_code, const char *string);
void NetworkServerSendError(uint16 client_index, NetworkErrorCode error);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 2340bbd0b..3cc9e17b8 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -87,7 +87,7 @@ enum NetworkGameWindowWidgets {
NGWW_CONNECTION, ///< Label in from of connection droplist
NGWW_CONN_BTN, ///< 'Connection' droplist button
- NGWW_PLAYER, ///< Panel with editbox to set player name
+ NGWW_CLIENT, ///< Panel with editbox to set client name
NGWW_NAME, ///< 'Name' button
NGWW_CLIENTS, ///< 'Clients' button
@@ -286,7 +286,7 @@ protected:
public:
NetworkGameWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_NAME_LENGTH, desc)
{
- ttd_strlcpy(this->edit_str_buf, _settings_client.network.player_name, this->edit_str_size);
+ ttd_strlcpy(this->edit_str_buf, _settings_client.network.client_name, this->edit_str_size);
this->afilter = CS_ALPHANUMERAL;
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 120);
@@ -295,7 +295,7 @@ public:
this->vscroll.cap = 11;
this->resize.step_height = NET_PRC__SIZE_OF_ROW;
- this->field = NGWW_PLAYER;
+ this->field = NGWW_CLIENT;
this->server = NULL;
this->servers.SetListing(this->last_sorting);
@@ -339,10 +339,10 @@ public:
SetDParam(1, _lan_internet_types_dropdown[_settings_client.network.lan_internet]);
this->DrawWidgets();
- /* Edit box to set player name */
- this->DrawEditBox(NGWW_PLAYER);
+ /* Edit box to set client name */
+ this->DrawEditBox(NGWW_CLIENT);
- DrawString(this->widget[NGWW_PLAYER].left - 100, 23, STR_NETWORK_PLAYER_NAME, TC_GOLD);
+ DrawString(this->widget[NGWW_CLIENT].left - 100, 23, STR_NETWORK_PLAYER_NAME, TC_GOLD);
/* Sort based on widgets: name, clients, compatibility */
switch (this->servers.SortType()) {
@@ -446,8 +446,8 @@ public:
{
this->field = widget;
switch (widget) {
- case NGWW_PLAYER:
- ShowOnScreenKeyboard(this, NGWW_PLAYER, 0, 0);
+ case NGWW_CLIENT:
+ ShowOnScreenKeyboard(this, NGWW_CLIENT, 0, 0);
break;
case NGWW_CANCEL: // Cancel button
@@ -554,7 +554,7 @@ public:
virtual void OnMouseLoop()
{
- if (this->field == NGWW_PLAYER) this->HandleEditBox(NGWW_PLAYER);
+ if (this->field == NGWW_CLIENT) this->HandleEditBox(NGWW_CLIENT);
}
virtual void OnInvalidateData(int data)
@@ -567,7 +567,7 @@ public:
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
EventState state = ES_NOT_HANDLED;
- if (this->field != NGWW_PLAYER) {
+ if (this->field != NGWW_CLIENT) {
if (this->server != NULL) {
if (keycode == WKC_DELETE) { // Press 'delete' to remove servers
NetworkGameListRemoveItem(this->server);
@@ -578,13 +578,13 @@ public:
return state;
}
- if (this->HandleEditBoxKey(NGWW_PLAYER, key, keycode, state) == 1) return state; // enter pressed
+ if (this->HandleEditBoxKey(NGWW_CLIENT, key, keycode, state) == 1) return state; // enter pressed
/* The name is only allowed when it starts with a letter! */
if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') {
- ttd_strlcpy(_settings_client.network.player_name, this->edit_str_buf, lengthof(_settings_client.network.player_name));
+ ttd_strlcpy(_settings_client.network.client_name, this->edit_str_buf, lengthof(_settings_client.network.client_name));
} else {
- ttd_strlcpy(_settings_client.network.player_name, "Player", lengthof(_settings_client.network.player_name));
+ ttd_strlcpy(_settings_client.network.client_name, "Player", lengthof(_settings_client.network.client_name));
}
return state;
}
@@ -670,7 +670,7 @@ static const Widget _network_game_window_widgets[] = {
{ WWT_TEXT, RESIZE_NONE, COLOUR_LIGHT_BLUE, 9, 85, 23, 35, STR_NETWORK_CONNECTION, STR_NULL}, // NGWW_CONNECTION
{ WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_LIGHT_BLUE, 90, 181, 22, 33, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP}, // NGWW_CONN_BTN
-{ WWT_EDITBOX, RESIZE_LR, COLOUR_LIGHT_BLUE, 290, 440, 22, 33, STR_NETWORK_PLAYER_NAME_OSKTITLE, STR_NETWORK_ENTER_NAME_TIP}, // NGWW_PLAYER
+{ WWT_EDITBOX, RESIZE_LR, COLOUR_LIGHT_BLUE, 290, 440, 22, 33, STR_NETWORK_PLAYER_NAME_OSKTITLE, STR_NETWORK_ENTER_NAME_TIP}, // NGWW_CLIENT
/* LEFT SIDE */
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_WHITE, 10, 70, 42, 53, STR_NETWORK_GAME_NAME, STR_NETWORK_GAME_NAME_TIP}, // NGWW_NAME
@@ -864,7 +864,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
_settings_client.network.max_clients = Clamp(_settings_client.network.max_clients + widget - NSSW_CLIENTS_TXT, 2, MAX_CLIENTS);
break;
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU:
- _settings_client.network.max_companies = Clamp(_settings_client.network.max_companies + widget - NSSW_COMPANIES_TXT, 1, MAX_PLAYERS);
+ _settings_client.network.max_companies = Clamp(_settings_client.network.max_companies + widget - NSSW_COMPANIES_TXT, 1, MAX_COMPANIES);
break;
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU:
_settings_client.network.max_spectators = Clamp(_settings_client.network.max_spectators + widget - NSSW_SPECTATORS_TXT, 0, MAX_CLIENTS);
@@ -874,7 +874,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
_left_button_clicked = false;
break;
- case NSSW_CLIENTS_TXT: // Click on number of players
+ case NSSW_CLIENTS_TXT: // Click on number of clients
this->widget_id = NSSW_CLIENTS_TXT;
SetDParam(0, _settings_client.network.max_clients);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_CLIENTS, 3, 50, this, CS_NUMERAL, QSF_NONE);
@@ -977,7 +977,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
switch (this->widget_id) {
default: NOT_REACHED();
case NSSW_CLIENTS_TXT: _settings_client.network.max_clients = Clamp(value, 2, MAX_CLIENTS); break;
- case NSSW_COMPANIES_TXT: _settings_client.network.max_companies = Clamp(value, 1, MAX_PLAYERS); break;
+ case NSSW_COMPANIES_TXT: _settings_client.network.max_companies = Clamp(value, 1, MAX_COMPANIES); break;
case NSSW_SPECTATORS_TXT: _settings_client.network.max_spectators = Clamp(value, 0, MAX_CLIENTS); break;
}
}
@@ -1046,16 +1046,16 @@ static void ShowNetworkStartServerWindow()
new NetworkStartServerWindow(&_network_start_server_window_desc);
}
-static PlayerID NetworkLobbyFindCompanyIndex(byte pos)
+static CompanyID NetworkLobbyFindCompanyIndex(byte pos)
{
- /* Scroll through all _network_player_info and get the 'pos' item that is not empty */
- for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
- if (_network_player_info[i].company_name[0] != '\0') {
+ /* Scroll through all _network_company_info and get the 'pos' item that is not empty */
+ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
+ if (!StrEmpty(_network_company_info[i].company_name)) {
if (pos-- == 0) return i;
}
}
- return PLAYER_FIRST;
+ return COMPANY_FIRST;
}
/** Enum for NetworkLobbyWindow, referring to _network_lobby_window_widgets */
@@ -1071,11 +1071,11 @@ enum NetworkLobbyWindowWidgets {
};
struct NetworkLobbyWindow : public Window {
- PlayerID company; ///< Select company
+ CompanyID company; ///< Select company
NetworkGameList *server; ///< Selected server
NetworkLobbyWindow(const WindowDesc *desc, NetworkGameList *ngl) :
- Window(desc), company(INVALID_PLAYER), server(ngl)
+ Window(desc), company(INVALID_COMPANY), server(ngl)
{
this->vscroll.cap = 10;
@@ -1088,7 +1088,7 @@ struct NetworkLobbyWindow : public Window {
int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos;
/* Join button is disabled when no company is selected */
- this->SetWidgetDisabledState(NLWW_JOIN, this->company == INVALID_PLAYER);
+ this->SetWidgetDisabledState(NLWW_JOIN, this->company == INVALID_COMPANY);
/* Cannot start new company if there are too many */
this->SetWidgetDisabledState(NLWW_NEW, gi->companies_on >= gi->companies_max);
/* Cannot spectate if there are too many spectators */
@@ -1107,11 +1107,11 @@ struct NetworkLobbyWindow : public Window {
GfxFillRect(11, y - 1, 154, y + 10, 10); // show highlighted item with a different colour
}
- DoDrawStringTruncated(_network_player_info[company].company_name, 13, y, TC_BLACK, 135 - 13);
- if (_network_player_info[company].use_password != 0) DrawSprite(SPR_LOCK, PAL_NONE, 135, y);
+ DoDrawStringTruncated(_network_company_info[company].company_name, 13, y, TC_BLACK, 135 - 13);
+ if (_network_company_info[company].use_password != 0) DrawSprite(SPR_LOCK, PAL_NONE, 135, y);
/* If the company's income was positive puts a green dot else a red dot */
- if (_network_player_info[company].income >= 0) income = true;
+ if (_network_company_info[company].income >= 0) income = true;
DrawSprite(SPR_BLOT, income ? PALETTE_TO_GREEN : PALETTE_TO_RED, 145, y);
pos++;
@@ -1122,7 +1122,7 @@ struct NetworkLobbyWindow : public Window {
/* Draw info about selected company when it is selected in the left window */
GfxFillRect(174, 39, 403, 75, 157);
DrawStringCentered(290, 50, STR_NETWORK_COMPANY_INFO, TC_FROMSTRING);
- if (this->company != INVALID_PLAYER) {
+ if (this->company != INVALID_COMPANY) {
const uint x = 183;
const uint trunc_width = this->widget[NLWW_DETAILS].right - x;
y = 80;
@@ -1134,47 +1134,47 @@ struct NetworkLobbyWindow : public Window {
DrawString(x, y, STR_NETWORK_CLIENTS, TC_GOLD);
y += 10;
- SetDParamStr(0, _network_player_info[this->company].company_name);
+ SetDParamStr(0, _network_company_info[this->company].company_name);
DrawStringTruncated(x, y, STR_NETWORK_COMPANY_NAME, TC_GOLD, trunc_width);
y += 10;
- SetDParam(0, _network_player_info[this->company].inaugurated_year);
+ SetDParam(0, _network_company_info[this->company].inaugurated_year);
DrawString(x, y, STR_NETWORK_INAUGURATION_YEAR, TC_GOLD); // inauguration year
y += 10;
- SetDParam(0, _network_player_info[this->company].company_value);
+ SetDParam(0, _network_company_info[this->company].company_value);
DrawString(x, y, STR_NETWORK_VALUE, TC_GOLD); // company value
y += 10;
- SetDParam(0, _network_player_info[this->company].money);
+ SetDParam(0, _network_company_info[this->company].money);
DrawString(x, y, STR_NETWORK_CURRENT_BALANCE, TC_GOLD); // current balance
y += 10;
- SetDParam(0, _network_player_info[this->company].income);
+ SetDParam(0, _network_company_info[this->company].income);
DrawString(x, y, STR_NETWORK_LAST_YEARS_INCOME, TC_GOLD); // last year's income
y += 10;
- SetDParam(0, _network_player_info[this->company].performance);
+ SetDParam(0, _network_company_info[this->company].performance);
DrawString(x, y, STR_NETWORK_PERFORMANCE, TC_GOLD); // performance
y += 10;
- SetDParam(0, _network_player_info[this->company].num_vehicle[0]);
- SetDParam(1, _network_player_info[this->company].num_vehicle[1]);
- SetDParam(2, _network_player_info[this->company].num_vehicle[2]);
- SetDParam(3, _network_player_info[this->company].num_vehicle[3]);
- SetDParam(4, _network_player_info[this->company].num_vehicle[4]);
+ SetDParam(0, _network_company_info[this->company].num_vehicle[0]);
+ SetDParam(1, _network_company_info[this->company].num_vehicle[1]);
+ SetDParam(2, _network_company_info[this->company].num_vehicle[2]);
+ SetDParam(3, _network_company_info[this->company].num_vehicle[3]);
+ SetDParam(4, _network_company_info[this->company].num_vehicle[4]);
DrawString(x, y, STR_NETWORK_VEHICLES, TC_GOLD); // vehicles
y += 10;
- SetDParam(0, _network_player_info[this->company].num_station[0]);
- SetDParam(1, _network_player_info[this->company].num_station[1]);
- SetDParam(2, _network_player_info[this->company].num_station[2]);
- SetDParam(3, _network_player_info[this->company].num_station[3]);
- SetDParam(4, _network_player_info[this->company].num_station[4]);
+ SetDParam(0, _network_company_info[this->company].num_station[0]);
+ SetDParam(1, _network_company_info[this->company].num_station[1]);
+ SetDParam(2, _network_company_info[this->company].num_station[2]);
+ SetDParam(3, _network_company_info[this->company].num_station[3]);
+ SetDParam(4, _network_company_info[this->company].num_station[4]);
DrawString(x, y, STR_NETWORK_STATIONS, TC_GOLD); // stations
y += 10;
- SetDParamStr(0, _network_player_info[this->company].players);
+ SetDParamStr(0, _network_company_info[this->company].clients);
DrawStringTruncated(x, y, STR_NETWORK_PLAYERS, TC_GOLD, trunc_width); // players
}
}
@@ -1193,7 +1193,7 @@ struct NetworkLobbyWindow : public Window {
if (id_v >= this->vscroll.cap) break;
id_v += this->vscroll.pos;
- this->company = (id_v >= this->server->info.companies_on) ? INVALID_PLAYER : NetworkLobbyFindCompanyIndex(id_v);
+ this->company = (id_v >= this->server->info.companies_on) ? INVALID_COMPANY : NetworkLobbyFindCompanyIndex(id_v);
this->SetDirty();
} break;
@@ -1204,12 +1204,12 @@ struct NetworkLobbyWindow : public Window {
break;
case NLWW_NEW: // New company
- _network_playas = PLAYER_NEW_COMPANY;
+ _network_playas = COMPANY_NEW_COMPANY;
NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port);
break;
case NLWW_SPECTATE: // Spectate game
- _network_playas = PLAYER_SPECTATOR;
+ _network_playas = COMPANY_SPECTATOR;
NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port);
break;
@@ -1240,7 +1240,7 @@ static const Widget _network_lobby_window_widgets[] = {
{ WWT_MATRIX, RESIZE_NONE, COLOUR_LIGHT_BLUE, 10, 155, 50, 190, (10 << 8) + 1, STR_NETWORK_COMPANY_LIST_TIP}, // NLWW_MATRIX
{ WWT_SCROLLBAR, RESIZE_NONE, COLOUR_LIGHT_BLUE, 156, 167, 38, 190, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
-/* company/player info */
+/* company info */
{ WWT_PANEL, RESIZE_NONE, COLOUR_LIGHT_BLUE, 173, 404, 38, 190, 0x0, STR_NULL}, // NLWW_DETAILS
/* buttons */
@@ -1276,7 +1276,7 @@ static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
// and also makes able to give money to them, kick them (if server)
// and stuff like that.
-extern void DrawPlayerIcon(PlayerID pid, int x, int y);
+extern void DrawCompanyIcon(CompanyID cid, int x, int y);
// Every action must be of this form
typedef void ClientList_Action_Proc(byte client_no);
@@ -1326,7 +1326,7 @@ static const NetworkClientInfo *NetworkFindClientInfo(byte client_no)
// Here we start to define the options out of the menu
static void ClientList_Kick(byte client_no)
{
- if (client_no < MAX_PLAYERS)
+ if (client_no < MAX_COMPANIES)
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED);
}
@@ -1341,7 +1341,7 @@ static void ClientList_Ban(byte client_no)
}
}
- if (client_no < MAX_PLAYERS) {
+ if (client_no < MAX_COMPANIES) {
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED);
}
}
@@ -1402,7 +1402,7 @@ struct NetworkClientListPopupWindow : Window {
this->proc[i++] = &ClientList_SpeakToClient;
}
- if (IsValidPlayerID(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) {
+ if (IsValidCompanyID(ci->client_playas) || ci->client_playas == COMPANY_SPECTATOR) {
GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY, lastof(this->action[i]));
this->proc[i++] = &ClientList_SpeakToCompany;
}
@@ -1410,8 +1410,8 @@ struct NetworkClientListPopupWindow : Window {
this->proc[i++] = &ClientList_SpeakToAll;
if (_network_own_client_index != ci->client_index) {
- /* We are no spectator and the player we want to give money to is no spectator and money gifts are allowed */
- if (IsValidPlayerID(_network_playas) && IsValidPlayerID(ci->client_playas) && _settings_game.economy.give_money) {
+ /* We are no spectator and the company we want to give money to is no spectator and money gifts are allowed */
+ if (IsValidCompanyID(_network_playas) && IsValidCompanyID(ci->client_playas) && _settings_game.economy.give_money) {
GetString(this->action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY, lastof(this->action[i]));
this->proc[i++] = &ClientList_GiveMoney;
}
@@ -1600,7 +1600,7 @@ struct NetworkClientListWindow : Window
}
/* Filter out spectators */
- if (IsValidPlayerID(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
+ if (IsValidCompanyID(ci->client_playas)) DrawCompanyIcon(ci->client_playas, 64, y + 1);
DoDrawString(ci->client_name, 81, y, colour);
diff --git a/src/network/network_gui.h b/src/network/network_gui.h
index 77276a8fb..d0a5b4996 100644
--- a/src/network/network_gui.h
+++ b/src/network/network_gui.h
@@ -11,7 +11,7 @@
#include "network_type.h"
void ShowNetworkNeedPassword(NetworkPasswordType npt);
-void ShowNetworkGiveMoneyWindow(PlayerID player); // PlayerID
+void ShowNetworkGiveMoneyWindow(CompanyID company);
void ShowNetworkChatQueryWindow(DestType type, int dest);
void ShowJoinStatusWindow();
void ShowNetworkGameWindow();
diff --git a/src/network/network_internal.h b/src/network/network_internal.h
index 42c7f66be..37354cb5e 100644
--- a/src/network/network_internal.h
+++ b/src/network/network_internal.h
@@ -91,7 +91,7 @@ enum NetworkLanguage {
NETLANG_COUNT
};
-extern NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
+extern NetworkCompanyInfo _network_company_info[MAX_COMPANIES];
extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
extern uint32 _frame_counter_max; // To where we may go with our clients
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index d1e1614f6..e99ef8bc1 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -47,7 +47,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CLIENT_INFO)(NetworkTCPSocketHandler
// Function: Sends info about a client
// Data:
// uint16: The index of the client (always unique on a server. 1 = server)
- // uint8: As which player the client is playing
+ // uint8: As which company the client is playing
// String: The name of the client
//
@@ -71,10 +71,10 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
int i;
- Player *player;
+ Company *company;
Packet *p;
- byte active = ActivePlayerCount();
+ byte active = ActiveCompanyCount();
if (active == 0) {
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
@@ -88,35 +88,35 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
NetworkPopulateCompanyInfo();
- FOR_ALL_PLAYERS(player) {
+ FOR_ALL_COMPANIES(company) {
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
p->Send_uint8 (active);
- p->Send_uint8 (player->index);
+ p->Send_uint8 (company->index);
- p->Send_string(_network_player_info[player->index].company_name);
- p->Send_uint32(_network_player_info[player->index].inaugurated_year);
- p->Send_uint64(_network_player_info[player->index].company_value);
- p->Send_uint64(_network_player_info[player->index].money);
- p->Send_uint64(_network_player_info[player->index].income);
- p->Send_uint16(_network_player_info[player->index].performance);
+ p->Send_string(_network_company_info[company->index].company_name);
+ p->Send_uint32(_network_company_info[company->index].inaugurated_year);
+ p->Send_uint64(_network_company_info[company->index].company_value);
+ p->Send_uint64(_network_company_info[company->index].money);
+ p->Send_uint64(_network_company_info[company->index].income);
+ p->Send_uint16(_network_company_info[company->index].performance);
/* Send 1 if there is a passord for the company else send 0 */
- p->Send_bool(!StrEmpty(_network_player_info[player->index].password));
+ p->Send_bool(!StrEmpty(_network_company_info[company->index].password));
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
- p->Send_uint16(_network_player_info[player->index].num_vehicle[i]);
+ p->Send_uint16(_network_company_info[company->index].num_vehicle[i]);
}
for (i = 0; i < NETWORK_STATION_TYPES; i++) {
- p->Send_uint16(_network_player_info[player->index].num_station[i]);
+ p->Send_uint16(_network_company_info[company->index].num_station[i]);
}
- if (_network_player_info[player->index].players[0] == '\0') {
+ if (StrEmpty(_network_company_info[company->index].clients)) {
p->Send_string("<none>");
} else {
- p->Send_string(_network_player_info[player->index].players);
+ p->Send_string(_network_company_info[company->index].clients);
}
cs->Send_Packet(p);
@@ -276,7 +276,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WAIT)
NetworkTCPSocketHandler *new_cs;
Packet *p;
- // Count how many players are waiting in the queue
+ // Count how many clients are waiting in the queue
FOR_ALL_CLIENTS(new_cs) {
if (new_cs->status == STATUS_MAP_WAIT) waiting++;
}
@@ -300,9 +300,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
// if MAP_PACKET_NORMAL:
// piece of the map (till max-size of packet)
// if MAP_PACKET_END:
- // uint32: seed0 of player
- // uint32: seed1 of player
- // last 2 are repeated MAX_PLAYERS time
+ // nothing
//
static FILE *file_pointer;
@@ -476,7 +474,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkTCPSocketHandler *cs
// Packet: SERVER_COMMAND
// Function: Sends a DoCommand to the client
// Data:
- // uint8: PlayerID (0..MAX_PLAYERS-1)
+ // uint8: CompanyID (0..MAX_COMPANIES-1)
// uint32: CommandID (see command.h)
// uint32: P1 (free variables used in DoCommand)
// uint32: P2
@@ -488,7 +486,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkTCPSocketHandler *cs
Packet *p = NetworkSend_Init(PACKET_SERVER_COMMAND);
- p->Send_uint8 (cp->player);
+ p->Send_uint8 (cp->company);
p->Send_uint32(cp->cmd);
p->Send_uint32(cp->p1);
p->Send_uint32(cp->p2);
@@ -619,7 +617,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)
if (!StrEmpty(_settings_client.network.server_password)) {
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_GAME_PASSWORD);
} else {
- if (IsValidPlayerID(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
+ if (IsValidCompanyID(ci->client_playas) && _network_company_info[ci->client_playas].password[0] != '\0') {
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
} else {
SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
@@ -638,7 +636,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
char name[NETWORK_CLIENT_NAME_LENGTH];
char unique_id[NETWORK_UNIQUE_ID_LENGTH];
NetworkClientInfo *ci;
- PlayerID playas;
+ CompanyID playas;
NetworkLanguage client_lang;
char client_revision[NETWORK_REVISION_LENGTH];
@@ -660,31 +658,31 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
// join another company does not affect these values
switch (playas) {
- case PLAYER_NEW_COMPANY: /* New company */
- if (ActivePlayerCount() >= _settings_client.network.max_companies) {
+ case COMPANY_NEW_COMPANY: /* New company */
+ if (ActiveCompanyCount() >= _settings_client.network.max_companies) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
return;
}
break;
- case PLAYER_SPECTATOR: /* Spectator */
+ case COMPANY_SPECTATOR: /* Spectator */
if (NetworkSpectatorCount() >= _settings_client.network.max_spectators) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
return;
}
break;
default: /* Join another company (companies 1-8 (index 0-7)) */
- if (!IsValidPlayerID(playas)) {
- SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH);
+ if (!IsValidCompanyID(playas)) {
+ SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_COMPANY_MISMATCH);
return;
}
break;
}
// We need a valid name.. make it Player
- if (*name == '\0') ttd_strlcpy(name, "Player", sizeof(name));
+ if (StrEmpty(name)) ttd_strlcpy(name, "Player", sizeof(name));
if (!NetworkFindName(name)) { // Change name if duplicate
- // We could not create a name for this player
+ // We could not create a name for this client
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NAME_IN_USE);
return;
}
@@ -697,7 +695,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
ci->client_lang = client_lang;
/* Make sure companies to which people try to join are not autocleaned */
- if (IsValidPlayerID(playas)) _network_player_info[playas].months_empty = 0;
+ if (IsValidCompanyID(playas)) _network_company_info[playas].months_empty = 0;
if (_grfconfig == NULL) {
RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)(cs, NULL);
@@ -725,7 +723,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayerID(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
+ if (IsValidCompanyID(ci->client_playas) && _network_company_info[ci->client_playas].password[0] != '\0') {
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
return;
}
@@ -736,7 +734,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
} else if (cs->status == STATUS_AUTHORIZING && type == NETWORK_COMPANY_PASSWORD) {
ci = DEREF_CLIENT_INFO(cs);
- if (strcmp(password, _network_player_info[ci->client_playas].password) != 0) {
+ if (strcmp(password, _network_company_info[ci->client_playas].password) != 0) {
// Password is invalid
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_PASSWORD);
return;
@@ -828,17 +826,17 @@ static bool CheckCommandFlags(const CommandPacket *cp, const NetworkClientInfo *
byte flags = GetCommandFlags(cp->cmd);
if (flags & CMD_SERVER && ci->client_index != NETWORK_SERVER_INDEX) {
- IConsolePrintF(CC_ERROR, "WARNING: server only command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: server only command from client %d (IP: %s), kicking...", ci->client_index, GetClientIP(ci));
return false;
}
if (flags & CMD_OFFLINE) {
- IConsolePrintF(CC_ERROR, "WARNING: offline only command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: offline only command from client %d (IP: %s), kicking...", ci->client_index, GetClientIP(ci));
return false;
}
- if (cp->cmd != CMD_PLAYER_CTRL && !IsValidPlayerID(cp->player) && ci->client_index != NETWORK_SERVER_INDEX) {
- IConsolePrintF(CC_ERROR, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ if (cp->cmd != CMD_COMPANY_CTRL && !IsValidCompanyID(cp->company) && ci->client_index != NETWORK_SERVER_INDEX) {
+ IConsolePrintF(CC_ERROR, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_index, GetClientIP(ci));
return false;
}
@@ -863,11 +861,11 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
}
CommandPacket *cp = MallocT<CommandPacket>(1);
- cp->player = (Owner)p->Recv_uint8();
- cp->cmd = p->Recv_uint32();
- cp->p1 = p->Recv_uint32();
- cp->p2 = p->Recv_uint32();
- cp->tile = p->Recv_uint32();
+ cp->company = (CompanyID)p->Recv_uint8();
+ cp->cmd = p->Recv_uint32();
+ cp->p1 = p->Recv_uint32();
+ cp->p2 = p->Recv_uint32();
+ cp->tile = p->Recv_uint32();
p->Recv_string(cp->text, lengthof(cp->text));
callback = p->Recv_uint8();
@@ -881,7 +879,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
/* Check if cp->cmd is valid */
if (!IsValidCommand(cp->cmd)) {
- IConsolePrintF(CC_ERROR, "WARNING: invalid command from client %d (IP: %s).", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: invalid command from client %d (IP: %s).", ci->client_index, GetClientIP(ci));
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
free(cp);
return;
@@ -893,35 +891,35 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
return;
}
- /** Only CMD_PLAYER_CTRL is always allowed, for the rest, playas needs
- * to match the player in the packet. If it doesn't, the client has done
+ /** Only CMD_COMPANY_CTRL is always allowed, for the rest, playas needs
+ * to match the company in the packet. If it doesn't, the client has done
* something pretty naughty (or a bug), and will be kicked
*/
- if (!(cp->cmd == CMD_PLAYER_CTRL && cp->p1 == 0 && ci->client_playas == PLAYER_NEW_COMPANY) && ci->client_playas != cp->player) {
- IConsolePrintF(CC_ERROR, "WARNING: player %d (IP: %s) tried to execute a command as player %d, kicking...",
- ci->client_playas + 1, GetPlayerIP(ci), cp->player + 1);
- SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH);
+ if (!(cp->cmd == CMD_COMPANY_CTRL && cp->p1 == 0 && ci->client_playas == COMPANY_NEW_COMPANY) && ci->client_playas != cp->company) {
+ IConsolePrintF(CC_ERROR, "WARNING: client %d (IP: %s) tried to execute a command as company %d, kicking...",
+ ci->client_playas + 1, GetClientIP(ci), cp->company + 1);
+ SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_COMPANY_MISMATCH);
free(cp);
return;
}
- /** @todo CMD_PLAYER_CTRL with p1 = 0 announces a new player to the server. To give the
- * player the correct ID, the server injects p2 and executes the command. Any other p1
+ /** @todo CMD_COMPANY_CTRL with p1 = 0 announces a new company to the server. To give the
+ * company the correct ID, the server injects p2 and executes the command. Any other p1
* is prohibited. Pretty ugly and should be redone together with its function.
- * @see CmdPlayerCtrl() players.c:655
+ * @see CmdCompanyCtrl()
*/
- if (cp->cmd == CMD_PLAYER_CTRL) {
+ if (cp->cmd == CMD_COMPANY_CTRL) {
if (cp->p1 != 0) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_CHEATER);
free(cp);
return;
}
- /* XXX - Execute the command as a valid player. Normally this would be done by a
+ /* XXX - Execute the command as a valid company. Normally this would be done by a
* spectator, but that is not allowed any commands. So do an impersonation. The drawback
* of this is that the first company's last_built_tile is also updated... */
- cp->player = OWNER_BEGIN;
- cp->p2 = cs - _clients; // XXX - UGLY! p2 is mis-used to get the client-id in CmdPlayerCtrl
+ cp->company = OWNER_BEGIN;
+ cp->p2 = cs - _clients; // XXX - UGLY! p2 is mis-used to get the client-id in CmdCompanyCtrl
}
// The frame can be executed in the same frame as the next frame-packet
@@ -1038,7 +1036,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK)
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (client connected)", NETWORK_SERVER_INDEX);
}
- CheckMinPlayers();
+ CheckMinActiveClients();
/* Execute script for, e.g. MOTD */
IConsoleCmdExec("exec scripts/on_server_connect.scr 0");
@@ -1064,7 +1062,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
ci = NetworkFindClientInfoFromIndex(from_index);
/* Display the text locally, and that is it */
if (ci != NULL)
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), false, ci->client_name, "%s", msg);
} else {
/* Else find the client to send the message to */
FOR_ALL_CLIENTS(cs) {
@@ -1081,7 +1079,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
ci = NetworkFindClientInfoFromIndex(from_index);
ci_to = NetworkFindClientInfoFromIndex(dest);
if (ci != NULL && ci_to != NULL)
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), true, ci_to->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), true, ci_to->client_name, "%s", msg);
} else {
FOR_ALL_CLIENTS(cs) {
if (cs->index == from_index) {
@@ -1095,7 +1093,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
case DESTTYPE_TEAM: {
bool show_local = true; // If this is false, the message is already displayed
// on the client who did sent it.
- /* Find all clients that belong to this player */
+ /* Find all clients that belong to this company */
ci_to = NULL;
FOR_ALL_CLIENTS(cs) {
ci = DEREF_CLIENT_INFO(cs);
@@ -1109,22 +1107,22 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
ci = NetworkFindClientInfoFromIndex(from_index);
ci_own = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
if (ci != NULL && ci_own != NULL && ci_own->client_playas == dest) {
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), false, ci->client_name, "%s", msg);
if (from_index == NETWORK_SERVER_INDEX) show_local = false;
ci_to = ci_own;
}
- /* There is no such player */
+ /* There is no such client */
if (ci_to == NULL) break;
// Display the message locally (so you know you have sent it)
if (ci != NULL && show_local) {
if (from_index == NETWORK_SERVER_INDEX) {
char name[NETWORK_NAME_LENGTH];
- StringID str = IsValidPlayerID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
+ StringID str = IsValidCompanyID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);
GetString(name, str, lastof(name));
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci_own->client_playas), true, name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci_own->client_playas), true, name, "%s", msg);
} else {
FOR_ALL_CLIENTS(cs) {
if (cs->index == from_index) {
@@ -1144,7 +1142,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
}
ci = NetworkFindClientInfoFromIndex(from_index);
if (ci != NULL)
- NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringCompanyColor(ci->client_playas), false, ci->client_name, "%s", msg);
break;
}
}
@@ -1167,7 +1165,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT)
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
switch (action) {
case NETWORK_ACTION_GIVE_MONEY:
- if (!IsValidPlayerID(ci->client_playas)) break;
+ if (!IsValidCompanyID(ci->client_playas)) break;
/* Fall-through */
case NETWORK_ACTION_CHAT:
case NETWORK_ACTION_CHAT_CLIENT:
@@ -1175,7 +1173,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT)
NetworkServerSendChat(action, desttype, dest, msg, cs->index);
break;
default:
- IConsolePrintF(CC_ERROR, "WARNING: invalid chat action from client %d (IP: %s).", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: invalid chat action from client %d (IP: %s).", ci->client_index, GetClientIP(ci));
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
break;
}
@@ -1195,8 +1193,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD)
p->Recv_string(password, sizeof(password));
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayerID(ci->client_playas)) {
- ttd_strlcpy(_network_player_info[ci->client_playas].password, password, sizeof(_network_player_info[0].password));
+ if (IsValidCompanyID(ci->client_playas)) {
+ ttd_strlcpy(_network_company_info[ci->client_playas].password, password, sizeof(_network_company_info[0].password));
}
}
@@ -1301,7 +1299,7 @@ assert_compile(lengthof(_network_server_packet) == PACKET_END);
void NetworkPopulateCompanyInfo()
{
char password[NETWORK_PASSWORD_LENGTH];
- const Player *p;
+ const Company *c;
const Vehicle *v;
const Station *s;
NetworkTCPSocketHandler *cs;
@@ -1309,44 +1307,44 @@ void NetworkPopulateCompanyInfo()
uint i;
uint16 months_empty;
- for (PlayerID pid = PLAYER_FIRST; pid < MAX_PLAYERS; pid++) {
- if (!IsValidPlayerID(pid)) memset(&_network_player_info[pid], 0, sizeof(NetworkPlayerInfo));
+ for (CompanyID cid = COMPANY_FIRST; cid < MAX_COMPANIES; cid++) {
+ if (!IsValidCompanyID(cid)) memset(&_network_company_info[cid], 0, sizeof(NetworkCompanyInfo));
}
- FOR_ALL_PLAYERS(p) {
+ FOR_ALL_COMPANIES(c) {
// Clean the info but not the password
- ttd_strlcpy(password, _network_player_info[p->index].password, sizeof(password));
- months_empty = _network_player_info[p->index].months_empty;
- memset(&_network_player_info[p->index], 0, sizeof(NetworkPlayerInfo));
- _network_player_info[p->index].months_empty = months_empty;
- ttd_strlcpy(_network_player_info[p->index].password, password, sizeof(_network_player_info[p->index].password));
+ ttd_strlcpy(password, _network_company_info[c->index].password, sizeof(password));
+ months_empty = _network_company_info[c->index].months_empty;
+ memset(&_network_company_info[c->index], 0, sizeof(NetworkCompanyInfo));
+ _network_company_info[c->index].months_empty = months_empty;
+ ttd_strlcpy(_network_company_info[c->index].password, password, sizeof(_network_company_info[c->index].password));
// Grap the company name
- SetDParam(0, p->index);
- GetString(_network_player_info[p->index].company_name, STR_COMPANY_NAME, lastof(_network_player_info[p->index].company_name));
+ SetDParam(0, c->index);
+ GetString(_network_company_info[c->index].company_name, STR_COMPANY_NAME, lastof(_network_company_info[c->index].company_name));
// Check the income
- if (_cur_year - 1 == p->inaugurated_year) {
- // The player is here just 1 year, so display [2], else display[1]
- for (i = 0; i < lengthof(p->yearly_expenses[2]); i++) {
- _network_player_info[p->index].income -= p->yearly_expenses[2][i];
+ if (_cur_year - 1 == c->inaugurated_year) {
+ // The company is here just 1 year, so display [2], else display[1]
+ for (i = 0; i < lengthof(c->yearly_expenses[2]); i++) {
+ _network_company_info[c->index].income -= c->yearly_expenses[2][i];
}
} else {
- for (i = 0; i < lengthof(p->yearly_expenses[1]); i++) {
- _network_player_info[p->index].income -= p->yearly_expenses[1][i];
+ for (i = 0; i < lengthof(c->yearly_expenses[1]); i++) {
+ _network_company_info[c->index].income -= c->yearly_expenses[1][i];
}
}
// Set some general stuff
- _network_player_info[p->index].inaugurated_year = p->inaugurated_year;
- _network_player_info[p->index].company_value = p->old_economy[0].company_value;
- _network_player_info[p->index].money = p->player_money;
- _network_player_info[p->index].performance = p->old_economy[0].performance_history;
+ _network_company_info[c->index].inaugurated_year = c->inaugurated_year;
+ _network_company_info[c->index].company_value = c->old_economy[0].company_value;
+ _network_company_info[c->index].money = c->money;
+ _network_company_info[c->index].performance = c->old_economy[0].performance_history;
}
// Go through all vehicles and count the type of vehicles
FOR_ALL_VEHICLES(v) {
- if (!IsValidPlayerID(v->owner) || !v->IsPrimaryVehicle()) continue;
+ if (!IsValidCompanyID(v->owner) || !v->IsPrimaryVehicle()) continue;
byte type = 0;
switch (v->type) {
case VEH_TRAIN: type = 0; break;
@@ -1355,13 +1353,13 @@ void NetworkPopulateCompanyInfo()
case VEH_SHIP: type = 4; break;
default: continue;
}
- _network_player_info[v->owner].num_vehicle[type]++;
+ _network_company_info[v->owner].num_vehicle[type]++;
}
// Go through all stations and count the types of stations
FOR_ALL_STATIONS(s) {
- if (IsValidPlayerID(s->owner)) {
- NetworkPlayerInfo *npi = &_network_player_info[s->owner];
+ if (IsValidCompanyID(s->owner)) {
+ NetworkCompanyInfo *npi = &_network_company_info[s->owner];
if (s->facilities & FACIL_TRAIN) npi->num_station[0]++;
if (s->facilities & FACIL_TRUCK_STOP) npi->num_station[1]++;
@@ -1372,9 +1370,9 @@ void NetworkPopulateCompanyInfo()
}
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
- // Register local player (if not dedicated)
- if (ci != NULL && IsValidPlayerID(ci->client_playas))
- ttd_strlcpy(_network_player_info[ci->client_playas].players, ci->client_name, sizeof(_network_player_info[0].players));
+ // Register local company (if not dedicated)
+ if (ci != NULL && IsValidCompanyID(ci->client_playas))
+ ttd_strlcpy(_network_company_info[ci->client_playas].clients, ci->client_name, sizeof(_network_company_info[0].clients));
FOR_ALL_CLIENTS(cs) {
char client_name[NETWORK_CLIENT_NAME_LENGTH];
@@ -1382,12 +1380,12 @@ void NetworkPopulateCompanyInfo()
NetworkGetClientName(client_name, sizeof(client_name), cs);
ci = DEREF_CLIENT_INFO(cs);
- if (ci != NULL && IsValidPlayerID(ci->client_playas)) {
- if (!StrEmpty(_network_player_info[ci->client_playas].players)) {
- ttd_strlcat(_network_player_info[ci->client_playas].players, ", ", lengthof(_network_player_info[0].players));
+ if (ci != NULL && IsValidCompanyID(ci->client_playas)) {
+ if (!StrEmpty(_network_company_info[ci->client_playas].clients)) {
+ ttd_strlcat(_network_company_info[ci->client_playas].clients, ", ", lengthof(_network_company_info[0].clients));
}
- ttd_strlcat(_network_player_info[ci->client_playas].players, client_name, lengthof(_network_player_info[0].players));
+ ttd_strlcat(_network_company_info[ci->client_playas].clients, client_name, lengthof(_network_company_info[0].clients));
}
}
}
@@ -1424,8 +1422,8 @@ static void NetworkAutoCleanCompanies()
{
NetworkTCPSocketHandler *cs;
const NetworkClientInfo *ci;
- const Player *p;
- bool clients_in_company[MAX_PLAYERS];
+ const Company *c;
+ bool clients_in_company[MAX_COMPANIES];
if (!_settings_client.network.autoclean_companies) return;
@@ -1434,39 +1432,39 @@ static void NetworkAutoCleanCompanies()
/* Detect the active companies */
FOR_ALL_CLIENTS(cs) {
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayerID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
+ if (IsValidCompanyID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
}
if (!_network_dedicated) {
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
- if (IsValidPlayerID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
+ if (IsValidCompanyID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
}
/* Go through all the comapnies */
- FOR_ALL_PLAYERS(p) {
+ FOR_ALL_COMPANIES(c) {
/* Skip the non-active once */
- if (p->is_ai) continue;
+ if (c->is_ai) continue;
- if (!clients_in_company[p->index]) {
+ if (!clients_in_company[c->index]) {
/* The company is empty for one month more */
- _network_player_info[p->index].months_empty++;
+ _network_company_info[c->index].months_empty++;
/* Is the company empty for autoclean_unprotected-months, and is there no protection? */
- if (_settings_client.network.autoclean_unprotected != 0 && _network_player_info[p->index].months_empty > _settings_client.network.autoclean_unprotected && _network_player_info[p->index].password[0] == '\0') {
+ if (_settings_client.network.autoclean_unprotected != 0 && _network_company_info[c->index].months_empty > _settings_client.network.autoclean_unprotected && StrEmpty(_network_company_info[c->index].password)) {
/* Shut the company down */
- DoCommandP(0, 2, p->index, NULL, CMD_PLAYER_CTRL);
- IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", p->index + 1);
+ DoCommandP(0, 2, c->index, NULL, CMD_COMPANY_CTRL);
+ IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", c->index + 1);
}
- /* Is the compnay empty for autoclean_protected-months, and there is a protection? */
- if (_settings_client.network.autoclean_protected != 0 && _network_player_info[p->index].months_empty > _settings_client.network.autoclean_protected && _network_player_info[p->index].password[0] != '\0') {
+ /* Is the company empty for autoclean_protected-months, and there is a protection? */
+ if (_settings_client.network.autoclean_protected != 0 && _network_company_info[c->index].months_empty > _settings_client.network.autoclean_protected && !StrEmpty(_network_company_info[c->index].password)) {
/* Unprotect the company */
- _network_player_info[p->index].password[0] = '\0';
- IConsolePrintF(CC_DEFAULT, "Auto-removed protection from company #%d", p->index+1);
- _network_player_info[p->index].months_empty = 0;
+ _network_company_info[c->index].password[0] = '\0';
+ IConsolePrintF(CC_DEFAULT, "Auto-removed protection from company #%d", c->index + 1);
+ _network_company_info[c->index].months_empty = 0;
}
} else {
/* It is not empty, reset the date */
- _network_player_info[p->index].months_empty = 0;
+ _network_company_info[c->index].months_empty = 0;
}
}
}
@@ -1625,30 +1623,30 @@ void NetworkServerMonthlyLoop()
NetworkAutoCleanCompanies();
}
-void NetworkServerChangeOwner(PlayerID current_player, PlayerID new_player)
+void NetworkServerChangeOwner(Owner current_owner, Owner new_owner)
{
/* The server has to handle all administrative issues, for example
* updating and notifying all clients of what has happened */
NetworkTCPSocketHandler *cs;
NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
- /* The server has just changed from player */
- if (current_player == ci->client_playas) {
- ci->client_playas = new_player;
+ /* The server has just changed from owner */
+ if (current_owner == ci->client_playas) {
+ ci->client_playas = new_owner;
NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
}
- /* Find all clients that were in control of this company, and mark them as new_player */
+ /* Find all clients that were in control of this company, and mark them as new_owner */
FOR_ALL_CLIENTS(cs) {
ci = DEREF_CLIENT_INFO(cs);
- if (current_player == ci->client_playas) {
- ci->client_playas = new_player;
+ if (current_owner == ci->client_playas) {
+ ci->client_playas = new_owner;
NetworkUpdateClientInfo(ci->client_index);
}
}
}
-const char* GetPlayerIP(const NetworkClientInfo* ci)
+const char* GetClientIP(const NetworkClientInfo* ci)
{
struct in_addr addr;
@@ -1678,8 +1676,8 @@ void NetworkServerShowStatusToConsole()
status = (cs->status < (ptrdiff_t)lengthof(stat_str) ? stat_str[cs->status] : "unknown");
IConsolePrintF(CC_INFO, "Client #%1d name: '%s' status: '%s' frame-lag: %3d company: %1d IP: %s unique-id: '%s'",
cs->index, ci->client_name, status, lag,
- ci->client_playas + (IsValidPlayerID(ci->client_playas) ? 1 : 0),
- GetPlayerIP(ci), ci->unique_id);
+ ci->client_playas + (IsValidCompanyID(ci->client_playas) ? 1 : 0),
+ GetClientIP(ci), ci->unique_id);
}
}
@@ -1693,7 +1691,7 @@ void NetworkServerSendError(uint16 client_index, NetworkErrorCode error)
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(client_index), error);
}
-bool NetworkCompanyHasPlayers(PlayerID company)
+bool NetworkCompanyHasClients(CompanyID company)
{
const NetworkTCPSocketHandler *cs;
const NetworkClientInfo *ci;
diff --git a/src/network/network_type.h b/src/network/network_type.h
index 880a8ffae..b0258a37a 100644
--- a/src/network/network_type.h
+++ b/src/network/network_type.h
@@ -14,11 +14,11 @@
enum {
/**
- * How many clients can we have? Like.. MAX_PLAYERS - 1 is the amount of
- * players that can really play.. so.. a max of 4 spectators.. gives us..
- * MAX_PLAYERS + 3
+ * How many clients can we have? Like.. MAX_COMPANIES is the amount of
+ * companies that can really play.. so.. a max of 3 spectators.. gives us..
+ * MAX_COMPANIES + 3
*/
- MAX_CLIENTS = MAX_PLAYERS + 3,
+ MAX_CLIENTS = MAX_COMPANIES + 3,
/** Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1 */
MAX_CLIENT_INFO = MAX_CLIENTS + 1,
@@ -34,9 +34,9 @@ enum {
NETWORK_EMPTY_INDEX = 0,
};
-struct NetworkPlayerInfo {
+struct NetworkCompanyInfo {
char company_name[NETWORK_COMPANY_NAME_LENGTH]; ///< Company name
- char password[NETWORK_PASSWORD_LENGTH]; ///< The password for the player
+ char password[NETWORK_PASSWORD_LENGTH]; ///< The password for the company
Year inaugurated_year; ///< What year the company started in
Money company_value; ///< The company value
Money money; ///< The amount of money the company has
@@ -45,7 +45,7 @@ struct NetworkPlayerInfo {
bool use_password; ///< Is there a password
uint16 num_vehicle[NETWORK_VEHICLE_TYPES]; ///< How many vehicles are there of this type?
uint16 num_station[NETWORK_STATION_TYPES]; ///< How many stations are there of this type?
- char players[NETWORK_PLAYERS_LENGTH]; ///< The players that control this company (Name1, name2, ..)
+ char clients[NETWORK_CLIENTS_LENGTH]; ///< The clients that control this company (Name1, name2, ..)
uint16 months_empty; ///< How many months the company is empty
};
@@ -53,9 +53,9 @@ struct NetworkClientInfo {
uint16 client_index; ///< Index of the client (same as ClientState->index)
char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< Name of the client
byte client_lang; ///< The language of the client
- PlayerID client_playas; ///< As which player is this client playing (PlayerID)
+ CompanyID client_playas; ///< As which company is this client playing (CompanyID)
uint32 client_ip; ///< IP-address of the client (so he can be banned)
- Date join_date; ///< Gamedate the player has joined
+ Date join_date; ///< Gamedate the client has joined
char unique_id[NETWORK_UNIQUE_ID_LENGTH]; ///< Every play sends an unique id so we can indentify him
};
@@ -65,9 +65,9 @@ enum NetworkPasswordType {
};
enum DestType {
- DESTTYPE_BROADCAST, ///< Send message/notice to all players (All)
+ DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All)
DESTTYPE_TEAM, ///< Send message/notice to everyone playing the same company (Team)
- DESTTYPE_CLIENT, ///< Send message/notice to only a certain player (Private)
+ DESTTYPE_CLIENT, ///< Send message/notice to only a certain client (Private)
};
/** Actions that can be used for NetworkTextMessage */
@@ -98,7 +98,7 @@ enum NetworkErrorCode {
NETWORK_ERROR_WRONG_REVISION,
NETWORK_ERROR_NAME_IN_USE,
NETWORK_ERROR_WRONG_PASSWORD,
- NETWORK_ERROR_PLAYER_MISMATCH, // Happens in CLIENT_COMMAND
+ NETWORK_ERROR_COMPANY_MISMATCH, // Happens in CLIENT_COMMAND
NETWORK_ERROR_KICKED,
NETWORK_ERROR_CHEATER,
NETWORK_ERROR_FULL,
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 7e27ecd4e..c2b0aba8c 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -83,7 +83,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
ngi.server_lang = _settings_client.network.server_lang;
ngi.use_password = !StrEmpty(_settings_client.network.server_password);
ngi.clients_max = _settings_client.network.max_clients;
- ngi.companies_on = ActivePlayerCount();
+ ngi.companies_on = ActiveCompanyCount();
ngi.companies_max = _settings_client.network.max_companies;
ngi.spectators_on = NetworkSpectatorCount();
ngi.spectators_max = _settings_client.network.max_spectators;
@@ -116,36 +116,36 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_DETAIL_INFO)
/* Send the amount of active companies */
packet.Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
- packet.Send_uint8 (ActivePlayerCount());
+ packet.Send_uint8 (ActiveCompanyCount());
/* Fetch the latest version of everything */
NetworkPopulateCompanyInfo();
- Player *player;
+ Company *company;
byte current = 0;
- /* Go through all the players */
- FOR_ALL_PLAYERS(player) {
+ /* Go through all the companies */
+ FOR_ALL_COMPANIES(company) {
current++;
/* Send the information */
packet.Send_uint8 (current);
- packet.Send_string(_network_player_info[player->index].company_name);
- packet.Send_uint32(_network_player_info[player->index].inaugurated_year);
- packet.Send_uint64(_network_player_info[player->index].company_value);
- packet.Send_uint64(_network_player_info[player->index].money);
- packet.Send_uint64(_network_player_info[player->index].income);
- packet.Send_uint16(_network_player_info[player->index].performance);
+ packet.Send_string(_network_company_info[company->index].company_name);
+ packet.Send_uint32(_network_company_info[company->index].inaugurated_year);
+ packet.Send_uint64(_network_company_info[company->index].company_value);
+ packet.Send_uint64(_network_company_info[company->index].money);
+ packet.Send_uint64(_network_company_info[company->index].income);
+ packet.Send_uint16(_network_company_info[company->index].performance);
/* Send 1 if there is a passord for the company else send 0 */
- packet.Send_bool (!StrEmpty(_network_player_info[player->index].password));
+ packet.Send_bool (!StrEmpty(_network_company_info[company->index].password));
for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
- packet.Send_uint16(_network_player_info[player->index].num_vehicle[i]);
+ packet.Send_uint16(_network_company_info[company->index].num_vehicle[i]);
}
for (int i = 0; i < NETWORK_STATION_TYPES; i++) {
- packet.Send_uint16(_network_player_info[player->index].num_station[i]);
+ packet.Send_uint16(_network_company_info[company->index].num_station[i]);
}
}
diff --git a/src/newgrf_callbacks.h b/src/newgrf_callbacks.h
index 2bae20e0e..d8e1cf8cd 100644
--- a/src/newgrf_callbacks.h
+++ b/src/newgrf_callbacks.h
@@ -127,7 +127,7 @@ enum CallbackID {
/** Called to determine the type (if any) of foundation to draw for industry tile. */
CBID_INDUSTRY_DRAW_FOUNDATIONS = 0x30, // 15 bit callback
- /** Called when the player (or AI) tries to start or stop a vehicle. Mainly
+ /** Called when the company (or AI) tries to start or stop a vehicle. Mainly
* used for preventing a vehicle from leaving the depot. */
CBID_VEHICLE_START_STOP_CHECK = 0x31, // 15 bit callback, but 0xFF test is done with 8 bit
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index c42f24674..8a78f17b7 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -445,8 +445,8 @@ static uint8 LiveryHelper(EngineID engine, const Vehicle *v)
const Livery *l;
if (v == NULL) {
- if (!IsValidPlayerID(_current_player)) return 0;
- l = GetEngineLivery(engine, _current_player, INVALID_ENGINE, NULL);
+ if (!IsValidCompanyID(_current_company)) return 0;
+ l = GetEngineLivery(engine, _current_company, INVALID_ENGINE, NULL);
} else if (v->type == VEH_TRAIN) {
l = GetEngineLivery((v->u.rail.first_engine != INVALID_ENGINE && (IsArticulatedPart(v) || UsesWagonOverride(v))) ? v->u.rail.first_engine : v->engine_type, v->owner, v->u.rail.first_engine, v);
} else {
@@ -464,7 +464,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
if (v == NULL) {
/* Vehicle does not exist, so we're in a purchase list */
switch (variable) {
- case 0x43: return _current_player | (LiveryHelper(object->u.vehicle.self_type, NULL) << 24); // Owner information
+ case 0x43: return _current_company | (LiveryHelper(object->u.vehicle.self_type, NULL) << 24); // Owner information
case 0x46: return 0; // Motion counter
case 0x48: return GetEngine(object->u.vehicle.self_type)->flags; // Vehicle Type Info
case 0x49: return _cur_year; // 'Long' format build year
@@ -542,8 +542,8 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
return cargo_classes | (common_cargo_type << 8) | (common_subtype << 16) | (user_def_data << 24);
}
- case 0x43: // Player information
- return v->owner | (GetPlayer(v->owner)->is_ai ? 0x10000 : 0) | (LiveryHelper(v->engine_type, v) << 24);
+ case 0x43: // Company information
+ return v->owner | (GetCompany(v->owner)->is_ai ? 0x10000 : 0) | (LiveryHelper(v->engine_type, v) << 24);
case 0x44: // Aircraft information
if (v->type != VEH_AIRCRAFT) return UINT_MAX;
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 9622588b8..290e358e2 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -579,10 +579,10 @@ bool CanDeleteHouse(TileIndex tile)
{
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
- /* Human players are always allowed to remove buildings, as is water and
+ /* Humans are always allowed to remove buildings, as is water and
* anyone using the scenario editor. */
- if ((IsValidPlayerID(_current_player) && IsHumanPlayer(_current_player))
- || _current_player == OWNER_WATER || _current_player == OWNER_NONE) return true;
+ if ((IsValidCompanyID(_current_company) && IsHumanCompany(_current_company))
+ || _current_company == OWNER_WATER || _current_company == OWNER_NONE) return true;
if (HasBit(hs->callback_mask, CBM_HOUSE_DENY_DESTRUCTION)) {
uint16 callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 55c8da417..d7fd441ae 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -267,16 +267,16 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
/* Layout number */
case 0x44: return industry->selected_layout;
- /* player info */
+ /* Company info */
case 0x45: {
byte colours;
bool is_ai = false;
- if (IsValidPlayerID(industry->founder)) {
- const Player *p = GetPlayer(industry->founder);
- const Livery *l = &p->livery[LS_DEFAULT];
+ if (IsValidCompanyID(industry->founder)) {
+ const Company *c = GetCompany(industry->founder);
+ const Livery *l = &c->livery[LS_DEFAULT];
- is_ai = p->is_ai;
+ is_ai = c->is_ai;
colours = l->colour1 + l->colour2 * 16;
} else {
colours = GB(Random(), 0, 8);
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index f90ae845c..103ff25f8 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -382,10 +382,10 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0x41:
case 0x46:
case 0x47:
- case 0x49: return 0x2110000; // Platforms, tracks & position
- case 0x42: return 0; // Rail type (XXX Get current type from GUI?)
- case 0x43: return _current_player; // Station owner
- case 0x44: return 2; // PBS status
+ case 0x49: return 0x2110000; // Platforms, tracks & position
+ case 0x42: return 0; // Rail type (XXX Get current type from GUI?)
+ case 0x43: return _current_company; // Station owner
+ case 0x44: return 2; // PBS status
case 0xFA: return Clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value
}
@@ -782,7 +782,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
const RailtypeInfo *rti = GetRailTypeInfo(railtype);
SpriteID relocation;
SpriteID image;
- SpriteID palette = PLAYER_SPRITE_COLOR(_local_player);
+ SpriteID palette = COMPANY_SPRITE_COLOR(_local_company);
uint tile = 2;
statspec = GetCustomStationSpec(sclass, station);
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index fb4f1e3f9..5018c48aa 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -51,7 +51,7 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni)
{
const CompanyNewsInformation *cni = (const CompanyNewsInformation*)ni->free_data;
- DrawPlayerFace(cni->face, cni->colour, 2, 23);
+ DrawCompanyManagerFace(cni->face, cni->colour, 2, 23);
GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOR);
SetDParamStr(0, cni->president_name);
@@ -123,26 +123,26 @@ struct NewsSubtypeData {
* Data common to all news items of a given subtype (actual data)
*/
static const struct NewsSubtypeData _news_subtype_data[NS_END] = {
- /* type, display_mode, flags, callback */
- { NT_ARRIVAL_PLAYER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ARRIVAL_PLAYER
- { NT_ARRIVAL_OTHER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ARRIVAL_OTHER
- { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_ACCIDENT_TILE
- { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ACCIDENT_VEHICLE
- { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_TROUBLE
- { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_MERGER
- { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_BANKRUPT
- { NT_COMPANY_INFO, NM_NORMAL, NF_TILE, DrawNewsBankrupcy }, ///< NS_COMPANY_NEW
- { NT_INDUSTRY_OPEN, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_OPEN
- { NT_INDUSTRY_CLOSE, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_CLOSE
- { NT_ECONOMY, NM_NORMAL, NF_NONE, NULL }, ///< NS_ECONOMY
- { NT_INDUSTRY_PLAYER, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_PLAYER
- { NT_INDUSTRY_OTHER, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_OTHER
- { NT_INDUSTRY_NOBODY, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_NOBODY
- { NT_ADVICE, NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ADVICE
- { NT_NEW_VEHICLES, NM_NORMAL, NF_NONE, DrawNewsNewVehicleAvail }, ///< NS_NEW_VEHICLES
- { NT_ACCEPTANCE, NM_SMALL, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_ACCEPTANCE
- { NT_SUBSIDIES, NM_NORMAL, NF_TILE|NF_TILE2, NULL }, ///< NS_SUBSIDIES
- { NT_GENERAL, NM_NORMAL, NF_TILE, NULL }, ///< NS_GENERAL
+ /* type, display_mode, flags, callback */
+ { NT_ARRIVAL_COMPANY, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ARRIVAL_COMPANY
+ { NT_ARRIVAL_OTHER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ARRIVAL_OTHER
+ { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_ACCIDENT_TILE
+ { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ACCIDENT_VEHICLE
+ { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_TROUBLE
+ { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_MERGER
+ { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_BANKRUPT
+ { NT_COMPANY_INFO, NM_NORMAL, NF_TILE, DrawNewsBankrupcy }, ///< NS_COMPANY_NEW
+ { NT_INDUSTRY_OPEN, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_OPEN
+ { NT_INDUSTRY_CLOSE, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_CLOSE
+ { NT_ECONOMY, NM_NORMAL, NF_NONE, NULL }, ///< NS_ECONOMY
+ { NT_INDUSTRY_COMPANY, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_COMPANY
+ { NT_INDUSTRY_OTHER, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_OTHER
+ { NT_INDUSTRY_NOBODY, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_NOBODY
+ { NT_ADVICE, NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ADVICE
+ { NT_NEW_VEHICLES, NM_NORMAL, NF_NONE, DrawNewsNewVehicleAvail }, ///< NS_NEW_VEHICLES
+ { NT_ACCEPTANCE, NM_SMALL, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_ACCEPTANCE
+ { NT_SUBSIDIES, NM_NORMAL, NF_TILE|NF_TILE2, NULL }, ///< NS_SUBSIDIES
+ { NT_GENERAL, NM_NORMAL, NF_TILE, NULL }, ///< NS_GENERAL
};
/**
@@ -150,14 +150,14 @@ static const struct NewsSubtypeData _news_subtype_data[NS_END] = {
*/
NewsTypeData _news_type_data[NT_END] = {
/* name, age, sound, display */
- { "arrival_player", 60, SND_1D_APPLAUSE, ND_FULL }, ///< NT_ARRIVAL_PLAYER
+ { "arrival_player", 60, SND_1D_APPLAUSE, ND_FULL }, ///< NT_ARRIVAL_COMPANY
{ "arrival_other", 60, SND_1D_APPLAUSE, ND_FULL }, ///< NT_ARRIVAL_OTHER
{ "accident", 90, SND_BEGIN, ND_FULL }, ///< NT_ACCIDENT
{ "company_info", 60, SND_BEGIN, ND_FULL }, ///< NT_COMPANY_INFO
{ "open", 90, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_OPEN
{ "close", 90, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_CLOSE
{ "economy", 30, SND_BEGIN, ND_FULL }, ///< NT_ECONOMY
- { "production_player", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_PLAYER
+ { "production_player", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_COMPANY
{ "production_other", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_OTHER
{ "production_nobody", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_NOBODY
{ "advice", 150, SND_BEGIN, ND_FULL }, ///< NT_ADVICE
@@ -590,7 +590,7 @@ void DeleteStationNews(StationID sid)
while (ni != NULL) {
NewsItem *next = ni->next;
switch (ni->subtype) {
- case NS_ARRIVAL_PLAYER:
+ case NS_ARRIVAL_COMPANY:
case NS_ARRIVAL_OTHER:
case NS_ACCEPTANCE:
if (ni->data_b == sid) DeleteNewsItem(ni);
@@ -968,21 +968,21 @@ static const Widget _message_options_widgets[] = {
/* List of news-setting lines (4 widgets for each line).
* First widget must be number WIDGET_NEWSOPT_START_OPTION
*/
-NEWS_SETTINGS_LINE(26, NT_ARRIVAL_PLAYER, STR_0206_ARRIVAL_OF_FIRST_VEHICLE),
-NEWS_SETTINGS_LINE(26, NT_ARRIVAL_OTHER, STR_0207_ARRIVAL_OF_FIRST_VEHICLE),
-NEWS_SETTINGS_LINE(26, NT_ACCIDENT, STR_0208_ACCIDENTS_DISASTERS),
-NEWS_SETTINGS_LINE(26, NT_COMPANY_INFO, STR_0209_COMPANY_INFORMATION),
-NEWS_SETTINGS_LINE(26, NT_INDUSTRY_OPEN, STR_NEWS_INDUSTRY_OPEN),
-NEWS_SETTINGS_LINE(26, NT_INDUSTRY_CLOSE, STR_NEWS_INDUSTRY_CLOSE),
-NEWS_SETTINGS_LINE(26, NT_ECONOMY, STR_020A_ECONOMY_CHANGES),
-NEWS_SETTINGS_LINE(26, NT_INDUSTRY_PLAYER, STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER),
-NEWS_SETTINGS_LINE(26, NT_INDUSTRY_OTHER, STR_INDUSTRY_CHANGES_SERVED_BY_OTHER),
-NEWS_SETTINGS_LINE(26, NT_INDUSTRY_NOBODY, STR_OTHER_INDUSTRY_PRODUCTION_CHANGES),
-NEWS_SETTINGS_LINE(26, NT_ADVICE, STR_020B_ADVICE_INFORMATION_ON_PLAYER),
-NEWS_SETTINGS_LINE(26, NT_NEW_VEHICLES, STR_020C_NEW_VEHICLES),
-NEWS_SETTINGS_LINE(26, NT_ACCEPTANCE, STR_020D_CHANGES_OF_CARGO_ACCEPTANCE),
-NEWS_SETTINGS_LINE(26, NT_SUBSIDIES, STR_020E_SUBSIDIES),
-NEWS_SETTINGS_LINE(26, NT_GENERAL, STR_020F_GENERAL_INFORMATION),
+NEWS_SETTINGS_LINE(26, NT_ARRIVAL_COMPANY, STR_0206_ARRIVAL_OF_FIRST_VEHICLE),
+NEWS_SETTINGS_LINE(26, NT_ARRIVAL_OTHER, STR_0207_ARRIVAL_OF_FIRST_VEHICLE),
+NEWS_SETTINGS_LINE(26, NT_ACCIDENT, STR_0208_ACCIDENTS_DISASTERS),
+NEWS_SETTINGS_LINE(26, NT_COMPANY_INFO, STR_0209_COMPANY_INFORMATION),
+NEWS_SETTINGS_LINE(26, NT_INDUSTRY_OPEN, STR_NEWS_INDUSTRY_OPEN),
+NEWS_SETTINGS_LINE(26, NT_INDUSTRY_CLOSE, STR_NEWS_INDUSTRY_CLOSE),
+NEWS_SETTINGS_LINE(26, NT_ECONOMY, STR_020A_ECONOMY_CHANGES),
+NEWS_SETTINGS_LINE(26, NT_INDUSTRY_COMPANY, STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER),
+NEWS_SETTINGS_LINE(26, NT_INDUSTRY_OTHER, STR_INDUSTRY_CHANGES_SERVED_BY_OTHER),
+NEWS_SETTINGS_LINE(26, NT_INDUSTRY_NOBODY, STR_OTHER_INDUSTRY_PRODUCTION_CHANGES),
+NEWS_SETTINGS_LINE(26, NT_ADVICE, STR_020B_ADVICE_INFORMATION_ON_PLAYER),
+NEWS_SETTINGS_LINE(26, NT_NEW_VEHICLES, STR_020C_NEW_VEHICLES),
+NEWS_SETTINGS_LINE(26, NT_ACCEPTANCE, STR_020D_CHANGES_OF_CARGO_ACCEPTANCE),
+NEWS_SETTINGS_LINE(26, NT_SUBSIDIES, STR_020E_SUBSIDIES),
+NEWS_SETTINGS_LINE(26, NT_GENERAL, STR_020F_GENERAL_INFORMATION),
{ WIDGETS_END},
};
diff --git a/src/news_type.h b/src/news_type.h
index 5d1cc3215..02e6f1e8f 100644
--- a/src/news_type.h
+++ b/src/news_type.h
@@ -13,17 +13,17 @@
* Type of news.
*/
enum NewsType {
- NT_ARRIVAL_PLAYER, ///< Cargo arrived for player
+ NT_ARRIVAL_COMPANY, ///< Cargo arrived for company
NT_ARRIVAL_OTHER, ///< Cargo arrived for competitor
NT_ACCIDENT, ///< An accident or disaster has occurred
NT_COMPANY_INFO, ///< Company info (new companies, bankrupcy messages)
NT_INDUSTRY_OPEN, ///< Opening of industries
NT_INDUSTRY_CLOSE, ///< Closing of industries
NT_ECONOMY, ///< Economic changes (recession, industry up/dowm)
- NT_INDUSTRY_PLAYER, ///< Production changes of industry serviced by local player
+ NT_INDUSTRY_COMPANY,///< Production changes of industry serviced by local company
NT_INDUSTRY_OTHER, ///< Production changes of industry serviced by competitor(s)
NT_INDUSTRY_NOBODY, ///< Other industry production changes
- NT_ADVICE, ///< Bits of news about vehicles of the player
+ NT_ADVICE, ///< Bits of news about vehicles of the company
NT_NEW_VEHICLES, ///< New vehicle has become available
NT_ACCEPTANCE, ///< A type of cargo is (no longer) accepted
NT_SUBSIDIES, ///< News about subsidies (announcements, expirations, acceptance)
@@ -35,7 +35,7 @@ enum NewsType {
* News subtypes.
*/
enum NewsSubtype {
- NS_ARRIVAL_PLAYER, ///< NT_ARRIVAL_PLAYER
+ NS_ARRIVAL_COMPANY, ///< NT_ARRIVAL_COMPANY
NS_ARRIVAL_OTHER, ///< NT_ARRIVAL_OTHER
NS_ACCIDENT_TILE, ///< NT_ACCIDENT (tile)
NS_ACCIDENT_VEHICLE, ///< NT_ACCIDENT (vehicle)
@@ -46,7 +46,7 @@ enum NewsSubtype {
NS_INDUSTRY_OPEN, ///< NT_INDUSTRY_OPEN
NS_INDUSTRY_CLOSE, ///< NT_INDUSTRY_CLOSE
NS_ECONOMY, ///< NT_ECONOMY
- NS_INDUSTRY_PLAYER, ///< NT_INDUSTRY_PLAYER
+ NS_INDUSTRY_COMPANY, ///< NT_INDUSTRY_COMPANY
NS_INDUSTRY_OTHER, ///< NT_INDUSTRY_OTHER
NS_INDUSTRY_NOBODY, ///< NT_INDUSTRY_NOBODY
NS_ADVICE, ///< NT_ADVICE
@@ -130,7 +130,7 @@ struct CompanyNewsInformation {
uint32 face; ///< The face of the president
byte colour; ///< The colour related to the company
- void FillData(const struct Player *p, const struct Player *other = NULL);
+ void FillData(const struct Company *c, const struct Company *other = NULL);
};
#endif /* NEWS_TYPE_H */
diff --git a/src/npf.cpp b/src/npf.cpp
index d5f431b43..7721ceebf 100644
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -573,7 +573,7 @@ static void NPFSaveTargetData(AyStar* as, OpenListNode* current)
}
/**
- * Finds out if a given player's vehicles are allowed to enter a given tile.
+ * Finds out if a given company's vehicles are allowed to enter a given tile.
* @param owner The owner of the vehicle.
* @param tile The tile that is about to be entered.
* @param enterdir The direction in which the vehicle wants to enter the tile.
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index f7a0834c6..db987951e 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -363,7 +363,7 @@ static void FixOldVehicles()
* or vehicles that could not have an order would still have a
* (loading) order which causes assertions and the like later on.
*/
- if (!IsPlayerBuildableVehicleType(v) ||
+ if (!IsCompanyBuildableVehicleType(v) ||
(v->IsPrimaryVehicle() && v->current_order.IsType(OT_NOTHING))) {
v->current_order.MakeDummy();
}
@@ -770,60 +770,60 @@ static bool LoadOldIndustry(LoadgameState *ls, int num)
return true;
}
-static PlayerID _current_player_id;
+static CompanyID _current_company_id;
static int32 _old_yearly;
-static const OldChunks player_yearly_chunk[] = {
+static const OldChunks _company_yearly_chunk[] = {
OCL_VAR( OC_INT32, 1, &_old_yearly ),
OCL_END()
};
-static bool OldPlayerYearly(LoadgameState *ls, int num)
+static bool OldCompanyYearly(LoadgameState *ls, int num)
{
int i;
- Player *p = GetPlayer(_current_player_id);
+ Company *c = GetCompany(_current_company_id);
for (i = 0; i < 13; i++) {
- if (!LoadChunk(ls, NULL, player_yearly_chunk)) return false;
+ if (!LoadChunk(ls, NULL, _company_yearly_chunk)) return false;
- p->yearly_expenses[num][i] = _old_yearly;
+ c->yearly_expenses[num][i] = _old_yearly;
}
return true;
}
-static const OldChunks player_economy_chunk[] = {
- OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, PlayerEconomyEntry, income ),
- OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, PlayerEconomyEntry, expenses ),
- OCL_SVAR( OC_INT32, PlayerEconomyEntry, delivered_cargo ),
- OCL_SVAR( OC_INT32, PlayerEconomyEntry, performance_history ),
- OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, PlayerEconomyEntry, company_value ),
+static const OldChunks _company_economy_chunk[] = {
+ OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, CompanyEconomyEntry, income ),
+ OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, CompanyEconomyEntry, expenses ),
+ OCL_SVAR( OC_INT32, CompanyEconomyEntry, delivered_cargo ),
+ OCL_SVAR( OC_INT32, CompanyEconomyEntry, performance_history ),
+ OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, CompanyEconomyEntry, company_value ),
OCL_END()
};
-static bool OldPlayerEconomy(LoadgameState *ls, int num)
+static bool OldCompanyEconomy(LoadgameState *ls, int num)
{
int i;
- Player *p = GetPlayer(_current_player_id);
+ Company *c = GetCompany(_current_company_id);
- if (!LoadChunk(ls, &p->cur_economy, player_economy_chunk)) return false;
+ if (!LoadChunk(ls, &c->cur_economy, _company_economy_chunk)) return false;
/* Don't ask, but the number in TTD(Patch) are inversed to OpenTTD */
- p->cur_economy.income = -p->cur_economy.income;
- p->cur_economy.expenses = -p->cur_economy.expenses;
+ c->cur_economy.income = -c->cur_economy.income;
+ c->cur_economy.expenses = -c->cur_economy.expenses;
for (i = 0; i < 24; i++) {
- if (!LoadChunk(ls, &p->old_economy[i], player_economy_chunk)) return false;
+ if (!LoadChunk(ls, &c->old_economy[i], _company_economy_chunk)) return false;
- p->old_economy[i].income = -p->old_economy[i].income;
- p->old_economy[i].expenses = -p->old_economy[i].expenses;
+ c->old_economy[i].income = -c->old_economy[i].income;
+ c->old_economy[i].expenses = -c->old_economy[i].expenses;
}
return true;
}
-static const OldChunks player_ai_build_rec_chunk[] = {
+static const OldChunks _company_ai_build_rec_chunk[] = {
OCL_SVAR( OC_TILE, AiBuildRec, spec_tile ),
OCL_SVAR( OC_TILE, AiBuildRec, use_tile ),
OCL_SVAR( OC_UINT8, AiBuildRec, rand_rng ),
@@ -842,216 +842,215 @@ static const OldChunks player_ai_build_rec_chunk[] = {
static bool OldLoadAIBuildRec(LoadgameState *ls, int num)
{
- Player *p = GetPlayer(_current_player_id);
+ Company *c = GetCompany(_current_company_id);
switch (num) {
- case 0: return LoadChunk(ls, &_players_ai[p->index].src, player_ai_build_rec_chunk);
- case 1: return LoadChunk(ls, &_players_ai[p->index].dst, player_ai_build_rec_chunk);
- case 2: return LoadChunk(ls, &_players_ai[p->index].mid1, player_ai_build_rec_chunk);
- case 3: return LoadChunk(ls, &_players_ai[p->index].mid2, player_ai_build_rec_chunk);
+ case 0: return LoadChunk(ls, &_companies_ai[c->index].src, _company_ai_build_rec_chunk);
+ case 1: return LoadChunk(ls, &_companies_ai[c->index].dst, _company_ai_build_rec_chunk);
+ case 2: return LoadChunk(ls, &_companies_ai[c->index].mid1, _company_ai_build_rec_chunk);
+ case 3: return LoadChunk(ls, &_companies_ai[c->index].mid2, _company_ai_build_rec_chunk);
}
return false;
}
-static const OldChunks player_ai_chunk[] = {
- OCL_SVAR( OC_UINT8, PlayerAI, state ),
+static const OldChunks _company_ai_chunk[] = {
+ OCL_SVAR( OC_UINT8, CompanyAI, state ),
OCL_NULL( 1 ), ///< Junk
- OCL_SVAR( OC_UINT8, PlayerAI, state_mode ),
- OCL_SVAR( OC_UINT16, PlayerAI, state_counter ),
- OCL_SVAR( OC_UINT16, PlayerAI, timeout_counter ),
+ OCL_SVAR( OC_UINT8, CompanyAI, state_mode ),
+ OCL_SVAR( OC_UINT16, CompanyAI, state_counter ),
+ OCL_SVAR( OC_UINT16, CompanyAI, timeout_counter ),
OCL_CHUNK( 4, OldLoadAIBuildRec ),
OCL_NULL( 20 ), ///< More junk
- OCL_SVAR( OC_UINT8, PlayerAI, cargo_type ),
- OCL_SVAR( OC_UINT8, PlayerAI, num_wagons ),
- OCL_SVAR( OC_UINT8, PlayerAI, build_kind ),
- OCL_SVAR( OC_UINT8, PlayerAI, num_build_rec ),
- OCL_SVAR( OC_UINT8, PlayerAI, num_loco_to_build ),
- OCL_SVAR( OC_UINT8, PlayerAI, num_want_fullload ),
+ OCL_SVAR( OC_UINT8, CompanyAI, cargo_type ),
+ OCL_SVAR( OC_UINT8, CompanyAI, num_wagons ),
+ OCL_SVAR( OC_UINT8, CompanyAI, build_kind ),
+ OCL_SVAR( OC_UINT8, CompanyAI, num_build_rec ),
+ OCL_SVAR( OC_UINT8, CompanyAI, num_loco_to_build ),
+ OCL_SVAR( OC_UINT8, CompanyAI, num_want_fullload ),
OCL_NULL( 14 ), ///< Oh no more junk :|
OCL_NULL( 2 ), ///< Loco-id, not used
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[0] ),
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[1] ),
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[2] ),
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[3] ),
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[4] ),
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[5] ),
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[6] ),
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[7] ),
- OCL_SVAR( OC_UINT16, PlayerAI, wagon_list[8] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[0] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[1] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[2] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[3] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[4] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[5] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[6] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[7] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[8] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[9] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[10] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[11] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[12] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[13] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[14] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[15] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[16] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[17] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[18] ),
- OCL_SVAR( OC_UINT8, PlayerAI, order_list_blocks[19] ),
-
- OCL_SVAR( OC_UINT16, PlayerAI, start_tile_a ),
- OCL_SVAR( OC_UINT16, PlayerAI, start_tile_b ),
- OCL_SVAR( OC_UINT16, PlayerAI, cur_tile_a ),
- OCL_SVAR( OC_UINT16, PlayerAI, cur_tile_b ),
-
- OCL_SVAR( OC_UINT8, PlayerAI, start_dir_a ),
- OCL_SVAR( OC_UINT8, PlayerAI, start_dir_b ),
- OCL_SVAR( OC_UINT8, PlayerAI, cur_dir_a ),
- OCL_SVAR( OC_UINT8, PlayerAI, cur_dir_b ),
-
- OCL_SVAR( OC_UINT8, PlayerAI, banned_tile_count ),
-
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[0] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[0] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[1] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[1] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[2] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[2] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[3] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[3] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[4] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[4] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[5] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[5] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[6] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[6] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[7] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[7] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[8] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[8] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[9] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[9] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[10] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[10] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[11] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[11] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[12] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[12] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[13] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[13] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[14] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[14] ),
- OCL_SVAR( OC_TILE, PlayerAI, banned_tiles[15] ),
- OCL_SVAR( OC_UINT8, PlayerAI, banned_val[15] ),
-
- OCL_SVAR( OC_UINT8, PlayerAI, railtype_to_use ),
- OCL_SVAR( OC_UINT8, PlayerAI, route_type_mask ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[0] ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[1] ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[2] ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[3] ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[4] ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[5] ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[6] ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[7] ),
+ OCL_SVAR( OC_UINT16, CompanyAI, wagon_list[8] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[0] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[1] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[2] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[3] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[4] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[5] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[6] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[7] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[8] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[9] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[10] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[11] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[12] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[13] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[14] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[15] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[16] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[17] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[18] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, order_list_blocks[19] ),
+
+ OCL_SVAR( OC_UINT16, CompanyAI, start_tile_a ),
+ OCL_SVAR( OC_UINT16, CompanyAI, start_tile_b ),
+ OCL_SVAR( OC_UINT16, CompanyAI, cur_tile_a ),
+ OCL_SVAR( OC_UINT16, CompanyAI, cur_tile_b ),
+
+ OCL_SVAR( OC_UINT8, CompanyAI, start_dir_a ),
+ OCL_SVAR( OC_UINT8, CompanyAI, start_dir_b ),
+ OCL_SVAR( OC_UINT8, CompanyAI, cur_dir_a ),
+ OCL_SVAR( OC_UINT8, CompanyAI, cur_dir_b ),
+
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_tile_count ),
+
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[0] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[0] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[1] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[1] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[2] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[2] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[3] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[3] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[4] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[4] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[5] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[5] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[6] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[6] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[7] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[7] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[8] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[8] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[9] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[9] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[10] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[10] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[11] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[11] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[12] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[12] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[13] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[13] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[14] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[14] ),
+ OCL_SVAR( OC_TILE, CompanyAI, banned_tiles[15] ),
+ OCL_SVAR( OC_UINT8, CompanyAI, banned_val[15] ),
+
+ OCL_SVAR( OC_UINT8, CompanyAI, railtype_to_use ),
+ OCL_SVAR( OC_UINT8, CompanyAI, route_type_mask ),
OCL_END()
};
-static bool OldPlayerAI(LoadgameState *ls, int num)
+static bool OldCompanyAI(LoadgameState *ls, int num)
{
- return LoadChunk(ls, &_players_ai[_current_player_id], player_ai_chunk);
+ return LoadChunk(ls, &_companies_ai[_current_company_id], _company_ai_chunk);
}
uint8 ai_tick;
-static const OldChunks player_chunk[] = {
+static const OldChunks _company_chunk[] = {
OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
- OCL_SVAR( OC_UINT32, Player, name_2 ),
- OCL_SVAR( OC_UINT32, Player, face ),
+ OCL_SVAR( OC_UINT32, Company, name_2 ),
+ OCL_SVAR( OC_UINT32, Company, face ),
OCL_VAR ( OC_UINT16, 1, &_old_string_id_2 ),
- OCL_SVAR( OC_UINT32, Player, president_name_2 ),
+ OCL_SVAR( OC_UINT32, Company, president_name_2 ),
- OCL_SVAR( OC_INT32, Player, player_money ),
- OCL_SVAR( OC_INT32, Player, current_loan ),
+ OCL_SVAR( OC_INT32, Company, money ),
+ OCL_SVAR( OC_INT32, Company, current_loan ),
- OCL_SVAR( OC_UINT8, Player, player_color ),
- OCL_SVAR( OC_UINT8, Player, player_money_fraction ),
- OCL_SVAR( OC_UINT8, Player, quarters_of_bankrupcy ),
- OCL_SVAR( OC_UINT8, Player, bankrupt_asked ),
- OCL_SVAR( OC_FILE_U32 | OC_VAR_I64, Player, bankrupt_value ),
- OCL_SVAR( OC_UINT16, Player, bankrupt_timeout ),
+ OCL_SVAR( OC_UINT8, Company, colour ),
+ OCL_SVAR( OC_UINT8, Company, money_fraction ),
+ OCL_SVAR( OC_UINT8, Company, quarters_of_bankrupcy ),
+ OCL_SVAR( OC_UINT8, Company, bankrupt_asked ),
+ OCL_SVAR( OC_FILE_U32 | OC_VAR_I64, Company, bankrupt_value ),
+ OCL_SVAR( OC_UINT16, Company, bankrupt_timeout ),
- OCL_SVAR( OC_UINT32, Player, cargo_types ),
+ OCL_SVAR( OC_UINT32, Company, cargo_types ),
- OCL_CHUNK( 3, OldPlayerYearly ),
- OCL_CHUNK( 1, OldPlayerEconomy ),
+ OCL_CHUNK( 3, OldCompanyYearly ),
+ OCL_CHUNK( 1, OldCompanyEconomy ),
- OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Player, inaugurated_year),
- OCL_SVAR( OC_TILE, Player, last_build_coordinate ),
- OCL_SVAR( OC_UINT8, Player, num_valid_stat_ent ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Company, inaugurated_year),
+ OCL_SVAR( OC_TILE, Company, last_build_coordinate ),
+ OCL_SVAR( OC_UINT8, Company, num_valid_stat_ent ),
- OCL_CHUNK( 1, OldPlayerAI ),
+ OCL_CHUNK( 1, OldCompanyAI ),
- OCL_SVAR( OC_UINT8, Player, block_preview ),
+ OCL_SVAR( OC_UINT8, Company, block_preview ),
OCL_VAR( OC_UINT8, 1, &ai_tick ),
- OCL_SVAR( OC_UINT8, Player, avail_railtypes ),
- OCL_SVAR( OC_TILE, Player, location_of_HQ ),
- OCL_SVAR( OC_UINT8, Player, share_owners[0] ),
- OCL_SVAR( OC_UINT8, Player, share_owners[1] ),
- OCL_SVAR( OC_UINT8, Player, share_owners[2] ),
- OCL_SVAR( OC_UINT8, Player, share_owners[3] ),
+ OCL_SVAR( OC_UINT8, Company, avail_railtypes ),
+ OCL_SVAR( OC_TILE, Company, location_of_HQ ),
+ OCL_SVAR( OC_UINT8, Company, share_owners[0] ),
+ OCL_SVAR( OC_UINT8, Company, share_owners[1] ),
+ OCL_SVAR( OC_UINT8, Company, share_owners[2] ),
+ OCL_SVAR( OC_UINT8, Company, share_owners[3] ),
OCL_NULL( 8 ), ///< junk at end of chunk
OCL_END()
};
-static bool LoadOldPlayer(LoadgameState *ls, int num)
+static bool LoadOldCompany(LoadgameState *ls, int num)
{
- Player *p = new (num) Player();
+ Company *c = new (num) Company();
- _current_player_id = (PlayerID)num;
+ _current_company_id = (CompanyID)num;
- if (!LoadChunk(ls, p, player_chunk)) return false;
+ if (!LoadChunk(ls, c, _company_chunk)) return false;
if (_old_string_id == 0) {
- delete p;
+ delete c;
return true;
}
- p->name_1 = RemapOldStringID(_old_string_id);
- p->president_name_1 = RemapOldStringID(_old_string_id_2);
- _players_ai[_current_player_id].tick = ai_tick;
+ c->name_1 = RemapOldStringID(_old_string_id);
+ c->president_name_1 = RemapOldStringID(_old_string_id_2);
+ _companies_ai[_current_company_id].tick = ai_tick;
if (num == 0) {
- /* If the first player has no name, make sure we call it UNNAMED */
- if (p->name_1 == 0)
- p->name_1 = STR_SV_UNNAMED;
+ /* If the first company has no name, make sure we call it UNNAMED */
+ if (c->name_1 == 0)
+ c->name_1 = STR_SV_UNNAMED;
} else {
/* Beside some multiplayer maps (1 on 1), which we don't official support,
- all other players are an AI.. mark them as such */
- p->is_ai = true;
+ * all other companys are an AI.. mark them as such */
+ c->is_ai = true;
}
/* Sometimes it is better to not ask.. in old scenarios, the money
- was always 893288 pounds. In the newer versions this is correct,
- but correct for those oldies
- Ps: this also means that if you had exact 893288 pounds, you will go back
- to 10000.. this is a very VERY small chance ;) */
- if (p->player_money == 893288)
- p->player_money = p->current_loan = 100000;
-
- _player_colors[num] = p->player_color;
- p->inaugurated_year -= ORIGINAL_BASE_YEAR;
- if (p->location_of_HQ == 0xFFFF)
- p->location_of_HQ = 0;
-
- /* State 20 for AI players is sell vehicle. Since the AI struct is not
- * really figured out as of now, _players_ai[p->index].cur_veh; needed for 'sell vehicle'
+ * was always 893288 pounds. In the newer versions this is correct,
+ * but correct for those oldies
+ * Ps: this also means that if you had exact 893288 pounds, you will go back
+ * to 10000.. this is a very VERY small chance ;) */
+ if (c->money == 893288) c->money = c->current_loan = 100000;
+
+ _company_colours[num] = c->colour;
+ c->inaugurated_year -= ORIGINAL_BASE_YEAR;
+ if (c->location_of_HQ == 0xFFFF)
+ c->location_of_HQ = 0;
+
+ /* State 20 for AI companies is sell vehicle. Since the AI struct is not
+ * really figured out as of now, _companies_ai[c->index].cur_veh; needed for 'sell vehicle'
* is NULL and the function will crash. To fix this, just change the state
* to some harmless state, like 'loop vehicle'; 1 */
- if (!IsHumanPlayer((PlayerID)num) && _players_ai[p->index].state == 20) _players_ai[p->index].state = 1;
+ if (!IsHumanCompany((CompanyID)num) && _companies_ai[c->index].state == 20) _companies_ai[c->index].state = 1;
- if (p->is_ai && (!_networking || _network_server) && _ai.enabled)
- AI_StartNewAI(p->index);
+ if (c->is_ai && (!_networking || _network_server) && _ai.enabled)
+ AI_StartNewAI(c->index);
return true;
}
@@ -1323,7 +1322,7 @@ static bool LoadOldSign(LoadgameState *ls, int num)
}
static const OldChunks engine_chunk[] = {
- OCL_SVAR( OC_UINT16, Engine, player_avail ),
+ OCL_SVAR( OC_UINT16, Engine, company_avail ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Engine, intro_date ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Engine, age ),
OCL_SVAR( OC_UINT16, Engine, reliability ),
@@ -1337,7 +1336,7 @@ static const OldChunks engine_chunk[] = {
OCL_SVAR( OC_UINT8, Engine, lifelength ),
OCL_SVAR( OC_UINT8, Engine, flags ),
- OCL_SVAR( OC_UINT8, Engine, preview_player_rank ),
+ OCL_SVAR( OC_UINT8, Engine, preview_company_rank ),
OCL_SVAR( OC_UINT8, Engine, preview_wait ),
OCL_NULL( 2 ), ///< Junk
@@ -1542,7 +1541,7 @@ static const OldChunks main_chunk[] = {
OCL_CHUNK(250, LoadOldStation ),
OCL_CHUNK( 90, LoadOldIndustry ),
- OCL_CHUNK( 8, LoadOldPlayer ),
+ OCL_CHUNK( 8, LoadOldCompany ),
OCL_ASSERT( 0x547F2 ),
@@ -1577,16 +1576,16 @@ static const OldChunks main_chunk[] = {
OCL_CHUNK(256, LoadOldEngineName ),
OCL_NULL( 144 ), ///< AI cargo-stuff, calculated in InitializeLandscapeVariables
- OCL_NULL( 2 ), ///< Company indexes of players, no longer in use
+ OCL_NULL( 2 ), ///< Company indexes of companies, no longer in use
OCL_VAR ( OC_FILE_U8 | OC_VAR_U16, 1, &_station_tick_ctr ),
OCL_VAR ( OC_UINT8, 1, &_settings_game.locale.currency ),
OCL_VAR ( OC_UINT8, 1, &_settings_game.locale.units ),
- OCL_VAR ( OC_FILE_U8 | OC_VAR_U32, 1, &_cur_player_tick_index ),
+ OCL_VAR ( OC_FILE_U8 | OC_VAR_U32, 1, &_cur_company_tick_index ),
OCL_NULL( 2 ), ///< Date stuff, calculated automatically
- OCL_NULL( 8 ), ///< Player colors, calculated automatically
+ OCL_NULL( 8 ), ///< Company colors, calculated automatically
OCL_VAR ( OC_UINT8, 1, &_economy.infl_amount ),
OCL_VAR ( OC_UINT8, 1, &_economy.infl_amount_pr ),
@@ -1693,7 +1692,7 @@ static bool LoadOldMain(LoadgameState *ls)
FOR_ALL_ENGINES(e) {
if (_date >= (e->intro_date + 365)) {
e->flags = (e->flags & ~ENGINE_EXCLUSIVE_PREVIEW) | ENGINE_AVAILABLE;
- e->player_avail = (byte)-1;
+ e->company_avail = (CompanyMask)-1;
}
}
diff --git a/src/openttd.cpp b/src/openttd.cpp
index edb65df79..95df73f24 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -98,7 +98,7 @@ void ProcessAsyncSaveFinish();
void CallWindowTickEvent();
extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
-extern Player* DoStartupNewPlayer(bool is_ai);
+extern Company *DoStartupNewCompany(bool is_ai);
extern void ShowOSErrorBox(const char *buf, bool system);
extern void InitializeRailGUI();
@@ -182,7 +182,7 @@ static void ShowHelp()
" -g [savegame] = Start new/save game immediately\n"
" -G seed = Set random seed\n"
#if defined(ENABLE_NETWORK)
- " -n [ip:port#player] = Start networkgame\n"
+ " -n [ip:port#company]= Start networkgame\n"
" -D [ip][:port] = Start dedicated server\n"
" -l ip[:port] = Redirect DEBUG()\n"
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
@@ -307,7 +307,7 @@ static void InitializeDynamicVariables()
/* Dynamic stuff needs to be initialized somewhere... */
_industry_mngr.ResetMapping();
_industile_mngr.ResetMapping();
- _Player_pool.AddBlockToPool();
+ _Company_pool.AddBlockToPool();
}
@@ -341,7 +341,7 @@ static void ShutdownGame()
_Group_pool.CleanPool();
_CargoPacket_pool.CleanPool();
_Engine_pool.CleanPool();
- _Player_pool.CleanPool();
+ _Company_pool.CleanPool();
free(_config_file);
@@ -363,9 +363,9 @@ static void LoadIntroGame()
if (SaveOrLoad("opntitle.dat", SL_LOAD, DATA_DIR) != SL_OK) {
GenerateWorld(GW_EMPTY, 64, 64); // if failed loading, make empty world.
WaitTillGeneratedWorld();
- SetLocalPlayer(PLAYER_SPECTATOR);
+ SetLocalCompany(COMPANY_SPECTATOR);
} else {
- SetLocalPlayer(PLAYER_FIRST);
+ SetLocalCompany(COMPANY_FIRST);
}
_pause_game = 0;
@@ -437,7 +437,7 @@ int ttd_main(int argc, char *argv[])
dedicated = true;
if (mgo.opt != NULL) {
/* Use the existing method for parsing (openttd -n).
- * However, we do ignore the #player part. */
+ * However, we do ignore the #company part. */
const char *temp = NULL;
const char *port = NULL;
ParseConnectionString(&temp, &port, mgo.opt);
@@ -649,20 +649,20 @@ int ttd_main(int argc, char *argv[])
if (network && _network_available) {
if (network_conn != NULL) {
const char *port = NULL;
- const char *player = NULL;
+ const char *company = NULL;
uint16 rport;
rport = NETWORK_DEFAULT_PORT;
- _network_playas = PLAYER_NEW_COMPANY;
+ _network_playas = COMPANY_NEW_COMPANY;
- ParseConnectionString(&player, &port, network_conn);
+ ParseConnectionString(&company, &port, network_conn);
- if (player != NULL) {
- _network_playas = (PlayerID)atoi(player);
+ if (company != NULL) {
+ _network_playas = (CompanyID)atoi(company);
- if (_network_playas != PLAYER_SPECTATOR) {
+ if (_network_playas != COMPANY_SPECTATOR) {
_network_playas--;
- if (_network_playas >= MAX_PLAYERS) return false;
+ if (_network_playas >= MAX_COMPANIES) return false;
}
}
if (port != NULL) rport = atoi(port);
@@ -719,21 +719,21 @@ static void MakeNewGameDone()
/* In a dedicated server, the server does not play */
if (_network_dedicated) {
- SetLocalPlayer(PLAYER_SPECTATOR);
+ SetLocalCompany(COMPANY_SPECTATOR);
return;
}
- /* Create a single player */
- DoStartupNewPlayer(false);
+ /* Create a single company */
+ DoStartupNewCompany(false);
- SetLocalPlayer(PLAYER_FIRST);
- _current_player = _local_player;
+ SetLocalCompany(COMPANY_FIRST);
+ _current_company = _local_company;
DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
InitializeRailGUI();
#ifdef ENABLE_NETWORK
- /* We are the server, we start a new player (not dedicated),
+ /* We are the server, we start a new company (not dedicated),
* so set the default password *if* needed. */
if (_network_server && !StrEmpty(_settings_client.network.default_company_pass)) {
char *password = _settings_client.network.default_company_pass;
@@ -759,7 +759,7 @@ static void MakeNewGame(bool from_heightmap)
static void MakeNewEditorWorldDone()
{
- SetLocalPlayer(OWNER_NONE);
+ SetLocalCompany(OWNER_NONE);
MarkWholeScreenDirty();
}
@@ -774,7 +774,7 @@ static void MakeNewEditorWorld()
GenerateWorld(GW_EMPTY, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
}
-void StartupPlayers();
+void StartupCompanies();
void StartupDisasters();
extern void StartupEconomy();
@@ -816,12 +816,12 @@ static void StartScenario()
/* Inititalize data */
StartupEconomy();
- StartupPlayers();
+ StartupCompanies();
StartupEngines();
StartupDisasters();
- SetLocalPlayer(PLAYER_FIRST);
- _current_player = _local_player;
+ SetLocalCompany(COMPANY_FIRST);
+ _current_company = _local_company;
DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
MarkWholeScreenDirty();
@@ -927,9 +927,9 @@ void SwitchMode(int new_mode)
if (_saveload_mode == SLD_LOAD_SCENARIO) {
StartupEngines();
}
- /* Update the local player for a loaded game. It is either always
- * player #1 (eg 0) or in the case of a dedicated server a spectator */
- SetLocalPlayer(_network_dedicated ? PLAYER_SPECTATOR : PLAYER_FIRST);
+ /* Update the local company for a loaded game. It is either always
+ * company #1 (eg 0) or in the case of a dedicated server a spectator */
+ SetLocalCompany(_network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST);
/* Decrease pause counter (was increased from opening load dialog) */
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
#ifdef ENABLE_NETWORK
@@ -951,7 +951,7 @@ void SwitchMode(int new_mode)
break;
case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */
- SetLocalPlayer(OWNER_NONE);
+ SetLocalCompany(OWNER_NONE);
GenerateWorld(GW_HEIGHTMAP, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
MarkWholeScreenDirty();
@@ -959,7 +959,7 @@ void SwitchMode(int new_mode)
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */
if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) {
- SetLocalPlayer(OWNER_NONE);
+ SetLocalCompany(OWNER_NONE);
_settings_newgame.game_creation.starting_year = _cur_year;
} else {
SetDParam(0, STR_JUST_RAW_STRING);
@@ -987,7 +987,7 @@ void SwitchMode(int new_mode)
break;
case SM_GENRANDLAND: /* Generate random land within scenario editor */
- SetLocalPlayer(OWNER_NONE);
+ SetLocalCompany(OWNER_NONE);
GenerateWorld(GW_RANDOM, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
/* XXX: set date */
MarkWholeScreenDirty();
@@ -1034,7 +1034,7 @@ void StateGameLoop()
case VEH_ROAD: {
extern byte GetRoadVehLength(const Vehicle *v);
if (GetRoadVehLength(v) != v->u.road.cached_veh_length) {
- printf("cache mismatch: vehicle %i, player %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber);
+ printf("cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber);
}
} break;
@@ -1051,7 +1051,7 @@ void StateGameLoop()
length = 0;
for (Vehicle *u = v; u != NULL; u = u->Next()) {
if (memcmp(&wagons[length], &u->u.rail, sizeof(VehicleRail)) != 0) {
- printf("cache mismatch: vehicle %i, player %i, unit number %i, wagon %i\n", v->index, (int)v->owner, v->unitnumber, length);
+ printf("cache mismatch: vehicle %i, company %i, unit number %i, wagon %i\n", v->index, (int)v->owner, v->unitnumber, length);
}
length++;
}
@@ -1063,7 +1063,7 @@ void StateGameLoop()
uint speed = v->u.air.cached_max_speed;
UpdateAircraftCache(v);
if (speed != v->u.air.cached_max_speed) {
- printf("cache mismatch: vehicle %i, player %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber);
+ printf("cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber);
}
} break;
@@ -1075,8 +1075,8 @@ void StateGameLoop()
/* All these actions has to be done from OWNER_NONE
* for multiplayer compatibility */
- PlayerID p = _current_player;
- _current_player = OWNER_NONE;
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_NONE;
AnimateAnimatedTiles();
IncreaseDate();
@@ -1089,7 +1089,7 @@ void StateGameLoop()
CallWindowTickEvent();
NewsLoop();
- _current_player = p;
+ _current_company = old_company;
}
}
@@ -1104,8 +1104,8 @@ static void DoAutosave()
if (_networking) return;
#endif /* PSP */
- if (_settings_client.gui.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
- SetDParam(0, _local_player);
+ if (_settings_client.gui.keep_all_autosave && _local_company != COMPANY_SPECTATOR) {
+ SetDParam(0, _local_company);
SetDParam(1, _date);
GetString(buf, STR_4004, lastof(buf));
ttd_strlcat(buf, ".sav", lengthof(buf));
@@ -1203,16 +1203,16 @@ static void UpdateExclusiveRights()
Town *t;
FOR_ALL_TOWNS(t) {
- t->exclusivity = INVALID_PLAYER;
+ t->exclusivity = INVALID_COMPANY;
}
/* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete)
* could be implemented this way:
* 1.) Go through all stations
- * Build an array town_blocked[ town_id ][ player_id ]
- * that stores if at least one station in that town is blocked for a player
+ * Build an array town_blocked[ town_id ][ company_id ]
+ * that stores if at least one station in that town is blocked for a company
* 2.) Go through that array, if you find a town that is not blocked for
- * one player, but for all others, then give him exclusivity.
+ * one company, but for all others, then give him exclusivity.
*/
}
@@ -1282,13 +1282,13 @@ static bool InitializeWindowsAndCaches()
UpdateAllTownVirtCoords();
UpdateAllWaypointSigns();
- Player *p;
- FOR_ALL_PLAYERS(p) {
- /* For each player, verify (while loading a scenario) that the inauguration date is the current year and set it
- * accordingly if it is not the case. No need to set it on players that are not been used already,
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ /* For each company, verify (while loading a scenario) that the inauguration date is the current year and set it
+ * accordingly if it is not the case. No need to set it on companies that are not been used already,
* thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */
- if (_file_to_saveload.filetype == FT_SCENARIO && p->inaugurated_year != MIN_YEAR) {
- p->inaugurated_year = _cur_year;
+ if (_file_to_saveload.filetype == FT_SCENARIO && c->inaugurated_year != MIN_YEAR) {
+ c->inaugurated_year = _cur_year;
}
}
@@ -1307,7 +1307,7 @@ static bool InitializeWindowsAndCaches()
bool AfterLoadGame()
{
TileIndex map_size = MapSize();
- Player *p;
+ Company *c;
if (CheckSavegameVersion(98)) GamelogOldver();
@@ -1334,19 +1334,18 @@ bool AfterLoadGame()
* walk through the whole map.. */
if (CheckSavegameVersionOldStyle(4, 3)) {
for (TileIndex t = 0; t < map_size; t++) {
- if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_PLAYERS) {
+ if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_COMPANIES) {
SetTileOwner(t, OWNER_WATER);
}
}
}
if (CheckSavegameVersion(84)) {
- Player *p;
- FOR_ALL_PLAYERS(p) {
- p->name = CopyFromOldName(p->name_1);
- if (p->name != NULL) p->name_1 = STR_SV_UNNAMED;
- p->president_name = CopyFromOldName(p->president_name_1);
- if (p->president_name != NULL) p->president_name_1 = SPECSTR_PRESIDENT_NAME;
+ FOR_ALL_COMPANIES(c) {
+ c->name = CopyFromOldName(c->name_1);
+ if (c->name != NULL) c->name_1 = STR_SV_UNNAMED;
+ c->president_name = CopyFromOldName(c->president_name_1);
+ if (c->president_name != NULL) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
}
Station *st;
@@ -1369,7 +1368,7 @@ bool AfterLoadGame()
}
for (uint i = 0; i < GetSignPoolSize(); i++) {
- /* invalid signs are determined by si->ower == INVALID_PLAYER now */
+ /* invalid signs are determined by si->ower == INVALID_COMPANY now */
Sign *si = GetSign(i);
if (!si->IsValid() && si->name != NULL) {
si->owner = OWNER_NONE;
@@ -1444,11 +1443,11 @@ bool AfterLoadGame()
if (CheckSavegameVersion(87)) UpdateVoidTiles();
/* If Load Scenario / New (Scenario) Game is used,
- * a player does not exist yet. So create one here.
- * 1 exeption: network-games. Those can have 0 players
+ * a company does not exist yet. So create one here.
+ * 1 exeption: network-games. Those can have 0 companies
* But this exeption is not true for non dedicated network_servers! */
- if (!IsValidPlayerID(PLAYER_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated)))
- DoStartupNewPlayer(false);
+ if (!IsValidCompanyID(COMPANY_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated)))
+ DoStartupNewCompany(false);
if (CheckSavegameVersion(72)) {
/* Locks/shiplifts in very old savegames had OWNER_WATER as owner */
@@ -1589,24 +1588,24 @@ bool AfterLoadGame()
/* From version 16.0, we included autorenew on engines, which are now saved, but
* of course, we do need to initialize them for older savegames. */
if (CheckSavegameVersion(16)) {
- FOR_ALL_PLAYERS(p) {
- p->engine_renew_list = NULL;
- p->engine_renew = false;
- p->engine_renew_months = -6;
- p->engine_renew_money = 100000;
+ FOR_ALL_COMPANIES(c) {
+ c->engine_renew_list = NULL;
+ c->engine_renew = false;
+ c->engine_renew_months = -6;
+ c->engine_renew_money = 100000;
}
- /* When loading a game, _local_player is not yet set to the correct value.
+ /* When loading a game, _local_company is not yet set to the correct value.
* However, in a dedicated server we are a spectator, so nothing needs to
- * happen. In case we are not a dedicated server, the local player always
- * becomes player 0, unless we are in the scenario editor where all the
- * players are 'invalid'.
+ * happen. In case we are not a dedicated server, the local company always
+ * becomes company 0, unless we are in the scenario editor where all the
+ * companies are 'invalid'.
*/
- if (!_network_dedicated && IsValidPlayerID(PLAYER_FIRST)) {
- p = GetPlayer(PLAYER_FIRST);
- p->engine_renew = _settings_client.gui.autorenew;
- p->engine_renew_months = _settings_client.gui.autorenew_months;
- p->engine_renew_money = _settings_client.gui.autorenew_money;
+ if (!_network_dedicated && IsValidCompanyID(COMPANY_FIRST)) {
+ c = GetCompany(COMPANY_FIRST);
+ c->engine_renew = _settings_client.gui.autorenew;
+ c->engine_renew_months = _settings_client.gui.autorenew_months;
+ c->engine_renew_money = _settings_client.gui.autorenew_money;
}
}
@@ -1808,11 +1807,11 @@ bool AfterLoadGame()
}
- /* In version 16.1 of the savegame a player can decide if trains, which get
+ /* In version 16.1 of the savegame a company can decide if trains, which get
* replaced, shall keep their old length. In all prior versions, just default
* to false */
if (CheckSavegameVersionOldStyle(16, 1)) {
- FOR_ALL_PLAYERS(p) p->renew_keep_length = false;
+ FOR_ALL_COMPANIES(c) c->renew_keep_length = false;
}
/* In version 17, ground type is moved from m2 to m4 for depots and
@@ -1913,11 +1912,11 @@ bool AfterLoadGame()
YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK);
- if (CheckSavegameVersion(34)) FOR_ALL_PLAYERS(p) ResetPlayerLivery(p);
+ if (CheckSavegameVersion(34)) FOR_ALL_COMPANIES(c) ResetCompanyLivery(c);
- FOR_ALL_PLAYERS(p) {
- p->avail_railtypes = GetPlayerRailtypes(p->index);
- p->avail_roadtypes = GetPlayerRoadtypes(p->index);
+ FOR_ALL_COMPANIES(c) {
+ c->avail_railtypes = GetCompanyRailtypes(c->index);
+ c->avail_roadtypes = GetCompanyRoadtypes(c->index);
}
if (!CheckSavegameVersion(27)) AfterLoadStations();
@@ -1928,18 +1927,17 @@ bool AfterLoadGame()
Station *st;
Waypoint *wp;
Engine *e;
- Player *player;
Industry *i;
Vehicle *v;
_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
_cur_year += ORIGINAL_BASE_YEAR;
- FOR_ALL_STATIONS(st) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
- FOR_ALL_WAYPOINTS(wp) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
- FOR_ALL_ENGINES(e) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
- FOR_ALL_PLAYERS(player) player->inaugurated_year += ORIGINAL_BASE_YEAR;
- FOR_ALL_INDUSTRIES(i) i->last_prod_year += ORIGINAL_BASE_YEAR;
+ FOR_ALL_STATIONS(st) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
+ FOR_ALL_WAYPOINTS(wp) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
+ FOR_ALL_ENGINES(e) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
+ FOR_ALL_COMPANIES(c) c->inaugurated_year += ORIGINAL_BASE_YEAR;
+ FOR_ALL_INDUSTRIES(i) i->last_prod_year += ORIGINAL_BASE_YEAR;
FOR_ALL_VEHICLES(v) {
v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR;
@@ -2139,7 +2137,7 @@ bool AfterLoadGame()
}
}
- if (CheckSavegameVersion(49)) FOR_ALL_PLAYERS(p) p->face = ConvertFromOldPlayerFace(p->face);
+ if (CheckSavegameVersion(49)) FOR_ALL_COMPANIES(c) c->face = ConvertFromOldCompanyManagerFace(c->face);
if (CheckSavegameVersion(52)) {
for (TileIndex t = 0; t < map_size; t++) {
@@ -2337,18 +2335,17 @@ bool AfterLoadGame()
}
}
- /* Set all share owners to PLAYER_SPECTATOR for
- * 1) all inactive players
- * (when inactive players were stored in the savegame - TTD, TTDP and some
- * *really* old revisions of OTTD; else it is already set in InitializePlayers())
- * 2) shares that are owned by inactive players or self
- * (caused by cheating players in earlier revisions) */
- Player *p;
- FOR_ALL_PLAYERS(p) {
+ /* Set all share owners to INVALID_COMPANY for
+ * 1) all inactive companies
+ * (when inactive companies were stored in the savegame - TTD, TTDP and some
+ * *really* old revisions of OTTD; else it is already set in InitializeCompanies())
+ * 2) shares that are owned by inactive companies or self
+ * (caused by cheating clients in earlier revisions) */
+ FOR_ALL_COMPANIES(c) {
for (uint i = 0; i < 4; i++) {
- PlayerID o = p->share_owners[i];
- if (o == PLAYER_SPECTATOR) continue;
- if (!IsValidPlayerID(o) || o == p->index) p->share_owners[i] = PLAYER_SPECTATOR;
+ CompanyID company = c->share_owners[i];
+ if (company == INVALID_COMPANY) continue;
+ if (!IsValidCompanyID(company) || company == c->index) c->share_owners[i] = INVALID_COMPANY;
}
}
}
@@ -2396,13 +2393,13 @@ bool AfterLoadGame()
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
Owner o = GetTileOwner(t);
- if (o < MAX_PLAYERS && !IsValidPlayerID(o)) {
- _current_player = o;
- ChangeTileOwner(t, o, PLAYER_SPECTATOR);
+ if (o < MAX_COMPANIES && !IsValidCompanyID(o)) {
+ _current_company = o;
+ ChangeTileOwner(t, o, INVALID_OWNER);
}
if (IsBuoyTile(t)) {
/* reset buoy owner to OWNER_NONE in the station struct
- * (even if it is owned by active player) */
+ * (even if it is owned by active company) */
GetStationByTile(t)->owner = OWNER_NONE;
}
} else if (IsTileType(t, MP_ROAD)) {
@@ -2410,13 +2407,13 @@ bool AfterLoadGame()
for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
/* update even non-existing road types to update tile owner too */
Owner o = GetRoadOwner(t, rt);
- if (o < MAX_PLAYERS && !IsValidPlayerID(o)) SetRoadOwner(t, rt, OWNER_NONE);
+ if (o < MAX_COMPANIES && !IsValidCompanyID(o)) SetRoadOwner(t, rt, OWNER_NONE);
}
if (IsLevelCrossing(t)) {
Owner o = GetTileOwner(t);
- if (!IsValidPlayerID(o)) {
+ if (!IsValidCompanyID(o)) {
/* remove leftover rail piece from crossing (from very old savegames) */
- _current_player = o;
+ _current_company = o;
DoCommand(t, 0, GetCrossingRailTrack(t), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
}
}
@@ -2551,7 +2548,7 @@ bool AfterLoadGame()
Waypoint *wp;
FOR_ALL_WAYPOINTS(wp) {
Owner owner = (IsRailWaypointTile(wp->xy) ? GetTileOwner(wp->xy) : OWNER_NONE);
- wp->owner = IsValidPlayerID(owner) ? owner : OWNER_NONE;
+ wp->owner = IsValidCompanyID(owner) ? owner : OWNER_NONE;
}
}
@@ -2566,7 +2563,7 @@ bool AfterLoadGame()
/* signs with invalid owner left from older savegames */
Sign *si;
FOR_ALL_SIGNS(si) {
- if (si->owner != OWNER_NONE && !IsValidPlayerID(si->owner)) si->owner = OWNER_NONE;
+ if (si->owner != OWNER_NONE && !IsValidCompanyID(si->owner)) si->owner = OWNER_NONE;
}
}
@@ -2598,7 +2595,7 @@ void ReloadNewGRFData()
/* Check and update house and town values */
UpdateHousesAndTowns();
/* Update livery selection windows */
- for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) InvalidateWindowData(WC_PLAYER_COLOR, i, _loaded_newgrf_features.has_2CC);
+ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOR, i, _loaded_newgrf_features.has_2CC);
/* redraw the whole screen */
MarkWholeScreenDirty();
CheckTrainsLengths();
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 2a9da30e3..efe853e2f 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -285,7 +285,7 @@ void Order::AssignOrder(const Order &other)
/**
* Delete all news items regarding defective orders about a vehicle
* This could kill still valid warnings (for example about void order when just
- * another order gets added), but assume the player will notice the problems,
+ * another order gets added), but assume the company will notice the problems,
* when (s)he's changing the orders.
*/
static void DeleteOrderWarnings(const Vehicle* v)
@@ -437,7 +437,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
}
} else {
- if (!IsPlayerBuildableVehicleType(v)) return CMD_ERROR;
+ if (!IsCompanyBuildableVehicleType(v)) return CMD_ERROR;
}
if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR;
@@ -495,7 +495,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (!HasOrderPoolFree(1)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
- if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _settings_game.pf.pathfinder_for_ships != VPF_NPF) {
+ if (v->type == VEH_SHIP && IsHumanCompany(v->owner) && _settings_game.pf.pathfinder_for_ships != VPF_NPF) {
/* Make sure the new destination is not too far away from the previous */
const Order *prev = NULL;
uint n = 0;
@@ -1390,7 +1390,7 @@ void CheckOrders(const Vehicle* v)
if (v->FirstShared() != v) return;
/* Only check every 20 days, so that we don't flood the message log */
- if (v->owner == _local_player && v->day_counter % 20 == 0) {
+ if (v->owner == _local_company && v->day_counter % 20 == 0) {
int n_st, problem_type = -1;
const Order *order;
int message = 0;
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 7a2586676..ce8a61545 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -279,7 +279,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (_settings_game.order.gotodepot) {
switch (GetTileType(tile)) {
case MP_RAILWAY:
- if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
+ if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) {
if (IsRailDepot(tile)) {
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
@@ -289,7 +289,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
break;
case MP_ROAD:
- if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
+ if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_company)) {
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
return order;
@@ -298,7 +298,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
case MP_STATION:
if (v->type != VEH_AIRCRAFT) break;
- if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
+ if (IsHangar(tile) && IsTileOwner(tile, _local_company)) {
order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS);
return order;
}
@@ -306,7 +306,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
case MP_WATER:
if (v->type != VEH_SHIP) break;
- if (IsShipDepot(tile) && IsTileOwner(tile, _local_player)) {
+ if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) {
TileIndex tile2 = GetOtherShipDepotTile(tile);
order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
@@ -321,7 +321,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
/* check waypoint */
if (IsRailWaypointTile(tile) &&
v->type == VEH_TRAIN &&
- IsTileOwner(tile, _local_player)) {
+ IsTileOwner(tile, _local_company)) {
order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
return order;
@@ -331,7 +331,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
StationID st_index = GetStationIndex(tile);
const Station *st = GetStation(st_index);
- if (st->owner == _current_player || st->owner == OWNER_NONE) {
+ if (st->owner == _current_company || st->owner == OWNER_NONE) {
byte facil;
(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
@@ -668,7 +668,7 @@ public:
int sel = OrderGetSel();
const Order *order = GetVehicleOrder(this->vehicle, sel);
- if (this->vehicle->owner == _local_player) {
+ if (this->vehicle->owner == _local_company) {
/* Set the strings for the dropdown boxes. */
this->widget[ORDER_WIDGET_COND_VARIABLE].data = _order_conditional_variable[order == NULL ? 0 : order->GetConditionVariable()];
this->widget[ORDER_WIDGET_COND_COMPARATOR].data = _order_conditional_condition[order == NULL ? 0 : order->GetConditionComparator()];
@@ -833,7 +833,7 @@ public:
/* Select clicked order */
this->selected_order = sel;
- if (this->vehicle->owner == _local_player) {
+ if (this->vehicle->owner == _local_company) {
/* Activate drag and drop */
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, this);
}
@@ -1007,7 +1007,7 @@ public:
//('?', OrderClick_Service},
};
- if (this->vehicle->owner != _local_player) return ES_NOT_HANDLED;
+ if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED;
for (uint i = 0; i < lengthof(keytoevent); i++) {
if (keycode == keytoevent[i].keycode) {
@@ -1093,7 +1093,7 @@ public:
};
/**
- * Widget definition for player train orders
+ * Widget definition for "your" train orders
*/
static const Widget _orders_train_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ORDER_WIDGET_CLOSEBOX
@@ -1136,7 +1136,7 @@ static const WindowDesc _orders_train_desc = {
};
/**
- * Widget definition for player orders (!train)
+ * Widget definition for "your" orders (!train)
*/
static const Widget _orders_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ORDER_WIDGET_CLOSEBOX
@@ -1228,7 +1228,7 @@ void ShowOrdersWindow(const Vehicle *v)
DeleteWindowById(WC_VEHICLE_ORDERS, veh);
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
- if (v->owner != _local_player) {
+ if (v->owner != _local_company) {
new OrdersWindow(&_other_orders_desc, v);
} else {
new OrdersWindow((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, v);
diff --git a/src/order_type.h b/src/order_type.h
index 01df949be..5ac9f89a1 100644
--- a/src/order_type.h
+++ b/src/order_type.h
@@ -72,7 +72,7 @@ enum OrderNonStopFlags {
* Reasons that could cause us to go to the depot.
*/
enum OrderDepotTypeFlags {
- ODTF_MANUAL = 0, ///< The player initiated this order manually.
+ ODTF_MANUAL = 0, ///< Manually initiated order.
ODTFB_SERVICE = 1 << 0, ///< This depot order is because of the servicing limit.
ODTFB_PART_OF_ORDERS = 1 << 1, ///< This depot order is because of a regular order.
};
diff --git a/src/player_base.h b/src/player_base.h
index e699773a4..17e67d0c6 100644
--- a/src/player_base.h
+++ b/src/player_base.h
@@ -1,9 +1,9 @@
/* $Id$ */
-/** @file player_base.h Definition of stuff that is very close to a player, like the player struct itself. */
+/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */
-#ifndef PLAYER_BASE_H
-#define PLAYER_BASE_H
+#ifndef COMPANY_BASE_H
+#define COMPANY_BASE_H
#include "player_type.h"
#include "oldpool.h"
@@ -16,23 +16,23 @@
#include "economy_type.h"
#include "tile_type.h"
-struct PlayerEconomyEntry {
+struct CompanyEconomyEntry {
Money income;
Money expenses;
int32 delivered_cargo;
- int32 performance_history; ///< player score (scale 0-1000)
+ int32 performance_history; ///< company score (scale 0-1000)
Money company_value;
};
/* The third parameter and the number after >> MUST be the same,
- * otherwise more (or less) players will be allowed to be
- * created than what MAX_PLAYER specifies!
+ * otherwise more (or less) companies will be allowed to be
+ * created than what MAX_COMPANIES specifies!
*/
-DECLARE_OLD_POOL(Player, Player, 1, MAX_PLAYERS >> 1)
+DECLARE_OLD_POOL(Company, Company, 1, MAX_COMPANIES >> 1)
-struct Player : PoolItem<Player, PlayerByte, &_Player_pool> {
- Player(uint16 name_1 = 0, bool is_ai = false);
- ~Player();
+struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
+ Company(uint16 name_1 = 0, bool is_ai = false);
+ ~Company();
uint32 name_2;
uint16 name_1;
@@ -42,14 +42,14 @@ struct Player : PoolItem<Player, PlayerByte, &_Player_pool> {
uint32 president_name_2;
char *president_name;
- PlayerFace face;
+ CompanyManagerFace face;
- Money player_money;
+ Money money;
+ byte money_fraction;
Money current_loan;
- byte player_color;
+ byte colour;
Livery livery[LS_END];
- byte player_money_fraction;
RailTypes avail_railtypes;
RoadTypes avail_roadtypes;
byte block_preview;
@@ -59,49 +59,49 @@ struct Player : PoolItem<Player, PlayerByte, &_Player_pool> {
TileIndex location_of_HQ;
TileIndex last_build_coordinate;
- PlayerByte share_owners[4];
+ OwnerByte share_owners[4];
Year inaugurated_year;
byte num_valid_stat_ent;
byte quarters_of_bankrupcy;
- byte bankrupt_asked; ///< which players were asked about buying it?
+ byte bankrupt_asked; ///< which companies were asked about buying it?
int16 bankrupt_timeout;
Money bankrupt_value;
bool is_ai;
Money yearly_expenses[3][EXPENSES_END];
- PlayerEconomyEntry cur_economy;
- PlayerEconomyEntry old_economy[24];
+ CompanyEconomyEntry cur_economy;
+ CompanyEconomyEntry old_economy[24];
EngineRenewList engine_renew_list; ///< Defined later
bool engine_renew;
bool renew_keep_length;
int16 engine_renew_months;
uint32 engine_renew_money;
- uint16 *num_engines; ///< caches the number of engines of each type the player owns (no need to save this)
+ uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this)
inline bool IsValid() const { return this->name_1 != 0; }
};
-static inline bool IsValidPlayerID(PlayerID index)
+static inline bool IsValidCompanyID(CompanyID company)
{
- return (uint)index < GetPlayerPoolSize() && GetPlayer(index)->IsValid();
+ return (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
}
-#define FOR_ALL_PLAYERS_FROM(d, start) for (d = GetPlayer(start); d != NULL; d = (d->index + 1U < GetPlayerPoolSize()) ? GetPlayer(d->index + 1U) : NULL) if (d->IsValid())
-#define FOR_ALL_PLAYERS(d) FOR_ALL_PLAYERS_FROM(d, 0)
+#define FOR_ALL_COMPANIES_FROM(d, start) for (d = GetCompany(start); d != NULL; d = (d->index + 1U < GetCompanyPoolSize()) ? GetCompany(d->index + 1U) : NULL) if (d->IsValid())
+#define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0)
-static inline byte ActivePlayerCount()
+static inline byte ActiveCompanyCount()
{
- const Player *p;
+ const Company *c;
byte count = 0;
- FOR_ALL_PLAYERS(p) count++;
+ FOR_ALL_COMPANIES(c) count++;
return count;
}
-Money CalculateCompanyValue(const Player *p);
+Money CalculateCompanyValue(const Company *c);
-#endif /* PLAYER_BASE_H */
+#endif /* COMPANY_BASE_H */
diff --git a/src/player_face.h b/src/player_face.h
index 2a293e331..6f2a96ff9 100644
--- a/src/player_face.h
+++ b/src/player_face.h
@@ -1,9 +1,9 @@
/* $Id$ */
-/** @file player_face.h Functionality related to the player's face */
+/** @file company_manager_face.h Functionality related to the company manager's face */
-#ifndef PLAYER_FACE_H
-#define PLAYER_FACE_H
+#ifndef COMPANY_MANAGER_FACE_H
+#define COMPANY_MANAGER_FACE_H
#include "core/random_func.hpp"
#include "core/bitmath_func.hpp"
@@ -21,214 +21,214 @@ enum GenderEthnicity {
};
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity); ///< See GenderRace as a bitset
-/** Bitgroups of the PlayerFace variable */
-enum PlayerFaceVariable {
- PFV_GENDER,
- PFV_ETHNICITY,
- PFV_GEN_ETHN,
- PFV_HAS_MOUSTACHE,
- PFV_HAS_TIE_EARRING,
- PFV_HAS_GLASSES,
- PFV_EYE_COLOUR,
- PFV_CHEEKS,
- PFV_CHIN,
- PFV_EYEBROWS,
- PFV_MOUSTACHE,
- PFV_LIPS,
- PFV_NOSE,
- PFV_HAIR,
- PFV_JACKET,
- PFV_COLLAR,
- PFV_TIE_EARRING,
- PFV_GLASSES,
- PFV_END
+/** Bitgroups of the CompanyManagerFace variable */
+enum CompanyManagerFaceVariable {
+ CMFV_GENDER,
+ CMFV_ETHNICITY,
+ CMFV_GEN_ETHN,
+ CMFV_HAS_MOUSTACHE,
+ CMFV_HAS_TIE_EARRING,
+ CMFV_HAS_GLASSES,
+ CMFV_EYE_COLOUR,
+ CMFV_CHEEKS,
+ CMFV_CHIN,
+ CMFV_EYEBROWS,
+ CMFV_MOUSTACHE,
+ CMFV_LIPS,
+ CMFV_NOSE,
+ CMFV_HAIR,
+ CMFV_JACKET,
+ CMFV_COLLAR,
+ CMFV_TIE_EARRING,
+ CMFV_GLASSES,
+ CMFV_END
};
-DECLARE_POSTFIX_INCREMENT(PlayerFaceVariable);
+DECLARE_POSTFIX_INCREMENT(CompanyManagerFaceVariable);
-/** Information about the valid values of PlayerFace bitgroups as well as the sprites to draw */
-struct PlayerFaceBitsInfo {
- byte offset; ///< Offset in bits into the PlayerFace
- byte length; ///< Number of bits used in the PlayerFace
+/** Information about the valid values of CompanyManagerFace bitgroups as well as the sprites to draw */
+struct CompanyManagerFaceBitsInfo {
+ byte offset; ///< Offset in bits into the CompanyManagerFace
+ byte length; ///< Number of bits used in the CompanyManagerFace
byte valid_values[GE_END]; ///< The number of valid values per gender/ethnicity
SpriteID first_sprite[GE_END]; ///< The first sprite per gender/ethnicity
};
-/** Lookup table for indices into the PlayerFace, valid ranges and sprites */
-static const PlayerFaceBitsInfo _pf_info[] = {
+/** Lookup table for indices into the CompanyManagerFace, valid ranges and sprites */
+static const CompanyManagerFaceBitsInfo _cmf_info[] = {
/* Index off len WM WF BM BF WM WF BM BF */
- /* PFV_GENDER */ { 0, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< 0 = male, 1 = female
- /* PFV_ETHNICITY */ { 1, 2, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< 0 = (Western-)Caucasian, 1 = African(-American)/Black
- /* PFV_GEN_ETHN */ { 0, 3, { 4, 4, 4, 4 }, { 0, 0, 0, 0 } }, ///< Shortcut to get/set gender _and_ ethnicity
- /* PFV_HAS_MOUSTACHE */ { 3, 1, { 2, 0, 2, 0 }, { 0, 0, 0, 0 } }, ///< Females do not have a moustache
- /* PFV_HAS_TIE_EARRING */ { 3, 1, { 0, 2, 0, 2 }, { 0, 0, 0, 0 } }, ///< Draw the earring for females or not. For males the tie is always drawn.
- /* PFV_HAS_GLASSES */ { 4, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< Whether to draw glasses or not
- /* PFV_EYE_COLOUR */ { 5, 2, { 3, 3, 1, 1 }, { 0, 0, 0, 0 } }, ///< Palette modification
- /* PFV_CHEEKS */ { 0, 0, { 1, 1, 1, 1 }, { 0x325, 0x326, 0x390, 0x3B0 } }, ///< Cheeks are only indexed by their gender/ethnicity
- /* PFV_CHIN */ { 7, 2, { 4, 1, 2, 2 }, { 0x327, 0x327, 0x391, 0x3B1 } },
- /* PFV_EYEBROWS */ { 9, 4, { 12, 16, 11, 16 }, { 0x32B, 0x337, 0x39A, 0x3B8 } },
- /* PFV_MOUSTACHE */ { 13, 2, { 3, 0, 3, 0 }, { 0x367, 0, 0x397, 0 } }, ///< Depends on PFV_HAS_MOUSTACHE
- /* PFV_LIPS */ { 13, 4, { 12, 10, 9, 9 }, { 0x35B, 0x351, 0x3A5, 0x3C8 } }, ///< Depends on !PFV_HAS_MOUSTACHE
- /* PFV_NOSE */ { 17, 3, { 8, 4, 4, 5 }, { 0x349, 0x34C, 0x393, 0x3B3 } }, ///< Depends on !PFV_HAS_MOUSTACHE
- /* PFV_HAIR */ { 20, 4, { 9, 5, 5, 4 }, { 0x382, 0x38B, 0x3D4, 0x3D9 } },
- /* PFV_JACKET */ { 24, 2, { 3, 3, 3, 3 }, { 0x36B, 0x378, 0x36B, 0x378 } },
- /* PFV_COLLAR */ { 26, 2, { 4, 4, 4, 4 }, { 0x36E, 0x37B, 0x36E, 0x37B } },
- /* PFV_TIE_EARRING */ { 28, 3, { 6, 3, 6, 3 }, { 0x372, 0x37F, 0x372, 0x3D1 } }, ///< Depends on PFV_HAS_TIE_EARRING
- /* PFV_GLASSES */ { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } } ///< Depends on PFV_HAS_GLASSES
+ /* CMFV_GENDER */ { 0, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< 0 = male, 1 = female
+ /* CMFV_ETHNICITY */ { 1, 2, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< 0 = (Western-)Caucasian, 1 = African(-American)/Black
+ /* CMFV_GEN_ETHN */ { 0, 3, { 4, 4, 4, 4 }, { 0, 0, 0, 0 } }, ///< Shortcut to get/set gender _and_ ethnicity
+ /* CMFV_HAS_MOUSTACHE */ { 3, 1, { 2, 0, 2, 0 }, { 0, 0, 0, 0 } }, ///< Females do not have a moustache
+ /* CMFV_HAS_TIE_EARRING */ { 3, 1, { 0, 2, 0, 2 }, { 0, 0, 0, 0 } }, ///< Draw the earring for females or not. For males the tie is always drawn.
+ /* CMFV_HAS_GLASSES */ { 4, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< Whether to draw glasses or not
+ /* CMFV_EYE_COLOUR */ { 5, 2, { 3, 3, 1, 1 }, { 0, 0, 0, 0 } }, ///< Palette modification
+ /* CMFV_CHEEKS */ { 0, 0, { 1, 1, 1, 1 }, { 0x325, 0x326, 0x390, 0x3B0 } }, ///< Cheeks are only indexed by their gender/ethnicity
+ /* CMFV_CHIN */ { 7, 2, { 4, 1, 2, 2 }, { 0x327, 0x327, 0x391, 0x3B1 } },
+ /* CMFV_EYEBROWS */ { 9, 4, { 12, 16, 11, 16 }, { 0x32B, 0x337, 0x39A, 0x3B8 } },
+ /* CMFV_MOUSTACHE */ { 13, 2, { 3, 0, 3, 0 }, { 0x367, 0, 0x397, 0 } }, ///< Depends on CMFV_HAS_MOUSTACHE
+ /* CMFV_LIPS */ { 13, 4, { 12, 10, 9, 9 }, { 0x35B, 0x351, 0x3A5, 0x3C8 } }, ///< Depends on !CMFV_HAS_MOUSTACHE
+ /* CMFV_NOSE */ { 17, 3, { 8, 4, 4, 5 }, { 0x349, 0x34C, 0x393, 0x3B3 } }, ///< Depends on !CMFV_HAS_MOUSTACHE
+ /* CMFV_HAIR */ { 20, 4, { 9, 5, 5, 4 }, { 0x382, 0x38B, 0x3D4, 0x3D9 } },
+ /* CMFV_JACKET */ { 24, 2, { 3, 3, 3, 3 }, { 0x36B, 0x378, 0x36B, 0x378 } },
+ /* CMFV_COLLAR */ { 26, 2, { 4, 4, 4, 4 }, { 0x36E, 0x37B, 0x36E, 0x37B } },
+ /* CMFV_TIE_EARRING */ { 28, 3, { 6, 3, 6, 3 }, { 0x372, 0x37F, 0x372, 0x3D1 } }, ///< Depends on CMFV_HAS_TIE_EARRING
+ /* CMFV_GLASSES */ { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } } ///< Depends on CMFV_HAS_GLASSES
};
-assert_compile(lengthof(_pf_info) == PFV_END);
+assert_compile(lengthof(_cmf_info) == CMFV_END);
/**
- * Gets the player's face bits for the given player face variable
- * @param pf the face to extract the bits from
- * @param pfv the face variable to get the data of
- * @param ge the gender and ethnicity of the face
- * @pre _pf_info[pfv].valid_values[ge] != 0
+ * Gets the company manager's face bits for the given company manager's face variable
+ * @param cmf the face to extract the bits from
+ * @param cmfv the face variable to get the data of
+ * @param ge the gender and ethnicity of the face
+ * @pre _cmf_info[cmfv].valid_values[ge] != 0
* @return the requested bits
*/
-static inline uint GetPlayerFaceBits(PlayerFace pf, PlayerFaceVariable pfv, GenderEthnicity ge)
+static inline uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
{
- assert(_pf_info[pfv].valid_values[ge] != 0);
+ assert(_cmf_info[cmfv].valid_values[ge] != 0);
- return GB(pf, _pf_info[pfv].offset, _pf_info[pfv].length);
+ return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length);
}
/**
- * Sets the player's face bits for the given player face variable
- * @param pf the face to write the bits to
- * @param pfv the face variable to write the data of
- * @param ge the gender and ethnicity of the face
- * @param val the new value
- * @pre val < _pf_info[pfv].valid_values[ge]
+ * Sets the company manager's face bits for the given company manager's face variable
+ * @param cmf the face to write the bits to
+ * @param cmfv the face variable to write the data of
+ * @param ge the gender and ethnicity of the face
+ * @param val the new value
+ * @pre val < _cmf_info[cmfv].valid_values[ge]
*/
-static inline void SetPlayerFaceBits(PlayerFace &pf, PlayerFaceVariable pfv, GenderEthnicity ge, uint val)
+static inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
{
- assert(val < _pf_info[pfv].valid_values[ge]);
+ assert(val < _cmf_info[cmfv].valid_values[ge]);
- SB(pf, _pf_info[pfv].offset, _pf_info[pfv].length, val);
+ SB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length, val);
}
/**
- * Increase/Decrease the player face variable by the given amount.
+ * Increase/Decrease the company manager's face variable by the given amount.
* If the new value greater than the max value for this variable it will be set to 0.
* Or is it negativ (< 0) it will be set to max value.
*
- * @param pf the player face to write the bits to
- * @param pfv the player face variable to write the data of
- * @param ge the gender and ethnicity of the player face
+ * @param cmf the company manager face to write the bits to
+ * @param cmfv the company manager face variable to write the data of
+ * @param ge the gender and ethnicity of the company manager's face
* @param amount the amount which change the value
*
- * @pre 0 <= val < _pf_info[pfv].valid_values[ge]
+ * @pre 0 <= val < _cmf_info[cmfv].valid_values[ge]
*/
-static inline void IncreasePlayerFaceBits(PlayerFace &pf, PlayerFaceVariable pfv, GenderEthnicity ge, int8 amount)
+static inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount)
{
- int8 val = GetPlayerFaceBits(pf, pfv, ge) + amount; // the new value for the pfv
+ int8 val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv
/* scales the new value to the correct scope */
- if (val >= _pf_info[pfv].valid_values[ge]) {
+ if (val >= _cmf_info[cmfv].valid_values[ge]) {
val = 0;
} else if (val < 0) {
- val = _pf_info[pfv].valid_values[ge] - 1;
+ val = _cmf_info[cmfv].valid_values[ge] - 1;
}
- SetPlayerFaceBits(pf, pfv, ge, val); // save the new value
+ SetCompanyManagerFaceBits(cmf, cmfv, ge, val); // save the new value
}
/**
- * Checks whether the player bits have a valid range
- * @param pf the face to extract the bits from
- * @param pfv the face variable to get the data of
- * @param ge the gender and ethnicity of the face
+ * Checks whether the company manager's face bits have a valid range
+ * @param cmf the face to extract the bits from
+ * @param cmfv the face variable to get the data of
+ * @param ge the gender and ethnicity of the face
* @return true if and only if the bits are valid
*/
-static inline bool ArePlayerFaceBitsValid(PlayerFace pf, PlayerFaceVariable pfv, GenderEthnicity ge)
+static inline bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
{
- return GB(pf, _pf_info[pfv].offset, _pf_info[pfv].length) < _pf_info[pfv].valid_values[ge];
+ return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length) < _cmf_info[cmfv].valid_values[ge];
}
/**
- * Scales a player face bits variable to the correct scope
- * @param pfv the face variable to write the data of
+ * Scales a company manager's face bits variable to the correct scope
+ * @param cmfv the face variable to write the data of
* @param ge the gender and ethnicity of the face
* @param val the to value to scale
- * @pre val < (1U << _pf_info[pfv].length), i.e. val has a value of 0..2^(bits used for this variable)-1
+ * @pre val < (1U << _cmf_info[cmfv].length), i.e. val has a value of 0..2^(bits used for this variable)-1
* @return the scaled value
*/
-static inline uint ScalePlayerFaceValue(PlayerFaceVariable pfv, GenderEthnicity ge, uint val)
+static inline uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
{
- assert(val < (1U << _pf_info[pfv].length));
+ assert(val < (1U << _cmf_info[cmfv].length));
- return (val * _pf_info[pfv].valid_values[ge]) >> _pf_info[pfv].length;
+ return (val * _cmf_info[cmfv].valid_values[ge]) >> _cmf_info[cmfv].length;
}
/**
- * Scales all player face bits to the correct scope
+ * Scales all company manager's face bits to the correct scope
*
- * @param pf the player face to write the bits to
+ * @param cmf the company manager's face to write the bits to
*/
-static inline void ScaleAllPlayerFaceBits(PlayerFace &pf)
+static inline void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf)
{
- IncreasePlayerFaceBits(pf, PFV_ETHNICITY, GE_WM, 0); // scales the ethnicity
+ IncreaseCompanyManagerFaceBits(cmf, CMFV_ETHNICITY, GE_WM, 0); // scales the ethnicity
- GenderEthnicity ge = (GenderEthnicity)GB(pf, _pf_info[PFV_GEN_ETHN].offset, _pf_info[PFV_GEN_ETHN].length); // gender & ethnicity of the face
+ GenderEthnicity ge = (GenderEthnicity)GB(cmf, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // gender & ethnicity of the face
/* Is a male face with moustache. Need to reduce CPU load in the loop. */
- bool is_moust_male = !HasBit(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE, ge) != 0;
+ bool is_moust_male = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0;
- for (PlayerFaceVariable pfv = PFV_EYE_COLOUR; pfv < PFV_END; pfv++) { // scales all other variables
+ for (CompanyManagerFaceVariable cmfv = CMFV_EYE_COLOUR; cmfv < CMFV_END; cmfv++) { // scales all other variables
/* The moustache variable will be scaled only if it is a male face with has a moustache */
- if (pfv != PFV_MOUSTACHE || is_moust_male) {
- IncreasePlayerFaceBits(pf, pfv, ge, 0);
+ if (cmfv != CMFV_MOUSTACHE || is_moust_male) {
+ IncreaseCompanyManagerFaceBits(cmf, cmfv, ge, 0);
}
}
}
/**
* Make a random new face.
- * If it is for the advanced player face window then the new face have the same gender
+ * If it is for the advanced company manager's face window then the new face have the same gender
* and ethnicity as the old one, else the gender is equal and the ethnicity is random.
*
- * @param pf the player face to write the bits to
- * @param ge the gender and ethnicity of the old player face
- * @param adv if it for the advanced player face window
+ * @param cmf the company manager's face to write the bits to
+ * @param ge the gender and ethnicity of the old company manager's face
+ * @param adv if it for the advanced company manager's face window
*
* @pre scale 'ge' to a valid gender/ethnicity combination
*/
-static inline void RandomPlayerFaceBits(PlayerFace &pf, GenderEthnicity ge, bool adv)
+static inline void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv)
{
- pf = InteractiveRandom(); // random all player face bits
+ cmf = InteractiveRandom(); // random all company manager's face bits
/* scale ge: 0 == GE_WM, 1 == GE_WF, 2 == GE_BM, 3 == GE_BF (and maybe in future: ...) */
ge = (GenderEthnicity)((uint)ge % GE_END);
- /* set the gender (and ethnicity) for the new player face */
+ /* set the gender (and ethnicity) for the new company manager's face */
if (adv) {
- SetPlayerFaceBits(pf, PFV_GEN_ETHN, ge, ge);
+ SetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, ge, ge);
} else {
- SetPlayerFaceBits(pf, PFV_GENDER, ge, HasBit(ge, GENDER_FEMALE));
+ SetCompanyManagerFaceBits(cmf, CMFV_GENDER, ge, HasBit(ge, GENDER_FEMALE));
}
- /* scales all player face bits to the correct scope */
- ScaleAllPlayerFaceBits(pf);
+ /* scales all company manager's face bits to the correct scope */
+ ScaleAllCompanyManagerFaceBits(cmf);
}
/**
- * Gets the sprite to draw for the given player face variable
- * @param pf the face to extract the data from
- * @param pfv the face variable to get the sprite of
- * @param ge the gender and ethnicity of the face
- * @pre _pf_info[pfv].valid_values[ge] != 0
+ * Gets the sprite to draw for the given company manager's face variable
+ * @param cmf the face to extract the data from
+ * @param cmfv the face variable to get the sprite of
+ * @param ge the gender and ethnicity of the face
+ * @pre _cmf_info[cmfv].valid_values[ge] != 0
* @return sprite to draw
*/
-static inline SpriteID GetPlayerFaceSprite(PlayerFace pf, PlayerFaceVariable pfv, GenderEthnicity ge)
+static inline SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
{
- assert(_pf_info[pfv].valid_values[ge] != 0);
+ assert(_cmf_info[cmfv].valid_values[ge] != 0);
- return _pf_info[pfv].first_sprite[ge] + GB(pf, _pf_info[pfv].offset, _pf_info[pfv].length);
+ return _cmf_info[cmfv].first_sprite[ge] + GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length);
}
-void DrawPlayerFace(PlayerFace face, int color, int x, int y);
-PlayerFace ConvertFromOldPlayerFace(uint32 face);
-bool IsValidPlayerIDFace(PlayerFace pf);
+void DrawCompanyManagerFace(CompanyManagerFace face, int color, int x, int y);
+CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face);
+bool IsValidCompanyManagerFace(CompanyManagerFace cmf);
-#endif /* PLAYER_FACE_H */
+#endif /* COMPANY_MANAGER_FACE_H */
diff --git a/src/player_func.h b/src/player_func.h
index cc55f4661..66f5161a9 100644
--- a/src/player_func.h
+++ b/src/player_func.h
@@ -1,49 +1,49 @@
/* $Id$ */
-/** @file player_func.h Functions related to players. */
+/** @file company_func.h Functions related to companies. */
-#ifndef PLAYER_FUNC_H
-#define PLAYER_FUNC_H
+#ifndef COMPANY_FUNC_H
+#define COMPANY_FUNC_H
#include "core/math_func.hpp"
#include "player_type.h"
#include "tile_type.h"
#include "strings_type.h"
-void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player);
+void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
void GetNameOfOwner(Owner owner, TileIndex tile);
-void SetLocalPlayer(PlayerID new_player);
+void SetLocalCompany(CompanyID new_company);
-extern PlayerByte _local_player;
-extern PlayerByte _current_player;
-/* NOSAVE: can be determined from player structs */
-extern byte _player_colors[MAX_PLAYERS];
-extern PlayerFace _player_face; ///< for player face storage in openttd.cfg
+extern CompanyByte _local_company;
+extern CompanyByte _current_company;
-bool IsHumanPlayer(PlayerID pi);
+extern byte _company_colours[MAX_COMPANIES]; ///< NOSAVE: can be determined from company structs
+extern CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
-static inline bool IsLocalPlayer()
+bool IsHumanCompany(CompanyID company);
+
+static inline bool IsLocalCompany()
{
- return _local_player == _current_player;
+ return _local_company == _current_company;
}
-static inline bool IsInteractivePlayer(PlayerID pi)
+static inline bool IsInteractiveCompany(CompanyID company)
{
- return pi == _local_player;
+ return company == _local_company;
}
struct HighScore {
char company[100];
- StringID title; ///< NO_SAVE, has troubles with changing string-numbers.
+ StringID title; ///< NOSAVE, has troubles with changing string-numbers.
uint16 score; ///< do NOT change type, will break hs.dat
};
extern HighScore _highscore_table[5][5]; // 4 difficulty-settings (+ network); top 5
void SaveToHighScore();
void LoadFromHighScore();
-int8 SaveHighScoreValue(const Player *p);
+int8 SaveHighScoreValue(const Company *p);
int8 SaveHighScoreValueNetwork();
-#endif /* PLAYER_FUNC_H */
+#endif /* COMPANY_FUNC_H */
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index 77a850ead..cd057a681 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -1,6 +1,6 @@
/* $Id$ */
-/** @file player_gui.cpp Player related GUIs. */
+/** @file company_gui.cpp Company related GUIs. */
#include "stdafx.h"
#include "openttd.h"
@@ -37,10 +37,10 @@ enum {
FIRST_GUI_CALL = INT_MAX, ///< default value to specify thuis is the first call of the resizable gui
};
-static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
-static void DoSelectPlayerFace(Window *parent, bool show_big, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
+static void DoShowCompanyFinances(CompanyID company, bool show_small, bool show_stickied, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
+static void DoSelectCompanyManagerFace(Window *parent, bool show_big, int top = FIRST_GUI_CALL, int left = FIRST_GUI_CALL);
-static void DrawPlayerEconomyStats(const Player *p, bool small)
+static void DrawCompanyEconomyStats(const Company *c, bool small)
{
int x, y, i, j, year;
const Money (*tbl)[EXPENSES_END];
@@ -58,9 +58,9 @@ static void DrawPlayerEconomyStats(const Player *p, bool small)
year = _cur_year - 2;
j = 3;
x = 215;
- tbl = p->yearly_expenses + 2;
+ tbl = c->yearly_expenses + 2;
do {
- if (year >= p->inaugurated_year) {
+ if (year >= c->inaugurated_year) {
SetDParam(0, year);
DrawStringRightAlignedUnderline(x, 15, STR_7010, TC_FROMSTRING);
sum = 0;
@@ -99,30 +99,30 @@ static void DrawPlayerEconomyStats(const Player *p, bool small)
}
DrawString(2, y, STR_7026_BANK_BALANCE, TC_FROMSTRING);
- SetDParam(0, p->player_money);
+ SetDParam(0, c->money);
DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
y += 10;
DrawString(2, y, STR_7027_LOAN, TC_FROMSTRING);
- SetDParam(0, p->current_loan);
+ SetDParam(0, c->current_loan);
DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
y += 12;
GfxFillRect(182 - 75, y - 2, 182, y - 2, 215);
- SetDParam(0, p->player_money - p->current_loan);
+ SetDParam(0, c->money - c->current_loan);
DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING);
}
-enum PlayerFinancesWindowWidgets {
- PFW_WIDGET_TOGGLE_SIZE = 2,
- PFW_WIDGET_INCREASE_LOAN = 6,
- PFW_WIDGET_REPAY_LOAN = 7,
+enum CompanyFinancesWindowWidgets {
+ CFW_WIDGET_TOGGLE_SIZE = 2,
+ CFW_WIDGET_INCREASE_LOAN = 6,
+ CFW_WIDGET_REPAY_LOAN = 7,
};
-static const Widget _player_finances_widgets[] = {
+static const Widget _company_finances_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
@@ -134,7 +134,7 @@ static const Widget _player_finances_widgets[] = {
{ WIDGETS_END},
};
-static const Widget _player_finances_small_widgets[] = {
+static const Widget _company_finances_small_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 253, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 254, 267, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
@@ -146,12 +146,12 @@ static const Widget _player_finances_small_widgets[] = {
{ WIDGETS_END},
};
-struct PlayerFinancesWindow : Window {
+struct CompanyFinancesWindow : Window {
bool small;
- PlayerFinancesWindow(const WindowDesc *desc, PlayerID player, bool show_small,
+ CompanyFinancesWindow(const WindowDesc *desc, CompanyID company, bool show_small,
bool show_stickied, int top, int left) :
- Window(desc, player),
+ Window(desc, company),
small(show_small)
{
this->caption_color = this->window_number;
@@ -169,98 +169,98 @@ struct PlayerFinancesWindow : Window {
virtual void OnPaint()
{
- PlayerID player = (PlayerID)this->window_number;
- const Player *p = GetPlayer(player);
+ CompanyID company = (CompanyID)this->window_number;
+ const Company *c = GetCompany(company);
- /* Recheck the size of the window as it might need to be resized due to the local player changing */
- int new_height = ((player != _local_player) ? 0 : 12) + ((this->small != 0) ? 48 : 74 + 10 * EXPENSES_END);
+ /* Recheck the size of the window as it might need to be resized due to the local company changing */
+ int new_height = ((company != _local_company) ? 0 : 12) + ((this->small != 0) ? 48 : 74 + 10 * EXPENSES_END);
if (this->height != new_height) {
/* Make window dirty before and after resizing */
this->SetDirty();
this->height = new_height;
this->SetDirty();
- this->SetWidgetHiddenState(PFW_WIDGET_INCREASE_LOAN, player != _local_player);
- this->SetWidgetHiddenState(PFW_WIDGET_REPAY_LOAN, player != _local_player);
+ this->SetWidgetHiddenState(CFW_WIDGET_INCREASE_LOAN, company != _local_company);
+ this->SetWidgetHiddenState(CFW_WIDGET_REPAY_LOAN, company != _local_company);
}
/* Borrow button only shows when there is any more money to loan */
- this->SetWidgetDisabledState(PFW_WIDGET_INCREASE_LOAN, p->current_loan == _economy.max_loan);
+ this->SetWidgetDisabledState(CFW_WIDGET_INCREASE_LOAN, c->current_loan == _economy.max_loan);
/* Repay button only shows when there is any more money to repay */
- this->SetWidgetDisabledState(PFW_WIDGET_REPAY_LOAN, player != _local_player || p->current_loan == 0);
+ this->SetWidgetDisabledState(CFW_WIDGET_REPAY_LOAN, company != _local_company || c->current_loan == 0);
- SetDParam(0, p->index);
- SetDParam(1, p->index);
+ SetDParam(0, c->index);
+ SetDParam(1, c->index);
SetDParam(2, LOAN_INTERVAL);
this->DrawWidgets();
- DrawPlayerEconomyStats(p, this->small);
+ DrawCompanyEconomyStats(c, this->small);
}
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
- case PFW_WIDGET_TOGGLE_SIZE: {/* toggle size */
+ case CFW_WIDGET_TOGGLE_SIZE: {/* toggle size */
bool new_mode = !this->small;
bool stickied = !!(this->flags4 & WF_STICKY);
int oldtop = this->top; ///< current top position of the window before closing it
int oldleft = this->left; ///< current left position of the window before closing it
- PlayerID player = (PlayerID)this->window_number;
+ CompanyID company = (CompanyID)this->window_number;
delete this;
/* Open up the (toggled size) Finance window at the same position as the previous */
- DoShowPlayerFinances(player, new_mode, stickied, oldtop, oldleft);
+ DoShowCompanyFinances(company, new_mode, stickied, oldtop, oldleft);
}
break;
- case PFW_WIDGET_INCREASE_LOAN: /* increase loan */
+ case CFW_WIDGET_INCREASE_LOAN: /* increase loan */
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
break;
- case PFW_WIDGET_REPAY_LOAN: /* repay loan */
+ case CFW_WIDGET_REPAY_LOAN: /* repay loan */
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
break;
}
}
};
-static const WindowDesc _player_finances_desc = {
+static const WindowDesc _company_finances_desc = {
WDP_AUTO, WDP_AUTO, 407, 86 + 10 * EXPENSES_END, 407, 86 + 10 * EXPENSES_END,
WC_FINANCES, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
- _player_finances_widgets,
+ _company_finances_widgets,
};
-static const WindowDesc _player_finances_small_desc = {
+static const WindowDesc _company_finances_small_desc = {
WDP_AUTO, WDP_AUTO, 280, 60, 280, 60,
WC_FINANCES, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
- _player_finances_small_widgets,
+ _company_finances_small_widgets,
};
/**
- * Open the small/large finance window of the player
+ * Open the small/large finance window of the company
*
- * @param player the player who's finances are requested to be seen
+ * @param company the company who's finances are requested to be seen
* @param show_small show large or small version opf the window
* @param show_stickied previous "stickyness" of the window
* @param top previous top position of the window
* @param left previous left position of the window
*
- * @pre is player a valid player
+ * @pre is company a valid company
*/
-static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top, int left)
+static void DoShowCompanyFinances(CompanyID company, bool show_small, bool show_stickied, int top, int left)
{
- if (!IsValidPlayerID(player)) return;
+ if (!IsValidCompanyID(company)) return;
- if (BringWindowToFrontById(WC_FINANCES, player)) return;
- new PlayerFinancesWindow(show_small ? &_player_finances_small_desc : &_player_finances_desc, player, show_small, show_stickied, top, left);
+ if (BringWindowToFrontById(WC_FINANCES, company)) return;
+ new CompanyFinancesWindow(show_small ? &_company_finances_small_desc : &_company_finances_desc, company, show_small, show_stickied, top, left);
}
-void ShowPlayerFinances(PlayerID player)
+void ShowCompanyFinances(CompanyID company)
{
- DoShowPlayerFinances(player, false, false);
+ DoShowCompanyFinances(company, false, false);
}
/* List of colours for the livery window */
@@ -321,24 +321,24 @@ public:
}
};
-struct SelectPlayerLiveryWindow : public Window {
+struct SelectCompanyLiveryWindow : public Window {
private:
uint32 sel;
LiveryClass livery_class;
- enum PlayerLiveryWindowWidgets {
- PLW_WIDGET_CLOSE,
- PLW_WIDGET_CAPTION,
- PLW_WIDGET_CLASS_GENERAL,
- PLW_WIDGET_CLASS_RAIL,
- PLW_WIDGET_CLASS_ROAD,
- PLW_WIDGET_CLASS_SHIP,
- PLW_WIDGET_CLASS_AIRCRAFT,
- PLW_WIDGET_SPACER_CLASS,
- PLW_WIDGET_SPACER_DROPDOWN,
- PLW_WIDGET_PRI_COL_DROPDOWN,
- PLW_WIDGET_SEC_COL_DROPDOWN,
- PLW_WIDGET_MATRIX,
+ enum SelectCompanyLiveryWindowWidgets {
+ SCLW_WIDGET_CLOSE,
+ SCLW_WIDGET_CAPTION,
+ SCLW_WIDGET_CLASS_GENERAL,
+ SCLW_WIDGET_CLASS_RAIL,
+ SCLW_WIDGET_CLASS_ROAD,
+ SCLW_WIDGET_CLASS_SHIP,
+ SCLW_WIDGET_CLASS_AIRCRAFT,
+ SCLW_WIDGET_SPACER_CLASS,
+ SCLW_WIDGET_SPACER_DROPDOWN,
+ SCLW_WIDGET_PRI_COL_DROPDOWN,
+ SCLW_WIDGET_SEC_COL_DROPDOWN,
+ SCLW_WIDGET_MATRIX,
};
void ShowColourDropDownMenu(uint32 widget)
@@ -347,11 +347,11 @@ private:
const Livery *livery;
LiveryScheme scheme;
- /* Disallow other player colours for the primary colour */
- if (HasBit(this->sel, LS_DEFAULT) && widget == PLW_WIDGET_PRI_COL_DROPDOWN) {
- const Player *p;
- FOR_ALL_PLAYERS(p) {
- if (p->index != _local_player) SetBit(used_colours, p->player_color);
+ /* Disallow other company colours for the primary colour */
+ if (HasBit(this->sel, LS_DEFAULT) && widget == SCLW_WIDGET_PRI_COL_DROPDOWN) {
+ const Company *c;
+ FOR_ALL_COMPANIES(c) {
+ if (c->index != _local_company) SetBit(used_colours, c->colour);
}
}
@@ -360,36 +360,36 @@ private:
if (HasBit(this->sel, scheme)) break;
}
if (scheme == LS_END) scheme = LS_DEFAULT;
- livery = &GetPlayer((PlayerID)this->window_number)->livery[scheme];
+ livery = &GetCompany((CompanyID)this->window_number)->livery[scheme];
DropDownList *list = new DropDownList();
for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
}
- ShowDropDownList(this, list, widget == PLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget);
+ ShowDropDownList(this, list, widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget);
}
public:
- SelectPlayerLiveryWindow(const WindowDesc *desc, PlayerID player) : Window(desc, player)
+ SelectCompanyLiveryWindow(const WindowDesc *desc, CompanyID company) : Window(desc, company)
{
- this->caption_color = player;
+ this->caption_color = company;
this->livery_class = LC_OTHER;
this->sel = 1;
- this->LowerWidget(PLW_WIDGET_CLASS_GENERAL);
+ this->LowerWidget(SCLW_WIDGET_CLASS_GENERAL);
this->OnInvalidateData(_loaded_newgrf_features.has_2CC);
this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
{
- const Player *p = GetPlayer((PlayerID)this->window_number);
+ const Company *c = GetCompany((CompanyID)this->window_number);
LiveryScheme scheme = LS_DEFAULT;
int y = 51;
/* Disable dropdown controls if no scheme is selected */
- this->SetWidgetDisabledState(PLW_WIDGET_PRI_COL_DROPDOWN, this->sel == 0);
- this->SetWidgetDisabledState(PLW_WIDGET_SEC_COL_DROPDOWN, this->sel == 0);
+ this->SetWidgetDisabledState(SCLW_WIDGET_PRI_COL_DROPDOWN, this->sel == 0);
+ this->SetWidgetDisabledState(SCLW_WIDGET_SEC_COL_DROPDOWN, this->sel == 0);
if (this->sel != 0) {
for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
@@ -398,8 +398,8 @@ public:
if (scheme == LS_END) scheme = LS_DEFAULT;
}
- SetDParam(0, STR_00D1_DARK_BLUE + p->livery[scheme].colour1);
- SetDParam(1, STR_00D1_DARK_BLUE + p->livery[scheme].colour2);
+ SetDParam(0, STR_00D1_DARK_BLUE + c->livery[scheme].colour1);
+ SetDParam(1, STR_00D1_DARK_BLUE + c->livery[scheme].colour2);
this->DrawWidgets();
@@ -408,17 +408,17 @@ public:
bool sel = HasBit(this->sel, scheme) != 0;
if (scheme != LS_DEFAULT) {
- DrawSprite(p->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
+ DrawSprite(c->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
}
DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
- DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour1), 152, y);
- DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
+ DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(c->livery[scheme].colour1), 152, y);
+ DrawString(165, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
- if (!this->IsWidgetHidden(PLW_WIDGET_SEC_COL_DROPDOWN)) {
- DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour2), 277, y);
- DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
+ if (!this->IsWidgetHidden(SCLW_WIDGET_SEC_COL_DROPDOWN)) {
+ DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(c->livery[scheme].colour2), 277, y);
+ DrawString(290, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
}
y += 14;
@@ -439,17 +439,17 @@ public:
switch (widget) {
/* Livery Class buttons */
- case PLW_WIDGET_CLASS_GENERAL:
- case PLW_WIDGET_CLASS_RAIL:
- case PLW_WIDGET_CLASS_ROAD:
- case PLW_WIDGET_CLASS_SHIP:
- case PLW_WIDGET_CLASS_AIRCRAFT: {
+ case SCLW_WIDGET_CLASS_GENERAL:
+ case SCLW_WIDGET_CLASS_RAIL:
+ case SCLW_WIDGET_CLASS_ROAD:
+ case SCLW_WIDGET_CLASS_SHIP:
+ case SCLW_WIDGET_CLASS_AIRCRAFT: {
LiveryScheme scheme;
- this->RaiseWidget(this->livery_class + PLW_WIDGET_CLASS_GENERAL);
- this->livery_class = (LiveryClass)(widget - PLW_WIDGET_CLASS_GENERAL);
+ this->RaiseWidget(this->livery_class + SCLW_WIDGET_CLASS_GENERAL);
+ this->livery_class = (LiveryClass)(widget - SCLW_WIDGET_CLASS_GENERAL);
this->sel = 0;
- this->LowerWidget(this->livery_class + PLW_WIDGET_CLASS_GENERAL);
+ this->LowerWidget(this->livery_class + SCLW_WIDGET_CLASS_GENERAL);
/* Select the first item in the list */
for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
@@ -459,21 +459,21 @@ public:
}
}
this->height = 49 + livery_height[this->livery_class] * 14;
- this->widget[PLW_WIDGET_MATRIX].bottom = this->height - 1;
- this->widget[PLW_WIDGET_MATRIX].data = livery_height[this->livery_class] << 8 | 1;
+ this->widget[SCLW_WIDGET_MATRIX].bottom = this->height - 1;
+ this->widget[SCLW_WIDGET_MATRIX].data = livery_height[this->livery_class] << 8 | 1;
MarkWholeScreenDirty();
break;
}
- case PLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */
- ShowColourDropDownMenu(PLW_WIDGET_PRI_COL_DROPDOWN);
+ case SCLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */
+ ShowColourDropDownMenu(SCLW_WIDGET_PRI_COL_DROPDOWN);
break;
- case PLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */
- ShowColourDropDownMenu(PLW_WIDGET_SEC_COL_DROPDOWN);
+ case SCLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */
+ ShowColourDropDownMenu(SCLW_WIDGET_SEC_COL_DROPDOWN);
break;
- case PLW_WIDGET_MATRIX: {
+ case SCLW_WIDGET_MATRIX: {
LiveryScheme scheme;
LiveryScheme j = (LiveryScheme)((pt.y - 48) / 14);
@@ -485,7 +485,7 @@ public:
/* If clicking on the left edge, toggle using the livery */
if (pt.x < 10) {
- DoCommandP(0, j | (2 << 8), !GetPlayer((PlayerID)this->window_number)->livery[j].in_use, NULL, CMD_SET_PLAYER_COLOR);
+ DoCommandP(0, j | (2 << 8), !GetCompany((CompanyID)this->window_number)->livery[j].in_use, NULL, CMD_SET_COMPANY_COLOR);
}
if (_ctrl_pressed) {
@@ -503,7 +503,7 @@ public:
{
for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
if (HasBit(this->sel, scheme)) {
- DoCommandP(0, scheme | (widget == PLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, NULL, CMD_SET_PLAYER_COLOR);
+ DoCommandP(0, scheme | (widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, NULL, CMD_SET_COMPANY_COLOR);
}
}
}
@@ -516,16 +516,16 @@ public:
has2cc = !!data;
- int r = this->widget[has2cc ? PLW_WIDGET_SEC_COL_DROPDOWN : PLW_WIDGET_PRI_COL_DROPDOWN].right;
- this->SetWidgetHiddenState(PLW_WIDGET_SEC_COL_DROPDOWN, !has2cc);
- this->widget[PLW_WIDGET_CAPTION].right = r;
- this->widget[PLW_WIDGET_SPACER_CLASS].right = r;
- this->widget[PLW_WIDGET_MATRIX].right = r;
+ int r = this->widget[has2cc ? SCLW_WIDGET_SEC_COL_DROPDOWN : SCLW_WIDGET_PRI_COL_DROPDOWN].right;
+ this->SetWidgetHiddenState(SCLW_WIDGET_SEC_COL_DROPDOWN, !has2cc);
+ this->widget[SCLW_WIDGET_CAPTION].right = r;
+ this->widget[SCLW_WIDGET_SPACER_CLASS].right = r;
+ this->widget[SCLW_WIDGET_MATRIX].right = r;
this->width = r + 1;
}
};
-static const Widget _select_player_livery_widgets[] = {
+static const Widget _select_company_livery_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 399, 0, 13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 21, 14, 35, SPR_IMG_COMPANY_GENERAL, STR_LIVERY_GENERAL_TIP },
@@ -541,34 +541,34 @@ static const Widget _select_player_livery_widgets[] = {
{ WIDGETS_END },
};
-static const WindowDesc _select_player_livery_desc = {
+static const WindowDesc _select_company_livery_desc = {
WDP_AUTO, WDP_AUTO, 400, 49 + 1 * 14, 400, 49 + 1 * 14,
- WC_PLAYER_COLOR, WC_NONE,
+ WC_COMPANY_COLOR, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
- _select_player_livery_widgets,
+ _select_company_livery_widgets,
};
/**
- * Draws the face of a player.
- * @param pf the player's face
+ * Draws the face of a company manager's face.
+ * @param cmf the company manager's face
* @param color the (background) color of the gradient
* @param x x-position to draw the face
* @param y y-position to draw the face
*/
-void DrawPlayerFace(PlayerFace pf, int color, int x, int y)
+void DrawCompanyManagerFace(CompanyManagerFace cmf, int color, int x, int y)
{
- GenderEthnicity ge = (GenderEthnicity)GetPlayerFaceBits(pf, PFV_GEN_ETHN, GE_WM);
+ GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM);
- bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE, ge) != 0;
- bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetPlayerFaceBits(pf, PFV_HAS_TIE_EARRING, ge) != 0;
- bool has_glasses = GetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge) != 0;
+ bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0;
+ bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
+ bool has_glasses = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
SpriteID pal;
/* Modify eye colour palette only if 2 or more valid values exist */
- if (_pf_info[PFV_EYE_COLOUR].valid_values[ge] < 2) {
+ if (_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
pal = PAL_NONE;
} else {
- switch (GetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge)) {
+ switch (GetCompanyManagerFaceBits(cmf, CMFV_EYE_COLOUR, ge)) {
default: NOT_REACHED();
case 0: pal = PALETTE_TO_BROWN; break;
case 1: pal = PALETTE_TO_BLUE; break;
@@ -579,90 +579,90 @@ void DrawPlayerFace(PlayerFace pf, int color, int x, int y)
/* Draw the gradient (background) */
DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y);
- for (PlayerFaceVariable pfv = PFV_CHEEKS; pfv < PFV_END; pfv++) {
- switch (pfv) {
- case PFV_MOUSTACHE: if (!has_moustache) continue; break;
- case PFV_LIPS: /* FALL THROUGH */
- case PFV_NOSE: if (has_moustache) continue; break;
- case PFV_TIE_EARRING: if (!has_tie_earring) continue; break;
- case PFV_GLASSES: if (!has_glasses) continue; break;
+ for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
+ switch (cmfv) {
+ case CMFV_MOUSTACHE: if (!has_moustache) continue; break;
+ case CMFV_LIPS: /* FALL THROUGH */
+ case CMFV_NOSE: if (has_moustache) continue; break;
+ case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
+ case CMFV_GLASSES: if (!has_glasses) continue; break;
default: break;
}
- DrawSprite(GetPlayerFaceSprite(pf, pfv, ge), (pfv == PFV_EYEBROWS) ? pal : PAL_NONE, x, y);
+ DrawSprite(GetCompanyManagerFaceSprite(cmf, cmfv, ge), (cmfv == CMFV_EYEBROWS) ? pal : PAL_NONE, x, y);
}
}
-/** Widget description for the normal/simple player face selection dialog */
-static const Widget _select_player_face_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // PFW_WIDGET_CLOSEBOX
-{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 174, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // PFW_WIDGET_CAPTION
-{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 189, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_ADVANCED_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 189, 14, 150, 0x0, STR_NULL}, // PFW_WIDGET_SELECT_FACE
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 151, 162, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 189, 151, 162, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT
-{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 75, 86, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // PFW_WIDGET_MALE
-{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 87, 98, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // PFW_WIDGET_FEMALE
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_7046_NEW_FACE, STR_704B_GENERATE_RANDOM_NEW_FACE}, // PFW_WIDGET_RANDOM_NEW_FACE
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 16, 27, STR_FACE_ADVANCED, STR_FACE_ADVANCED_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
+/** Widget description for the normal/simple company manager face selection dialog */
+static const Widget _select_company_manager_face_widgets[] = {
+{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SCMFW_WIDGET_CLOSEBOX
+{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 174, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // SCMFW_WIDGET_CAPTION
+{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 189, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_ADVANCED_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 189, 14, 150, 0x0, STR_NULL}, // SCMFW_WIDGET_SELECT_FACE
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 151, 162, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // SCMFW_WIDGET_CANCEL
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 189, 151, 162, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // SCMFW_WIDGET_ACCEPT
+{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 75, 86, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // SCMFW_WIDGET_MALE
+{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 87, 98, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // SCMFW_WIDGET_FEMALE
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_7046_NEW_FACE, STR_704B_GENERATE_RANDOM_NEW_FACE}, // SCMFW_WIDGET_RANDOM_NEW_FACE
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 187, 16, 27, STR_FACE_ADVANCED, STR_FACE_ADVANCED_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
{ WIDGETS_END},
};
-/** Widget description for the advanced player face selection dialog */
-static const Widget _select_player_face_adv_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // PFW_WIDGET_CLOSEBOX
-{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 204, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // PFW_WIDGET_CAPTION
-{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 205, 219, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_SIMPLE_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 219, 14, 207, 0x0, STR_NULL}, // PFW_WIDGET_SELECT_FACE
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 208, 219, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // PFW_WIDGET_CANCEL
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 219, 208, 219, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // PFW_WIDGET_ACCEPT
-{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 32, 43, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // PFW_WIDGET_MALE
-{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 32, 43, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // PFW_WIDGET_FEMALE
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_RANDOM, STR_704B_GENERATE_RANDOM_NEW_FACE}, // PFW_WIDGET_RANDOM_NEW_FACE
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 217, 16, 27, STR_FACE_SIMPLE, STR_FACE_SIMPLE_TIP}, // PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 158, 169, STR_FACE_LOAD, STR_FACE_LOAD_TIP}, // PFW_WIDGET_LOAD
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 170, 181, STR_FACE_FACECODE, STR_FACE_FACECODE_TIP}, // PFW_WIDGET_FACECODE
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 182, 193, STR_FACE_SAVE, STR_FACE_SAVE_TIP}, // PFW_WIDGET_SAVE
-{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 46, 57, STR_FACE_EUROPEAN, STR_FACE_SELECT_EUROPEAN}, // PFW_WIDGET_ETHNICITY_EUR
-{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 46, 57, STR_FACE_AFRICAN, STR_FACE_SELECT_AFRICAN}, // PFW_WIDGET_ETHNICITY_AFR
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 60, 71, STR_EMPTY, STR_FACE_MOUSTACHE_EARRING_TIP}, // PFW_WIDGET_HAS_MOUSTACHE_EARRING
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 72, 83, STR_EMPTY, STR_FACE_GLASSES_TIP}, // PFW_WIDGET_HAS_GLASSES
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 110, 121, SPR_ARROW_LEFT, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 110, 121, STR_EMPTY, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 110, 121, SPR_ARROW_RIGHT, STR_FACE_EYECOLOUR_TIP}, // PFW_WIDGET_EYECOLOUR_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 158, 169, SPR_ARROW_LEFT, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 158, 169, STR_EMPTY, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 158, 169, SPR_ARROW_RIGHT, STR_FACE_CHIN_TIP}, // PFW_WIDGET_CHIN_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 98, 109, SPR_ARROW_LEFT, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 98, 109, STR_EMPTY, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 98, 109, SPR_ARROW_RIGHT, STR_FACE_EYEBROWS_TIP}, // PFW_WIDGET_EYEBROWS_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 146, 157, SPR_ARROW_LEFT, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 146, 157, STR_EMPTY, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 146, 157, SPR_ARROW_RIGHT, STR_FACE_LIPS_MOUSTACHE_TIP}, // PFW_WIDGET_LIPS_MOUSTACHE_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 134, 145, SPR_ARROW_LEFT, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 134, 145, STR_EMPTY, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 134, 145, SPR_ARROW_RIGHT, STR_FACE_NOSE_TIP}, // PFW_WIDGET_NOSE_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 86, 97, SPR_ARROW_LEFT, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 86, 97, STR_EMPTY, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 86, 97, SPR_ARROW_RIGHT, STR_FACE_HAIR_TIP}, // PFW_WIDGET_HAIR_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 170, 181, SPR_ARROW_LEFT, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 170, 181, STR_EMPTY, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 170, 181, SPR_ARROW_RIGHT, STR_FACE_JACKET_TIP}, // PFW_WIDGET_JACKET_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 182, 193, SPR_ARROW_LEFT, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 182, 193, STR_EMPTY, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 182, 193, SPR_ARROW_RIGHT, STR_FACE_COLLAR_TIP}, // PFW_WIDGET_COLLAR_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 194, 205, SPR_ARROW_LEFT, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 194, 205, STR_EMPTY, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 194, 205, SPR_ARROW_RIGHT, STR_FACE_TIE_EARRING_TIP}, // PFW_WIDGET_TIE_EARRING_R
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 122, 133, SPR_ARROW_LEFT, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES_L
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 122, 133, STR_EMPTY, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES
-{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 122, 133, SPR_ARROW_RIGHT, STR_FACE_GLASSES_TIP_2}, // PFW_WIDGET_GLASSES_R
+/** Widget description for the advanced company manager face selection dialog */
+static const Widget _select_company_manager_face_adv_widgets[] = {
+{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SCMFW_WIDGET_CLOSEBOX
+{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 204, 0, 13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // SCMFW_WIDGET_CAPTION
+{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 205, 219, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_FACE_SIMPLE_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 219, 14, 207, 0x0, STR_NULL}, // SCMFW_WIDGET_SELECT_FACE
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 94, 208, 219, STR_012E_CANCEL, STR_7047_CANCEL_NEW_FACE_SELECTION}, // SCMFW_WIDGET_CANCEL
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 219, 208, 219, STR_012F_OK, STR_7048_ACCEPT_NEW_FACE_SELECTION}, // SCMFW_WIDGET_ACCEPT
+{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 32, 43, STR_7044_MALE, STR_7049_SELECT_MALE_FACES}, // SCMFW_WIDGET_MALE
+{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 32, 43, STR_7045_FEMALE, STR_704A_SELECT_FEMALE_FACES}, // SCMFW_WIDGET_FEMALE
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 137, 148, STR_RANDOM, STR_704B_GENERATE_RANDOM_NEW_FACE}, // SCMFW_WIDGET_RANDOM_NEW_FACE
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 95, 217, 16, 27, STR_FACE_SIMPLE, STR_FACE_SIMPLE_TIP}, // SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 158, 169, STR_FACE_LOAD, STR_FACE_LOAD_TIP}, // SCMFW_WIDGET_LOAD
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 170, 181, STR_FACE_FACECODE, STR_FACE_FACECODE_TIP}, // SCMFW_WIDGET_FACECODE
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 93, 182, 193, STR_FACE_SAVE, STR_FACE_SAVE_TIP}, // SCMFW_WIDGET_SAVE
+{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 96, 156, 46, 57, STR_FACE_EUROPEAN, STR_FACE_SELECT_EUROPEAN}, // SCMFW_WIDGET_ETHNICITY_EUR
+{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 157, 217, 46, 57, STR_FACE_AFRICAN, STR_FACE_SELECT_AFRICAN}, // SCMFW_WIDGET_ETHNICITY_AFR
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 60, 71, STR_EMPTY, STR_FACE_MOUSTACHE_EARRING_TIP}, // SCMFW_WIDGET_HAS_MOUSTACHE_EARRING
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 175, 217, 72, 83, STR_EMPTY, STR_FACE_GLASSES_TIP}, // SCMFW_WIDGET_HAS_GLASSES
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 110, 121, SPR_ARROW_LEFT, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 110, 121, STR_EMPTY, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 110, 121, SPR_ARROW_RIGHT, STR_FACE_EYECOLOUR_TIP}, // SCMFW_WIDGET_EYECOLOUR_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 158, 169, SPR_ARROW_LEFT, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 158, 169, STR_EMPTY, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 158, 169, SPR_ARROW_RIGHT, STR_FACE_CHIN_TIP}, // SCMFW_WIDGET_CHIN_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 98, 109, SPR_ARROW_LEFT, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 98, 109, STR_EMPTY, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 98, 109, SPR_ARROW_RIGHT, STR_FACE_EYEBROWS_TIP}, // SCMFW_WIDGET_EYEBROWS_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 146, 157, SPR_ARROW_LEFT, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 146, 157, STR_EMPTY, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 146, 157, SPR_ARROW_RIGHT, STR_FACE_LIPS_MOUSTACHE_TIP}, // SCMFW_WIDGET_LIPS_MOUSTACHE_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 134, 145, SPR_ARROW_LEFT, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 134, 145, STR_EMPTY, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 134, 145, SPR_ARROW_RIGHT, STR_FACE_NOSE_TIP}, // SCMFW_WIDGET_NOSE_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 86, 97, SPR_ARROW_LEFT, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 86, 97, STR_EMPTY, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 86, 97, SPR_ARROW_RIGHT, STR_FACE_HAIR_TIP}, // SCMFW_WIDGET_HAIR_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 170, 181, SPR_ARROW_LEFT, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 170, 181, STR_EMPTY, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 170, 181, SPR_ARROW_RIGHT, STR_FACE_JACKET_TIP}, // SCMFW_WIDGET_JACKET_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 182, 193, SPR_ARROW_LEFT, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 182, 193, STR_EMPTY, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 182, 193, SPR_ARROW_RIGHT, STR_FACE_COLLAR_TIP}, // SCMFW_WIDGET_COLLAR_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 194, 205, SPR_ARROW_LEFT, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 194, 205, STR_EMPTY, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 194, 205, SPR_ARROW_RIGHT, STR_FACE_TIE_EARRING_TIP}, // SCMFW_WIDGET_TIE_EARRING_R
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 175, 183, 122, 133, SPR_ARROW_LEFT, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES_L
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 184, 208, 122, 133, STR_EMPTY, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES
+{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_GREY, 209, 217, 122, 133, SPR_ARROW_RIGHT, STR_FACE_GLASSES_TIP_2}, // SCMFW_WIDGET_GLASSES_R
{ WIDGETS_END},
};
-class SelectPlayerFaceWindow : public Window
+class SelectCompanyManagerFaceWindow : public Window
{
- PlayerFace face; // player face bits
- bool advanced; // advance player face selection window
+ CompanyManagerFace face; ///< company manager face bits
+ bool advanced; ///< advanced company manager face selection window
GenderEthnicity ge;
bool is_female;
@@ -670,58 +670,58 @@ class SelectPlayerFaceWindow : public Window
/**
* Names of the widgets. Keep them in the same order as in the widget array.
- * Do not change the order of the widgets from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R,
+ * Do not change the order of the widgets from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R,
* this order is needed for the WE_CLICK event of DrawFaceStringLabel().
*/
- enum PlayerFaceWindowWidgets {
- PFW_WIDGET_CLOSEBOX = 0,
- PFW_WIDGET_CAPTION,
- PFW_WIDGET_TOGGLE_LARGE_SMALL,
- PFW_WIDGET_SELECT_FACE,
- PFW_WIDGET_CANCEL,
- PFW_WIDGET_ACCEPT,
- PFW_WIDGET_MALE,
- PFW_WIDGET_FEMALE,
- PFW_WIDGET_RANDOM_NEW_FACE,
- PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON,
- /* from here is the advanced player face selection window */
- PFW_WIDGET_LOAD,
- PFW_WIDGET_FACECODE,
- PFW_WIDGET_SAVE,
- PFW_WIDGET_ETHNICITY_EUR,
- PFW_WIDGET_ETHNICITY_AFR,
- PFW_WIDGET_HAS_MOUSTACHE_EARRING,
- PFW_WIDGET_HAS_GLASSES,
- PFW_WIDGET_EYECOLOUR_L,
- PFW_WIDGET_EYECOLOUR,
- PFW_WIDGET_EYECOLOUR_R,
- PFW_WIDGET_CHIN_L,
- PFW_WIDGET_CHIN,
- PFW_WIDGET_CHIN_R,
- PFW_WIDGET_EYEBROWS_L,
- PFW_WIDGET_EYEBROWS,
- PFW_WIDGET_EYEBROWS_R,
- PFW_WIDGET_LIPS_MOUSTACHE_L,
- PFW_WIDGET_LIPS_MOUSTACHE,
- PFW_WIDGET_LIPS_MOUSTACHE_R,
- PFW_WIDGET_NOSE_L,
- PFW_WIDGET_NOSE,
- PFW_WIDGET_NOSE_R,
- PFW_WIDGET_HAIR_L,
- PFW_WIDGET_HAIR,
- PFW_WIDGET_HAIR_R,
- PFW_WIDGET_JACKET_L,
- PFW_WIDGET_JACKET,
- PFW_WIDGET_JACKET_R,
- PFW_WIDGET_COLLAR_L,
- PFW_WIDGET_COLLAR,
- PFW_WIDGET_COLLAR_R,
- PFW_WIDGET_TIE_EARRING_L,
- PFW_WIDGET_TIE_EARRING,
- PFW_WIDGET_TIE_EARRING_R,
- PFW_WIDGET_GLASSES_L,
- PFW_WIDGET_GLASSES,
- PFW_WIDGET_GLASSES_R,
+ enum SelectCompanyManagerFaceWidgets {
+ SCMFW_WIDGET_CLOSEBOX = 0,
+ SCMFW_WIDGET_CAPTION,
+ SCMFW_WIDGET_TOGGLE_LARGE_SMALL,
+ SCMFW_WIDGET_SELECT_FACE,
+ SCMFW_WIDGET_CANCEL,
+ SCMFW_WIDGET_ACCEPT,
+ SCMFW_WIDGET_MALE,
+ SCMFW_WIDGET_FEMALE,
+ SCMFW_WIDGET_RANDOM_NEW_FACE,
+ SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON,
+ /* from here is the advanced company manager face selection window */
+ SCMFW_WIDGET_LOAD,
+ SCMFW_WIDGET_FACECODE,
+ SCMFW_WIDGET_SAVE,
+ SCMFW_WIDGET_ETHNICITY_EUR,
+ SCMFW_WIDGET_ETHNICITY_AFR,
+ SCMFW_WIDGET_HAS_MOUSTACHE_EARRING,
+ SCMFW_WIDGET_HAS_GLASSES,
+ SCMFW_WIDGET_EYECOLOUR_L,
+ SCMFW_WIDGET_EYECOLOUR,
+ SCMFW_WIDGET_EYECOLOUR_R,
+ SCMFW_WIDGET_CHIN_L,
+ SCMFW_WIDGET_CHIN,
+ SCMFW_WIDGET_CHIN_R,
+ SCMFW_WIDGET_EYEBROWS_L,
+ SCMFW_WIDGET_EYEBROWS,
+ SCMFW_WIDGET_EYEBROWS_R,
+ SCMFW_WIDGET_LIPS_MOUSTACHE_L,
+ SCMFW_WIDGET_LIPS_MOUSTACHE,
+ SCMFW_WIDGET_LIPS_MOUSTACHE_R,
+ SCMFW_WIDGET_NOSE_L,
+ SCMFW_WIDGET_NOSE,
+ SCMFW_WIDGET_NOSE_R,
+ SCMFW_WIDGET_HAIR_L,
+ SCMFW_WIDGET_HAIR,
+ SCMFW_WIDGET_HAIR_R,
+ SCMFW_WIDGET_JACKET_L,
+ SCMFW_WIDGET_JACKET,
+ SCMFW_WIDGET_JACKET_R,
+ SCMFW_WIDGET_COLLAR_L,
+ SCMFW_WIDGET_COLLAR,
+ SCMFW_WIDGET_COLLAR_R,
+ SCMFW_WIDGET_TIE_EARRING_L,
+ SCMFW_WIDGET_TIE_EARRING,
+ SCMFW_WIDGET_TIE_EARRING_R,
+ SCMFW_WIDGET_GLASSES_L,
+ SCMFW_WIDGET_GLASSES,
+ SCMFW_WIDGET_GLASSES_R,
};
/**
* Draw dynamic a label to the left of the button and a value in the button
@@ -754,17 +754,17 @@ class SelectPlayerFaceWindow : public Window
void UpdateData()
{
- this->ge = (GenderEthnicity)GB(this->face, _pf_info[PFV_GEN_ETHN].offset, _pf_info[PFV_GEN_ETHN].length); // get the gender and ethnicity
+ this->ge = (GenderEthnicity)GB(this->face, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // get the gender and ethnicity
this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
- this->is_moust_male = !is_female && GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
+ this->is_moust_male = !is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
}
public:
- SelectPlayerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced, int top, int left) : Window(desc, parent->window_number)
+ SelectCompanyManagerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced, int top, int left) : Window(desc, parent->window_number)
{
this->parent = parent;
this->caption_color = this->window_number;
- this->face = GetPlayer((PlayerID)this->window_number)->face;
+ this->face = GetCompany((CompanyID)this->window_number)->face;
this->advanced = advanced;
this->UpdateData();
@@ -781,105 +781,105 @@ public:
virtual void OnPaint()
{
/* lower the non-selected gender button */
- this->SetWidgetLoweredState(PFW_WIDGET_MALE, !this->is_female);
- this->SetWidgetLoweredState(PFW_WIDGET_FEMALE, this->is_female);
+ this->SetWidgetLoweredState(SCMFW_WIDGET_MALE, !this->is_female);
+ this->SetWidgetLoweredState(SCMFW_WIDGET_FEMALE, this->is_female);
- /* advanced player face selection window */
+ /* advanced company manager face selection window */
if (this->advanced) {
/* lower the non-selected ethnicity button */
- this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK));
- this->SetWidgetLoweredState(PFW_WIDGET_ETHNICITY_AFR, HasBit(this->ge, ETHNICITY_BLACK));
+ this->SetWidgetLoweredState(SCMFW_WIDGET_ETHNICITY_EUR, !HasBit(this->ge, ETHNICITY_BLACK));
+ this->SetWidgetLoweredState(SCMFW_WIDGET_ETHNICITY_AFR, HasBit(this->ge, ETHNICITY_BLACK));
- /* Disable dynamically the widgets which PlayerFaceVariable has less than 2 options
+ /* Disable dynamically the widgets which CompanyManagerFaceVariable has less than 2 options
* (or in other words you haven't any choice).
* If the widgets depend on a HAS-variable and this is false the widgets will be disabled, too. */
/* Eye colour buttons */
- this->SetWidgetsDisabledState(_pf_info[PFV_EYE_COLOUR].valid_values[this->ge] < 2,
- PFW_WIDGET_EYECOLOUR, PFW_WIDGET_EYECOLOUR_L, PFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_EYE_COLOUR].valid_values[this->ge] < 2,
+ SCMFW_WIDGET_EYECOLOUR, SCMFW_WIDGET_EYECOLOUR_L, SCMFW_WIDGET_EYECOLOUR_R, WIDGET_LIST_END);
/* Chin buttons */
- this->SetWidgetsDisabledState(_pf_info[PFV_CHIN].valid_values[this->ge] < 2,
- PFW_WIDGET_CHIN, PFW_WIDGET_CHIN_L, PFW_WIDGET_CHIN_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_CHIN].valid_values[this->ge] < 2,
+ SCMFW_WIDGET_CHIN, SCMFW_WIDGET_CHIN_L, SCMFW_WIDGET_CHIN_R, WIDGET_LIST_END);
/* Eyebrows buttons */
- this->SetWidgetsDisabledState(_pf_info[PFV_EYEBROWS].valid_values[this->ge] < 2,
- PFW_WIDGET_EYEBROWS, PFW_WIDGET_EYEBROWS_L, PFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_EYEBROWS].valid_values[this->ge] < 2,
+ SCMFW_WIDGET_EYEBROWS, SCMFW_WIDGET_EYEBROWS_L, SCMFW_WIDGET_EYEBROWS_R, WIDGET_LIST_END);
/* Lips or (if it a male face with a moustache) moustache buttons */
- this->SetWidgetsDisabledState(_pf_info[this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS].valid_values[this->ge] < 2,
- PFW_WIDGET_LIPS_MOUSTACHE, PFW_WIDGET_LIPS_MOUSTACHE_L, PFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS].valid_values[this->ge] < 2,
+ SCMFW_WIDGET_LIPS_MOUSTACHE, SCMFW_WIDGET_LIPS_MOUSTACHE_L, SCMFW_WIDGET_LIPS_MOUSTACHE_R, WIDGET_LIST_END);
/* Nose buttons | male faces with moustache haven't any nose options */
- this->SetWidgetsDisabledState(_pf_info[PFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male,
- PFW_WIDGET_NOSE, PFW_WIDGET_NOSE_L, PFW_WIDGET_NOSE_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male,
+ SCMFW_WIDGET_NOSE, SCMFW_WIDGET_NOSE_L, SCMFW_WIDGET_NOSE_R, WIDGET_LIST_END);
/* Hair buttons */
- this->SetWidgetsDisabledState(_pf_info[PFV_HAIR].valid_values[this->ge] < 2,
- PFW_WIDGET_HAIR, PFW_WIDGET_HAIR_L, PFW_WIDGET_HAIR_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_HAIR].valid_values[this->ge] < 2,
+ SCMFW_WIDGET_HAIR, SCMFW_WIDGET_HAIR_L, SCMFW_WIDGET_HAIR_R, WIDGET_LIST_END);
/* Jacket buttons */
- this->SetWidgetsDisabledState(_pf_info[PFV_JACKET].valid_values[this->ge] < 2,
- PFW_WIDGET_JACKET, PFW_WIDGET_JACKET_L, PFW_WIDGET_JACKET_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_JACKET].valid_values[this->ge] < 2,
+ SCMFW_WIDGET_JACKET, SCMFW_WIDGET_JACKET_L, SCMFW_WIDGET_JACKET_R, WIDGET_LIST_END);
/* Collar buttons */
- this->SetWidgetsDisabledState(_pf_info[PFV_COLLAR].valid_values[this->ge] < 2,
- PFW_WIDGET_COLLAR, PFW_WIDGET_COLLAR_L, PFW_WIDGET_COLLAR_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_COLLAR].valid_values[this->ge] < 2,
+ SCMFW_WIDGET_COLLAR, SCMFW_WIDGET_COLLAR_L, SCMFW_WIDGET_COLLAR_R, WIDGET_LIST_END);
/* Tie/earring buttons | female faces without earring haven't any earring options */
- this->SetWidgetsDisabledState(_pf_info[PFV_TIE_EARRING].valid_values[this->ge] < 2 ||
- (this->is_female && GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge) == 0),
- PFW_WIDGET_TIE_EARRING, PFW_WIDGET_TIE_EARRING_L, PFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_TIE_EARRING].valid_values[this->ge] < 2 ||
+ (this->is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge) == 0),
+ SCMFW_WIDGET_TIE_EARRING, SCMFW_WIDGET_TIE_EARRING_L, SCMFW_WIDGET_TIE_EARRING_R, WIDGET_LIST_END);
/* Glasses buttons | faces without glasses haven't any glasses options */
- this->SetWidgetsDisabledState(_pf_info[PFV_GLASSES].valid_values[this->ge] < 2 || GetPlayerFaceBits(this->face, PFV_HAS_GLASSES, this->ge) == 0,
- PFW_WIDGET_GLASSES, PFW_WIDGET_GLASSES_L, PFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_cmf_info[CMFV_GLASSES].valid_values[this->ge] < 2 || GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES, this->ge) == 0,
+ SCMFW_WIDGET_GLASSES, SCMFW_WIDGET_GLASSES_L, SCMFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
}
this->DrawWidgets();
- /* Draw dynamic button value and labels for the advanced player face selection window */
+ /* Draw dynamic button value and labels for the advanced company manager face selection window */
if (this->advanced) {
if (this->is_female) {
/* Only for female faces */
- this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING, GetPlayerFaceBits(this->face, PFV_HAS_TIE_EARRING, this->ge), true );
- this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING, STR_FACE_EARRING, GetPlayerFaceBits(this->face, PFV_TIE_EARRING, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge), true );
+ this->DrawFaceStringLabel(SCMFW_WIDGET_TIE_EARRING, STR_FACE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false);
} else {
/* Only for male faces */
- this->DrawFaceStringLabel(PFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE, this->ge), true );
- this->DrawFaceStringLabel(PFW_WIDGET_TIE_EARRING, STR_FACE_TIE, GetPlayerFaceBits(this->face, PFV_TIE_EARRING, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_MOUSTACHE_EARRING, STR_FACE_MOUSTACHE, GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE, this->ge), true );
+ this->DrawFaceStringLabel(SCMFW_WIDGET_TIE_EARRING, STR_FACE_TIE, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false);
}
if (this->is_moust_male) {
/* Only for male faces with moustache */
- this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_MOUSTACHE, GetPlayerFaceBits(this->face, PFV_MOUSTACHE, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_MOUSTACHE, GetCompanyManagerFaceBits(this->face, CMFV_MOUSTACHE, this->ge), false);
} else {
/* Only for female faces or male faces without moustache */
- this->DrawFaceStringLabel(PFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_LIPS, GetPlayerFaceBits(this->face, PFV_LIPS, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_LIPS_MOUSTACHE, STR_FACE_LIPS, GetCompanyManagerFaceBits(this->face, CMFV_LIPS, this->ge), false);
}
/* For all faces */
- this->DrawFaceStringLabel(PFW_WIDGET_HAS_GLASSES, STR_FACE_GLASSES, GetPlayerFaceBits(this->face, PFV_HAS_GLASSES, this->ge), true );
- this->DrawFaceStringLabel(PFW_WIDGET_HAIR, STR_FACE_HAIR, GetPlayerFaceBits(this->face, PFV_HAIR, this->ge), false);
- this->DrawFaceStringLabel(PFW_WIDGET_EYEBROWS, STR_FACE_EYEBROWS, GetPlayerFaceBits(this->face, PFV_EYEBROWS, this->ge), false);
- this->DrawFaceStringLabel(PFW_WIDGET_EYECOLOUR, STR_FACE_EYECOLOUR, GetPlayerFaceBits(this->face, PFV_EYE_COLOUR, this->ge), false);
- this->DrawFaceStringLabel(PFW_WIDGET_GLASSES, STR_FACE_GLASSES, GetPlayerFaceBits(this->face, PFV_GLASSES, this->ge), false);
- this->DrawFaceStringLabel(PFW_WIDGET_NOSE, STR_FACE_NOSE, GetPlayerFaceBits(this->face, PFV_NOSE, this->ge), false);
- this->DrawFaceStringLabel(PFW_WIDGET_CHIN, STR_FACE_CHIN, GetPlayerFaceBits(this->face, PFV_CHIN, this->ge), false);
- this->DrawFaceStringLabel(PFW_WIDGET_JACKET, STR_FACE_JACKET, GetPlayerFaceBits(this->face, PFV_JACKET, this->ge), false);
- this->DrawFaceStringLabel(PFW_WIDGET_COLLAR, STR_FACE_COLLAR, GetPlayerFaceBits(this->face, PFV_COLLAR, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_HAS_GLASSES, STR_FACE_GLASSES, GetCompanyManagerFaceBits(this->face, CMFV_HAS_GLASSES, this->ge), true );
+ this->DrawFaceStringLabel(SCMFW_WIDGET_HAIR, STR_FACE_HAIR, GetCompanyManagerFaceBits(this->face, CMFV_HAIR, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_EYEBROWS, STR_FACE_EYEBROWS, GetCompanyManagerFaceBits(this->face, CMFV_EYEBROWS, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_EYECOLOUR, STR_FACE_EYECOLOUR, GetCompanyManagerFaceBits(this->face, CMFV_EYE_COLOUR, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_GLASSES, STR_FACE_GLASSES, GetCompanyManagerFaceBits(this->face, CMFV_GLASSES, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_NOSE, STR_FACE_NOSE, GetCompanyManagerFaceBits(this->face, CMFV_NOSE, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_CHIN, STR_FACE_CHIN, GetCompanyManagerFaceBits(this->face, CMFV_CHIN, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_JACKET, STR_FACE_JACKET, GetCompanyManagerFaceBits(this->face, CMFV_JACKET, this->ge), false);
+ this->DrawFaceStringLabel(SCMFW_WIDGET_COLLAR, STR_FACE_COLLAR, GetCompanyManagerFaceBits(this->face, CMFV_COLLAR, this->ge), false);
}
- /* Draw the player face picture */
- DrawPlayerFace(this->face, GetPlayer((PlayerID)this->window_number)->player_color, 2, 16);
+ /* Draw the company manager face picture */
+ DrawCompanyManagerFace(this->face, GetCompany((CompanyID)this->window_number)->colour, 2, 16);
}
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
/* Toggle size, advanced/simple face selection */
- case PFW_WIDGET_TOGGLE_LARGE_SMALL:
- case PFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: {
- DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE);
+ case SCMFW_WIDGET_TOGGLE_LARGE_SMALL:
+ case SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: {
+ DoCommandP(0, 0, this->face, NULL, CMD_SET_COMPANY_MANAGER_FACE);
/* Backup some data before deletion */
int oldtop = this->top; ///< current top position of the window before closing it
@@ -890,99 +890,99 @@ public:
delete this;
/* Open up the (toggled size) Face selection window at the same position as the previous */
- DoSelectPlayerFace(parent, adv, oldtop, oldleft);
+ DoSelectCompanyManagerFace(parent, adv, oldtop, oldleft);
} break;
/* OK button */
- case PFW_WIDGET_ACCEPT:
- DoCommandP(0, 0, this->face, NULL, CMD_SET_PLAYER_FACE);
+ case SCMFW_WIDGET_ACCEPT:
+ DoCommandP(0, 0, this->face, NULL, CMD_SET_COMPANY_MANAGER_FACE);
/* Fall-Through */
/* Cancel button */
- case PFW_WIDGET_CANCEL:
+ case SCMFW_WIDGET_CANCEL:
delete this;
break;
/* Load button */
- case PFW_WIDGET_LOAD:
- this->face = _player_face;
- ScaleAllPlayerFaceBits(this->face);
+ case SCMFW_WIDGET_LOAD:
+ this->face = _company_manager_face;
+ ScaleAllCompanyManagerFaceBits(this->face);
ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0);
this->UpdateData();
this->SetDirty();
break;
- /* 'Player face number' button, view and/or set player face number */
- case PFW_WIDGET_FACECODE:
+ /* 'Company manager face number' button, view and/or set company manager face number */
+ case SCMFW_WIDGET_FACECODE:
SetDParam(0, this->face);
ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL, QSF_NONE);
break;
/* Save button */
- case PFW_WIDGET_SAVE:
- _player_face = this->face;
+ case SCMFW_WIDGET_SAVE:
+ _company_manager_face = this->face;
ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0);
break;
/* Toggle gender (male/female) button */
- case PFW_WIDGET_MALE:
- case PFW_WIDGET_FEMALE:
- SetPlayerFaceBits(this->face, PFV_GENDER, this->ge, widget - PFW_WIDGET_MALE);
- ScaleAllPlayerFaceBits(this->face);
+ case SCMFW_WIDGET_MALE:
+ case SCMFW_WIDGET_FEMALE:
+ SetCompanyManagerFaceBits(this->face, CMFV_GENDER, this->ge, widget - SCMFW_WIDGET_MALE);
+ ScaleAllCompanyManagerFaceBits(this->face);
this->UpdateData();
this->SetDirty();
break;
/* Randomize face button */
- case PFW_WIDGET_RANDOM_NEW_FACE:
- RandomPlayerFaceBits(this->face, this->ge, this->advanced);
+ case SCMFW_WIDGET_RANDOM_NEW_FACE:
+ RandomCompanyManagerFaceBits(this->face, this->ge, this->advanced);
this->UpdateData();
this->SetDirty();
break;
/* Toggle ethnicity (european/african) button */
- case PFW_WIDGET_ETHNICITY_EUR:
- case PFW_WIDGET_ETHNICITY_AFR:
- SetPlayerFaceBits(this->face, PFV_ETHNICITY, this->ge, widget - PFW_WIDGET_ETHNICITY_EUR);
- ScaleAllPlayerFaceBits(this->face);
+ case SCMFW_WIDGET_ETHNICITY_EUR:
+ case SCMFW_WIDGET_ETHNICITY_AFR:
+ SetCompanyManagerFaceBits(this->face, CMFV_ETHNICITY, this->ge, widget - SCMFW_WIDGET_ETHNICITY_EUR);
+ ScaleAllCompanyManagerFaceBits(this->face);
this->UpdateData();
this->SetDirty();
break;
default:
- /* For all buttons from PFW_WIDGET_HAS_MOUSTACHE_EARRING to PFW_WIDGET_GLASSES_R is the same function.
+ /* For all buttons from SCMFW_WIDGET_HAS_MOUSTACHE_EARRING to SCMFW_WIDGET_GLASSES_R is the same function.
* Therefor is this combined function.
- * First it checks which PlayerFaceVariable will be change and then
+ * First it checks which CompanyManagerFaceVariable will be change and then
* a: invert the value for boolean variables
- * or b: it checks inside of IncreasePlayerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */
- if (this->advanced && widget >= PFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= PFW_WIDGET_GLASSES_R) {
- PlayerFaceVariable pfv; // which PlayerFaceVariable shall be edited
+ * or b: it checks inside of IncreaseCompanyManagerFaceBits() if a left (_L) butten is pressed and then decrease else increase the variable */
+ if (this->advanced && widget >= SCMFW_WIDGET_HAS_MOUSTACHE_EARRING && widget <= SCMFW_WIDGET_GLASSES_R) {
+ CompanyManagerFaceVariable cmfv; // which CompanyManagerFaceVariable shall be edited
- if (widget < PFW_WIDGET_EYECOLOUR_L) { // Bool buttons
- switch (widget - PFW_WIDGET_HAS_MOUSTACHE_EARRING) {
+ if (widget < SCMFW_WIDGET_EYECOLOUR_L) { // Bool buttons
+ switch (widget - SCMFW_WIDGET_HAS_MOUSTACHE_EARRING) {
default: NOT_REACHED();
- case 0: pfv = this->is_female ? PFV_HAS_TIE_EARRING : PFV_HAS_MOUSTACHE; break; // Has earring/moustache button
- case 1: pfv = PFV_HAS_GLASSES; break; // Has glasses button
+ case 0: cmfv = this->is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE; break; // Has earring/moustache button
+ case 1: cmfv = CMFV_HAS_GLASSES; break; // Has glasses button
}
- SetPlayerFaceBits(this->face, pfv, this->ge, !GetPlayerFaceBits(this->face, pfv, this->ge));
- ScaleAllPlayerFaceBits(this->face);
+ SetCompanyManagerFaceBits(this->face, cmfv, this->ge, !GetCompanyManagerFaceBits(this->face, cmfv, this->ge));
+ ScaleAllCompanyManagerFaceBits(this->face);
} else { // Value buttons
- switch ((widget - PFW_WIDGET_EYECOLOUR_L) / 3) {
+ switch ((widget - SCMFW_WIDGET_EYECOLOUR_L) / 3) {
default: NOT_REACHED();
- case 0: pfv = PFV_EYE_COLOUR; break; // Eye colour buttons
- case 1: pfv = PFV_CHIN; break; // Chin buttons
- case 2: pfv = PFV_EYEBROWS; break; // Eyebrows buttons
- case 3: pfv = this->is_moust_male ? PFV_MOUSTACHE : PFV_LIPS; break; // Moustache or lips buttons
- case 4: pfv = PFV_NOSE; break; // Nose buttons
- case 5: pfv = PFV_HAIR; break; // Hair buttons
- case 6: pfv = PFV_JACKET; break; // Jacket buttons
- case 7: pfv = PFV_COLLAR; break; // Collar buttons
- case 8: pfv = PFV_TIE_EARRING; break; // Tie/earring buttons
- case 9: pfv = PFV_GLASSES; break; // Glasses buttons
+ case 0: cmfv = CMFV_EYE_COLOUR; break; // Eye colour buttons
+ case 1: cmfv = CMFV_CHIN; break; // Chin buttons
+ case 2: cmfv = CMFV_EYEBROWS; break; // Eyebrows buttons
+ case 3: cmfv = this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS; break; // Moustache or lips buttons
+ case 4: cmfv = CMFV_NOSE; break; // Nose buttons
+ case 5: cmfv = CMFV_HAIR; break; // Hair buttons
+ case 6: cmfv = CMFV_JACKET; break; // Jacket buttons
+ case 7: cmfv = CMFV_COLLAR; break; // Collar buttons
+ case 8: cmfv = CMFV_TIE_EARRING; break; // Tie/earring buttons
+ case 9: cmfv = CMFV_GLASSES; break; // Glasses buttons
}
/* 0 == left (_L), 1 == middle or 2 == right (_R) - button click */
- IncreasePlayerFaceBits(this->face, pfv, this->ge, (((widget - PFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1);
+ IncreaseCompanyManagerFaceBits(this->face, cmfv, this->ge, (((widget - SCMFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1);
}
this->UpdateData();
this->SetDirty();
@@ -994,10 +994,10 @@ public:
virtual void OnQueryTextFinished(char *str)
{
if (str == NULL) return;
- /* Set a new player face number */
+ /* Set a new company manager face number */
if (!StrEmpty(str)) {
this->face = strtoul(str, NULL, 10);
- ScaleAllPlayerFaceBits(this->face);
+ ScaleAllCompanyManagerFaceBits(this->face);
ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0);
this->UpdateData();
this->SetDirty();
@@ -1007,58 +1007,56 @@ public:
}
};
-/** normal/simple player face selection window description */
-static const WindowDesc _select_player_face_desc = {
+/** normal/simple company manager face selection window description */
+static const WindowDesc _select_company_manager_face_desc = {
WDP_AUTO, WDP_AUTO, 190, 163, 190, 163,
- WC_PLAYER_FACE, WC_NONE,
+ WC_COMPANY_MANAGER_FACE, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
- _select_player_face_widgets,
+ _select_company_manager_face_widgets,
};
-/** advanced player face selection window description */
-static const WindowDesc _select_player_face_adv_desc = {
+/** advanced company manager face selection window description */
+static const WindowDesc _select_company_manager_face_adv_desc = {
WDP_AUTO, WDP_AUTO, 220, 220, 220, 220,
- WC_PLAYER_FACE, WC_NONE,
+ WC_COMPANY_MANAGER_FACE, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
- _select_player_face_adv_widgets,
+ _select_company_manager_face_adv_widgets,
};
/**
- * Open the simple/advanced player face selection window
+ * Open the simple/advanced company manager face selection window
*
- * @param player the player which face shall be edited
- * @param adv simple or advanced player face selection window
+ * @param parent the parent company window
+ * @param adv simple or advanced face selection window
* @param top previous top position of the window
* @param left previous left position of the window
- *
- * @pre is player a valid player
*/
-static void DoSelectPlayerFace(Window *parent, bool adv, int top, int left)
+static void DoSelectCompanyManagerFace(Window *parent, bool adv, int top, int left)
{
- if (!IsValidPlayerID((PlayerID)parent->window_number)) return;
+ if (!IsValidCompanyID((CompanyID)parent->window_number)) return;
- if (BringWindowToFrontById(WC_PLAYER_FACE, parent->window_number)) return;
- new SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, parent, adv, top, left); // simple or advanced window
+ if (BringWindowToFrontById(WC_COMPANY_MANAGER_FACE, parent->window_number)) return;
+ new SelectCompanyManagerFaceWindow(adv ? &_select_company_manager_face_adv_desc : &_select_company_manager_face_desc, parent, adv, top, left); // simple or advanced window
}
/* Names of the widgets. Keep them in the same order as in the widget array */
-enum PlayerCompanyWindowWidgets {
- PCW_WIDGET_CLOSEBOX = 0,
- PCW_WIDGET_CAPTION,
- PCW_WIDGET_FACE,
- PCW_WIDGET_NEW_FACE,
- PCW_WIDGET_COLOR_SCHEME,
- PCW_WIDGET_PRESIDENT_NAME,
- PCW_WIDGET_COMPANY_NAME,
- PCW_WIDGET_BUILD_VIEW_HQ,
- PCW_WIDGET_RELOCATE_HQ,
- PCW_WIDGET_BUY_SHARE,
- PCW_WIDGET_SELL_SHARE,
- PCW_WIDGET_COMPANY_PASSWORD,
+enum CompanyWindowWidgets {
+ CW_WIDGET_CLOSEBOX = 0,
+ CW_WIDGET_CAPTION,
+ CW_WIDGET_FACE,
+ CW_WIDGET_NEW_FACE,
+ CW_WIDGET_COLOR_SCHEME,
+ CW_WIDGET_PRESIDENT_NAME,
+ CW_WIDGET_COMPANY_NAME,
+ CW_WIDGET_BUILD_VIEW_HQ,
+ CW_WIDGET_RELOCATE_HQ,
+ CW_WIDGET_BUY_SHARE,
+ CW_WIDGET_SELL_SHARE,
+ CW_WIDGET_COMPANY_PASSWORD,
};
-static const Widget _player_company_widgets[] = {
+static const Widget _company_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 359, 0, 13, STR_7001, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 359, 14, 157, 0x0, STR_NULL},
@@ -1077,9 +1075,9 @@ static const Widget _player_company_widgets[] = {
/**
* Draws text "Vehicles:" and number of all vehicle types, or "(none)"
- * @param player ID of player to print statistics of
+ * @param company ID of company to print statistics of
*/
-static void DrawPlayerVehiclesAmount(PlayerID player)
+static void DrawCompanyVehiclesAmount(CompanyID company)
{
const int x = 110;
int y = 63;
@@ -1092,7 +1090,7 @@ static void DrawPlayerVehiclesAmount(PlayerID player)
DrawString(x, y, STR_7039_VEHICLES, TC_FROMSTRING);
FOR_ALL_VEHICLES(v) {
- if (v->owner == player) {
+ if (v->owner == company) {
switch (v->type) {
case VEH_TRAIN: if (IsFrontEngine(v)) train++; break;
case VEH_ROAD: if (IsRoadVehFront(v)) road++; break;
@@ -1131,29 +1129,29 @@ static void DrawPlayerVehiclesAmount(PlayerID player)
}
}
-int GetAmountOwnedBy(const Player *p, PlayerID owner)
+int GetAmountOwnedBy(const Company *c, Owner owner)
{
- return (p->share_owners[0] == owner) +
- (p->share_owners[1] == owner) +
- (p->share_owners[2] == owner) +
- (p->share_owners[3] == owner);
+ return (c->share_owners[0] == owner) +
+ (c->share_owners[1] == owner) +
+ (c->share_owners[2] == owner) +
+ (c->share_owners[3] == owner);
}
/**
* Draws list of all companies with shares
- * @param p pointer to the Player structure
+ * @param c pointer to the Company structure
*/
-static void DrawCompanyOwnerText(const Player *p)
+static void DrawCompanyOwnerText(const Company *c)
{
- const Player *p2;
+ const Company *c2;
uint num = 0;
const byte height = GetCharacterHeight(FS_NORMAL);
- FOR_ALL_PLAYERS(p2) {
- uint amt = GetAmountOwnedBy(p, p2->index);
+ FOR_ALL_COMPANIES(c2) {
+ uint amt = GetAmountOwnedBy(c, c2->index);
if (amt != 0) {
SetDParam(0, amt * 25);
- SetDParam(1, p2->index);
+ SetDParam(1, c2->index);
DrawString(120, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING);
}
@@ -1161,16 +1159,13 @@ static void DrawCompanyOwnerText(const Player *p)
}
/**
- * Player company window event definition
- *
- * @param w window pointer
- * @param e event been triggered
+ * Window with general information about a company
*/
-struct PlayerCompanyWindow : Window
+struct CompanyWindow : Window
{
- PlayerCompanyWindowWidgets query_widget;
+ CompanyWindowWidgets query_widget;
- PlayerCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
+ CompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->caption_color = this->window_number;
this->FindWindowPlacementAndResize(desc);
@@ -1178,102 +1173,102 @@ struct PlayerCompanyWindow : Window
virtual void OnPaint()
{
- const Player *p = GetPlayer((PlayerID)this->window_number);
- bool local = this->window_number == _local_player;
-
- this->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE, !local);
- this->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME, !local);
- this->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local);
- this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME, !local);
- this->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_HQ == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
- if (local && p->location_of_HQ != 0) this->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
- this->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_HQ == 0);
- this->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ, !local || p->location_of_HQ == 0);
- this->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE, local);
- this->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE, local);
- this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
+ const Company *c = GetCompany((CompanyID)this->window_number);
+ bool local = this->window_number == _local_company;
+
+ this->SetWidgetHiddenState(CW_WIDGET_NEW_FACE, !local);
+ this->SetWidgetHiddenState(CW_WIDGET_COLOR_SCHEME, !local);
+ this->SetWidgetHiddenState(CW_WIDGET_PRESIDENT_NAME, !local);
+ this->SetWidgetHiddenState(CW_WIDGET_COMPANY_NAME, !local);
+ this->widget[CW_WIDGET_BUILD_VIEW_HQ].data = (local && c->location_of_HQ == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
+ if (local && c->location_of_HQ != 0) this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
+ this->SetWidgetDisabledState(CW_WIDGET_BUILD_VIEW_HQ, !local && c->location_of_HQ == 0);
+ this->SetWidgetHiddenState(CW_WIDGET_RELOCATE_HQ, !local || c->location_of_HQ == 0);
+ this->SetWidgetHiddenState(CW_WIDGET_BUY_SHARE, local);
+ this->SetWidgetHiddenState(CW_WIDGET_SELL_SHARE, local);
+ this->SetWidgetHiddenState(CW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
if (!local) {
if (_settings_game.economy.allow_shares) { // Shares are allowed
/* If all shares are owned by someone (none by nobody), disable buy button */
- this->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
- /* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
- (GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
+ this->SetWidgetDisabledState(CW_WIDGET_BUY_SHARE, GetAmountOwnedBy(c, INVALID_OWNER) == 0 ||
+ /* Only 25% left to buy. If the company is human, disable buying it up.. TODO issues! */
+ (GetAmountOwnedBy(c, INVALID_OWNER) == 1 && !c->is_ai) ||
/* Spectators cannot do anything of course */
- _local_player == PLAYER_SPECTATOR);
+ _local_company == COMPANY_SPECTATOR);
- /* If the player doesn't own any shares, disable sell button */
- this->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
+ /* If the company doesn't own any shares, disable sell button */
+ this->SetWidgetDisabledState(CW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(c, _local_company) == 0) ||
/* Spectators cannot do anything of course */
- _local_player == PLAYER_SPECTATOR);
+ _local_company == COMPANY_SPECTATOR);
} else { // Shares are not allowed, disable buy/sell buttons
- this->DisableWidget(PCW_WIDGET_BUY_SHARE);
- this->DisableWidget(PCW_WIDGET_SELL_SHARE);
+ this->DisableWidget(CW_WIDGET_BUY_SHARE);
+ this->DisableWidget(CW_WIDGET_SELL_SHARE);
}
}
- SetDParam(0, p->index);
- SetDParam(1, p->index);
+ SetDParam(0, c->index);
+ SetDParam(1, c->index);
this->DrawWidgets();
- /* Player face */
- DrawPlayerFace(p->face, p->player_color, 2, 16);
+ /* Company manager's face */
+ DrawCompanyManagerFace(c->face, c->colour, 2, 16);
/* "xxx (Manager)" */
- SetDParam(0, p->index);
+ SetDParam(0, c->index);
DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, MAX_LENGTH_PRESIDENT_NAME_PIXELS);
/* "Inaugurated:" */
- SetDParam(0, p->inaugurated_year);
+ SetDParam(0, c->inaugurated_year);
DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING);
/* "Colour scheme:" */
DrawString(110, 43, STR_7006_COLOR_SCHEME, TC_FROMSTRING);
/* Draw company-colour bus */
- DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 44);
+ DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOR(c->index), 215, 44);
/* "Vehicles:" */
- DrawPlayerVehiclesAmount((PlayerID)this->window_number);
+ DrawCompanyVehiclesAmount((CompanyID)this->window_number);
/* "Company value:" */
- SetDParam(0, CalculateCompanyValue(p));
+ SetDParam(0, CalculateCompanyValue(c));
DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING);
/* Shares list */
- DrawCompanyOwnerText(p);
+ DrawCompanyOwnerText(c);
}
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
- case PCW_WIDGET_NEW_FACE: DoSelectPlayerFace(this, false); break;
+ case CW_WIDGET_NEW_FACE: DoSelectCompanyManagerFace(this, false); break;
- case PCW_WIDGET_COLOR_SCHEME:
- if (BringWindowToFrontById(WC_PLAYER_COLOR, this->window_number)) break;
- new SelectPlayerLiveryWindow(&_select_player_livery_desc, (PlayerID)this->window_number);
+ case CW_WIDGET_COLOR_SCHEME:
+ if (BringWindowToFrontById(WC_COMPANY_COLOR, this->window_number)) break;
+ new SelectCompanyLiveryWindow(&_select_company_livery_desc, (CompanyID)this->window_number);
break;
- case PCW_WIDGET_PRESIDENT_NAME:
- this->query_widget = PCW_WIDGET_PRESIDENT_NAME;
+ case CW_WIDGET_PRESIDENT_NAME:
+ this->query_widget = CW_WIDGET_PRESIDENT_NAME;
SetDParam(0, this->window_number);
ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME_BYTES, MAX_LENGTH_PRESIDENT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
break;
- case PCW_WIDGET_COMPANY_NAME:
- this->query_widget = PCW_WIDGET_COMPANY_NAME;
+ case CW_WIDGET_COMPANY_NAME:
+ this->query_widget = CW_WIDGET_COMPANY_NAME;
SetDParam(0, this->window_number);
ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_COMPANY_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
break;
- case PCW_WIDGET_BUILD_VIEW_HQ: {
- TileIndex tile = GetPlayer((PlayerID)this->window_number)->location_of_HQ;
+ case CW_WIDGET_BUILD_VIEW_HQ: {
+ TileIndex tile = GetCompany((CompanyID)this->window_number)->location_of_HQ;
if (tile == 0) {
- if ((byte)this->window_number != _local_player) return;
+ if ((byte)this->window_number != _local_company) return;
SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
SetTileSelectSize(2, 2);
- this->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ);
- this->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ);
+ this->LowerWidget(CW_WIDGET_BUILD_VIEW_HQ);
+ this->InvalidateWidget(CW_WIDGET_BUILD_VIEW_HQ);
} else {
if (_ctrl_pressed) {
ShowExtraViewPortWindow(tile);
@@ -1284,24 +1279,24 @@ struct PlayerCompanyWindow : Window
break;
}
- case PCW_WIDGET_RELOCATE_HQ:
+ case CW_WIDGET_RELOCATE_HQ:
SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
SetTileSelectSize(2, 2);
- this->LowerWidget(PCW_WIDGET_RELOCATE_HQ);
- this->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ);
+ this->LowerWidget(CW_WIDGET_RELOCATE_HQ);
+ this->InvalidateWidget(CW_WIDGET_RELOCATE_HQ);
break;
- case PCW_WIDGET_BUY_SHARE:
+ case CW_WIDGET_BUY_SHARE:
DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
break;
- case PCW_WIDGET_SELL_SHARE:
+ case CW_WIDGET_SELL_SHARE:
DoCommandP(0, this->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
break;
#ifdef ENABLE_NETWORK
- case PCW_WIDGET_COMPANY_PASSWORD:
- if (this->window_number == _local_player) ShowNetworkCompanyPasswordWindow(this);
+ case CW_WIDGET_COMPANY_PASSWORD:
+ if (this->window_number == _local_company) ShowNetworkCompanyPasswordWindow(this);
break;
#endif /* ENABLE_NETWORK */
}
@@ -1317,7 +1312,7 @@ struct PlayerCompanyWindow : Window
{
if (DoCommandP(tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
ResetObjectToPlace();
- this->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
+ this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
this->RaiseButtons();
}
@@ -1334,29 +1329,29 @@ struct PlayerCompanyWindow : Window
switch (this->query_widget) {
default: NOT_REACHED();
- case PCW_WIDGET_PRESIDENT_NAME:
+ case CW_WIDGET_PRESIDENT_NAME:
DoCommandP(0, 0, 0, NULL, CMD_RENAME_PRESIDENT | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
break;
- case PCW_WIDGET_COMPANY_NAME:
+ case CW_WIDGET_COMPANY_NAME:
DoCommandP(0, 0, 0, NULL, CMD_RENAME_COMPANY | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
break;
}
}
};
-static const WindowDesc _player_company_desc = {
+static const WindowDesc _company_desc = {
WDP_AUTO, WDP_AUTO, 360, 170, 360, 170,
WC_COMPANY, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
- _player_company_widgets,
+ _company_widgets,
};
-void ShowPlayerCompany(PlayerID player)
+void ShowCompany(CompanyID company)
{
- if (!IsValidPlayerID(player)) return;
+ if (!IsValidCompanyID(company)) return;
- AllocateWindowDescFront<PlayerCompanyWindow>(&_player_company_desc, player);
+ AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
}
@@ -1369,15 +1364,15 @@ struct BuyCompanyWindow : Window {
virtual void OnPaint()
{
- Player *p = GetPlayer((PlayerID)this->window_number);
+ Company *c = GetCompany((CompanyID)this->window_number);
SetDParam(0, STR_COMPANY_NAME);
- SetDParam(1, p->index);
+ SetDParam(1, c->index);
this->DrawWidgets();
- DrawPlayerFace(p->face, p->player_color, 2, 16);
+ DrawCompanyManagerFace(c->face, c->colour, 2, 16);
- SetDParam(0, p->index);
- SetDParam(1, p->bankrupt_value);
+ SetDParam(0, c->index);
+ SetDParam(1, c->bankrupt_value);
DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238);
}
@@ -1412,9 +1407,9 @@ static const WindowDesc _buy_company_desc = {
};
-void ShowBuyCompanyDialog(uint player)
+void ShowBuyCompanyDialog(CompanyID company)
{
- AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, player);
+ AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, company);
}
/********** HIGHSCORE and ENDGAME windows */
@@ -1465,9 +1460,9 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
this->background_img = SPR_TYCOON_IMG1_BEGIN;
- if (_local_player != PLAYER_SPECTATOR) {
- const Player *p = GetPlayer(_local_player);
- if (p->old_economy[0].performance_history == SCORE_MAX) {
+ if (_local_company != COMPANY_SPECTATOR) {
+ const Company *c = GetCompany(_local_company);
+ if (c->old_economy[0].performance_history == SCORE_MAX) {
this->background_img = SPR_TYCOON_IMG2_BEGIN;
}
}
@@ -1478,10 +1473,10 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
this->window_number = lengthof(_highscore_table) - 1;
this->rank = SaveHighScoreValueNetwork();
} else {
- /* in single player _local player is always valid */
- const Player *p = GetPlayer(_local_player);
+ /* in single player _local company is always valid */
+ const Company *c = GetCompany(_local_company);
this->window_number = _settings_game.difficulty.diff_level;
- this->rank = SaveHighScoreValue(p);
+ this->rank = SaveHighScoreValue(c);
}
MarkWholeScreenDirty();
@@ -1495,24 +1490,24 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
virtual void OnPaint()
{
- const Player *p;
+ const Company *c;
uint x, y;
this->SetupHighScoreEndWindow(&x, &y);
- if (!IsValidPlayerID(_local_player)) return;
+ if (!IsValidCompanyID(_local_company)) return;
- p = GetPlayer(_local_player);
+ c = GetCompany(_local_company);
/* We need to get performance from last year because the image is shown
* at the start of the new year when these things have already been copied */
if (this->background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
- SetDParam(0, p->index);
- SetDParam(1, p->index);
- SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
+ SetDParam(0, c->index);
+ SetDParam(1, c->index);
+ SetDParam(2, EndGameGetPerformanceTitleFromValue(c->old_economy[0].performance_history));
DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640);
} else {
- SetDParam(0, p->index);
- SetDParam(1, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history));
+ SetDParam(0, c->index);
+ SetDParam(1, EndGameGetPerformanceTitleFromValue(c->old_economy[0].performance_history));
DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640);
}
}
diff --git a/src/player_gui.h b/src/player_gui.h
index a1ed36fcb..93f382789 100644
--- a/src/player_gui.h
+++ b/src/player_gui.h
@@ -1,20 +1,20 @@
/* $Id$ */
-/** @file player_gui.h GUI Functions related to players. */
+/** @file company_gui.h GUI Functions related to companies. */
-#ifndef PLAYER_GUI_H
-#define PLAYER_GUI_H
+#ifndef COMPANY_GUI_H
+#define COMPANY_GUI_H
#include "player_type.h"
-uint16 GetDrawStringPlayerColor(PlayerID player);
-void DrawPlayerIcon(PlayerID p, int x, int y);
+uint16 GetDrawStringCompanyColor(CompanyID company);
+void DrawCompanyIcon(CompanyID p, int x, int y);
-void ShowPlayerStations(PlayerID player);
-void ShowPlayerFinances(PlayerID player);
-void ShowPlayerCompany(PlayerID player);
+void ShowCompanyStations(CompanyID company);
+void ShowCompanyFinances(CompanyID company);
+void ShowCompany(CompanyID company);
-void InvalidatePlayerWindows(const Player *p);
-void DeletePlayerWindows(PlayerID pi);
+void InvalidateCompanyWindows(const Company *c);
+void DeleteCompanyWindows(CompanyID company);
-#endif /* PLAYER_GUI_H */
+#endif /* COMPANY_GUI_H */
diff --git a/src/player_type.h b/src/player_type.h
index aa7aea868..13ea10c48 100644
--- a/src/player_type.h
+++ b/src/player_type.h
@@ -1,32 +1,32 @@
/* $Id$ */
-/** @file player_type.h Types related to players. */
+/** @file company_type.h Types related to companies. */
-#ifndef PLAYER_TYPE_H
-#define PLAYER_TYPE_H
+#ifndef COMPANY_TYPE_H
+#define COMPANY_TYPE_H
#include "core/enum_type.hpp"
/**
- * Enum for all players/owners.
+ * Enum for all companies/owners.
*/
enum Owner {
- /* Player identifiers All players below MAX_PLAYERS are playable
- * players, above, they are special, computer controlled players */
- OWNER_BEGIN = 0x00, ///< First Owner
- PLAYER_FIRST = 0x00, ///< First Player, same as owner
- MAX_PLAYERS = 0x08, ///< Maximum numbe rof players
+ /* All companies below MAX_COMPANIES are playable
+ * companies, above, they are special, computer controlled 'companies' */
+ OWNER_BEGIN = 0x00, ///< First owner
+ COMPANY_FIRST = 0x00, ///< First company, same as owner
+ MAX_COMPANIES = 0x08, ///< Maximum number of companies
OWNER_TOWN = 0x0F, ///< A town owns the tile, or a town is expanding
OWNER_NONE = 0x10, ///< The tile has no ownership
OWNER_WATER = 0x11, ///< The tile/execution is done by "water"
OWNER_END, ///< Last + 1 owner
INVALID_OWNER = 0xFF, ///< An invalid owner
- INVALID_PLAYER = 0xFF, ///< And a valid owner
+ INVALID_COMPANY = 0xFF, ///< An invalid company
- /* 'Fake' Players used for networks */
- PLAYER_INACTIVE_CLIENT = 253, ///< The client is joining
- PLAYER_NEW_COMPANY = 254, ///< The client wants a new company
- PLAYER_SPECTATOR = 255, ///< The client is spectating
+ /* 'Fake' companies used for networks */
+ COMPANY_INACTIVE_CLIENT = 253, ///< The client is joining
+ COMPANY_NEW_COMPANY = 254, ///< The client wants a new company
+ COMPANY_SPECTATOR = 255, ///< The client is spectating
};
DECLARE_POSTFIX_INCREMENT(Owner);
@@ -41,12 +41,12 @@ enum {
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
typedef TinyEnumT<Owner> OwnerByte;
-typedef Owner PlayerID;
-typedef OwnerByte PlayerByte;
+typedef Owner CompanyID;
+typedef OwnerByte CompanyByte;
-typedef uint8 PlayerMask;
+typedef uint8 CompanyMask;
-struct Player;
-typedef uint32 PlayerFace; ///< player face bits, info see in player_face.h
+struct Company;
+typedef uint32 CompanyManagerFace; ///< Company manager face bits, info see in company_manager_face.h
-#endif /* PLAYER_TYPE_H */
+#endif /* COMPANY_TYPE_H */
diff --git a/src/players.cpp b/src/players.cpp
index dc3f8ef94..824c47c91 100644
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -1,6 +1,6 @@
/* $Id$ */
-/** @file players.cpp Handling of players. */
+/** @file company_cmd.cpp Handling of companies. */
#include "stdafx.h"
#include "openttd.h"
@@ -43,21 +43,21 @@
#include "table/strings.h"
#include "table/sprites.h"
-PlayerByte _local_player;
-PlayerByte _current_player;
-/* NOSAVE: can be determined from player structs */
-byte _player_colors[MAX_PLAYERS];
-PlayerFace _player_face; ///< for player face storage in openttd.cfg
+CompanyByte _local_company;
+CompanyByte _current_company;
+/* NOSAVE: can be determined from company structs */
+byte _company_colours[MAX_COMPANIES];
+CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
HighScore _highscore_table[5][5]; // 4 difficulty-settings (+ network); top 5
-DEFINE_OLD_POOL_GENERIC(Player, Player)
+DEFINE_OLD_POOL_GENERIC(Company, Company)
-Player::Player(uint16 name_1, bool is_ai) : name_1(name_1), is_ai(is_ai)
+Company::Company(uint16 name_1, bool is_ai) : name_1(name_1), is_ai(is_ai)
{
- for (uint j = 0; j < 4; j++) this->share_owners[j] = PLAYER_SPECTATOR;
+ for (uint j = 0; j < 4; j++) this->share_owners[j] = COMPANY_SPECTATOR;
}
-Player::~Player()
+Company::~Company()
{
free(this->name);
free(this->president_name);
@@ -65,26 +65,26 @@ Player::~Player()
if (CleaningPool()) return;
- DeletePlayerWindows(this->index);
+ DeleteCompanyWindows(this->index);
this->name_1 = 0;
}
/**
- * Sets the local player and updates the patch settings that are set on a
- * per-company (player) basis to reflect the core's state in the GUI.
- * @param new_player the new player
- * @pre IsValidPlayerID(new_player) || new_player == PLAYER_SPECTATOR || new_player == OWNER_NONE
+ * Sets the local company and updates the patch settings that are set on a
+ * per-company basis to reflect the core's state in the GUI.
+ * @param new_company the new company
+ * @pre IsValidCompanyID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE
*/
-void SetLocalPlayer(PlayerID new_player)
+void SetLocalCompany(CompanyID new_company)
{
- /* Player could also be PLAYER_SPECTATOR or OWNER_NONE */
- assert(IsValidPlayerID(new_player) || new_player == PLAYER_SPECTATOR || new_player == OWNER_NONE);
+ /* company could also be COMPANY_SPECTATOR or OWNER_NONE */
+ assert(IsValidCompanyID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
- _local_player = new_player;
+ _local_company = new_company;
/* Do not update the patches if we are in the intro GUI */
- if (IsValidPlayerID(new_player) && _game_mode != GM_MENU) {
- const Player *p = GetPlayer(new_player);
+ if (IsValidCompanyID(new_company) && _game_mode != GM_MENU) {
+ const Company *p = GetCompany(new_company);
_settings_client.gui.autorenew = p->engine_renew;
_settings_client.gui.autorenew_months = p->engine_renew_months;
_settings_client.gui.autorenew_money = p->engine_renew_money;
@@ -92,27 +92,27 @@ void SetLocalPlayer(PlayerID new_player)
}
}
-bool IsHumanPlayer(PlayerID pi)
+bool IsHumanCompany(CompanyID company)
{
- return !GetPlayer(pi)->is_ai;
+ return !GetCompany(company)->is_ai;
}
-uint16 GetDrawStringPlayerColor(PlayerID player)
+uint16 GetDrawStringCompanyColor(CompanyID company)
{
/* Get the color for DrawString-subroutines which matches the color
- * of the player */
- if (!IsValidPlayerID(player)) return _colour_gradient[COLOUR_WHITE][4] | IS_PALETTE_COLOR;
- return (_colour_gradient[_player_colors[player]][4]) | IS_PALETTE_COLOR;
+ * of the company */
+ if (!IsValidCompanyID(company)) return _colour_gradient[COLOUR_WHITE][4] | IS_PALETTE_COLOR;
+ return (_colour_gradient[_company_colours[company]][4]) | IS_PALETTE_COLOR;
}
-void DrawPlayerIcon(PlayerID p, int x, int y)
+void DrawCompanyIcon(CompanyID p, int x, int y)
{
- DrawSprite(SPR_PLAYER_ICON, PLAYER_SPRITE_COLOR(p), x, y);
+ DrawSprite(SPR_PLAYER_ICON, COMPANY_SPRITE_COLOR(p), x, y);
}
/**
- * Converts an old player face format to the new player face format
+ * Converts an old company manager's face format to the new company manager's face format
*
* Meaning of the bits in the old face (some bits are used in several times):
* - 4 and 5: chin
@@ -129,100 +129,100 @@ void DrawPlayerIcon(PlayerID p, int x, int y)
* @param face the face in the old format
* @return the face in the new format
*/
-PlayerFace ConvertFromOldPlayerFace(uint32 face)
+CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
{
- PlayerFace pf = 0;
+ CompanyManagerFace cmf = 0;
GenderEthnicity ge = GE_WM;
if (HasBit(face, 31)) SetBit(ge, GENDER_FEMALE);
if (HasBit(face, 27) && (HasBit(face, 26) == HasBit(face, 19))) SetBit(ge, ETHNICITY_BLACK);
- SetPlayerFaceBits(pf, PFV_GEN_ETHN, ge, ge);
- SetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge, GB(face, 28, 3) <= 1);
- SetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge, HasBit(ge, ETHNICITY_BLACK) ? 0 : ClampU(GB(face, 20, 3), 5, 7) - 5);
- SetPlayerFaceBits(pf, PFV_CHIN, ge, ScalePlayerFaceValue(PFV_CHIN, ge, GB(face, 4, 2)));
- SetPlayerFaceBits(pf, PFV_EYEBROWS, ge, ScalePlayerFaceValue(PFV_EYEBROWS, ge, GB(face, 6, 4)));
- SetPlayerFaceBits(pf, PFV_HAIR, ge, ScalePlayerFaceValue(PFV_HAIR, ge, GB(face, 16, 4)));
- SetPlayerFaceBits(pf, PFV_JACKET, ge, ScalePlayerFaceValue(PFV_JACKET, ge, GB(face, 20, 2)));
- SetPlayerFaceBits(pf, PFV_COLLAR, ge, ScalePlayerFaceValue(PFV_COLLAR, ge, GB(face, 22, 2)));
- SetPlayerFaceBits(pf, PFV_GLASSES, ge, GB(face, 28, 1));
+ SetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, ge, ge);
+ SetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge, GB(face, 28, 3) <= 1);
+ SetCompanyManagerFaceBits(cmf, CMFV_EYE_COLOUR, ge, HasBit(ge, ETHNICITY_BLACK) ? 0 : ClampU(GB(face, 20, 3), 5, 7) - 5);
+ SetCompanyManagerFaceBits(cmf, CMFV_CHIN, ge, ScaleCompanyManagerFaceValue(CMFV_CHIN, ge, GB(face, 4, 2)));
+ SetCompanyManagerFaceBits(cmf, CMFV_EYEBROWS, ge, ScaleCompanyManagerFaceValue(CMFV_EYEBROWS, ge, GB(face, 6, 4)));
+ SetCompanyManagerFaceBits(cmf, CMFV_HAIR, ge, ScaleCompanyManagerFaceValue(CMFV_HAIR, ge, GB(face, 16, 4)));
+ SetCompanyManagerFaceBits(cmf, CMFV_JACKET, ge, ScaleCompanyManagerFaceValue(CMFV_JACKET, ge, GB(face, 20, 2)));
+ SetCompanyManagerFaceBits(cmf, CMFV_COLLAR, ge, ScaleCompanyManagerFaceValue(CMFV_COLLAR, ge, GB(face, 22, 2)));
+ SetCompanyManagerFaceBits(cmf, CMFV_GLASSES, ge, GB(face, 28, 1));
uint lips = GB(face, 10, 4);
if (!HasBit(ge, GENDER_FEMALE) && lips < 4) {
- SetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE, ge, true);
- SetPlayerFaceBits(pf, PFV_MOUSTACHE, ge, max(lips, 1U) - 1);
+ SetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge, true);
+ SetCompanyManagerFaceBits(cmf, CMFV_MOUSTACHE, ge, max(lips, 1U) - 1);
} else {
if (!HasBit(ge, GENDER_FEMALE)) {
lips = lips * 15 / 16;
lips -= 3;
if (HasBit(ge, ETHNICITY_BLACK) && lips > 8) lips = 0;
} else {
- lips = ScalePlayerFaceValue(PFV_LIPS, ge, lips);
+ lips = ScaleCompanyManagerFaceValue(CMFV_LIPS, ge, lips);
}
- SetPlayerFaceBits(pf, PFV_LIPS, ge, lips);
+ SetCompanyManagerFaceBits(cmf, CMFV_LIPS, ge, lips);
uint nose = GB(face, 13, 3);
if (ge == GE_WF) {
nose = (nose * 3 >> 3) * 3 >> 2; // There is 'hole' in the nose sprites for females
} else {
- nose = ScalePlayerFaceValue(PFV_NOSE, ge, nose);
+ nose = ScaleCompanyManagerFaceValue(CMFV_NOSE, ge, nose);
}
- SetPlayerFaceBits(pf, PFV_NOSE, ge, nose);
+ SetCompanyManagerFaceBits(cmf, CMFV_NOSE, ge, nose);
}
uint tie_earring = GB(face, 24, 4);
if (!HasBit(ge, GENDER_FEMALE) || tie_earring < 3) { // Not all females have an earring
- if (HasBit(ge, GENDER_FEMALE)) SetPlayerFaceBits(pf, PFV_HAS_TIE_EARRING, ge, true);
- SetPlayerFaceBits(pf, PFV_TIE_EARRING, ge, HasBit(ge, GENDER_FEMALE) ? tie_earring : ScalePlayerFaceValue(PFV_TIE_EARRING, ge, tie_earring / 2));
+ if (HasBit(ge, GENDER_FEMALE)) SetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge, true);
+ SetCompanyManagerFaceBits(cmf, CMFV_TIE_EARRING, ge, HasBit(ge, GENDER_FEMALE) ? tie_earring : ScaleCompanyManagerFaceValue(CMFV_TIE_EARRING, ge, tie_earring / 2));
}
- return pf;
+ return cmf;
}
/**
- * Checks whether a player's face is a valid encoding.
+ * Checks whether a company manager's face is a valid encoding.
* Unused bits are not enforced to be 0.
- * @param pf the fact to check
+ * @param cmf the fact to check
* @return true if and only if the face is valid
*/
-bool IsValidPlayerIDFace(PlayerFace pf)
+bool IsValidCompanyManagerFace(CompanyManagerFace cmf)
{
- if (!ArePlayerFaceBitsValid(pf, PFV_GEN_ETHN, GE_WM)) return false;
-
- GenderEthnicity ge = (GenderEthnicity)GetPlayerFaceBits(pf, PFV_GEN_ETHN, GE_WM);
- bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetPlayerFaceBits(pf, PFV_HAS_MOUSTACHE, ge) != 0;
- bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetPlayerFaceBits(pf, PFV_HAS_TIE_EARRING, ge) != 0;
- bool has_glasses = GetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge) != 0;
-
- if (!ArePlayerFaceBitsValid(pf, PFV_EYE_COLOUR, ge)) return false;
- for (PlayerFaceVariable pfv = PFV_CHEEKS; pfv < PFV_END; pfv++) {
- switch (pfv) {
- case PFV_MOUSTACHE: if (!has_moustache) continue; break;
- case PFV_LIPS: /* FALL THROUGH */
- case PFV_NOSE: if (has_moustache) continue; break;
- case PFV_TIE_EARRING: if (!has_tie_earring) continue; break;
- case PFV_GLASSES: if (!has_glasses) continue; break;
+ if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_GEN_ETHN, GE_WM)) return false;
+
+ GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM);
+ bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0;
+ bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
+ bool has_glasses = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
+
+ if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_EYE_COLOUR, ge)) return false;
+ for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
+ switch (cmfv) {
+ case CMFV_MOUSTACHE: if (!has_moustache) continue; break;
+ case CMFV_LIPS: /* FALL THROUGH */
+ case CMFV_NOSE: if (has_moustache) continue; break;
+ case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
+ case CMFV_GLASSES: if (!has_glasses) continue; break;
default: break;
}
- if (!ArePlayerFaceBitsValid(pf, pfv, ge)) return false;
+ if (!AreCompanyManagerFaceBitsValid(cmf, cmfv, ge)) return false;
}
return true;
}
-void InvalidatePlayerWindows(const Player *p)
+void InvalidateCompanyWindows(const Company *company)
{
- PlayerID pid = p->index;
+ CompanyID cid = company->index;
- if (pid == _local_player) InvalidateWindow(WC_STATUS_BAR, 0);
- InvalidateWindow(WC_FINANCES, pid);
+ if (cid == _local_company) InvalidateWindow(WC_STATUS_BAR, 0);
+ InvalidateWindow(WC_FINANCES, cid);
}
-bool CheckPlayerHasMoney(CommandCost cost)
+bool CheckCompanyHasMoney(CommandCost cost)
{
if (cost.GetCost() > 0) {
- PlayerID pid = _current_player;
- if (IsValidPlayerID(pid) && cost.GetCost() > GetPlayer(pid)->player_money) {
+ CompanyID company = _current_company;
+ if (IsValidCompanyID(company) && cost.GetCost() > GetCompany(company)->money) {
SetDParam(0, cost.GetCost());
_error_message = STR_0003_NOT_ENOUGH_CASH_REQUIRES;
return false;
@@ -231,48 +231,48 @@ bool CheckPlayerHasMoney(CommandCost cost)
return true;
}
-static void SubtractMoneyFromAnyPlayer(Player *p, CommandCost cost)
+static void SubtractMoneyFromAnyCompany(Company *c, CommandCost cost)
{
if (cost.GetCost() == 0) return;
assert(cost.GetExpensesType() != INVALID_EXPENSES);
- p->player_money -= cost.GetCost();
- p->yearly_expenses[0][cost.GetExpensesType()] += cost.GetCost();
+ c->money -= cost.GetCost();
+ c->yearly_expenses[0][cost.GetExpensesType()] += cost.GetCost();
if (HasBit(1 << EXPENSES_TRAIN_INC |
1 << EXPENSES_ROADVEH_INC |
1 << EXPENSES_AIRCRAFT_INC |
1 << EXPENSES_SHIP_INC, cost.GetExpensesType())) {
- p->cur_economy.income -= cost.GetCost();
+ c->cur_economy.income -= cost.GetCost();
} else if (HasBit(1 << EXPENSES_TRAIN_RUN |
1 << EXPENSES_ROADVEH_RUN |
1 << EXPENSES_AIRCRAFT_RUN |
1 << EXPENSES_SHIP_RUN |
1 << EXPENSES_PROPERTY |
1 << EXPENSES_LOAN_INT, cost.GetExpensesType())) {
- p->cur_economy.expenses -= cost.GetCost();
+ c->cur_economy.expenses -= cost.GetCost();
}
- InvalidatePlayerWindows(p);
+ InvalidateCompanyWindows(c);
}
-void SubtractMoneyFromPlayer(CommandCost cost)
+void SubtractMoneyFromCompany(CommandCost cost)
{
- PlayerID pid = _current_player;
+ CompanyID cid = _current_company;
- if (IsValidPlayerID(pid)) SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
+ if (IsValidCompanyID(cid)) SubtractMoneyFromAnyCompany(GetCompany(cid), cost);
}
-void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cst)
+void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cst)
{
- Player *p = GetPlayer(player);
- byte m = p->player_money_fraction;
+ Company *c = GetCompany(company);
+ byte m = c->money_fraction;
Money cost = cst.GetCost();
- p->player_money_fraction = m - (byte)cost;
+ c->money_fraction = m - (byte)cost;
cost >>= 8;
- if (p->player_money_fraction > m) cost++;
- if (cost != 0) SubtractMoneyFromAnyPlayer(p, CommandCost(cst.GetExpensesType(), cost));
+ if (c->money_fraction > m) cost++;
+ if (cost != 0) SubtractMoneyFromAnyCompany(c, CommandCost(cst.GetExpensesType(), cost));
}
void GetNameOfOwner(Owner owner, TileIndex tile)
@@ -280,16 +280,14 @@ void GetNameOfOwner(Owner owner, TileIndex tile)
SetDParam(2, owner);
if (owner != OWNER_TOWN) {
- if (!IsValidPlayerID(owner)) {
+ if (!IsValidCompanyID(owner)) {
SetDParam(0, STR_0150_SOMEONE);
} else {
- const Player* p = GetPlayer(owner);
-
SetDParam(0, STR_COMPANY_NAME);
- SetDParam(1, p->index);
+ SetDParam(1, owner);
}
} else {
- const Town* t = ClosestTownFromTile(tile, (uint)-1);
+ const Town *t = ClosestTownFromTile(tile, (uint)-1);
SetDParam(0, STR_TOWN);
SetDParam(1, t->index);
@@ -297,11 +295,11 @@ void GetNameOfOwner(Owner owner, TileIndex tile)
}
-bool CheckOwnership(PlayerID owner)
+bool CheckOwnership(Owner owner)
{
assert(owner < OWNER_END);
- if (owner == _current_player) return true;
+ if (owner == _current_company) return true;
_error_message = STR_013B_OWNED_BY;
GetNameOfOwner(owner, 0);
return false;
@@ -313,26 +311,26 @@ bool CheckTileOwnership(TileIndex tile)
assert(owner < OWNER_END);
- if (owner == _current_player) return true;
+ if (owner == _current_company) return true;
_error_message = STR_013B_OWNED_BY;
- /* no need to get the name of the owner unless we're the local player (saves some time) */
- if (IsLocalPlayer()) GetNameOfOwner(owner, tile);
+ /* no need to get the name of the owner unless we're the local company (saves some time) */
+ if (IsLocalCompany()) GetNameOfOwner(owner, tile);
return false;
}
-static void GenerateCompanyName(Player *p)
+static void GenerateCompanyName(Company *c)
{
TileIndex tile;
Town *t;
StringID str;
- Player *pp;
+ Company *cc;
uint32 strp;
char buffer[100];
- if (p->name_1 != STR_SV_UNNAMED) return;
+ if (c->name_1 != STR_SV_UNNAMED) return;
- tile = p->last_build_coordinate;
+ tile = c->last_build_coordinate;
if (tile == 0) return;
t = ClosestTownFromTile(tile, (uint)-1);
@@ -342,36 +340,36 @@ static void GenerateCompanyName(Player *p)
strp = t->townnameparts;
verify_name:;
- /* No player must have this name already */
- FOR_ALL_PLAYERS(pp) {
- if (pp->name_1 == str && pp->name_2 == strp) goto bad_town_name;
+ /* No companies must have this name already */
+ FOR_ALL_COMPANIES(cc) {
+ if (cc->name_1 == str && cc->name_2 == strp) goto bad_town_name;
}
GetString(buffer, str, lastof(buffer));
if (strlen(buffer) >= MAX_LENGTH_COMPANY_NAME_BYTES) goto bad_town_name;
set_name:;
- p->name_1 = str;
- p->name_2 = strp;
+ c->name_1 = str;
+ c->name_2 = strp;
MarkWholeScreenDirty();
- if (!IsHumanPlayer(p->index)) {
+ if (!IsHumanCompany(c->index)) {
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
- cni->FillData(p);
+ cni->FillData(c);
SetDParam(0, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED);
SetDParam(1, STR_705F_STARTS_CONSTRUCTION_NEAR);
SetDParamStr(2, cni->company_name);
SetDParam(3, t->index);
- AddNewsItem(STR_02B6, NS_COMPANY_NEW, p->last_build_coordinate, 0, cni);
+ AddNewsItem(STR_02B6, NS_COMPANY_NEW, c->last_build_coordinate, 0, cni);
}
return;
}
bad_town_name:;
- if (p->president_name_1 == SPECSTR_PRESIDENT_NAME) {
+ if (c->president_name_1 == SPECSTR_PRESIDENT_NAME) {
str = SPECSTR_ANDCO_NAME;
- strp = p->president_name_2;
+ strp = c->president_name_2;
goto set_name;
} else {
str = SPECSTR_ANDCO_NAME;
@@ -400,7 +398,7 @@ static const Colours _similar_colour[COLOUR_END][2] = {
{ COLOUR_GREY, INVALID_COLOUR }, // COLOUR_WHITE
};
-static byte GeneratePlayerColour()
+static byte GenerateCompanyColour()
{
Colours colours[COLOUR_END];
@@ -422,10 +420,10 @@ static byte GeneratePlayerColour()
}
};
- /* Move the colors that look similar to each player's color to the side */
- Player *p;
- FOR_ALL_PLAYERS(p) {
- Colours pcolour = (Colours)p->player_color;
+ /* Move the colors that look similar to each company's color to the side */
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ Colours pcolour = (Colours)c->colour;
for (uint i = 0; i < COLOUR_END; i++) {
if (colours[i] == pcolour) {
@@ -452,25 +450,25 @@ static byte GeneratePlayerColour()
NOT_REACHED();
}
-static void GeneratePresidentName(Player *p)
+static void GeneratePresidentName(Company *c)
{
- Player *pp;
+ Company *cc;
char buffer[100], buffer2[40];
for (;;) {
restart:;
- p->president_name_2 = Random();
- p->president_name_1 = SPECSTR_PRESIDENT_NAME;
+ c->president_name_2 = Random();
+ c->president_name_1 = SPECSTR_PRESIDENT_NAME;
- SetDParam(0, p->index);
+ SetDParam(0, c->index);
GetString(buffer, STR_PLAYER_NAME, lastof(buffer));
if (strlen(buffer) >= 32 || GetStringBoundingBox(buffer).width >= 94)
continue;
- FOR_ALL_PLAYERS(pp) {
- if (p != pp) {
- SetDParam(0, pp->index);
+ FOR_ALL_COMPANIES(cc) {
+ if (c != cc) {
+ SetDParam(0, cc->index);
GetString(buffer2, STR_PLAYER_NAME, lastof(buffer2));
if (strcmp(buffer2, buffer) == 0)
goto restart;
@@ -480,81 +478,81 @@ restart:;
}
}
-void ResetPlayerLivery(Player *p)
+void ResetCompanyLivery(Company *c)
{
for (LiveryScheme scheme = LS_BEGIN; scheme < LS_END; scheme++) {
- p->livery[scheme].in_use = false;
- p->livery[scheme].colour1 = p->player_color;
- p->livery[scheme].colour2 = p->player_color;
+ c->livery[scheme].in_use = false;
+ c->livery[scheme].colour1 = c->colour;
+ c->livery[scheme].colour2 = c->colour;
}
}
/**
- * Create a new player and sets all player variables default values
+ * Create a new company and sets all company variables default values
*
- * @param is_ai is a ai player?
- * @return the player struct
+ * @param is_ai is a ai company?
+ * @return the company struct
*/
-Player *DoStartupNewPlayer(bool is_ai)
+Company *DoStartupNewCompany(bool is_ai)
{
- if (!Player::CanAllocateItem()) return NULL;
+ if (!Company::CanAllocateItem()) return NULL;
- Player *p = new Player(STR_SV_UNNAMED, is_ai);
+ Company *c = new Company(STR_SV_UNNAMED, is_ai);
- memset(&_players_ai[p->index], 0, sizeof(PlayerAI));
- memset(&_players_ainew[p->index], 0, sizeof(PlayerAiNew));
+ memset(&_companies_ai[c->index], 0, sizeof(CompanyAI));
+ memset(&_companies_ainew[c->index], 0, sizeof(CompanyAiNew));
/* Make a color */
- p->player_color = GeneratePlayerColour();
- ResetPlayerLivery(p);
- _player_colors[p->index] = p->player_color;
+ c->colour = GenerateCompanyColour();
+ ResetCompanyLivery(c);
+ _company_colours[c->index] = c->colour;
- p->player_money = p->current_loan = 100000;
+ c->money = c->current_loan = 100000;
- _players_ai[p->index].state = 5; // AIS_WANT_NEW_ROUTE
- p->share_owners[0] = p->share_owners[1] = p->share_owners[2] = p->share_owners[3] = PLAYER_SPECTATOR;
+ _companies_ai[c->index].state = 5; // AIS_WANT_NEW_ROUTE
+ c->share_owners[0] = c->share_owners[1] = c->share_owners[2] = c->share_owners[3] = INVALID_OWNER;
- p->avail_railtypes = GetPlayerRailtypes(p->index);
- p->avail_roadtypes = GetPlayerRoadtypes(p->index);
- p->inaugurated_year = _cur_year;
- RandomPlayerFaceBits(p->face, (GenderEthnicity)Random(), false); // create a random player face
+ c->avail_railtypes = GetCompanyRailtypes(c->index);
+ c->avail_roadtypes = GetCompanyRoadtypes(c->index);
+ c->inaugurated_year = _cur_year;
+ RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false); // create a random company manager face
/* Engine renewal settings */
- p->engine_renew_list = NULL;
- p->renew_keep_length = false;
- p->engine_renew = _settings_client.gui.autorenew;
- p->engine_renew_months = _settings_client.gui.autorenew_months;
- p->engine_renew_money = _settings_client.gui.autorenew_money;
+ c->engine_renew_list = NULL;
+ c->renew_keep_length = false;
+ c->engine_renew = _settings_client.gui.autorenew;
+ c->engine_renew_months = _settings_client.gui.autorenew_months;
+ c->engine_renew_money = _settings_client.gui.autorenew_money;
- GeneratePresidentName(p);
+ GeneratePresidentName(c);
InvalidateWindow(WC_GRAPH_LEGEND, 0);
InvalidateWindow(WC_TOOLBAR_MENU, 0);
InvalidateWindow(WC_CLIENT_LIST, 0);
if (is_ai && (!_networking || _network_server) && _ai.enabled)
- AI_StartNewAI(p->index);
+ AI_StartNewAI(c->index);
- p->num_engines = CallocT<uint16>(GetEnginePoolSize());
+ c->num_engines = CallocT<uint16>(GetEnginePoolSize());
- return p;
+ return c;
}
-void StartupPlayers()
+void StartupCompanies()
{
/* The AI starts like in the setting with +2 month max */
_next_competitor_start = _settings_game.difficulty.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1;
}
-static void MaybeStartNewPlayer()
+static void MaybeStartNewCompany()
{
uint n;
- Player *p;
+ Company *c;
/* count number of competitors */
n = 0;
- FOR_ALL_PLAYERS(p) {
- if (p->is_ai) n++;
+ FOR_ALL_COMPANIES(c) {
+ if (c->is_ai) n++;
}
/* when there's a lot of computers in game, the probability that a new one starts is lower */
@@ -565,7 +563,7 @@ static void MaybeStartNewPlayer()
)) {
/* Send a command to all clients to start up a new AI.
* Works fine for Multiplayer and Singleplayer */
- DoCommandP(0, 1, 0, NULL, CMD_PLAYER_CTRL);
+ DoCommandP(0, 1, 0, NULL, CMD_COMPANY_CTRL);
}
/* The next AI starts like the difficulty setting said, with +2 month max */
@@ -573,44 +571,44 @@ static void MaybeStartNewPlayer()
_next_competitor_start += _network_server ? InteractiveRandomRange(60 * DAY_TICKS) : RandomRange(60 * DAY_TICKS);
}
-void InitializePlayers()
+void InitializeCompanies()
{
- _Player_pool.CleanPool();
- _Player_pool.AddBlockToPool();
- _cur_player_tick_index = 0;
+ _Company_pool.CleanPool();
+ _Company_pool.AddBlockToPool();
+ _cur_company_tick_index = 0;
}
-void OnTick_Players()
+void OnTick_Companies()
{
if (_game_mode == GM_EDITOR) return;
- if (IsValidPlayerID((PlayerID)_cur_player_tick_index)) {
- Player *p = GetPlayer((PlayerID)_cur_player_tick_index);
- if (p->name_1 != 0) GenerateCompanyName(p);
+ if (IsValidCompanyID((CompanyID)_cur_company_tick_index)) {
+ Company *c = GetCompany((CompanyID)_cur_company_tick_index);
+ if (c->name_1 != 0) GenerateCompanyName(c);
if (AI_AllowNewAI() && _game_mode != GM_MENU && !--_next_competitor_start) {
- MaybeStartNewPlayer();
+ MaybeStartNewCompany();
}
}
- _cur_player_tick_index = (_cur_player_tick_index + 1) % MAX_PLAYERS;
+ _cur_company_tick_index = (_cur_company_tick_index + 1) % MAX_COMPANIES;
}
-void PlayersYearlyLoop()
+void CompaniesYearlyLoop()
{
- Player *p;
+ Company *c;
/* Copy statistics */
- FOR_ALL_PLAYERS(p) {
- memmove(&p->yearly_expenses[1], &p->yearly_expenses[0], sizeof(p->yearly_expenses) - sizeof(p->yearly_expenses[0]));
- memset(&p->yearly_expenses[0], 0, sizeof(p->yearly_expenses[0]));
- InvalidateWindow(WC_FINANCES, p->index);
+ FOR_ALL_COMPANIES(c) {
+ memmove(&c->yearly_expenses[1], &c->yearly_expenses[0], sizeof(c->yearly_expenses) - sizeof(c->yearly_expenses[0]));
+ memset(&c->yearly_expenses[0], 0, sizeof(c->yearly_expenses[0]));
+ InvalidateWindow(WC_FINANCES, c->index);
}
- if (_settings_client.gui.show_finances && _local_player != PLAYER_SPECTATOR) {
- ShowPlayerFinances(_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) {
+ if (_settings_client.gui.show_finances && _local_company != COMPANY_SPECTATOR) {
+ ShowCompanyFinances(_local_company);
+ c = GetCompany(_local_company);
+ if (c->num_valid_stat_ent > 5 && c->old_economy[0].performance_history < c->old_economy[4].performance_history) {
SndPlayFx(SND_01_BAD_YEAR);
} else {
SndPlayFx(SND_00_GOOD_YEAR);
@@ -648,17 +646,17 @@ void PlayersYearlyLoop()
*/
CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- if (!IsValidPlayerID(_current_player)) return CMD_ERROR;
+ if (!IsValidCompanyID(_current_company)) return CMD_ERROR;
- Player *p = GetPlayer(_current_player);
+ Company *c = GetCompany(_current_company);
switch (GB(p1, 0, 3)) {
case 0:
- if (p->engine_renew == HasBit(p2, 0)) return CMD_ERROR;
+ if (c->engine_renew == HasBit(p2, 0)) return CMD_ERROR;
if (flags & DC_EXEC) {
- p->engine_renew = HasBit(p2, 0);
- if (IsLocalPlayer()) {
- _settings_client.gui.autorenew = p->engine_renew;
+ c->engine_renew = HasBit(p2, 0);
+ if (IsLocalCompany()) {
+ _settings_client.gui.autorenew = c->engine_renew;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
@@ -666,12 +664,12 @@ CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
case 1:
if (Clamp((int16)p2, -12, 12) != (int16)p2) return CMD_ERROR;
- if (p->engine_renew_months == (int16)p2) return CMD_ERROR;
+ if (c->engine_renew_months == (int16)p2) return CMD_ERROR;
if (flags & DC_EXEC) {
- p->engine_renew_months = (int16)p2;
- if (IsLocalPlayer()) {
- _settings_client.gui.autorenew_months = p->engine_renew_months;
+ c->engine_renew_months = (int16)p2;
+ if (IsLocalCompany()) {
+ _settings_client.gui.autorenew_months = c->engine_renew_months;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
@@ -679,12 +677,12 @@ CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
case 2:
if (ClampU(p2, 0, 2000000) != p2) return CMD_ERROR;
- if (p->engine_renew_money == p2) return CMD_ERROR;
+ if (c->engine_renew_money == p2) return CMD_ERROR;
if (flags & DC_EXEC) {
- p->engine_renew_money = p2;
- if (IsLocalPlayer()) {
- _settings_client.gui.autorenew_money = p->engine_renew_money;
+ c->engine_renew_money = p2;
+ if (IsLocalCompany()) {
+ _settings_client.gui.autorenew_money = c->engine_renew_money;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
@@ -698,14 +696,14 @@ CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
if (!IsValidGroupID(id_g) && !IsAllGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR;
if (new_engine_type != INVALID_ENGINE) {
- if (!CheckAutoreplaceValidity(old_engine_type, new_engine_type, _current_player)) return CMD_ERROR;
+ if (!CheckAutoreplaceValidity(old_engine_type, new_engine_type, _current_company)) return CMD_ERROR;
- cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, id_g, flags);
+ cost = AddEngineReplacementForCompany(c, old_engine_type, new_engine_type, id_g, flags);
} else {
- cost = RemoveEngineReplacementForPlayer(p, old_engine_type, id_g, flags);
+ cost = RemoveEngineReplacementForCompany(c, old_engine_type, id_g, flags);
}
- if (IsLocalPlayer()) InvalidateAutoreplaceWindow(old_engine_type, id_g);
+ if (IsLocalCompany()) InvalidateAutoreplaceWindow(old_engine_type, id_g);
return cost;
}
@@ -715,25 +713,25 @@ CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
if (ClampU(p2, 0, 2000000) != p2) return CMD_ERROR;
if (flags & DC_EXEC) {
- p->engine_renew = HasBit(p1, 15);
- p->engine_renew_months = (int16)GB(p1, 16, 16);
- p->engine_renew_money = p2;
-
- if (IsLocalPlayer()) {
- _settings_client.gui.autorenew = p->engine_renew;
- _settings_client.gui.autorenew_months = p->engine_renew_months;
- _settings_client.gui.autorenew_money = p->engine_renew_money;
+ c->engine_renew = HasBit(p1, 15);
+ c->engine_renew_months = (int16)GB(p1, 16, 16);
+ c->engine_renew_money = p2;
+
+ if (IsLocalCompany()) {
+ _settings_client.gui.autorenew = c->engine_renew;
+ _settings_client.gui.autorenew_months = c->engine_renew_months;
+ _settings_client.gui.autorenew_money = c->engine_renew_money;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
break;
case 5:
- if (p->renew_keep_length == HasBit(p2, 0)) return CMD_ERROR;
+ if (c->renew_keep_length == HasBit(p2, 0)) return CMD_ERROR;
if (flags & DC_EXEC) {
- p->renew_keep_length = HasBit(p2, 0);
- if (IsLocalPlayer()) {
+ c->renew_keep_length = HasBit(p2, 0);
+ if (IsLocalCompany()) {
InvalidateWindow(WC_REPLACE_VEHICLE, VEH_TRAIN);
}
}
@@ -748,9 +746,9 @@ CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
* @param p the current company.
* @param other the other company.
*/
-void CompanyNewsInformation::FillData(const Player *p, const Player *other)
+void CompanyNewsInformation::FillData(const Company *c, const Company *other)
{
- SetDParam(0, p->index);
+ SetDParam(0, c->index);
GetString(this->company_name, STR_COMPANY_NAME, lastof(this->company_name));
if (other == NULL) {
@@ -758,184 +756,184 @@ void CompanyNewsInformation::FillData(const Player *p, const Player *other)
} else {
SetDParam(0, other->index);
GetString(this->other_company_name, STR_COMPANY_NAME, lastof(this->other_company_name));
- p = other;
+ c = other;
}
- SetDParam(0, p->index);
+ SetDParam(0, c->index);
GetString(this->president_name, STR_7058_PRESIDENT, lastof(this->president_name));
- this->colour = p->player_color;
- this->face = p->face;
+ this->colour = c->colour;
+ this->face = c->face;
}
-/** Control the players: add, delete, etc.
+/** Control the companies: add, delete, etc.
* @param tile unused
* @param flags operation to perform
* @param p1 various functionality
- * - p1 = 0 - create a new player, Which player (network) it will be is in p2
- * - p1 = 1 - create a new AI player
- * - p1 = 2 - delete a player. Player is identified by p2
- * - p1 = 3 - merge two companies together. Player to merge #1 with player #2. Identified by p2
+ * - p1 = 0 - create a new company, Which company (network) it will be is in p2
+ * - p1 = 1 - create a new AI company
+ * - p1 = 2 - delete a company. Company is identified by p2
+ * - p1 = 3 - merge two companies together. merge #1 with #2. Identified by p2
* @param p2 various functionality, dictated by p1
- * - p1 = 0 - ClientID of the newly created player
- * - p1 = 2 - PlayerID of the that is getting deleted
- * - p1 = 3 - #1 p2 = (bit 0-15) - player to merge (p2 & 0xFFFF)
- * - #2 p2 = (bit 16-31) - player to be merged into ((p2>>16)&0xFFFF)
- * @todo In the case of p1=0, create new player, the clientID of the new player is in parameter
+ * - p1 = 0 - ClientID of the newly created client
+ * - p1 = 2 - CompanyID of the that is getting deleted
+ * - p1 = 3 - #1 p2 = (bit 0-15) - company to merge (p2 & 0xFFFF)
+ * - #2 p2 = (bit 16-31) - company to be merged into ((p2>>16)&0xFFFF)
+ * @todo In the case of p1=0, create new company, the clientID of the new client is in parameter
* p2. This parameter is passed in at function DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
* on the server itself. First of all this is unbelievably ugly; second of all, well,
* it IS ugly! <b>Someone fix this up :)</b> So where to fix?@n
* @arg - network_server.c:838 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)@n
* @arg - network_client.c:536 DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) from where the map has been received
*/
-CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- if (flags & DC_EXEC) _current_player = OWNER_NONE;
+ if (flags & DC_EXEC) _current_company = OWNER_NONE;
InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0);
switch (p1) {
- case 0: { /* Create a new player */
- /* This command is only executed in a multiplayer game */
- if (!_networking) return CMD_ERROR;
+ case 0: { /* Create a new company */
+ /* This command is only executed in a multiplayer game */
+ if (!_networking) return CMD_ERROR;
#ifdef ENABLE_NETWORK
- /* Joining Client:
- * _local_player: PLAYER_SPECTATOR
- * _network_playas/cid = requested company/player
- *
- * Other client(s)/server:
- * _local_player/_network_playas: what they play as
- * cid = requested company/player of joining client */
- uint16 cid = p2; // ClientID
+ /* Joining Client:
+ * _local_company: COMPANY_SPECTATOR
+ * _network_playas/cid = requested company/clientid
+ *
+ * Other client(s)/server:
+ * _local_company/_network_playas: what they play as
+ * cid = requested company/company of joining client */
+ uint16 cid = p2; // ClientID
+
+ /* Has the network client a correct ClientID? */
+ if (!(flags & DC_EXEC)) return CommandCost();
+ if (cid >= MAX_CLIENT_INFO) return CommandCost();
+
+ /* Delete multiplayer progress bar */
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+
+ Company *c = DoStartupNewCompany(false);
+
+ /* A new company could not be created, revert to being a spectator */
+ if (c == NULL) {
+ if (_network_server) {
+ NetworkClientInfo *ci = &_network_client_info[cid];
+ ci->client_playas = COMPANY_SPECTATOR;
+ NetworkUpdateClientInfo(ci->client_index);
+ } else if (_local_company == COMPANY_SPECTATOR) {
+ _network_playas = COMPANY_SPECTATOR;
+ }
+ break;
+ }
+
+ /* This is the joining client who wants a new company */
+ if (_local_company != _network_playas && _network_playas == c->index) {
+ assert(_local_company == COMPANY_SPECTATOR);
+ SetLocalCompany(c->index);
+ if (!StrEmpty(_settings_client.network.default_company_pass)) {
+ char *password = _settings_client.network.default_company_pass;
+ NetworkChangeCompanyPassword(1, &password);
+ }
- /* Has the network client a correct ClientID? */
- if (!(flags & DC_EXEC)) return CommandCost();
- if (cid >= MAX_CLIENT_INFO) return CommandCost();
+ _current_company = _local_company;
- /* Delete multiplayer progress bar */
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ /* Now that we have a new company, broadcast our autorenew settings to
+ * all clients so everything is in sync */
+ NetworkSend_Command(0,
+ (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4,
+ _settings_client.gui.autorenew_money,
+ CMD_SET_AUTOREPLACE,
+ NULL
+ );
- Player *p = DoStartupNewPlayer(false);
+ MarkWholeScreenDirty();
+ }
- /* A new player could not be created, revert to being a spectator */
- if (p == NULL) {
if (_network_server) {
+ /* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
+ * server-side in network_server.c:838, function
+ * DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
NetworkClientInfo *ci = &_network_client_info[cid];
- ci->client_playas = PLAYER_SPECTATOR;
+ ci->client_playas = c->index;
NetworkUpdateClientInfo(ci->client_index);
- } else if (_local_player == PLAYER_SPECTATOR) {
- _network_playas = PLAYER_SPECTATOR;
- }
- break;
- }
-
- /* This is the joining client who wants a new company */
- if (_local_player != _network_playas && _network_playas == p->index) {
- assert(_local_player == PLAYER_SPECTATOR);
- SetLocalPlayer(p->index);
- if (!StrEmpty(_settings_client.network.default_company_pass)) {
- char *password = _settings_client.network.default_company_pass;
- NetworkChangeCompanyPassword(1, &password);
- }
- _current_player = _local_player;
-
- /* Now that we have a new player, broadcast our autorenew settings to
- * all clients so everything is in sync */
- NetworkSend_Command(0,
- (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4,
- _settings_client.gui.autorenew_money,
- CMD_SET_AUTOREPLACE,
- NULL
- );
-
- MarkWholeScreenDirty();
- }
-
- if (_network_server) {
- /* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
- * server-side in network_server.c:838, function
- * DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
- NetworkClientInfo *ci = &_network_client_info[cid];
- ci->client_playas = p->index;
- NetworkUpdateClientInfo(ci->client_index);
-
- if (IsValidPlayerID(ci->client_playas)) {
- PlayerID player_backup = _local_player;
- _network_player_info[p->index].months_empty = 0;
-
- /* XXX - When a client joins, we automatically set its name to the
- * player's name (for some reason). As it stands now only the server
- * knows the client's name, so it needs to send out a "broadcast" to
- * do this. To achieve this we send a network command. However, it
- * uses _local_player to execute the command as. To prevent abuse
- * (eg. only yourself can change your name/company), we 'cheat' by
- * impersonation _local_player as the server. Not the best solution;
- * but it works.
- * TODO: Perhaps this could be improved by when the client is ready
- * with joining to let it send itself the command, and not the server?
- * For example in network_client.c:534? */
- _cmd_text = ci->client_name;
- _local_player = ci->client_playas;
- NetworkSend_Command(0, 0, 0, CMD_RENAME_PRESIDENT, NULL);
- _local_player = player_backup;
+ if (IsValidCompanyID(ci->client_playas)) {
+ CompanyID company_backup = _local_company;
+ _network_company_info[c->index].months_empty = 0;
+
+ /* XXX - When a client joins, we automatically set its name to the
+ * client's name (for some reason). As it stands now only the server
+ * knows the client's name, so it needs to send out a "broadcast" to
+ * do this. To achieve this we send a network command. However, it
+ * uses _local_company to execute the command as. To prevent abuse
+ * (eg. only yourself can change your name/company), we 'cheat' by
+ * impersonation _local_company as the server. Not the best solution;
+ * but it works.
+ * TODO: Perhaps this could be improved by when the client is ready
+ * with joining to let it send itself the command, and not the server?
+ * For example in network_client.c:534? */
+ _cmd_text = ci->client_name;
+ _local_company = ci->client_playas;
+ NetworkSend_Command(0, 0, 0, CMD_RENAME_PRESIDENT, NULL);
+ _local_company = company_backup;
+ }
}
- }
#endif /* ENABLE_NETWORK */
- } break;
+ } break;
- case 1: /* Make a new AI player */
- if (!(flags & DC_EXEC)) return CommandCost();
+ case 1: /* Make a new AI company */
+ if (!(flags & DC_EXEC)) return CommandCost();
- DoStartupNewPlayer(true);
- break;
+ DoStartupNewCompany(true);
+ break;
- case 2: { /* Delete a player */
- Player *p;
+ case 2: { /* Delete a company */
+ Company *c;
- if (!IsValidPlayerID((PlayerID)p2)) return CMD_ERROR;
+ if (!IsValidCompanyID((CompanyID)p2)) return CMD_ERROR;
- if (!(flags & DC_EXEC)) return CommandCost();
+ if (!(flags & DC_EXEC)) return CommandCost();
- p = GetPlayer((PlayerID)p2);
+ c = GetCompany((CompanyID)p2);
- /* Only allow removal of HUMAN companies */
- if (IsHumanPlayer(p->index)) {
- /* Delete any open window of the company */
- DeletePlayerWindows(p->index);
+ /* Only allow removal of HUMAN companies */
+ if (IsHumanCompany(c->index)) {
+ /* Delete any open window of the company */
+ DeleteCompanyWindows(c->index);
- CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
- cni->FillData(p);
+ CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
+ cni->FillData(c);
- /* Show the bankrupt news */
- SetDParam(0, STR_705C_BANKRUPT);
- SetDParam(1, STR_705D_HAS_BEEN_CLOSED_DOWN_BY);
- SetDParamStr(2, cni->company_name);
- AddNewsItem(STR_02B6, NS_COMPANY_BANKRUPT, 0, 0, cni);
+ /* Show the bankrupt news */
+ SetDParam(0, STR_705C_BANKRUPT);
+ SetDParam(1, STR_705D_HAS_BEEN_CLOSED_DOWN_BY);
+ SetDParamStr(2, cni->company_name);
+ AddNewsItem(STR_02B6, NS_COMPANY_BANKRUPT, 0, 0, cni);
- /* Remove the company */
- ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
+ /* Remove the company */
+ ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
- delete p;
- }
- } break;
+ delete c;
+ }
+ } break;
- case 3: { /* Merge a company (#1) into another company (#2), elimination company #1 */
- PlayerID pid_old = (PlayerID)GB(p2, 0, 16);
- PlayerID pid_new = (PlayerID)GB(p2, 16, 16);
+ case 3: { /* Merge a company (#1) into another company (#2), elimination company #1 */
+ CompanyID cid_old = (CompanyID)GB(p2, 0, 16);
+ CompanyID cid_new = (CompanyID)GB(p2, 16, 16);
- if (!IsValidPlayerID(pid_old) || !IsValidPlayerID(pid_new)) return CMD_ERROR;
+ if (!IsValidCompanyID(cid_old) || !IsValidCompanyID(cid_new)) return CMD_ERROR;
- if (!(flags & DC_EXEC)) return CMD_ERROR;
+ if (!(flags & DC_EXEC)) return CMD_ERROR;
- ChangeOwnershipOfPlayerItems(pid_old, pid_new);
- delete GetPlayer(pid_old);
- } break;
+ ChangeOwnershipOfCompanyItems(cid_old, cid_new);
+ delete GetCompany(cid_old);
+ } break;
- default: return CMD_ERROR;
+ default: return CMD_ERROR;
}
return CommandCost();
@@ -967,12 +965,12 @@ StringID EndGameGetPerformanceTitleFromValue(uint value)
return _endgame_perf_titles[value];
}
-/** Save the highscore for the player */
-int8 SaveHighScoreValue(const Player *p)
+/** Save the highscore for the company */
+int8 SaveHighScoreValue(const Company *c)
{
HighScore *hs = _highscore_table[_settings_game.difficulty.diff_level];
uint i;
- uint16 score = p->old_economy[0].performance_history;
+ uint16 score = c->old_economy[0].performance_history;
/* Exclude cheaters from the honour of being in the highscore table */
if (CheatHasBeenUsed()) return -1;
@@ -982,8 +980,8 @@ int8 SaveHighScoreValue(const Player *p)
if (hs[i].score <= score) {
/* move all elements one down starting from the replaced one */
memmove(&hs[i + 1], &hs[i], sizeof(HighScore) * (lengthof(_highscore_table[0]) - i - 1));
- SetDParam(0, p->index);
- SetDParam(1, p->index);
+ SetDParam(0, c->index);
+ SetDParam(1, c->index);
GetString(hs[i].company, STR_HIGHSCORE_NAME, lastof(hs[i].company)); // get manager/company name string
hs[i].score = score;
hs[i].title = EndGameGetPerformanceTitleFromValue(score);
@@ -994,8 +992,8 @@ int8 SaveHighScoreValue(const Player *p)
return -1; // too bad; we did not make it into the top5
}
-/** Sort all players given their performance */
-static int CDECL HighScoreSorter(const Player* const *a, const Player* const *b)
+/** Sort all companies given their performance */
+static int CDECL HighScoreSorter(const Company* const *a, const Company* const *b)
{
return (*b)->old_economy[0].performance_history - (*a)->old_economy[0].performance_history;
}
@@ -1004,15 +1002,15 @@ static int CDECL HighScoreSorter(const Player* const *a, const Player* const *b)
#define LAST_HS_ITEM lengthof(_highscore_table) - 1
int8 SaveHighScoreValueNetwork()
{
- const Player* p;
- const Player* pl[MAX_PLAYERS];
+ const Company *c;
+ const Company *cl[MAX_COMPANIES];
uint count = 0;
- int8 player = -1;
+ int8 company = -1;
- /* Sort all active players with the highest score first */
- FOR_ALL_PLAYERS(p) pl[count++] = p;
+ /* Sort all active companies with the highest score first */
+ FOR_ALL_COMPANIES(c) cl[count++] = c;
- GSortT(pl, count, &HighScoreSorter);
+ GSortT(cl, count, &HighScoreSorter);
{
uint i;
@@ -1023,19 +1021,19 @@ int8 SaveHighScoreValueNetwork()
for (i = 0; i < lengthof(_highscore_table[LAST_HS_ITEM]) && i < count; i++) {
HighScore* hs = &_highscore_table[LAST_HS_ITEM][i];
- SetDParam(0, pl[i]->index);
- SetDParam(1, pl[i]->index);
+ SetDParam(0, cl[i]->index);
+ SetDParam(1, cl[i]->index);
GetString(hs->company, STR_HIGHSCORE_NAME, lastof(hs->company)); // get manager/company name string
- hs->score = pl[i]->old_economy[0].performance_history;
+ hs->score = cl[i]->old_economy[0].performance_history;
hs->title = EndGameGetPerformanceTitleFromValue(hs->score);
- /* get the ranking of the local player */
- if (pl[i]->index == _local_player) player = i;
+ /* get the ranking of the local company */
+ if (cl[i]->index == _local_company) company = i;
}
}
- /* Add top5 players to highscore table */
- return player;
+ /* Add top5 companys to highscore table */
+ return company;
}
/** Save HighScore table to file */
@@ -1099,63 +1097,63 @@ void LoadFromHighScore()
_settings_client.gui.ending_year = 2051;
}
-/* Save/load of players */
-static const SaveLoad _player_desc[] = {
- SLE_VAR(Player, name_2, SLE_UINT32),
- SLE_VAR(Player, name_1, SLE_STRINGID),
- SLE_CONDSTR(Player, name, SLE_STR, 0, 84, SL_MAX_VERSION),
+/* Save/load of companies */
+static const SaveLoad _company_desc[] = {
+ SLE_VAR(Company, name_2, SLE_UINT32),
+ SLE_VAR(Company, name_1, SLE_STRINGID),
+ SLE_CONDSTR(Company, name, SLE_STR, 0, 84, SL_MAX_VERSION),
- SLE_VAR(Player, president_name_1, SLE_UINT16),
- SLE_VAR(Player, president_name_2, SLE_UINT32),
- SLE_CONDSTR(Player, president_name, SLE_STR, 0, 84, SL_MAX_VERSION),
+ SLE_VAR(Company, president_name_1, SLE_UINT16),
+ SLE_VAR(Company, president_name_2, SLE_UINT32),
+ SLE_CONDSTR(Company, president_name, SLE_STR, 0, 84, SL_MAX_VERSION),
- SLE_VAR(Player, face, SLE_UINT32),
+ SLE_VAR(Company, face, SLE_UINT32),
/* money was changed to a 64 bit field in savegame version 1. */
- SLE_CONDVAR(Player, player_money, SLE_VAR_I64 | SLE_FILE_I32, 0, 0),
- SLE_CONDVAR(Player, player_money, SLE_INT64, 1, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, money, SLE_VAR_I64 | SLE_FILE_I32, 0, 0),
+ SLE_CONDVAR(Company, money, SLE_INT64, 1, SL_MAX_VERSION),
- SLE_CONDVAR(Player, current_loan, SLE_VAR_I64 | SLE_FILE_I32, 0, 64),
- SLE_CONDVAR(Player, current_loan, SLE_INT64, 65, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, current_loan, SLE_VAR_I64 | SLE_FILE_I32, 0, 64),
+ SLE_CONDVAR(Company, current_loan, SLE_INT64, 65, SL_MAX_VERSION),
- SLE_VAR(Player, player_color, SLE_UINT8),
- SLE_VAR(Player, player_money_fraction, SLE_UINT8),
- SLE_CONDVAR(Player, avail_railtypes, SLE_UINT8, 0, 57),
- SLE_VAR(Player, block_preview, SLE_UINT8),
+ SLE_VAR(Company, colour, SLE_UINT8),
+ SLE_VAR(Company, money_fraction, SLE_UINT8),
+ SLE_CONDVAR(Company, avail_railtypes, SLE_UINT8, 0, 57),
+ SLE_VAR(Company, block_preview, SLE_UINT8),
- SLE_CONDVAR(Player, cargo_types, SLE_FILE_U16 | SLE_VAR_U32, 0, 93),
- SLE_CONDVAR(Player, cargo_types, SLE_UINT32, 94, SL_MAX_VERSION),
- SLE_CONDVAR(Player, location_of_HQ, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(Player, location_of_HQ, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(Player, last_build_coordinate, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
- SLE_CONDVAR(Player, last_build_coordinate, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDVAR(Player, inaugurated_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
- SLE_CONDVAR(Player, inaugurated_year, SLE_INT32, 31, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, cargo_types, SLE_FILE_U16 | SLE_VAR_U32, 0, 93),
+ SLE_CONDVAR(Company, cargo_types, SLE_UINT32, 94, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, location_of_HQ, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
+ SLE_CONDVAR(Company, location_of_HQ, SLE_UINT32, 6, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, last_build_coordinate, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
+ SLE_CONDVAR(Company, last_build_coordinate, SLE_UINT32, 6, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, inaugurated_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
+ SLE_CONDVAR(Company, inaugurated_year, SLE_INT32, 31, SL_MAX_VERSION),
- SLE_ARR(Player, share_owners, SLE_UINT8, 4),
+ SLE_ARR(Company, share_owners, SLE_UINT8, 4),
- SLE_VAR(Player, num_valid_stat_ent, SLE_UINT8),
+ SLE_VAR(Company, num_valid_stat_ent, SLE_UINT8),
- SLE_VAR(Player, quarters_of_bankrupcy, SLE_UINT8),
- SLE_VAR(Player, bankrupt_asked, SLE_UINT8),
- SLE_VAR(Player, bankrupt_timeout, SLE_INT16),
- SLE_CONDVAR(Player, bankrupt_value, SLE_VAR_I64 | SLE_FILE_I32, 0, 64),
- SLE_CONDVAR(Player, bankrupt_value, SLE_INT64, 65, SL_MAX_VERSION),
+ SLE_VAR(Company, quarters_of_bankrupcy, SLE_UINT8),
+ SLE_VAR(Company, bankrupt_asked, SLE_UINT8),
+ SLE_VAR(Company, bankrupt_timeout, SLE_INT16),
+ SLE_CONDVAR(Company, bankrupt_value, SLE_VAR_I64 | SLE_FILE_I32, 0, 64),
+ SLE_CONDVAR(Company, bankrupt_value, SLE_INT64, 65, SL_MAX_VERSION),
/* yearly expenses was changed to 64-bit in savegame version 2. */
- SLE_CONDARR(Player, yearly_expenses, SLE_FILE_I32 | SLE_VAR_I64, 3 * 13, 0, 1),
- SLE_CONDARR(Player, yearly_expenses, SLE_INT64, 3 * 13, 2, SL_MAX_VERSION),
+ SLE_CONDARR(Company, yearly_expenses, SLE_FILE_I32 | SLE_VAR_I64, 3 * 13, 0, 1),
+ SLE_CONDARR(Company, yearly_expenses, SLE_INT64, 3 * 13, 2, SL_MAX_VERSION),
- SLE_CONDVAR(Player, is_ai, SLE_BOOL, 2, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, is_ai, SLE_BOOL, 2, SL_MAX_VERSION),
SLE_CONDNULL(1, 4, 99),
/* Engine renewal settings */
SLE_CONDNULL(512, 16, 18),
- SLE_CONDREF(Player, engine_renew_list, REF_ENGINE_RENEWS, 19, SL_MAX_VERSION),
- SLE_CONDVAR(Player, engine_renew, SLE_BOOL, 16, SL_MAX_VERSION),
- SLE_CONDVAR(Player, engine_renew_months, SLE_INT16, 16, SL_MAX_VERSION),
- SLE_CONDVAR(Player, engine_renew_money, SLE_UINT32, 16, SL_MAX_VERSION),
- SLE_CONDVAR(Player, renew_keep_length, SLE_BOOL, 2, SL_MAX_VERSION), // added with 16.1, but was blank since 2
+ SLE_CONDREF(Company, engine_renew_list, REF_ENGINE_RENEWS, 19, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, engine_renew, SLE_BOOL, 16, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, engine_renew_months, SLE_INT16, 16, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, engine_renew_money, SLE_UINT32, 16, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, renew_keep_length, SLE_BOOL, 2, SL_MAX_VERSION), // added with 16.1, but was blank since 2
/* reserve extra space in savegame here. (currently 63 bytes) */
SLE_CONDNULL(63, 2, SL_MAX_VERSION),
@@ -1163,73 +1161,73 @@ static const SaveLoad _player_desc[] = {
SLE_END()
};
-static const SaveLoad _player_economy_desc[] = {
+static const SaveLoad _company_economy_desc[] = {
/* these were changed to 64-bit in savegame format 2 */
- SLE_CONDVAR(PlayerEconomyEntry, income, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
- SLE_CONDVAR(PlayerEconomyEntry, income, SLE_INT64, 2, SL_MAX_VERSION),
- SLE_CONDVAR(PlayerEconomyEntry, expenses, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
- SLE_CONDVAR(PlayerEconomyEntry, expenses, SLE_INT64, 2, SL_MAX_VERSION),
- SLE_CONDVAR(PlayerEconomyEntry, company_value, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
- SLE_CONDVAR(PlayerEconomyEntry, company_value, SLE_INT64, 2, SL_MAX_VERSION),
+ SLE_CONDVAR(CompanyEconomyEntry, income, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
+ SLE_CONDVAR(CompanyEconomyEntry, income, SLE_INT64, 2, SL_MAX_VERSION),
+ SLE_CONDVAR(CompanyEconomyEntry, expenses, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
+ SLE_CONDVAR(CompanyEconomyEntry, expenses, SLE_INT64, 2, SL_MAX_VERSION),
+ SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_FILE_I32 | SLE_VAR_I64, 0, 1),
+ SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_INT64, 2, SL_MAX_VERSION),
- SLE_VAR(PlayerEconomyEntry, delivered_cargo, SLE_INT32),
- SLE_VAR(PlayerEconomyEntry, performance_history, SLE_INT32),
+ SLE_VAR(CompanyEconomyEntry, delivered_cargo, SLE_INT32),
+ SLE_VAR(CompanyEconomyEntry, performance_history, SLE_INT32),
SLE_END()
};
-static const SaveLoad _player_livery_desc[] = {
+static const SaveLoad _company_livery_desc[] = {
SLE_CONDVAR(Livery, in_use, SLE_BOOL, 34, SL_MAX_VERSION),
SLE_CONDVAR(Livery, colour1, SLE_UINT8, 34, SL_MAX_VERSION),
SLE_CONDVAR(Livery, colour2, SLE_UINT8, 34, SL_MAX_VERSION),
SLE_END()
};
-static void SaveLoad_PLYR(Player* p)
+static void SaveLoad_PLYR(Company *c)
{
int i;
- SlObject(p, _player_desc);
+ SlObject(c, _company_desc);
/* Write AI? */
- if (!IsHumanPlayer(p->index)) {
- SaveLoad_AI(p->index);
+ if (!IsHumanCompany(c->index)) {
+ SaveLoad_AI(c->index);
}
/* Write economy */
- SlObject(&p->cur_economy, _player_economy_desc);
+ SlObject(&c->cur_economy, _company_economy_desc);
/* Write old economy entries. */
- for (i = 0; i < p->num_valid_stat_ent; i++) {
- SlObject(&p->old_economy[i], _player_economy_desc);
+ for (i = 0; i < c->num_valid_stat_ent; i++) {
+ SlObject(&c->old_economy[i], _company_economy_desc);
}
/* Write each livery entry. */
int num_liveries = CheckSavegameVersion(63) ? LS_END - 4 : (CheckSavegameVersion(85) ? LS_END - 2: LS_END);
for (i = 0; i < num_liveries; i++) {
- SlObject(&p->livery[i], _player_livery_desc);
+ SlObject(&c->livery[i], _company_livery_desc);
}
if (num_liveries < LS_END) {
/* We want to insert some liveries somewhere in between. This means some have to be moved. */
- memmove(&p->livery[LS_FREIGHT_WAGON], &p->livery[LS_PASSENGER_WAGON_MONORAIL], (LS_END - LS_FREIGHT_WAGON) * sizeof(p->livery[0]));
- p->livery[LS_PASSENGER_WAGON_MONORAIL] = p->livery[LS_MONORAIL];
- p->livery[LS_PASSENGER_WAGON_MAGLEV] = p->livery[LS_MAGLEV];
+ memmove(&c->livery[LS_FREIGHT_WAGON], &c->livery[LS_PASSENGER_WAGON_MONORAIL], (LS_END - LS_FREIGHT_WAGON) * sizeof(c->livery[0]));
+ c->livery[LS_PASSENGER_WAGON_MONORAIL] = c->livery[LS_MONORAIL];
+ c->livery[LS_PASSENGER_WAGON_MAGLEV] = c->livery[LS_MAGLEV];
}
if (num_liveries == LS_END - 4) {
/* Copy bus/truck liveries over to trams */
- p->livery[LS_PASSENGER_TRAM] = p->livery[LS_BUS];
- p->livery[LS_FREIGHT_TRAM] = p->livery[LS_TRUCK];
+ c->livery[LS_PASSENGER_TRAM] = c->livery[LS_BUS];
+ c->livery[LS_FREIGHT_TRAM] = c->livery[LS_TRUCK];
}
}
static void Save_PLYR()
{
- Player *p;
- FOR_ALL_PLAYERS(p) {
- SlSetArrayIndex(p->index);
- SlAutolength((AutolengthProc*)SaveLoad_PLYR, p);
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ SlSetArrayIndex(c->index);
+ SlAutolength((AutolengthProc*)SaveLoad_PLYR, c);
}
}
@@ -1237,19 +1235,19 @@ static void Load_PLYR()
{
int index;
while ((index = SlIterateArray()) != -1) {
- Player *p = new (index) Player();
- SaveLoad_PLYR(p);
- _player_colors[index] = p->player_color;
+ Company *c = new (index) Company();
+ SaveLoad_PLYR(c);
+ _company_colours[index] = c->colour;
/* This is needed so an AI is attached to a loaded AI */
- if (p->is_ai && (!_networking || _network_server) && _ai.enabled) {
+ if (c->is_ai && (!_networking || _network_server) && _ai.enabled) {
/* Clear the memory of the new AI, otherwise we might be doing wrong things. */
- memset(&_players_ainew[index], 0, sizeof(PlayerAiNew));
- AI_StartNewAI(p->index);
+ memset(&_companies_ainew[index], 0, sizeof(CompanyAiNew));
+ AI_StartNewAI(c->index);
}
}
}
-extern const ChunkHandler _player_chunk_handlers[] = {
+extern const ChunkHandler _company_chunk_handlers[] = {
{ 'PLYR', Save_PLYR, Load_PLYR, CH_ARRAY | CH_LAST},
};
diff --git a/src/rail.cpp b/src/rail.cpp
index 7c508dd8b..61f9218be 100644
--- a/src/rail.cpp
+++ b/src/rail.cpp
@@ -174,25 +174,25 @@ RailType GetTileRailType(TileIndex tile)
return INVALID_RAILTYPE;
}
-bool HasRailtypeAvail(const PlayerID p, const RailType railtype)
+bool HasRailtypeAvail(const CompanyID company, const RailType railtype)
{
- return HasBit(GetPlayer(p)->avail_railtypes, railtype);
+ return HasBit(GetCompany(company)->avail_railtypes, railtype);
}
bool ValParamRailtype(const RailType rail)
{
- return HasRailtypeAvail(_current_player, rail);
+ return HasRailtypeAvail(_current_company, rail);
}
-RailType GetBestRailtype(const PlayerID p)
+RailType GetBestRailtype(const CompanyID company)
{
- if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
- if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO;
- if (HasRailtypeAvail(p, RAILTYPE_ELECTRIC)) return RAILTYPE_ELECTRIC;
+ if (HasRailtypeAvail(company, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
+ if (HasRailtypeAvail(company, RAILTYPE_MONO)) return RAILTYPE_MONO;
+ if (HasRailtypeAvail(company, RAILTYPE_ELECTRIC)) return RAILTYPE_ELECTRIC;
return RAILTYPE_RAIL;
}
-RailTypes GetPlayerRailtypes(PlayerID p)
+RailTypes GetCompanyRailtypes(CompanyID company)
{
RailTypes rt = RAILTYPES_NONE;
@@ -201,7 +201,7 @@ RailTypes GetPlayerRailtypes(PlayerID p)
const EngineInfo *ei = &e->info;
if (HasBit(ei->climates, _settings_game.game_creation.landscape) &&
- (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
+ (HasBit(e->company_avail, company) || _date >= e->intro_date + 365)) {
const RailVehicleInfo *rvi = &e->u.rail;
if (rvi->railveh_type != RAILVEH_WAGON) {
diff --git a/src/rail.h b/src/rail.h
index f90105242..04d2aa74d 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -210,35 +210,35 @@ Foundation GetRailFoundation(Slope tileh, TrackBits bits);
/**
- * Finds out if a Player has a certain railtype available
- * @param p Player in question
+ * Finds out if a company has a certain railtype available
+ * @param company the company in question
* @param railtype requested RailType
- * @return true if player has requested RailType available
+ * @return true if company has requested RailType available
*/
-bool HasRailtypeAvail(const PlayerID p, const RailType railtype);
+bool HasRailtypeAvail(const CompanyID company, const RailType railtype);
/**
* Validate functions for rail building.
* @param rail the railtype to check.
- * @return true if the current player may build the rail.
+ * @return true if the current company may build the rail.
*/
bool ValParamRailtype(const RailType rail);
/**
- * Returns the "best" railtype a player can build.
+ * Returns the "best" railtype a company can build.
* As the AI doesn't know what the BEST one is, we have our own priority list
* here. When adding new railtypes, modify this function
- * @param p the player "in action"
- * @return The "best" railtype a player has available
+ * @param company the company "in action"
+ * @return The "best" railtype a company has available
*/
-RailType GetBestRailtype(const PlayerID p);
+RailType GetBestRailtype(const CompanyID company);
/**
- * Get the rail types the given player can build.
- * @param p the player to get the rail types for.
+ * Get the rail types the given company can build.
+ * @param company the company to get the rail types for.
* @return the rail types.
*/
-RailTypes GetPlayerRailtypes(const PlayerID p);
+RailTypes GetCompanyRailtypes(const CompanyID p);
/**
* Reset all rail type information to its default values.
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 5c496ad76..0ae096163 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -155,7 +155,7 @@ static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags
/* Let's see if we may build this */
if (flags & DC_NO_RAIL_OVERLAP || HasSignals(tile)) {
- /* If we are not allowed to overlap (flag is on for ai players or we have
+ /* If we are not allowed to overlap (flag is on for ai companies or we have
* signals on the tile), check that */
return future == TRACK_BIT_HORZ || future == TRACK_BIT_VERT;
} else {
@@ -307,7 +307,7 @@ static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits ex
/* check track/slope combination */
if ((f_new == FOUNDATION_INVALID) ||
- ((f_new != FOUNDATION_NONE) && (!_settings_game.construction.build_on_slopes || _is_old_ai_player))) {
+ ((f_new != FOUNDATION_NONE) && (!_settings_game.construction.build_on_slopes || _is_old_ai_company))) {
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
}
@@ -344,7 +344,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
!EnsureNoTrainOnTrack(tile, track)) {
return CMD_ERROR;
}
- if (!IsTileOwner(tile, _current_player) ||
+ if (!IsTileOwner(tile, _current_company) ||
!IsCompatibleRail(GetRailType(tile), railtype)) {
/* Get detailed error message */
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -395,7 +395,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
default: break;
case ROADTYPES_TRAM:
/* Tram crossings must always have road. */
- if (flags & DC_EXEC) SetRoadOwner(tile, ROADTYPE_ROAD, _current_player);
+ if (flags & DC_EXEC) SetRoadOwner(tile, ROADTYPE_ROAD, _current_company);
roadtypes |= ROADTYPES_ROAD;
break;
@@ -412,7 +412,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
if ((track == TRACK_X && road == ROAD_Y) ||
(track == TRACK_Y && road == ROAD_X)) {
if (flags & DC_EXEC) {
- MakeRoadCrossing(tile, GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtypes, GetTownIndex(tile));
+ MakeRoadCrossing(tile, GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY), _current_company, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtypes, GetTownIndex(tile));
UpdateLevelCrossing(tile, false);
}
break;
@@ -442,7 +442,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
}
if (flags & DC_EXEC) {
- MakeRailNormal(tile, _current_player, trackbit, railtype);
+ MakeRailNormal(tile, _current_company, trackbit, railtype);
if (water_ground) SetRailGroundType(tile, RAIL_GROUND_WATER);
}
break;
@@ -450,7 +450,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
if (flags & DC_EXEC) {
MarkTileDirtyByTile(tile);
- AddTrackToSignalBuffer(tile, track, _current_player);
+ AddTrackToSignalBuffer(tile, track, _current_company);
YapfNotifyTrackLayoutChange(tile, track);
}
@@ -474,7 +474,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32
trackbit = TrackToTrackBits(track);
/* Need to read tile owner now because it may change when the rail is removed
- * Also, in case of floods, _current_player != owner
+ * Also, in case of floods, _current_company != owner
* There may be invalid tiletype even in exec run (when removing long track),
* so do not call GetTileOwner(tile) in any case here */
Owner owner = INVALID_OWNER;
@@ -485,7 +485,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32
case MP_ROAD: {
if (!IsLevelCrossing(tile) ||
GetCrossingRailBits(tile) != trackbit ||
- (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
+ (_current_company != OWNER_WATER && !CheckTileOwnership(tile)) ||
(!(flags & DC_BANKRUPT) && !EnsureNoVehicleOnGround(tile))) {
return CMD_ERROR;
}
@@ -505,7 +505,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32
TrackBits present;
if (!IsPlainRailTile(tile) ||
- (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
+ (_current_company != OWNER_WATER && !CheckTileOwnership(tile)) ||
!EnsureNoTrainOnTrack(tile, track)) {
return CMD_ERROR;
}
@@ -546,7 +546,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32
if (flags & DC_EXEC) {
/* if we got that far, 'owner' variable is set correctly */
- assert(IsValidPlayerID(owner));
+ assert(IsValidCompanyID(owner));
MarkTileDirtyByTile(tile);
if (crossing) {
@@ -590,7 +590,7 @@ bool FloodHalftile(TileIndex t)
TrackBits to_remove = lower_track & rail_bits;
if (to_remove != 0) {
- _current_player = OWNER_WATER;
+ _current_company = OWNER_WATER;
if (CmdFailed(DoCommand(t, 0, FIND_FIRST_BIT(to_remove), DC_EXEC, CMD_REMOVE_SINGLE_RAIL))) return flooded; // not yet floodable
flooded = true;
rail_bits = rail_bits & ~to_remove;
@@ -789,7 +789,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
*/
if (tileh != SLOPE_FLAT && (
- _is_old_ai_player ||
+ _is_old_ai_company ||
!_settings_game.construction.build_on_slopes ||
IsSteepSlope(tileh) ||
!CanBuildDepotByTileh(dir, tileh)
@@ -806,12 +806,12 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
if (flags & DC_EXEC) {
Depot *d = new Depot(tile);
- MakeRailDepot(tile, _current_player, dir, (RailType)p1);
+ MakeRailDepot(tile, _current_company, dir, (RailType)p1);
MarkTileDirtyByTile(tile);
d->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
- AddSideToSignalBuffer(tile, INVALID_DIAGDIR, _current_player);
+ AddSideToSignalBuffer(tile, INVALID_DIAGDIR, _current_company);
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
}
@@ -971,7 +971,7 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32
SetSignalStates(tile, (GetSignalStates(tile) & ~mask) | ((HasBit(GetTrackReservation(tile), track) ? (uint)-1 : 0) & mask));
}
MarkTileDirtyByTile(tile);
- AddTrackToSignalBuffer(tile, track, _current_player);
+ AddTrackToSignalBuffer(tile, track, _current_company);
YapfNotifyTrackLayoutChange(tile, track);
if (v != NULL) TryPathReserve(v, true);
}
@@ -1200,7 +1200,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint3
}
/* Only water can remove signals from anyone */
- if (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR;
+ if (_current_company != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR;
/* Do it? */
if (flags & DC_EXEC) {
@@ -1441,7 +1441,7 @@ CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
static CommandCost RemoveTrainDepot(TileIndex tile, uint32 flags)
{
- if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
+ if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER)
return CMD_ERROR;
if (!EnsureNoVehicleOnGround(tile))
@@ -1474,7 +1474,7 @@ static CommandCost ClearTile_Track(TileIndex tile, byte flags)
CommandCost ret;
if (flags & DC_AUTO) {
- if (!IsTileOwner(tile, _current_player))
+ if (!IsTileOwner(tile, _current_company))
return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER);
if (IsPlainRailTile(tile)) {
@@ -1902,7 +1902,7 @@ static void DrawTile_Track(TileInfo *ti)
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
SpriteID image;
- _drawtile_track_palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
+ _drawtile_track_palette = COMPANY_SPRITE_COLOR(GetTileOwner(ti->tile));
if (IsPlainRailTile(ti->tile)) {
TrackBits rails = GetTrackBits(ti->tile);
@@ -2039,7 +2039,7 @@ default_waypoint:
static void DrawTileSequence(int x, int y, SpriteID ground, const DrawTileSeqStruct* dtss, uint32 offset)
{
- SpriteID palette = PLAYER_SPRITE_COLOR(_local_player);
+ SpriteID palette = COMPANY_SPRITE_COLOR(_local_company);
DrawSprite(ground, PAL_NONE, x, y);
for (; dtss->image.sprite != 0; dtss++) {
@@ -2188,7 +2188,7 @@ static void TileLoop_Track(TileIndex tile)
case TRACK_BIT_RIGHT: new_ground = RAIL_GROUND_FENCE_VERT2; break;
default: {
- PlayerID owner = GetTileOwner(tile);
+ Owner owner = GetTileOwner(tile);
if (rail == (TRACK_BIT_LOWER | TRACK_BIT_RIGHT) || (
(rail & TRACK_BIT_3WAY_NW) == 0 &&
@@ -2414,12 +2414,12 @@ static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
}
}
-static void ChangeTileOwner_Track(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Track(TileIndex tile, Owner old_owner, Owner new_owner)
{
- if (!IsTileOwner(tile, old_player)) return;
+ if (!IsTileOwner(tile, old_owner)) return;
- if (new_player != PLAYER_SPECTATOR) {
- SetTileOwner(tile, new_player);
+ if (new_owner != INVALID_OWNER) {
+ SetTileOwner(tile, new_owner);
} else {
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
}
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 4ce44acae..ba2951477 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -843,7 +843,7 @@ void ShowBuildRailToolbar(RailType railtype, int button)
{
BuildRailToolbarWindow *w;
- if (!IsValidPlayerID(_current_player)) return;
+ if (!IsValidCompanyID(_current_company)) return;
if (!ValParamRailtype(railtype)) return;
// don't recreate the window if we're clicking on a button and the window exists.
@@ -1718,7 +1718,7 @@ void ReinitGuiAfterToggleElrail(bool disable)
/** Set the initial (default) railtype to use */
static void SetDefaultRailGui()
{
- if (_local_player == PLAYER_SPECTATOR || !IsValidPlayerID(_local_player)) return;
+ if (_local_company == COMPANY_SPECTATOR || !IsValidCompanyID(_local_company)) return;
extern RailType _last_built_railtype;
RailType rt = (RailType)_settings_client.gui.default_rail_type;
@@ -1745,11 +1745,11 @@ static void SetDefaultRailGui()
switch (rt) {
case RAILTYPE_END + 0:
rt = RAILTYPE_RAIL;
- while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_player, rt)) rt++;
+ while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_company, rt)) rt++;
break;
case RAILTYPE_END + 1:
- rt = GetBestRailtype(_local_player);
+ rt = GetBestRailtype(_local_company);
break;
default:
diff --git a/src/road.cpp b/src/road.cpp
index af6b5cbd1..add184f69 100644
--- a/src/road.cpp
+++ b/src/road.cpp
@@ -77,25 +77,25 @@ RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
return org_rb;
}
-bool HasRoadTypesAvail(const PlayerID p, const RoadTypes rts)
+bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts)
{
RoadTypes avail_roadtypes;
- if (p == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
+ if (company == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
avail_roadtypes = ROADTYPES_ROAD;
} else {
- if (!IsValidPlayerID(p)) return false;
- avail_roadtypes = (RoadTypes)GetPlayer(p)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
+ if (!IsValidCompanyID(company)) return false;
+ avail_roadtypes = (RoadTypes)GetCompany(company)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
}
return (rts & ~avail_roadtypes) == 0;
}
bool ValParamRoadType(const RoadType rt)
{
- return HasRoadTypesAvail(_current_player, RoadTypeToRoadTypes(rt));
+ return HasRoadTypesAvail(_current_company, RoadTypeToRoadTypes(rt));
}
-RoadTypes GetPlayerRoadtypes(PlayerID p)
+RoadTypes GetCompanyRoadtypes(CompanyID company)
{
RoadTypes rt = ROADTYPES_NONE;
@@ -104,7 +104,7 @@ RoadTypes GetPlayerRoadtypes(PlayerID p)
const EngineInfo *ei = &e->info;
if (HasBit(ei->climates, _settings_game.game_creation.landscape) &&
- (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
+ (HasBit(e->company_avail, company) || _date >= e->intro_date + 365)) {
SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
}
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 417c35010..d6c2ef91e 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -151,8 +151,8 @@ bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType
/* Water can always flood and towns can always remove "normal" road pieces.
* Towns are not be allowed to remove non "normal" road pieces, like tram
* tracks as that would result in trams that cannot turn. */
- if (_current_player == OWNER_WATER ||
- (rt == ROADTYPE_ROAD && !IsValidPlayerID(_current_player))) return true;
+ if (_current_company == OWNER_WATER ||
+ (rt == ROADTYPE_ROAD && !IsValidCompanyID(_current_company))) return true;
/* Only do the special processing if the road is owned
* by a town */
@@ -272,7 +272,7 @@ static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, Roa
const RoadBits other = GetOtherRoadBits(tile, rt);
const Foundation f = GetRoadFoundation(tileh, present);
- if (HasRoadWorks(tile) && _current_player != OWNER_WATER) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
+ if (HasRoadWorks(tile) && _current_company != OWNER_WATER) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
/* Autocomplete to a straight road
* @li on steep slopes
@@ -300,7 +300,7 @@ static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, Roa
if (flags & DC_EXEC) {
if (HasRoadWorks(tile)) {
/* flooding tile with road works, don't forget to remove the effect vehicle too */
- assert(_current_player == OWNER_WATER);
+ assert(_current_company == OWNER_WATER);
Vehicle *v;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_EFFECT && TileVirtXY(v->x_pos, v->y_pos) == tile) {
@@ -474,8 +474,8 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
RoadBits other_bits = ROAD_NONE;
/* Road pieces are max 4 bitset values (NE, NW, SE, SW) and town can only be non-zero
- * if a non-player is building the road */
- if ((IsValidPlayerID(_current_player) && p2 != 0) || (_current_player == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR;
+ * if a non-company is building the road */
+ if ((IsValidCompanyID(_current_company) && p2 != 0) || (_current_company == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR;
RoadBits pieces = Extract<RoadBits, 0>(p1);
@@ -506,7 +506,7 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
if ((existing & pieces) == pieces) {
/* We only want to set the (dis)allowed road directions */
- if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && IsRoadOwner(tile, ROADTYPE_ROAD, _current_player)) {
+ if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && IsRoadOwner(tile, ROADTYPE_ROAD, _current_company)) {
if (crossing) return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
@@ -569,7 +569,7 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
/* Always add road to the roadtypes (can't draw without it) */
bool reserved = HasBit(GetTrackReservation(tile), AxisToTrack(OtherAxis(roaddir)));
- MakeRoadCrossing(tile, _current_player, _current_player, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2);
+ MakeRoadCrossing(tile, _current_company, _current_company, _current_company, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2);
SetCrossingReservation(tile, reserved);
UpdateLevelCrossing(tile, false);
MarkTileDirtyByTile(tile);
@@ -650,8 +650,8 @@ do_clear:;
RoadTileType rtt = GetRoadTileType(tile);
if (existing == ROAD_NONE || rtt == ROAD_TILE_CROSSING) {
SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
- SetRoadOwner(tile, rt, _current_player);
- if (_current_player == OWNER_TOWN && rt == ROADTYPE_ROAD) SetTownIndex(tile, p2);
+ SetRoadOwner(tile, rt, _current_company);
+ if (_current_company == OWNER_TOWN && rt == ROADTYPE_ROAD) SetTownIndex(tile, p2);
}
if (rtt != ROAD_TILE_CROSSING) SetRoadBits(tile, existing | pieces, rt);
} break;
@@ -679,7 +679,7 @@ do_clear:;
break;
default:
- MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, _current_player, _current_player, _current_player);
+ MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, _current_company, _current_company, _current_company);
break;
}
@@ -883,7 +883,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
Depot *dep = new Depot(tile);
dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
- MakeRoadDepot(tile, _current_player, dir, rt);
+ MakeRoadDepot(tile, _current_company, dir, rt);
MarkTileDirtyByTile(tile);
}
return cost.AddCost(_price.build_road_depot);
@@ -891,7 +891,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
static CommandCost RemoveRoadDepot(TileIndex tile, uint32 flags)
{
- if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
+ if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) return CMD_ERROR;
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
@@ -1203,7 +1203,7 @@ static void DrawTile_Road(TileInfo *ti)
case ROAD_TILE_DEPOT: {
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
- SpriteID palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
+ SpriteID palette = COMPANY_SPRITE_COLOR(GetTileOwner(ti->tile));
const DrawTileSprites *dts;
if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) {
@@ -1243,7 +1243,7 @@ static void DrawTile_Road(TileInfo *ti)
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
{
- SpriteID palette = PLAYER_SPRITE_COLOR(_local_player);
+ SpriteID palette = COMPANY_SPRITE_COLOR(_local_company);
const DrawTileSprites *dts = (rt == ROADTYPE_TRAM) ? &_tram_depot[dir] : &_road_depot[dir];
x += 33;
@@ -1559,14 +1559,14 @@ static VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int
}
-static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owner)
{
if (IsRoadDepot(tile)) {
- if (GetTileOwner(tile) == old_player) {
- if (new_player == PLAYER_SPECTATOR) {
+ if (GetTileOwner(tile) == old_owner) {
+ if (new_owner == INVALID_OWNER) {
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
} else {
- SetTileOwner(tile, new_player);
+ SetTileOwner(tile, new_owner);
}
}
return;
@@ -1574,17 +1574,17 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID n
for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
/* Update all roadtypes, no matter if they are present */
- if (GetRoadOwner(tile, rt) == old_player) {
- SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
+ if (GetRoadOwner(tile, rt) == old_owner) {
+ SetRoadOwner(tile, rt, new_owner == INVALID_OWNER ? OWNER_NONE : new_owner);
}
}
if (IsLevelCrossing(tile)) {
- if (GetTileOwner(tile) == old_player) {
- if (new_player == PLAYER_SPECTATOR) {
+ if (GetTileOwner(tile) == old_owner) {
+ if (new_owner == INVALID_OWNER) {
DoCommand(tile, 0, GetCrossingRailTrack(tile), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
} else {
- SetTileOwner(tile, new_player);
+ SetTileOwner(tile, new_owner);
}
}
}
diff --git a/src/road_func.h b/src/road_func.h
index c0baeee3f..264bc21f4 100644
--- a/src/road_func.h
+++ b/src/road_func.h
@@ -140,26 +140,26 @@ static inline RoadBits AxisToRoadBits(Axis a)
}
/**
- * Finds out, whether given player has all given RoadTypes available
- * @param PlayerID ID of player
+ * Finds out, whether given company has all given RoadTypes available
+ * @param company ID of company
* @param rts RoadTypes to test
- * @return true if player has all requested RoadTypes available
+ * @return true if company has all requested RoadTypes available
*/
-bool HasRoadTypesAvail(const PlayerID p, const RoadTypes rts);
+bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts);
/**
* Validate functions for rail building.
* @param rt road type to check.
- * @return true if the current player may build the road.
+ * @return true if the current company may build the road.
*/
bool ValParamRoadType(const RoadType rt);
/**
- * Get the road types the given player can build.
- * @param p the player to get the roadtypes for.
+ * Get the road types the given company can build.
+ * @param company the company to get the roadtypes for.
* @return the road types.
*/
-RoadTypes GetPlayerRoadtypes(const PlayerID p);
+RoadTypes GetCompanyRoadtypes(const CompanyID company);
void UpdateLevelCrossing(TileIndex tile, bool sound = true);
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 9a215d127..ca45f35fe 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -421,7 +421,7 @@ struct BuildRoadToolbarWindow : Window {
/**
* Update the remove button lowered state of the road toolbar
*
- * @param clicked_widget The widget which the player clicked just now
+ * @param clicked_widget The widget which the client clicked just now
*/
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
{
@@ -676,7 +676,7 @@ static const WindowDesc _build_tramway_desc = {
void ShowBuildRoadToolbar(RoadType roadtype)
{
- if (!IsValidPlayerID(_current_player)) return;
+ if (!IsValidCompanyID(_current_company)) return;
_cur_roadtype = roadtype;
DeleteWindowByClass(WC_BUILD_TOOLBAR);
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 3739aa8ce..cf9810be5 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -180,7 +180,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
UnitID unit_num;
Engine *e;
- if (!IsEngineBuildable(p1, VEH_ROAD, _current_player)) return_cmd_error(STR_ROAD_VEHICLE_NOT_AVAILABLE);
+ if (!IsEngineBuildable(p1, VEH_ROAD, _current_company)) return_cmd_error(STR_ROAD_VEHICLE_NOT_AVAILABLE);
cost = EstimateRoadVehCost(p1);
if (flags & DC_QUERY_COST) return cost;
@@ -188,7 +188,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* The ai_new queries the vehicle cost before building the route,
* so we must check against cheaters no sooner than now. --pasky */
if (!IsRoadDepotTile(tile)) return CMD_ERROR;
- if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
+ if (!IsTileOwner(tile, _current_company)) return CMD_ERROR;
if (HasTileRoadType(tile, ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
@@ -218,7 +218,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v = new (v) RoadVehicle();
v->unitnumber = unit_num;
v->direction = DiagDirToDir(GetRoadDepotDirection(tile));
- v->owner = _current_player;
+ v->owner = _current_company;
v->tile = tile;
x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
@@ -283,10 +283,10 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
InvalidateWindow(WC_COMPANY, v->owner);
- if (IsLocalPlayer())
+ if (IsLocalCompany())
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Road window
- GetPlayer(_current_player)->num_engines[p1]++;
+ GetCompany(_current_company)->num_engines[p1]++;
}
return cost;
@@ -441,7 +441,7 @@ CommandCost CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint3
if (p2 & DEPOT_MASS_SEND) {
/* Mass goto depot requested */
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
- return SendAllVehiclesToDepot(VEH_ROAD, flags, p2 & DEPOT_SERVICE, _current_player, (p2 & VLW_MASK), p1);
+ return SendAllVehiclesToDepot(VEH_ROAD, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
}
if (!IsValidVehicleID(p1)) return CMD_ERROR;
@@ -805,7 +805,7 @@ static void RoadVehArrivesAt(const Vehicle* v, Station* st)
SetDParam(0, st->index);
AddNewsItem(
v->u.road.roadtype == ROADTYPE_ROAD ? STR_902F_CITIZENS_CELEBRATE_FIRST : STR_CITIZENS_CELEBRATE_FIRST_PASSENGER_TRAM,
- (v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
+ (v->owner == _local_company) ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
v->index,
st->index
);
@@ -817,7 +817,7 @@ static void RoadVehArrivesAt(const Vehicle* v, Station* st)
SetDParam(0, st->index);
AddNewsItem(
v->u.road.roadtype == ROADTYPE_ROAD ? STR_9030_CITIZENS_CELEBRATE_FIRST : STR_CITIZENS_CELEBRATE_FIRST_CARGO_TRAM,
- (v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
+ (v->owner == _local_company) ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
v->index,
st->index
);
@@ -1043,7 +1043,7 @@ static Trackdir RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection ent
if (IsTileType(tile, MP_ROAD)) {
if (IsRoadDepot(tile) && (!IsTileOwner(tile, v->owner) || GetRoadDepotDirection(tile) == enterdir || (GetRoadTypes(tile) & v->u.road.compatible_roadtypes) == 0)) {
- /* Road depot owned by another player or with the wrong orientation */
+ /* Road depot owned by another company or with the wrong orientation */
trackdirs = TRACKDIR_BIT_NONE;
}
} else if (IsTileType(tile, MP_STATION) && IsStandardRoadStopTile(tile)) {
@@ -1358,20 +1358,20 @@ static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev,
/**
* Can a tram track build without destruction on the given tile?
- * @param p the player that would be building the tram tracks
+ * @param c the company that would be building the tram tracks
* @param t the tile to build on.
* @param r the road bits needed.
* @return true when a track track can be build on 't'
*/
-static bool CanBuildTramTrackOnTile(PlayerID p, TileIndex t, RoadBits r)
+static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadBits r)
{
- /* The 'current' player is not necessarily the owner of the vehicle. */
- PlayerID original_player = _current_player;
- _current_player = p;
+ /* The 'current' company is not necessarily the owner of the vehicle. */
+ CompanyID original_company = _current_company;
+ _current_company = c;
CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, 0, CMD_BUILD_ROAD);
- _current_player = original_player;
+ _current_company = original_company;
return CmdSucceeded(ret);
}
@@ -1491,7 +1491,7 @@ again:
/*
* Taking the 'small' corner for trams only happens when:
* - We are not the from vehicle of an articulated tram.
- * - Or when the player cannot build on the next tile.
+ * - Or when the company cannot build on the next tile.
*
* The 'small' corner means that the vehicle is on the end of a
* tram track and needs to start turning there. To do this properly
@@ -1502,7 +1502,7 @@ again:
tile = v->tile;
start_frame = RVC_TURN_AROUND_START_FRAME_SHORT_TRAM;
} else {
- /* The player can build on the next tile, so wait till (s)he does. */
+ /* The company can build on the next tile, so wait till (s)he does. */
v->cur_speed = 0;
return false;
}
@@ -1985,7 +1985,7 @@ void RoadVehicle::OnNewDay()
this->profit_this_year -= cost.GetCost();
this->running_ticks = 0;
- SubtractMoneyFromPlayerFract(this->owner, cost);
+ SubtractMoneyFromCompanyFract(this->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
InvalidateWindowClasses(WC_ROADVEH_LIST);
@@ -2086,7 +2086,7 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
total_capacity += capacity;
- if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
+ if (IsHumanCompany(v->owner) && new_cid != v->cargo_type) {
cost.AddCost(GetRefitCost(v->engine_type));
}
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 01f6f6bf4..ce48465ca 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -1300,7 +1300,7 @@ extern const ChunkHandler _misc_chunk_handlers[];
extern const ChunkHandler _name_chunk_handlers[];
extern const ChunkHandler _cheat_chunk_handlers[] ;
extern const ChunkHandler _setting_chunk_handlers[];
-extern const ChunkHandler _player_chunk_handlers[];
+extern const ChunkHandler _company_chunk_handlers[];
extern const ChunkHandler _engine_chunk_handlers[];
extern const ChunkHandler _veh_chunk_handlers[];
extern const ChunkHandler _waypoint_chunk_handlers[];
@@ -1333,7 +1333,7 @@ static const ChunkHandler * const _chunk_handlers[] = {
_town_chunk_handlers,
_sign_chunk_handlers,
_station_chunk_handlers,
- _player_chunk_handlers,
+ _company_chunk_handlers,
_animated_tile_chunk_handlers,
_newgrf_chunk_handlers,
_group_chunk_handlers,
diff --git a/src/saveload.h b/src/saveload.h
index df2dc9f07..f32f15222 100644
--- a/src/saveload.h
+++ b/src/saveload.h
@@ -160,7 +160,7 @@ enum VarTypes {
/* 8 bytes allocated for a maximum of 8 flags
* Flags directing saving/loading of a variable */
- SLF_SAVE_NO = 1 << 8, ///< do not save with savegame, basically player-based
+ SLF_SAVE_NO = 1 << 8, ///< do not save with savegame, basically client-based
SLF_CONFIG_NO = 1 << 9, ///< do not save to config file
SLF_NETWORK_NO = 1 << 10, ///< do not synchronize over network (but it is saved if SSF_SAVE_NO is not set)
/* 5 more possible flags */
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 5a9ef0581..d8c310f05 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -547,10 +547,10 @@ static char *MakeScreenshotName(const char *ext)
int serial;
size_t len;
- if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_player == PLAYER_SPECTATOR) {
+ if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_company == COMPANY_SPECTATOR) {
ttd_strlcpy(_screenshot_name, "screenshot", lengthof(_screenshot_name));
} else {
- SetDParam(0, _local_player);
+ SetDParam(0, _local_company);
SetDParam(1, _date);
GetString(_screenshot_name, STR_4004, lastof(_screenshot_name));
}
diff --git a/src/settings.cpp b/src/settings.cpp
index b49833131..29343c280 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1089,15 +1089,15 @@ static int32 CheckNoiseToleranceLevel(const char *value)
#ifdef ENABLE_NETWORK
-static int32 UpdateMinPlayers(int32 p1)
+static int32 UpdateMinActiveClients(int32 p1)
{
- CheckMinPlayers();
+ CheckMinActiveClients();
return 0;
}
-static int32 UpdatePlayerName(int32 p1)
+static int32 UpdateClientName(int32 p1)
{
- NetworkUpdatePlayerName();
+ NetworkUpdateClientName();
return 0;
}
@@ -1180,7 +1180,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
SDTG_BOOL("large_aa", S, 0, _freetype.large_aa, false, STR_NULL, NULL),
#endif
SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size, 4, 1, 64, 0, STR_NULL, NULL),
- SDTG_VAR("player_face", SLE_UINT32, S, 0, _player_face, 0,0,0xFFFFFFFF,0, STR_NULL, NULL),
+ SDTG_VAR("player_face", SLE_UINT32, S, 0, _company_manager_face,0,0,0xFFFFFFFF,0, STR_NULL, NULL),
SDTG_VAR("transparency_options", SLE_UINT, S, 0, _transparency_opt, 0,0,0x1FF,0, STR_NULL, NULL),
SDTG_VAR("transparency_locks", SLE_UINT, S, 0, _transparency_lock, 0,0,0x1FF,0, STR_NULL, NULL),
SDTG_VAR("invisibility_options", SLE_UINT, S, 0, _invisibility_opt, 0,0, 0xFF,0, STR_NULL, NULL),
@@ -1224,7 +1224,7 @@ static const SettingDesc _gameopt_settings[] = {
* It is also a bit tricky since you would think that service_interval
* for example doesn't need to be synched. Every client assigns the
* service_interval value to the v->service_interval, meaning that every client
- * assigns his value. If the setting was player-based, that would mean that
+ * assigns his value. If the setting was company-based, that would mean that
* vehicles could decide on different moments that they are heading back to a
* service depot, causing desyncs on a massive scale. */
const SettingDesc _patch_settings[] = {
@@ -1470,7 +1470,7 @@ const SettingDesc _patch_settings[] = {
SDTC_VAR(network.server_port, SLE_UINT16, S, NO,NETWORK_DEFAULT_PORT,0,65535,0,STR_NULL, NULL),
SDTC_BOOL(network.server_advertise, S, NO, false, STR_NULL, NULL),
SDTC_VAR(network.lan_internet, SLE_UINT8, S, NO, 0, 0, 1, 0, STR_NULL, NULL),
- SDTC_STR(network.player_name, SLE_STRB, S, 0, NULL, STR_NULL, UpdatePlayerName),
+ SDTC_STR(network.client_name, SLE_STRB, S, 0, NULL, STR_NULL, UpdateClientName),
SDTC_STR(network.server_password, SLE_STRB, S, NO, NULL, STR_NULL, UpdateServerPassword),
SDTC_STR(network.rcon_password, SLE_STRB, S, NO, NULL, STR_NULL, UpdateRconPassword),
SDTC_STR(network.default_company_pass, SLE_STRB, S, 0, NULL, STR_NULL, NULL),
@@ -1480,11 +1480,11 @@ const SettingDesc _patch_settings[] = {
SDTC_BOOL(network.autoclean_companies, S, NO, false, STR_NULL, NULL),
SDTC_VAR(network.autoclean_unprotected, SLE_UINT8, S,D0|NO, 12, 0, 240, 0, STR_NULL, NULL),
SDTC_VAR(network.autoclean_protected, SLE_UINT8, S,D0|NO, 36, 0, 240, 0, STR_NULL, NULL),
- SDTC_VAR(network.max_companies, SLE_UINT8, S, NO, 8, 1, MAX_PLAYERS, 0, STR_NULL, NULL),
+ SDTC_VAR(network.max_companies, SLE_UINT8, S, NO, 8, 1,MAX_COMPANIES,0, STR_NULL, NULL),
SDTC_VAR(network.max_clients, SLE_UINT8, S, NO, 10, 2, MAX_CLIENTS, 0, STR_NULL, NULL),
SDTC_VAR(network.max_spectators, SLE_UINT8, S, NO, 10, 0, MAX_CLIENTS, 0, STR_NULL, NULL),
SDTC_VAR(network.restart_game_year, SLE_INT32, S,D0|NO|NC,0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
- SDTC_VAR(network.min_players, SLE_UINT8, S, NO, 0, 0, 10, 0, STR_NULL, UpdateMinPlayers),
+ SDTC_VAR(network.min_active_clients, SLE_UINT8, S, NO, 0, 0, 10, 0, STR_NULL, UpdateMinActiveClients),
SDTC_OMANY(network.server_lang, SLE_UINT8, S, NO, 0, 35, "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN", STR_NULL, NULL),
SDTC_BOOL(network.reload_cfg, S, NO, false, STR_NULL, NULL),
SDTC_STR(network.last_host, SLE_STRB, S, 0, "0.0.0.0", STR_NULL, NULL),
@@ -1899,9 +1899,9 @@ CommandCost CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint3
bool SetPatchValue(uint index, int32 value)
{
const SettingDesc *sd = &_patch_settings[index];
- /* If an item is player-based, we do not send it over the network
+ /* If an item is company-based, we do not send it over the network
* (if any) to change. Also *hack*hack* we update the _newgame version
- * of patches because changing a player-based setting in a game also
+ * of patches because changing a company-based setting in a game also
* changes its defaults. At least that is the convention we have chosen */
if (sd->save.conv & SLF_NETWORK_NO) {
void *var = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game, &sd->save);
@@ -1916,7 +1916,7 @@ bool SetPatchValue(uint index, int32 value)
return true;
}
- /* send non-player-based settings over the network */
+ /* send non-company-based settings over the network */
if (!_networking || (_networking && _network_server)) {
return DoCommandP(0, index, value, NULL, CMD_CHANGE_PATCH_SETTING);
}
diff --git a/src/settings_type.h b/src/settings_type.h
index c586d3198..adef05995 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -51,7 +51,7 @@ struct GUISettings {
bool smooth_scroll; ///< smooth scroll viewports
bool measure_tooltip; ///< show a permanent tooltip when dragging tools
byte liveries; ///< options for displaying company liveries, 0=none, 1=self, 2=all
- bool prefer_teamchat; ///< choose the chat message target with <ENTER>, true=all players, false=your team
+ bool prefer_teamchat; ///< choose the chat message target with <ENTER>, true=all clients, false=your team
uint8 advanced_vehicle_list; ///< use the "advanced" vehicle list
uint8 loading_indicators; ///< show loading indicators
uint8 default_rail_type; ///< the default rail type for the rail GUI
@@ -111,7 +111,7 @@ struct NetworkSettings {
char rcon_password[NETWORK_PASSWORD_LENGTH]; ///< passowrd for rconsole (server side)
bool server_advertise; ///< advertise the server to the masterserver
uint8 lan_internet; ///< search on the LAN or internet for servers
- char player_name[NETWORK_NAME_LENGTH]; ///< name of the player
+ char client_name[NETWORK_NAME_LENGTH]; ///< name of the player (as client)
char default_company_pass[NETWORK_PASSWORD_LENGTH]; ///< default password for new companies in encrypted form
char connect_to_ip[NETWORK_HOSTNAME_LENGTH]; ///< default for the "Add server" query
char network_id[NETWORK_UNIQUE_ID_LENGTH]; ///< semi-unique ID of the client
@@ -122,7 +122,7 @@ struct NetworkSettings {
uint8 max_clients; ///< maximum amount of clients
uint8 max_spectators; ///< maximum amount of spectators
Year restart_game_year; ///< year the server restarts
- uint8 min_players; ///< minimum amount of players to unpause the game
+ uint8 min_active_clients; ///< minimum amount of active clients to unpause the game
uint8 server_lang; ///< language of the server
bool reload_cfg; ///< reload the config file before restarting
char last_host[NETWORK_HOSTNAME_LENGTH]; ///< IP address of the last joined server
@@ -277,10 +277,10 @@ struct VehicleSettings {
bool realistic_acceleration; ///< realistic acceleration for trains
bool wagon_speed_limits; ///< enable wagon speed limits
bool disable_elrails; ///< when true, the elrails are disabled
- UnitID max_trains; ///< max trains in game per player
- UnitID max_roadveh; ///< max trucks in game per player
- UnitID max_aircraft; ///< max planes in game per player
- UnitID max_ships; ///< max ships in game per player
+ UnitID max_trains; ///< max trains in game per company
+ UnitID max_roadveh; ///< max trucks in game per company
+ UnitID max_aircraft; ///< max planes in game per company
+ UnitID max_ships; ///< max ships in game per company
bool servint_ispercent; ///< service intervals are in percents
uint16 servint_trains; ///< service interval for trains
uint16 servint_roadveh; ///< service interval for road vehicles
@@ -302,7 +302,7 @@ struct EconomySettings {
bool allow_shares; ///< allow the buying/selling of shares
byte dist_local_authority; ///< distance for town local authority, default 20
bool exclusive_rights; ///< allow buying exclusive rights
- bool give_money; ///< allow giving other players money
+ bool give_money; ///< allow giving other companies money
bool mod_road_rebuild; ///< roadworks remove unneccesary RoadBits
bool multiple_industry_per_town; ///< allow many industries of the same type per town
bool same_industry_close; ///< allow same type industries to be built close to each other
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 3d63347b9..172039531 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -176,7 +176,7 @@ void Ship::OnNewDay()
this->profit_this_year -= cost.GetCost();
this->running_ticks = 0;
- SubtractMoneyFromPlayerFract(this->owner, cost);
+ SubtractMoneyFromCompanyFract(this->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
/* we need this for the profit */
@@ -349,7 +349,7 @@ static void ShipArrivesAt(const Vehicle* v, Station* st)
SetDParam(0, st->index);
AddNewsItem(
STR_9833_CITIZENS_CELEBRATE_FIRST,
- (v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
+ (v->owner == _local_company) ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
v->index,
st->index
);
@@ -757,7 +757,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
UnitID unit_num;
Engine *e;
- if (!IsEngineBuildable(p1, VEH_SHIP, _current_player)) return_cmd_error(STR_SHIP_NOT_AVAILABLE);
+ if (!IsEngineBuildable(p1, VEH_SHIP, _current_company)) return_cmd_error(STR_SHIP_NOT_AVAILABLE);
value = EstimateShipCost(p1);
if (flags & DC_QUERY_COST) return value;
@@ -765,7 +765,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* The ai_new queries the vehicle cost before building the route,
* so we must check against cheaters no sooner than now. --pasky */
if (!IsShipDepotTile(tile)) return CMD_ERROR;
- if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
+ if (!IsTileOwner(tile, _current_company)) return CMD_ERROR;
unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_SHIP);
@@ -781,7 +781,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
Vehicle *v = new Ship();
v->unitnumber = unit_num;
- v->owner = _current_player;
+ v->owner = _current_company;
v->tile = tile;
x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
@@ -829,10 +829,10 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
InvalidateWindow(WC_COMPANY, v->owner);
- if (IsLocalPlayer())
+ if (IsLocalCompany())
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
- GetPlayer(_current_player)->num_engines[p1]++;
+ GetCompany(_current_company)->num_engines[p1]++;
}
return value;
@@ -899,7 +899,7 @@ CommandCost CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
if (p2 & DEPOT_MASS_SEND) {
/* Mass goto depot requested */
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
- return SendAllVehiclesToDepot(VEH_SHIP, flags, p2 & DEPOT_SERVICE, _current_player, (p2 & VLW_MASK), p1);
+ return SendAllVehiclesToDepot(VEH_SHIP, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
}
if (!IsValidVehicleID(p1)) return CMD_ERROR;
@@ -962,7 +962,7 @@ CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
_returned_refit_capacity = capacity;
- if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
+ if (IsHumanCompany(v->owner) && new_cid != v->cargo_type) {
cost = GetRefitCost(v->engine_type);
}
diff --git a/src/signal.cpp b/src/signal.cpp
index 9a86ceb8f..aa2c753d5 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -473,13 +473,13 @@ static inline void ResetSets()
/**
* Updates blocks in _globset buffer
*
- * @param owner player whose signals we are updating
+ * @param owner company whose signals we are updating
* @return state of the first block from _globset
- * @pre IsValidPlayerID(owner)
+ * @pre IsValidCompanyID(owner)
*/
static SigSegState UpdateSignalsInBuffer(Owner owner)
{
- assert(IsValidPlayerID(owner));
+ assert(IsValidCompanyID(owner));
bool first = true; // first block?
SigSegState state = SIGSEG_FREE; // value to return
@@ -594,7 +594,7 @@ void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE
};
- /* do not allow signal updates for two players in one run */
+ /* do not allow signal updates for two companies in one run */
assert(_globset.IsEmpty() || owner == _last_owner);
_last_owner = owner;
@@ -619,7 +619,7 @@ void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
*/
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
{
- /* do not allow signal updates for two players in one run */
+ /* do not allow signal updates for two companies in one run */
assert(_globset.IsEmpty() || owner == _last_owner);
_last_owner = owner;
diff --git a/src/signs.cpp b/src/signs.cpp
index a9827c015..c9da4655d 100644
--- a/src/signs.cpp
+++ b/src/signs.cpp
@@ -28,7 +28,7 @@ SignID _new_sign_id;
/* Initialize the sign-pool */
DEFINE_OLD_POOL_GENERIC(Sign, Sign)
-Sign::Sign(PlayerID owner)
+Sign::Sign(Owner owner)
{
this->owner = owner;
}
@@ -40,7 +40,7 @@ Sign::~Sign()
if (CleaningPool()) return;
DeleteRenameSignWindow(this->index);
- this->owner = INVALID_PLAYER;
+ this->owner = INVALID_OWNER;
}
/**
@@ -105,7 +105,7 @@ CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* When we execute, really make the sign */
if (flags & DC_EXEC) {
- Sign *si = new Sign(_current_player);
+ Sign *si = new Sign(_current_company);
int x = TileX(tile) * TILE_SIZE;
int y = TileY(tile) * TILE_SIZE;
@@ -146,7 +146,7 @@ CommandCost CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
free(si->name);
/* Assign the new one */
si->name = strdup(_cmd_text);
- si->owner = _current_player;
+ si->owner = _current_company;
/* Update; mark sign dirty twice, because it can either becom longer, or shorter */
MarkSignDirty(si);
diff --git a/src/signs_base.h b/src/signs_base.h
index 4d0d05926..1c25656e2 100644
--- a/src/signs_base.h
+++ b/src/signs_base.h
@@ -17,17 +17,17 @@ struct Sign : PoolItem<Sign, SignID, &_Sign_pool> {
int32 x;
int32 y;
byte z;
- PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games.
+ OwnerByte owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
/**
* Creates a new sign
*/
- Sign(PlayerID owner = INVALID_PLAYER);
+ Sign(Owner owner = INVALID_OWNER);
/** Destroy the sign */
~Sign();
- inline bool IsValid() const { return this->owner != INVALID_PLAYER; }
+ inline bool IsValid() const { return this->owner != INVALID_OWNER; }
};
static inline SignID GetMaxSignIndex()
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 496444a87..eee35a2c8 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -111,7 +111,7 @@ struct SignListWindow : Window, SignList {
for (uint16 i = this->vscroll.pos; i < this->vscroll.cap + this->vscroll.pos && i < this->vscroll.count; i++) {
const Sign *si = this->signs[i];
- if (si->owner != OWNER_NONE) DrawPlayerIcon(si->owner, 4, y + 1);
+ if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, 4, y + 1);
SetDParam(0, si->index);
DrawString(22, y, STR_SIGN_NAME, TC_YELLOW);
@@ -349,7 +349,7 @@ static const WindowDesc _query_sign_edit_desc = {
void HandleClickOnSign(const Sign *si)
{
- if (_ctrl_pressed && si->owner == _local_player) {
+ if (_ctrl_pressed && si->owner == _local_company) {
RenameSign(si->index, NULL);
return;
}
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 6343a5d83..7be78da54 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -597,7 +597,7 @@ public:
/* setup owner table */
if (this->map_type == SMT_OWNER) {
- const Player *p;
+ const Company *c;
/* fill with some special colors */
_owner_colors[OWNER_TOWN] = MKCOLOR(0xB4B4B4B4);
@@ -605,10 +605,10 @@ public:
_owner_colors[OWNER_WATER] = MKCOLOR(0xCACACACA);
_owner_colors[OWNER_END] = MKCOLOR(0x20202020); /* industry */
- /* now fill with the player colors */
- FOR_ALL_PLAYERS(p) {
- _owner_colors[p->index] =
- _colour_gradient[p->player_color][5] * 0x01010101;
+ /* now fill with the company colours */
+ FOR_ALL_COMPANIES(c) {
+ _owner_colors[c->index] =
+ _colour_gradient[c->colour][5] * 0x01010101;
}
}
diff --git a/src/sprite.h b/src/sprite.h
index 26bdb0595..2b1755432 100644
--- a/src/sprite.h
+++ b/src/sprite.h
@@ -8,7 +8,7 @@
#include "gfx_type.h"
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
-#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
+#define COMPANY_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_company_colours[owner]))
/**
* Whether a sprite comes from the original graphics files or a new grf file
diff --git a/src/station.cpp b/src/station.cpp
index 17af0e5ec..0486f1280 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -135,7 +135,7 @@ void Station::AddFacility(byte new_facility_bit, TileIndex facil_xy)
random_bits = Random();
}
facilities |= new_facility_bit;
- owner = _current_player;
+ owner = _current_company;
build_date = _date;
}
diff --git a/src/station_base.h b/src/station_base.h
index 94f88d85f..b6dd45553 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -139,7 +139,7 @@ public:
byte time_since_load;
byte time_since_unload;
byte delete_ctr;
- PlayerByte owner;
+ OwnerByte owner;
byte facilities;
byte airport_type;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 1160f433d..cabadaa2a 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -334,7 +334,7 @@ static Station *GetClosestStationFromTile(TileIndex tile)
Station *st;
FOR_ALL_STATIONS(st) {
- if (st->facilities == 0 && st->owner == _current_player) {
+ if (st->facilities == 0 && st->owner == _current_company) {
uint cur_dist = DistanceManhattan(tile, st->xy);
if (cur_dist < threshold) {
@@ -590,7 +590,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
if (old_acc == new_acc) return;
/* show a message to report that the acceptance was changed? */
- if (show_msg && st->owner == _local_player && st->facilities) {
+ if (show_msg && st->owner == _local_company && st->facilities) {
/* List of accept and reject strings for different number of
* cargo types */
static const StringID accept_msg[] = {
@@ -689,12 +689,12 @@ CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint
* 1) The tile is "steep" (i.e. stretches two height levels)
* -OR-
* 2) The tile is non-flat if
- * a) the player building is an "old-school" AI
+ * a) the company building is an "old-school" AI
* -OR-
* b) the build_on_slopes switch is disabled
*/
if (IsSteepSlope(tileh) ||
- ((_is_old_ai_player || !_settings_game.construction.build_on_slopes) && tileh != SLOPE_FLAT)) {
+ ((_is_old_ai_company || !_settings_game.construction.build_on_slopes) && tileh != SLOPE_FLAT)) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
@@ -919,7 +919,7 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
}
} else {
/* There's no station here. Don't check the tiles surrounding this
- * one if the player wanted to build an adjacent station. */
+ * one if the company wanted to build an adjacent station. */
if (HasBit(p1, 24)) check_surrounding = false;
}
}
@@ -935,12 +935,12 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
if (st != NULL) {
/* Reuse an existing station. */
- if (st->owner != _current_player)
+ if (st->owner != _current_company)
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
if (st->train_tile != 0) {
/* check if we want to expanding an already existing station? */
- if (_is_old_ai_player || !_settings_game.station.join_stations)
+ if (_is_old_ai_company || !_settings_game.station.join_stations)
return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD);
if (!CanExpandRailroadStation(st, finalvalues, axis))
return CMD_ERROR;
@@ -958,8 +958,8 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
st->town = ClosestTownFromTile(tile_org, UINT_MAX);
st->string_id = GenerateStationName(st, tile_org, STATIONNAMING_RAIL);
- if (IsValidPlayerID(_current_player)) {
- SetBit(st->town->have_ratings, _current_player);
+ if (IsValidCompanyID(_current_company)) {
+ SetBit(st->town->have_ratings, _current_company);
}
}
}
@@ -1057,7 +1057,7 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
tile += tile_delta;
} while (--w);
- AddTrackToSignalBuffer(tile_org, track, _current_player);
+ AddTrackToSignalBuffer(tile_org, track, _current_company);
YapfNotifyTrackLayoutChange(tile_org, track);
tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
} while (--numtracks);
@@ -1179,7 +1179,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1
/* Check ownership of station */
Station *st = GetStationByTile(tile2);
- if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) {
+ if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) {
continue;
}
@@ -1252,12 +1252,12 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1
static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
{
/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
- if (_current_player == OWNER_WATER && _settings_game.station.nonuniform_stations) {
+ if (_current_company == OWNER_WATER && _settings_game.station.nonuniform_stations) {
return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION);
}
- /* Current player owns the station? */
- if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR;
+ /* Current company owns the station? */
+ if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR;
/* determine width and height of platforms */
tile = st->train_tile;
@@ -1279,7 +1279,7 @@ static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 fla
if (flags & DC_EXEC) {
/* read variables before the station tile is removed */
Track track = GetRailStationTrack(tile);
- Owner owner = GetTileOwner(tile); // _current_player can be OWNER_WATER
+ Owner owner = GetTileOwner(tile); // _current_company can be OWNER_WATER
Vehicle *v = NULL;
if (GetRailwayStationReservation(tile)) {
v = GetTrainForReservation(tile, track);
@@ -1354,7 +1354,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
bool town_owned_road = false;
RoadTypes rts = (RoadTypes)GB(p2, 2, 3);
- if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR;
+ if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_company, rts)) return CMD_ERROR;
/* Trams only have drive through stops */
if (!is_drive_through && HasBit(rts, ROADTYPE_TRAM)) return CMD_ERROR;
@@ -1422,7 +1422,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
if (st != NULL) {
- if (st->owner != _current_player) {
+ if (st->owner != _current_company) {
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
}
@@ -1437,8 +1437,8 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
st->town = ClosestTownFromTile(tile, UINT_MAX);
st->string_id = GenerateStationName(st, tile, STATIONNAMING_ROAD);
- if (IsValidPlayerID(_current_player)) {
- SetBit(st->town->have_ratings, _current_player);
+ if (IsValidCompanyID(_current_company)) {
+ SetBit(st->town->have_ratings, _current_company);
}
st->sign.width_1 = 0;
}
@@ -1489,7 +1489,7 @@ static Vehicle *ClearRoadStopStatusEnum(Vehicle *v, void *)
*/
static CommandCost RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
{
- if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) {
+ if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) {
return CMD_ERROR;
}
@@ -1566,10 +1566,10 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
/* If the stop was a drive-through stop replace the road */
if ((flags & DC_EXEC) && CmdSucceeded(ret) && is_drive_through) {
/* Rebuild the drive throuhg road stop. As a road stop can only be
- * removed by the owner of the roadstop, _current_player is the
+ * removed by the owner of the roadstop, _current_company is the
* owner of the road stop. */
MakeRoadNormal(tile, road_bits, rts, is_towns_road ? ClosestTownFromTile(tile, UINT_MAX)->index : 0,
- is_towns_road ? OWNER_TOWN : _current_player, _current_player, _current_player);
+ is_towns_road ? OWNER_TOWN : _current_company, _current_company, _current_company);
}
return ret;
@@ -1815,7 +1815,7 @@ CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (st == NULL) st = GetClosestStationFromTile(tile);
if (st != NULL) {
- if (st->owner != _current_player) {
+ if (st->owner != _current_company) {
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
}
@@ -1836,8 +1836,8 @@ CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
st->town = t;
st->string_id = GenerateStationName(st, tile, !(afc->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_HELIPORT : STATIONNAMING_AIRPORT);
- if (IsValidPlayerID(_current_player)) {
- SetBit(st->town->have_ratings, _current_player);
+ if (IsValidCompanyID(_current_company)) {
+ SetBit(st->town->have_ratings, _current_company);
}
st->sign.width_1 = 0;
}
@@ -1889,7 +1889,7 @@ CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
static CommandCost RemoveAirport(Station *st, uint32 flags)
{
- if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) {
+ if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) {
return CMD_ERROR;
}
@@ -1969,8 +1969,8 @@ CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
st->town = ClosestTownFromTile(tile, UINT_MAX);
st->string_id = GenerateStationName(st, tile, STATIONNAMING_BUOY);
- if (IsValidPlayerID(_current_player)) {
- SetBit(st->town->have_ratings, _current_player);
+ if (IsValidCompanyID(_current_company)) {
+ SetBit(st->town->have_ratings, _current_company);
}
st->sign.width_1 = 0;
st->dock_tile = tile;
@@ -1994,16 +1994,16 @@ CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
/**
- * Tests whether the player's vehicles have this station in orders
- * When player == INVALID_PLAYER, then check all vehicles
+ * Tests whether the company's vehicles have this station in orders
+ * When company == INVALID_COMPANY, then check all vehicles
* @param station station ID
- * @param player player ID, INVALID_PLAYER to disable the check
+ * @param company company ID, INVALID_COMPANY to disable the check
*/
-bool HasStationInUse(StationID station, PlayerID player)
+bool HasStationInUse(StationID station, CompanyID company)
{
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (player == INVALID_PLAYER || v->owner == player) {
+ if (company == INVALID_COMPANY || v->owner == company) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == station) {
@@ -2018,11 +2018,11 @@ bool HasStationInUse(StationID station, PlayerID player)
static CommandCost RemoveBuoy(Station *st, uint32 flags)
{
/* XXX: strange stuff */
- if (!IsValidPlayerID(_current_player)) return_cmd_error(INVALID_STRING_ID);
+ if (!IsValidCompanyID(_current_company)) return_cmd_error(INVALID_STRING_ID);
TileIndex tile = st->dock_tile;
- if (HasStationInUse(st->index, INVALID_PLAYER)) return_cmd_error(STR_BUOY_IS_IN_USE);
+ if (HasStationInUse(st->index, INVALID_COMPANY)) return_cmd_error(STR_BUOY_IS_IN_USE);
/* remove the buoy if there is a ship on tile when company goes bankrupt... */
if (!(flags & DC_BANKRUPT) && !EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
@@ -2110,7 +2110,7 @@ CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (st == NULL) st = GetClosestStationFromTile(tile);
if (st != NULL) {
- if (st->owner != _current_player) {
+ if (st->owner != _current_company) {
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
}
@@ -2128,8 +2128,8 @@ CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
st->town = ClosestTownFromTile(tile, UINT_MAX);
st->string_id = GenerateStationName(st, tile, STATIONNAMING_DOCK);
- if (IsValidPlayerID(_current_player)) {
- SetBit(st->town->have_ratings, _current_player);
+ if (IsValidCompanyID(_current_company)) {
+ SetBit(st->town->have_ratings, _current_company);
}
}
}
@@ -2208,13 +2208,13 @@ static void DrawTile_Station(TileInfo *ti)
uint32 relocation = 0;
const Station *st = NULL;
const StationSpec *statspec = NULL;
- PlayerID owner = GetTileOwner(ti->tile);
+ Owner owner = GetTileOwner(ti->tile);
SpriteID palette;
- if (IsValidPlayerID(owner)) {
- palette = PLAYER_SPRITE_COLOR(owner);
+ if (IsValidCompanyID(owner)) {
+ palette = COMPANY_SPRITE_COLOR(owner);
} else {
- /* Some stations are not owner by a player, namely oil rigs */
+ /* Some stations are not owner by a company, namely oil rigs */
palette = PALETTE_TO_GREY;
}
@@ -2326,7 +2326,7 @@ static void DrawTile_Station(TileInfo *ti)
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
{
int32 total_offset = 0;
- SpriteID pal = PLAYER_SPRITE_COLOR(_local_player);
+ SpriteID pal = COMPANY_SPRITE_COLOR(_local_company);
const DrawTileSprites *t = &_station_display_datas[st][image];
if (railtype != INVALID_RAILTYPE) {
@@ -2649,7 +2649,7 @@ static void UpdateStationRating(Station *st)
(rating += 13, true);
}
- if (IsValidPlayerID(st->owner) && HasBit(st->town->statues, st->owner)) rating += 26;
+ if (IsValidCompanyID(st->owner) && HasBit(st->town->statues, st->owner)) rating += 26;
{
byte days = ge->days_since_pickup;
@@ -2762,7 +2762,7 @@ void StationMonthlyLoop()
}
-void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius)
+void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius)
{
Station *st;
@@ -3044,15 +3044,15 @@ void DeleteOilRig(TileIndex tile)
if (st->facilities == 0) delete st;
}
-static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_owner)
{
- if (!IsTileOwner(tile, old_player)) return;
+ if (!IsTileOwner(tile, old_owner)) return;
- if (new_player != PLAYER_SPECTATOR) {
+ if (new_owner != INVALID_OWNER) {
Station *st = GetStationByTile(tile);
- SetTileOwner(tile, new_player);
- if (!IsBuoy(tile)) st->owner = new_player; // do not set st->owner for buoys
+ SetTileOwner(tile, new_owner);
+ if (!IsBuoy(tile)) st->owner = new_owner; // do not set st->owner for buoys
InvalidateWindowClassesData(WC_STATION_LIST, 0);
} else {
if (IsDriveThroughStopTile(tile)) {
@@ -3060,13 +3060,13 @@ static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerI
DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? ROADSTOP_TRUCK : ROADSTOP_BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
assert(IsTileType(tile, MP_ROAD));
/* Change owner of tile and all roadtypes */
- ChangeTileOwner(tile, old_player, new_player);
+ ChangeTileOwner(tile, old_owner, new_owner);
} else {
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
/* Set tile owner of water under (now removed) buoy and dock to OWNER_NONE.
* Update owner of buoy if it was not removed (was in orders).
* Do not update when owned by OWNER_WATER (sea and rivers). */
- if ((IsTileType(tile, MP_WATER) || IsBuoyTile(tile)) && IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE);
+ if ((IsTileType(tile, MP_WATER) || IsBuoyTile(tile)) && IsTileOwner(tile, old_owner)) SetTileOwner(tile, OWNER_NONE);
}
}
}
diff --git a/src/station_func.h b/src/station_func.h
index d2f66fc63..5493f4e5a 100644
--- a/src/station_func.h
+++ b/src/station_func.h
@@ -14,7 +14,7 @@
#include "vehicle_type.h"
#include <set>
-void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius);
+void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
/** A set of stations (\c const \c Station* ) */
typedef std::set<Station*> StationSet;
@@ -31,7 +31,7 @@ void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int
const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);
-bool HasStationInUse(StationID station, PlayerID player);
+bool HasStationInUse(StationID station, CompanyID company);
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type);
uint GetNumRoadStops(const Station* st, RoadStopType type);
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 0bd274bf3..88d023ea0 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -84,9 +84,9 @@ static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount
typedef GUIList<const Station*> GUIStationList;
/**
- * The list of stations per player.
+ * The list of stations per company.
*/
-class PlayerStationsWindow : public Window
+class CompanyStationsWindow : public Window
{
protected:
/* Runtime saved values */
@@ -107,13 +107,13 @@ protected:
/**
* (Re)Build station list
*
- * @param owner player whose stations are to be in list
+ * @param owner company whose stations are to be in list
*/
- void BuildStationsList(const PlayerID owner)
+ void BuildStationsList(const Owner owner)
{
if (!this->stations.NeedRebuild()) return;
- DEBUG(misc, 3, "Building station list for player %d", owner);
+ DEBUG(misc, 3, "Building station list for company %d", owner);
this->stations.Clear();
@@ -208,7 +208,7 @@ protected:
}
public:
- PlayerStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
+ CompanyStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->caption_color = (byte)this->window_number;
this->vscroll.cap = 12;
@@ -276,21 +276,21 @@ public:
this->FindWindowPlacementAndResize(desc);
}
- ~PlayerStationsWindow()
+ ~CompanyStationsWindow()
{
this->last_sorting = this->stations.GetListing();
}
virtual void OnPaint()
{
- const PlayerID owner = (PlayerID)this->window_number;
+ const Owner owner = (Owner)this->window_number;
this->BuildStationsList(owner);
this->SortStationsList();
SetVScrollCount(this, this->stations.Length());
- /* draw widgets, with player's name in the caption */
+ /* draw widgets, with company's name in the caption */
SetDParam(0, owner);
SetDParam(1, this->vscroll.count);
@@ -326,7 +326,7 @@ public:
cg_ofst = this->IsWidgetLowered(SLW_FACILALL) ? 2 : 1;
DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
- if (this->vscroll.count == 0) { // player has no stations
+ if (this->vscroll.count == 0) { // company has no stations
DrawString(xb, 40, STR_304A_NONE, TC_FROMSTRING);
return;
}
@@ -373,7 +373,7 @@ public:
const Station *st = this->stations[id_v];
/* do not check HasStationInUse - it is slow and may be invalid */
- assert(st->owner == (PlayerID)this->window_number || (st->owner == OWNER_NONE && !st->IsBuoy()));
+ assert(st->owner == (Owner)this->window_number || (st->owner == OWNER_NONE && !st->IsBuoy()));
if (_ctrl_pressed) {
ShowExtraViewPortWindow(st->xy);
@@ -512,7 +512,7 @@ public:
{
if (_pause_game != 0) return;
if (this->stations.NeedResort()) {
- DEBUG(misc, 3, "Periodic rebuild station list player %d", this->window_number);
+ DEBUG(misc, 3, "Periodic rebuild station list company %d", this->window_number);
this->SetDirty();
}
}
@@ -538,15 +538,15 @@ public:
}
};
-Listing PlayerStationsWindow::last_sorting = {false, 0};
-byte PlayerStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
-bool PlayerStationsWindow::include_empty = true;
-const uint32 PlayerStationsWindow::cargo_filter_max = UINT32_MAX;
-uint32 PlayerStationsWindow::cargo_filter = UINT32_MAX;
-const Station *PlayerStationsWindow::last_station = NULL;
+Listing CompanyStationsWindow::last_sorting = {false, 0};
+byte CompanyStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
+bool CompanyStationsWindow::include_empty = true;
+const uint32 CompanyStationsWindow::cargo_filter_max = UINT32_MAX;
+uint32 CompanyStationsWindow::cargo_filter = UINT32_MAX;
+const Station *CompanyStationsWindow::last_station = NULL;
/* Availible station sorting functions */
-GUIStationList::SortFunction *const PlayerStationsWindow::sorter_funcs[] = {
+GUIStationList::SortFunction *const CompanyStationsWindow::sorter_funcs[] = {
&StationNameSorter,
&StationTypeSorter,
&StationWaitingSorter,
@@ -554,7 +554,7 @@ GUIStationList::SortFunction *const PlayerStationsWindow::sorter_funcs[] = {
};
/* Names of the sorting functions */
-const StringID PlayerStationsWindow::sorter_names[] = {
+const StringID CompanyStationsWindow::sorter_names[] = {
STR_SORT_BY_DROPDOWN_NAME,
STR_SORT_BY_FACILITY,
STR_SORT_BY_WAITING,
@@ -563,7 +563,7 @@ const StringID PlayerStationsWindow::sorter_names[] = {
};
-static const Widget _player_stations_widgets[] = {
+static const Widget _company_stations_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SLW_CLOSEBOX
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON},
@@ -589,23 +589,23 @@ static const Widget _player_stations_widgets[] = {
{ WIDGETS_END},
};
-static const WindowDesc _player_stations_desc = {
+static const WindowDesc _company_stations_desc = {
WDP_AUTO, WDP_AUTO, 358, 162, 358, 162,
WC_STATION_LIST, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
- _player_stations_widgets,
+ _company_stations_widgets,
};
/**
- * Opens window with list of player's stations
+ * Opens window with list of company's stations
*
- * @param player player whose stations' list show
+ * @param company whose stations' list show
*/
-void ShowPlayerStations(PlayerID player)
+void ShowCompanyStations(CompanyID company)
{
- if (!IsValidPlayerID(player)) return;
+ if (!IsValidCompanyID(company)) return;
- AllocateWindowDescFront<PlayerStationsWindow>(&_player_stations_desc, player);
+ AllocateWindowDescFront<CompanyStationsWindow>(&_company_stations_desc, company);
}
static const Widget _station_view_widgets[] = {
@@ -687,7 +687,7 @@ struct StationViewWindow : public Window {
StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- PlayerID owner = GetStation(window_number)->owner;
+ Owner owner = GetStation(window_number)->owner;
if (owner != OWNER_NONE) this->caption_color = owner;
this->vscroll.cap = 5;
this->resize.step_height = 10;
@@ -755,7 +755,7 @@ struct StationViewWindow : public Window {
SetVScrollCount(this, (int)cargolist.size() + 1); // update scrollbar
/* disable some buttons */
- this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_player);
+ this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_company);
this->SetWidgetDisabledState(SVW_TRAINS, !(st->facilities & FACIL_TRAIN));
this->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
this->SetWidgetDisabledState(SVW_PLANES, !(st->facilities & FACIL_AIRPORT));
@@ -929,16 +929,16 @@ struct StationViewWindow : public Window {
case SVW_PLANES: { // Show a list of scheduled aircraft to this station
const Station *st = GetStation(this->window_number);
- /* Since oilrigs have no owners, show the scheduled aircraft of current player */
- PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
+ /* Since oilrigs have no owners, show the scheduled aircraft of current company */
+ Owner owner = (st->owner == OWNER_NONE) ? _current_company : st->owner;
ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number);
break;
}
case SVW_SHIPS: { // Show a list of scheduled ships to this station
const Station *st = GetStation(this->window_number);
- /* Since oilrigs/bouys have no owners, show the scheduled ships of current player */
- PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
+ /* Since oilrigs/bouys have no owners, show the scheduled ships of current company */
+ Owner owner = (st->owner == OWNER_NONE) ? _current_company : st->owner;
ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
break;
}
diff --git a/src/station_gui.h b/src/station_gui.h
index 316daf88c..3435ff16d 100644
--- a/src/station_gui.h
+++ b/src/station_gui.h
@@ -5,7 +5,7 @@
#ifndef STATION_GUI_H
#define STATION_GUI_H
-/** Enum for PlayerStations, referring to _player_stations_widgets */
+/** Enum for CompanyStations, referring to _company_stations_widgets */
enum StationListWidgets {
SLW_CLOSEBOX = 0, ///< Close 'X' button
@@ -27,7 +27,7 @@ enum StationListWidgets {
SLW_SORTDROPBTN = 17, ///< Dropdown button
SLW_PAN_SORT_RIGHT = 18, ///< Panel right of sorting options
- SLW_CARGOSTART = 19, ///< Widget numbers used for list of cargo types (not present in _player_stations_widgets)
+ SLW_CARGOSTART = 19, ///< Widget numbers used for list of cargo types (not present in _company_stations_widgets)
};
/** Enum for StationView, referring to _station_view_widgets and _station_view_expanded_widgets */
diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp
index 47cac9ecb..692b0a8a5 100644
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -78,15 +78,15 @@ struct StatusBarWindow : Window {
virtual void OnPaint()
{
- const Player *p = (_local_player == PLAYER_SPECTATOR) ? NULL : GetPlayer(_local_player);
+ const Company *c = (_local_company == COMPANY_SPECTATOR) ? NULL : GetCompany(_local_company);
this->DrawWidgets();
SetDParam(0, _date);
DrawStringCentered(70, 1, (_pause_game || _settings_client.gui.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING);
- if (p != NULL) {
- /* Draw player money */
- SetDParam(0, p->player_money);
+ if (c != NULL) {
+ /* Draw company money */
+ SetDParam(0, c->money);
DrawStringCentered(this->widget[2].left + 70, 1, STR_0004, TC_FROMSTRING);
}
@@ -101,16 +101,16 @@ struct StatusBarWindow : Window {
/* Draw the scrolling news text */
if (!DrawScrollingStatusText(&_statusbar_news_item, this->ticker_scroll, this->widget[1].right - this->widget[1].left - 2)) {
this->ticker_scroll = -1280;
- if (p != NULL) {
+ if (c != NULL) {
/* This is the default text */
- SetDParam(0, p->index);
+ SetDParam(0, c->index);
DrawStringCenteredTruncated(this->widget[1].left + 1, this->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
}
}
} else {
- if (p != NULL) {
+ if (c != NULL) {
/* This is the default text */
- SetDParam(0, p->index);
+ SetDParam(0, c->index);
DrawStringCenteredTruncated(this->widget[1].left + 1, this->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
}
}
@@ -133,7 +133,7 @@ struct StatusBarWindow : Window {
{
switch (widget) {
case 1: ShowLastNewsMessage(); break;
- case 2: if (_local_player != PLAYER_SPECTATOR) ShowPlayerFinances(_local_player); break;
+ case 2: if (_local_company != COMPANY_SPECTATOR) ShowCompanyFinances(_local_company); break;
default: ResetObjectToPlace();
}
}
diff --git a/src/strings.cpp b/src/strings.cpp
index 5d0fa5675..845113297 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -49,7 +49,7 @@ uint64 _decode_parameters[20];
static char *StationGetSpecialString(char *buff, int x, const char* last);
static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char* last);
-static char *GetSpecialPlayerNameString(char *buff, int ind, const int64 *argv, const char* last);
+static char *GetSpecialNameString(char *buff, int ind, const int64 *argv, const char* last);
static char *FormatString(char *buff, const char *str, const int64 *argv, uint casei, const char* last);
@@ -130,7 +130,7 @@ static char *GetStringWithArgs(char *buffr, uint string, const int64 *argv, cons
case 14:
if (index >= 0xE4)
- return GetSpecialPlayerNameString(buffr, index - 0xE4, argv, last);
+ return GetSpecialNameString(buffr, index - 0xE4, argv, last);
break;
case 15:
@@ -959,39 +959,39 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
}
case SCC_COMPANY_NAME: { // {COMPANY}
- const Player *p = GetPlayer((PlayerID)GetInt32(&argv));
+ const Company *c = GetCompany((CompanyID)GetInt32(&argv));
- if (p->name != NULL) {
- buff = strecpy(buff, p->name, last);
+ if (c->name != NULL) {
+ buff = strecpy(buff, c->name, last);
} else {
int64 args[1];
- args[0] = p->name_2;
- buff = GetStringWithArgs(buff, p->name_1, args, last);
+ args[0] = c->name_2;
+ buff = GetStringWithArgs(buff, c->name_1, args, last);
}
break;
}
case SCC_COMPANY_NUM: { // {COMPANYNUM}
- PlayerID player = (PlayerID)GetInt32(&argv);
+ CompanyID company = (CompanyID)GetInt32(&argv);
- /* Nothing is added for AI or inactive players */
- if (IsValidPlayerID(player) && IsHumanPlayer(player)) {
+ /* Nothing is added for AI or inactive companies */
+ if (IsValidCompanyID(company) && IsHumanCompany(company)) {
int64 args[1];
- args[0] = player + 1;
+ args[0] = company + 1;
buff = GetStringWithArgs(buff, STR_7002_PLAYER, args, last);
}
break;
}
case SCC_PLAYER_NAME: { // {PLAYERNAME}
- const Player *p = GetPlayer((PlayerID)GetInt32(&argv));
+ const Company *c = GetCompany((CompanyID)GetInt32(&argv));
- if (p->president_name != NULL) {
- buff = strecpy(buff, p->president_name, last);
+ if (c->president_name != NULL) {
+ buff = strecpy(buff, c->president_name, last);
} else {
int64 args[1];
- args[0] = p->president_name_2;
- buff = GetStringWithArgs(buff, p->president_name_1, args, last);
+ args[0] = c->president_name_2;
+ buff = GetStringWithArgs(buff, c->president_name_1, args, last);
}
break;
}
@@ -1165,7 +1165,7 @@ static char *GenPresidentName(char *buff, uint32 x, const char* last)
return buff;
}
-static char *GetSpecialPlayerNameString(char *buff, int ind, const int64 *argv, const char* last)
+static char *GetSpecialNameString(char *buff, int ind, const int64 *argv, const char* last)
{
switch (ind) {
case 1: // not used
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 96008db84..53fe13647 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -153,8 +153,7 @@ struct SubsidyListWindow : Window {
SetupSubsidyDecodeParam(s, 1);
- PlayerID player = GetStation(s->to)->owner;
- SetDParam(3, player);
+ SetDParam(3, GetStation(s->to)->owner);
/* Displays the two connected stations */
xt = DrawStringTruncated(x + 2, y, STR_202C_FROM_TO, TC_FROMSTRING, width - 2);
diff --git a/src/table/sprites.h b/src/table/sprites.h
index e4a14efb2..d3091e41c 100644
--- a/src/table/sprites.h
+++ b/src/table/sprites.h
@@ -242,7 +242,7 @@ enum Sprites {
/* Manager face sprites */
SPR_GRADIENT = 874, // background gradient behind manager face
- /* Icon showing player colour. */
+ /* Icon showing company colour. */
SPR_PLAYER_ICON = 747,
/* is itself no foundation sprite, because tileh 0 has no foundation */
@@ -1530,7 +1530,7 @@ enum PaletteSprites {
PALETTE_TO_DARK_GREEN = 0x30E,
PALETTE_TO_BLUE = 0x30F,
PALETTE_TO_CREAM = 0x310,
- //maybe don't use as player color because it doesn't display in the graphs?
+ //maybe don't use as company color because it doesn't display in the graphs?
PALETTE_TO_MAUVE = 0x311,
PALETTE_TO_PURPLE = 0x312,
PALETTE_TO_ORANGE = 0x313,
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 753f34cc0..7e0fcf146 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -327,7 +327,7 @@ static const WindowDesc _terraform_desc = {
void ShowTerraformToolbar(Window *link)
{
- if (!IsValidPlayerID(_current_player)) return;
+ if (!IsValidCompanyID(_current_company)) return;
Window *w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
if (w != NULL && link != NULL) {
/* Align the terraform toolbar under the main toolbar and put the linked
@@ -487,7 +487,7 @@ enum EditorTerraformToolbarWidgets {
ETTW_INCREASE_SIZE = ETTW_BUTTONS_END, ///< Upwards arrow button to increase terraforming size
ETTW_DECREASE_SIZE, ///< Downwards arrow button to decrease terraforming size
ETTW_NEW_SCENARIO, ///< Button for generating a new scenario
- ETTW_RESET_LANDSCAPE, ///< Button for removing all player-owned property
+ ETTW_RESET_LANDSCAPE, ///< Button for removing all company-owned property
};
/**
@@ -557,22 +557,22 @@ static OnButtonClick * const _editor_terraform_button_proc[] = {
static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
{
if (confirmed) {
- Player *p;
+ Company *c;
/* Set generating_world to true to get instant-green grass after removing
- * player property. */
+ * company property. */
_generating_world = true;
- /* Delete all stations owned by a player */
+ /* Delete all stations owned by a company */
Station *st;
FOR_ALL_STATIONS(st) {
- if (IsValidPlayerID(st->owner)) delete st;
+ if (IsValidCompanyID(st->owner)) delete st;
}
- /* Delete all players */
- FOR_ALL_PLAYERS(p) {
- ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
- delete p;
+ /* Delete all companies */
+ FOR_ALL_COMPANIES(c) {
+ ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
+ delete c;
}
_generating_world = false;
}
diff --git a/src/tile_cmd.h b/src/tile_cmd.h
index ad3935b02..9faa1f0da 100644
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -81,7 +81,7 @@ typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
typedef void ClickTileProc(TileIndex tile);
typedef void AnimateTileProc(TileIndex tile);
typedef void TileLoopProc(TileIndex tile);
-typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
+typedef void ChangeTileOwnerProc(TileIndex tile, Owner old_owner, Owner new_owner);
/** @see VehicleEnterTileStatus to see what the return values mean */
typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
@@ -123,7 +123,7 @@ extern const TileTypeProcs * const _tile_type_procs[16];
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
-void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player);
+void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
void AnimateTile(TileIndex tile);
void ClickTile(TileIndex tile);
void GetTileDesc(TileIndex tile, TileDesc *td);
diff --git a/src/tile_map.h b/src/tile_map.h
index 108cc5adb..96678cdc4 100644
--- a/src/tile_map.h
+++ b/src/tile_map.h
@@ -122,7 +122,7 @@ static inline bool IsValidTile(TileIndex tile)
*
* This function returns the owner of a tile. This cannot used
* for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY
- * as no player owned any of these buildings.
+ * as no company owned any of these buildings.
*
* @param tile The tile to check
* @return The owner of the tile
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 4dfa376e2..0007b63f1 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -146,7 +146,7 @@ struct TimetableWindow : Window {
SetVScrollCount(this, v->num_orders * 2);
- if (v->owner == _local_player) {
+ if (v->owner == _local_company) {
bool disable = true;
if (selected != -1) {
const Order *order = GetVehicleOrder(v, ((selected + 1) / 2) % v->num_orders);
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 17622061f..99cf36a43 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -80,7 +80,7 @@ enum ToolbarNormalWidgets {
TBN_SUBSIDIES,
TBN_STATIONS,
TBN_FINANCES,
- TBN_PLAYERS,
+ TBN_COMPANIES,
TBN_GRAPHICS,
TBN_LEAGUE,
TBN_INDUSTRIES,
@@ -143,7 +143,7 @@ public:
};
/**
- * Drop down list entry for showing a company entry, with player 'blob'.
+ * Drop down list entry for showing a company entry, with companies 'blob'.
*/
class DropDownListCompanyItem : public DropDownListItem {
public:
@@ -161,20 +161,20 @@ public:
uint Width() const
{
char buffer[512];
- PlayerID player = (PlayerID)result;
- SetDParam(0, player);
- SetDParam(1, player);
+ CompanyID company = (CompanyID)result;
+ SetDParam(0, company);
+ SetDParam(1, company);
GetString(buffer, STR_7021, lastof(buffer));
return GetStringBoundingBox(buffer).width + 19;
}
void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const
{
- PlayerID player = (PlayerID)result;
- DrawPlayerIcon(player, x + 2, y + 1);
+ CompanyID company = (CompanyID)result;
+ DrawCompanyIcon(company, x + 2, y + 1);
- SetDParam(0, player);
- SetDParam(1, player);
+ SetDParam(0, company);
+ SetDParam(1, company);
int col;
if (this->greyed) {
col = TC_GREY;
@@ -201,21 +201,21 @@ static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count
/**
* Pop up a generic company list menu.
*/
-static void PopupMainPlayerToolbMenu(Window *w, int widget, int grey = 0)
+static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
{
DropDownList *list = new DropDownList();
- if (widget == TBN_PLAYERS && _networking) {
- /* Add the client list button for the Players menu */
+ if (widget == TBN_COMPANIES && _networking) {
+ /* Add the client list button for the companies menu */
list->push_back(new DropDownListStringItem(STR_NETWORK_CLIENT_LIST, -1, false));
}
- for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) {
- if (!IsValidPlayerID(p)) continue;
- list->push_back(new DropDownListCompanyItem(p, false, HasBit(grey, p)));
+ for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
+ if (!IsValidCompanyID(c)) continue;
+ list->push_back(new DropDownListCompanyItem(c, false, HasBit(grey, c)));
}
- ShowDropDownList(w, list, _local_player == PLAYER_SPECTATOR ? -1 : _local_player, widget, 240, true, true);
+ ShowDropDownList(w, list, _local_company == COMPANY_SPECTATOR ? -1 : _local_company, widget, 240, true, true);
SndPlayFx(SND_15_BEEP);
}
@@ -418,31 +418,31 @@ static void MenuClickSubsidies(int index)
static void ToolbarStationsClick(Window *w)
{
- PopupMainPlayerToolbMenu(w, TBN_STATIONS);
+ PopupMainCompanyToolbMenu(w, TBN_STATIONS);
}
static void MenuClickStations(int index)
{
- ShowPlayerStations((PlayerID)index);
+ ShowCompanyStations((CompanyID)index);
}
/* --- Finances button menu --- */
static void ToolbarFinancesClick(Window *w)
{
- PopupMainPlayerToolbMenu(w, TBN_FINANCES);
+ PopupMainCompanyToolbMenu(w, TBN_FINANCES);
}
static void MenuClickFinances(int index)
{
- ShowPlayerFinances((PlayerID)index);
+ ShowCompanyFinances((CompanyID)index);
}
/* --- Company's button menu --- */
-static void ToolbarPlayersClick(Window *w)
+static void ToolbarCompaniesClick(Window *w)
{
- PopupMainPlayerToolbMenu(w, TBN_PLAYERS);
+ PopupMainCompanyToolbMenu(w, TBN_COMPANIES);
}
static void MenuClickCompany(int index)
@@ -450,7 +450,7 @@ static void MenuClickCompany(int index)
if (_networking && index == -1) {
ShowClientList();
} else {
- ShowPlayerCompany((PlayerID)index);
+ ShowCompany((CompanyID)index);
}
}
@@ -496,7 +496,7 @@ static void MenuClickLeague(int index)
static void ToolbarIndustryClick(Window *w)
{
/* Disable build-industry menu if we are a spectator */
- PopupMainToolbMenu(w, TBN_INDUSTRIES, STR_INDUSTRY_DIR, (_current_player == PLAYER_SPECTATOR) ? 1 : 2);
+ PopupMainToolbMenu(w, TBN_INDUSTRIES, STR_INDUSTRY_DIR, (_current_company == COMPANY_SPECTATOR) ? 1 : 2);
}
static void MenuClickIndustry(int index)
@@ -517,7 +517,7 @@ static void ToolbarVehicleClick(Window *w, VehicleType veh)
FOR_ALL_VEHICLES(v) {
if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
}
- PopupMainPlayerToolbMenu(w, TBN_VEHICLESTART + veh, dis);
+ PopupMainCompanyToolbMenu(w, TBN_VEHICLESTART + veh, dis);
}
@@ -528,7 +528,7 @@ static void ToolbarTrainClick(Window *w)
static void MenuClickShowTrains(int index)
{
- ShowVehicleListWindow((PlayerID)index, VEH_TRAIN);
+ ShowVehicleListWindow((CompanyID)index, VEH_TRAIN);
}
/* --- Road vehicle button menu --- */
@@ -540,7 +540,7 @@ static void ToolbarRoadClick(Window *w)
static void MenuClickShowRoad(int index)
{
- ShowVehicleListWindow((PlayerID)index, VEH_ROAD);
+ ShowVehicleListWindow((CompanyID)index, VEH_ROAD);
}
/* --- Ship button menu --- */
@@ -552,7 +552,7 @@ static void ToolbarShipClick(Window *w)
static void MenuClickShowShips(int index)
{
- ShowVehicleListWindow((PlayerID)index, VEH_SHIP);
+ ShowVehicleListWindow((CompanyID)index, VEH_SHIP);
}
/* --- Aircraft button menu --- */
@@ -564,7 +564,7 @@ static void ToolbarAirClick(Window *w)
static void MenuClickShowAir(int index)
{
- ShowVehicleListWindow((PlayerID)index, VEH_AIRCRAFT);
+ ShowVehicleListWindow((CompanyID)index, VEH_AIRCRAFT);
}
/* --- Zoom in button --- */
@@ -591,11 +591,11 @@ static void ToolbarZoomOutClick(Window *w)
static void ToolbarBuildRailClick(Window *w)
{
- const Player *p = GetPlayer(_local_player);
+ const Company *c = GetCompany(_local_company);
DropDownList *list = new DropDownList();
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
const RailtypeInfo *rti = GetRailTypeInfo(rt);
- list->push_back(new DropDownListStringItem(rti->strings.menu_text, rt, !HasBit(p->avail_railtypes, rt)));
+ list->push_back(new DropDownListStringItem(rti->strings.menu_text, rt, !HasBit(c->avail_railtypes, rt)));
}
ShowDropDownList(w, list, _last_built_railtype, TBN_RAILS, 140, true, true);
SndPlayFx(SND_15_BEEP);
@@ -611,14 +611,14 @@ static void MenuClickBuildRail(int index)
static void ToolbarBuildRoadClick(Window *w)
{
- const Player *p = GetPlayer(_local_player);
+ const Company *c = GetCompany(_local_company);
DropDownList *list = new DropDownList();
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
/* Highways don't exist */
if (rt == ROADTYPE_HWAY) continue;
/* The standard road button is *always* available */
- list->push_back(new DropDownListStringItem(STR_180A_ROAD_CONSTRUCTION + rt, rt, !(HasBit(p->avail_roadtypes, rt) || rt == ROADTYPE_ROAD)));
+ list->push_back(new DropDownListStringItem(STR_180A_ROAD_CONSTRUCTION + rt, rt, !(HasBit(c->avail_roadtypes, rt) || rt == ROADTYPE_ROAD)));
}
ShowDropDownList(w, list, _last_built_roadtype, TBN_ROADS, 140, true, true);
SndPlayFx(SND_15_BEEP);
@@ -958,7 +958,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = {
ToolbarSubsidiesClick,
ToolbarStationsClick,
ToolbarFinancesClick,
- ToolbarPlayersClick,
+ ToolbarCompaniesClick,
ToolbarGraphsClick,
ToolbarLeagueClick,
ToolbarIndustryClick,
@@ -1001,9 +1001,9 @@ struct MainToolbarWindow : Window {
/* If spectator, disable all construction buttons
* ie : Build road, rail, ships, airports and landscaping
* Since enabled state is the default, just disable when needed */
- this->SetWidgetsDisabledState(_current_player == PLAYER_SPECTATOR, TBN_RAILS, TBN_ROADS, TBN_WATER, TBN_AIR, TBN_LANDSCAPE, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(_current_company == COMPANY_SPECTATOR, TBN_RAILS, TBN_ROADS, TBN_WATER, TBN_AIR, TBN_LANDSCAPE, WIDGET_LIST_END);
/* disable company list drop downs, if there are no companies */
- this->SetWidgetsDisabledState(ActivePlayerCount() == TBN_PAUSE, TBN_STATIONS, TBN_FINANCES, TBN_TRAINS, TBN_ROADVEHS, TBN_SHIPS, TBN_AIRCRAFTS, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(ActiveCompanyCount() == TBN_PAUSE, TBN_STATIONS, TBN_FINANCES, TBN_TRAINS, TBN_ROADVEHS, TBN_SHIPS, TBN_AIRCRAFTS, WIDGET_LIST_END);
this->SetWidgetDisabledState(TBN_RAILS, !CanBuildVehicleInfrastructure(VEH_TRAIN));
this->SetWidgetDisabledState(TBN_AIR, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
@@ -1030,16 +1030,16 @@ struct MainToolbarWindow : Window {
case WKC_F4: ShowSmallMap(); break;
case WKC_F5: ShowTownDirectory(); break;
case WKC_F6: ShowSubsidiesList(); break;
- case WKC_F7: ShowPlayerStations(_local_player); break;
- case WKC_F8: ShowPlayerFinances(_local_player); break;
- case WKC_F9: ShowPlayerCompany(_local_player); break;
+ case WKC_F7: ShowCompanyStations(_local_company); break;
+ case WKC_F8: ShowCompanyFinances(_local_company); break;
+ case WKC_F9: ShowCompany(_local_company); break;
case WKC_F10: ShowOperatingProfitGraph(); break;
case WKC_F11: ShowCompanyLeagueTable(); break;
case WKC_F12: ShowBuildIndustryWindow(); break;
- case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, VEH_TRAIN); break;
- case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, VEH_ROAD); break;
- case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, VEH_SHIP); break;
- case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, VEH_AIRCRAFT); break;
+ case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_company, VEH_TRAIN); break;
+ case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_company, VEH_ROAD); break;
+ case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_company, VEH_SHIP); break;
+ case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
case WKC_NUM_PLUS: // Fall through
case WKC_EQUALS: // Fall through
case WKC_SHIFT | WKC_EQUALS: // Fall through
@@ -1121,7 +1121,7 @@ static const Widget _toolb_normal_widgets[] = {
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 0, 0, 21, SPR_IMG_COMPANY_LIST, STR_0173_DISPLAY_LIST_OF_COMPANY}, // TBN_STATIONS
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 0, 0, 21, SPR_IMG_COMPANY_FINANCE, STR_0177_DISPLAY_COMPANY_FINANCES}, // TBN_FINANCES
-{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 0, 0, 21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL}, // TBN_PLAYERS
+{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 0, 0, 21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL}, // TBN_COMPANIES
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 0, 0, 21, SPR_IMG_GRAPHS, STR_0179_DISPLAY_GRAPHS}, // TBN_GRAPHICS
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 0, 0, 21, SPR_IMG_COMPANY_LEAGUE, STR_017A_DISPLAY_COMPANY_LEAGUE}, // TBN_LEAGUE
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 0, 0, 0, 21, SPR_IMG_INDUSTRY, STR_0312_FUND_CONSTRUCTION_OF_NEW}, // TBN_INDUSTRIES
diff --git a/src/town.h b/src/town.h
index 65cfe6cbb..bff83a87f 100644
--- a/src/town.h
+++ b/src/town.h
@@ -81,7 +81,7 @@ DECLARE_ENUM_AS_BIT_SET(HouseZones)
enum HouseExtraFlags {
NO_EXTRA_FLAG = 0,
BUILDING_IS_HISTORICAL = 1U << 0, ///< this house will only appear during town generation in random games, thus the historical
- BUILDING_IS_PROTECTED = 1U << 1, ///< towns and AI will not remove this house, while human players will be able tp
+ BUILDING_IS_PROTECTED = 1U << 1, ///< towns and AI will not remove this house, while human players will be able to
SYNCHRONISED_CALLBACK_1B = 1U << 2, ///< synchronized callback 1B will be performed, on multi tile houses
CALLBACK_1A_RANDOM_BITS = 1U << 3, ///< callback 1A needs random bits
};
@@ -120,15 +120,15 @@ struct Town : PoolItem<Town, TownID, &_Town_pool> {
/* level of noise that all the airports are generating */
uint16 noise_reached;
- /* Which players have a statue? */
+ /* Which companies have a statue? */
byte statues;
- /* Player ratings as well as a mask that determines which players have a rating. */
- PlayerMask have_ratings;
- uint8 unwanted[MAX_PLAYERS]; ///< how many months companies aren't wanted by towns (bribe)
- PlayerByte exclusivity; ///< which player has exslusivity
- uint8 exclusive_counter; ///< months till the exclusivity expires
- int16 ratings[MAX_PLAYERS];
+ /* Company ratings as well as a mask that determines which companies have a rating. */
+ CompanyMask have_ratings;
+ uint8 unwanted[MAX_COMPANIES]; ///< how many months companies aren't wanted by towns (bribe)
+ CompanyByte exclusivity; ///< which company has exclusivity
+ uint8 exclusive_counter; ///< months till the exclusivity expires
+ int16 ratings[MAX_COMPANIES];
/* Maximum amount of passengers and mail that can be transported. */
uint32 max_pass;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index b68f9cf70..58454636e 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -488,7 +488,7 @@ static void TileLoop_Town(TileIndex tile)
}
}
- _current_player = OWNER_TOWN;
+ _current_company = OWNER_TOWN;
if (hs->building_flags & BUILDING_HAS_1_TILE &&
HasBit(t->flags12, TOWN_IS_FUNDED) &&
@@ -503,7 +503,7 @@ static void TileLoop_Town(TileIndex tile)
if (GB(r, 24, 8) >= 12) BuildTownHouse(t, tile);
}
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
}
/**
@@ -529,8 +529,8 @@ static CommandCost ClearTile_Town(TileIndex tile, byte flags)
_cleared_town_rating += rating;
Town *t = _cleared_town = GetTownByTile(tile);
- if (IsValidPlayerID(_current_player)) {
- if (rating > t->ratings[_current_player] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
+ if (IsValidCompanyID(_current_company)) {
+ if (rating > t->ratings[_current_company] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
SetDParam(0, t->index);
return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
}
@@ -638,7 +638,7 @@ static TrackStatus GetTileTrackStatus_Town(TileIndex tile, TransportType mode, u
return 0;
}
-static void ChangeTileOwner_Town(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Town(TileIndex tile, Owner old_owner, Owner new_owner)
{
/* not used */
}
@@ -1284,9 +1284,9 @@ static bool GrowTown(Town *t)
{ 0, 0}
};
- /* Current player is a town */
- PlayerID old_player = _current_player;
- _current_player = OWNER_TOWN;
+ /* Current "company" is a town */
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_TOWN;
TileIndex tile = t->xy; // The tile we are working with ATM
@@ -1295,7 +1295,7 @@ static bool GrowTown(Town *t)
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
if (GetTownRoadBits(tile) != ROAD_NONE) {
int r = GrowTownAtRoad(t, tile);
- _current_player = old_player;
+ _current_company = old_company;
return r != 0;
}
tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
@@ -1309,14 +1309,14 @@ static bool GrowTown(Town *t)
if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) {
if (CmdSucceeded(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
- _current_player = old_player;
+ _current_company = old_company;
return true;
}
}
tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
}
- _current_player = old_player;
+ _current_company = old_company;
return false;
}
@@ -1455,10 +1455,10 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
t->act_food = 0;
t->act_water = 0;
- for (uint i = 0; i != MAX_PLAYERS; i++) t->ratings[i] = RATING_INITIAL;
+ for (uint i = 0; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
t->have_ratings = 0;
- t->exclusivity = INVALID_PLAYER;
+ t->exclusivity = INVALID_COMPANY;
t->exclusive_counter = 0;
t->statues = 0;
@@ -2143,17 +2143,17 @@ extern const byte _town_action_costs[8] = {
static void TownActionAdvertiseSmall(Town *t)
{
- ModifyStationRatingAround(t->xy, _current_player, 0x40, 10);
+ ModifyStationRatingAround(t->xy, _current_company, 0x40, 10);
}
static void TownActionAdvertiseMedium(Town *t)
{
- ModifyStationRatingAround(t->xy, _current_player, 0x70, 15);
+ ModifyStationRatingAround(t->xy, _current_company, 0x70, 15);
}
static void TownActionAdvertiseLarge(Town *t)
{
- ModifyStationRatingAround(t->xy, _current_player, 0xA0, 20);
+ ModifyStationRatingAround(t->xy, _current_company, 0xA0, 20);
}
static void TownActionRoadRebuild(Town *t)
@@ -2161,7 +2161,7 @@ static void TownActionRoadRebuild(Town *t)
t->road_build_months = 6;
char *company_name = MallocT<char>(64);
- SetDParam(0, _current_player);
+ SetDParam(0, _current_company);
GetString(company_name, STR_COMPANY_NAME, company_name + 64);
SetDParam(0, t->index);
@@ -2182,14 +2182,14 @@ static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
return false;
}
- PlayerID old = _current_player;
- _current_player = OWNER_NONE;
+ CompanyID old = _current_company;
+ _current_company = OWNER_NONE;
CommandCost r = DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
- _current_player = old;
+ _current_company = old;
if (CmdFailed(r)) return false;
- MakeStatue(tile, _current_player, town_id);
+ MakeStatue(tile, _current_company, town_id);
MarkTileDirtyByTile(tile);
return true;
@@ -2217,7 +2217,7 @@ static void TownActionBuildStatue(Town *t)
TileIndex tile = t->xy;
if (CircularTileSearch(&tile, 9, SearchTileForStatue, &t->index)) {
- SetBit(t->statues, _current_player); // Once found and built, "inform" the Town
+ SetBit(t->statues, _current_company); // Once found and built, "inform" the Town
}
}
@@ -2237,35 +2237,35 @@ static void TownActionBuyRights(Town *t)
if (!_settings_game.economy.exclusive_rights) return;
t->exclusive_counter = 12;
- t->exclusivity = _current_player;
+ t->exclusivity = _current_company;
- ModifyStationRatingAround(t->xy, _current_player, 130, 17);
+ ModifyStationRatingAround(t->xy, _current_company, 130, 17);
}
static void TownActionBribe(Town *t)
{
if (Chance16(1, 14)) {
/* set as unwanted for 6 months */
- t->unwanted[_current_player] = 6;
+ t->unwanted[_current_company] = 6;
/* set all close by station ratings to 0 */
Station *st;
FOR_ALL_STATIONS(st) {
- if (st->town == t && st->owner == _current_player) {
+ if (st->town == t && st->owner == _current_company) {
for (CargoID i = 0; i < NUM_CARGO; i++) st->goods[i].rating = 0;
}
}
/* only show errormessage to the executing player. All errors are handled command.c
* but this is special, because it can only 'fail' on a DC_EXEC */
- if (IsLocalPlayer()) ShowErrorMessage(STR_BRIBE_FAILED_2, STR_BRIBE_FAILED, 0, 0);
+ if (IsLocalCompany()) ShowErrorMessage(STR_BRIBE_FAILED_2, STR_BRIBE_FAILED, 0, 0);
/* decrease by a lot!
* ChangeTownRating is only for stuff in demolishing. Bribe failure should
* be independent of any cheat settings
*/
- if (t->ratings[_current_player] > RATING_BRIBE_DOWN_TO) {
- t->ratings[_current_player] = RATING_BRIBE_DOWN_TO;
+ if (t->ratings[_current_company] > RATING_BRIBE_DOWN_TO) {
+ t->ratings[_current_company] = RATING_BRIBE_DOWN_TO;
InvalidateWindow(WC_TOWN_AUTHORITY, t->index);
}
} else {
@@ -2285,7 +2285,7 @@ static TownActionProc *const _town_action_proc[] = {
TownActionBribe
};
-extern uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t);
+extern uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t);
/** Do a town action.
* This performs an action such as advertising, building a statue, funding buildings,
@@ -2301,7 +2301,7 @@ CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
Town *t = GetTown(p1);
- if (!HasBit(GetMaskOfTownActions(NULL, _current_player, t), p2)) return CMD_ERROR;
+ if (!HasBit(GetMaskOfTownActions(NULL, _current_company, t), p2)) return CMD_ERROR;
CommandCost cost(EXPENSES_OTHER, (_price.build_industry >> 8) * _town_action_costs[p2]);
@@ -2315,11 +2315,11 @@ CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
static void UpdateTownGrowRate(Town *t)
{
- /* Increase player ratings if they're low */
- const Player *p;
- FOR_ALL_PLAYERS(p) {
- if (t->ratings[p->index] < RATING_GROWTH_MAXIMUM) {
- t->ratings[p->index] = min((int)RATING_GROWTH_MAXIMUM, t->ratings[p->index] + RATING_GROWTH_UP_STEP);
+ /* Increase company ratings if they're low */
+ const Company *c;
+ FOR_ALL_COMPANIES(c) {
+ if (t->ratings[c->index] < RATING_GROWTH_MAXIMUM) {
+ t->ratings[c->index] = min((int)RATING_GROWTH_MAXIMUM, t->ratings[c->index] + RATING_GROWTH_UP_STEP);
}
}
@@ -2330,12 +2330,12 @@ static void UpdateTownGrowRate(Town *t)
if (DistanceSquare(st->xy, t->xy) <= t->squared_town_zone_radius[0]) {
if (st->time_since_load <= 20 || st->time_since_unload <= 20) {
n++;
- if (IsValidPlayerID(st->owner)) {
+ if (IsValidCompanyID(st->owner)) {
int new_rating = t->ratings[st->owner] + RATING_STATION_UP_STEP;
t->ratings[st->owner] = min(new_rating, INT16_MAX); // do not let it overflow
}
} else {
- if (IsValidPlayerID(st->owner)) {
+ if (IsValidCompanyID(st->owner)) {
int new_rating = t->ratings[st->owner] + RATING_STATION_DOWN_STEP;
t->ratings[st->owner] = max(new_rating, INT16_MIN);
}
@@ -2344,7 +2344,7 @@ static void UpdateTownGrowRate(Town *t)
}
/* clamp all ratings to valid values */
- for (uint i = 0; i < MAX_PLAYERS; i++) {
+ for (uint i = 0; i < MAX_COMPANIES; i++) {
t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM);
}
@@ -2412,21 +2412,21 @@ static void UpdateTownAmounts(Town *t)
static void UpdateTownUnwanted(Town *t)
{
- const Player *p;
+ const Company *c;
- FOR_ALL_PLAYERS(p) {
- if (t->unwanted[p->index] > 0) t->unwanted[p->index]--;
+ FOR_ALL_COMPANIES(c) {
+ if (t->unwanted[c->index] > 0) t->unwanted[c->index]--;
}
}
bool CheckIfAuthorityAllows(TileIndex tile)
{
- if (!IsValidPlayerID(_current_player)) return true;
+ if (!IsValidCompanyID(_current_company)) return true;
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
if (t == NULL) return true;
- if (t->ratings[_current_player] > RATING_VERYPOOR) return true;
+ if (t->ratings[_current_company] > RATING_VERYPOOR) return true;
_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
SetDParam(0, t->index);
@@ -2491,19 +2491,19 @@ static int GetRating(const Town *t)
return (*it).second;
}
}
- return t->ratings[_current_player];
+ return t->ratings[_current_company];
}
void ChangeTownRating(Town *t, int add, int max)
{
/* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */
if (t == NULL ||
- !IsValidPlayerID(_current_player) ||
+ !IsValidCompanyID(_current_company) ||
(_cheats.magic_bulldozer.value && add < 0)) {
return;
}
- SetBit(t->have_ratings, _current_player);
+ SetBit(t->have_ratings, _current_company);
int rating = GetRating(t);
if (add < 0) {
@@ -2520,7 +2520,7 @@ void ChangeTownRating(Town *t, int add, int max)
if (_town_rating_test) {
_town_test_ratings[t] = rating;
} else {
- t->ratings[_current_player] = rating;
+ t->ratings[_current_company] = rating;
InvalidateWindow(WC_TOWN_AUTHORITY, t->index);
}
}
@@ -2536,7 +2536,7 @@ static const int _default_rating_settings [3][3] = {
bool CheckforTownRating(uint32 flags, Town *t, byte type)
{
/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
- if (t == NULL || !IsValidPlayerID(_current_player) || _cheats.magic_bulldozer.value)
+ if (t == NULL || !IsValidCompanyID(_current_company) || _cheats.magic_bulldozer.value)
return true;
/* check if you're allowed to remove the street/bridge/tunnel/industry
@@ -2562,7 +2562,7 @@ void TownsMonthlyLoop()
if (t->road_build_months != 0) t->road_build_months--;
if (t->exclusive_counter != 0)
- if (--t->exclusive_counter == 0) t->exclusivity = INVALID_PLAYER;
+ if (--t->exclusive_counter == 0) t->exclusivity = INVALID_COMPANY;
UpdateTownGrowRate(t);
UpdateTownAmounts(t);
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 356fbfea1..59b73bae9 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -69,20 +69,20 @@ DECLARE_ENUM_AS_BIT_SET(TownActions);
/** Get a list of available actions to do at a town.
* @param nump if not NULL add put the number of available actions in it
- * @param pid the player that is querying the town
+ * @param cid the company that is querying the town
* @param t the town that is queried
* @return bitmasked value of enabled actions
*/
-uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t)
+uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t)
{
int num = 0;
TownActions buttons = TACT_NONE;
/* Spectators and unwanted have no options */
- if (pid != PLAYER_SPECTATOR && !(_settings_game.economy.bribe && t->unwanted[pid])) {
+ if (cid != COMPANY_SPECTATOR && !(_settings_game.economy.bribe && t->unwanted[cid])) {
/* Things worth more than this are not shown */
- Money avail = GetPlayer(pid)->player_money + _price.station_value * 200;
+ Money avail = GetCompany(cid)->money + _price.station_value * 200;
Money ref = _price.build_industry >> 8;
/* Check the action bits for validity and
@@ -90,16 +90,16 @@ uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t)
for (uint i = 0; i != lengthof(_town_action_costs); i++) {
const TownActions cur = (TownActions)(1 << i);
- /* Is the player not able to bribe ? */
- if (cur == TACT_BRIBE && (!_settings_game.economy.bribe || t->ratings[pid] >= RATING_BRIBE_MAXIMUM))
+ /* Is the company not able to bribe ? */
+ if (cur == TACT_BRIBE && (!_settings_game.economy.bribe || t->ratings[cid] >= RATING_BRIBE_MAXIMUM))
continue;
- /* Is the player not able to buy exclusive rights ? */
+ /* Is the company not able to buy exclusive rights ? */
if (cur == TACT_BUY_RIGHTS && !_settings_game.economy.exclusive_rights)
continue;
- /* Is the player not able to build a statue ? */
- if (cur == TACT_BUILD_STATUE && HasBit(t->statues, pid))
+ /* Is the company not able to build a statue ? */
+ if (cur == TACT_BUILD_STATUE && HasBit(t->statues, cid))
continue;
if (avail >= _town_action_costs[i] * ref) {
@@ -162,7 +162,7 @@ public:
virtual void OnPaint()
{
int numact;
- uint buttons = GetMaskOfTownActions(&numact, _local_player, this->town);
+ uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town);
SetVScrollCount(this, numact + 1);
@@ -177,18 +177,18 @@ public:
DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, TC_FROMSTRING);
- /* Draw list of players */
+ /* Draw list of companies */
int y = 25;
- const Player *p;
- FOR_ALL_PLAYERS(p) {
- if ((HasBit(this->town->have_ratings, p->index) || this->town->exclusivity == p->index)) {
- DrawPlayerIcon(p->index, 2, y);
+ const Company *c;
+ FOR_ALL_COMPANIES(c) {
+ if ((HasBit(this->town->have_ratings, c->index) || this->town->exclusivity == c->index)) {
+ DrawCompanyIcon(c->index, 2, y);
- SetDParam(0, p->index);
- SetDParam(1, p->index);
+ SetDParam(0, c->index);
+ SetDParam(1, c->index);
- int r = this->town->ratings[p->index];
+ int r = this->town->ratings[c->index];
StringID str;
(str = STR_3035_APPALLING, r <= RATING_APPALLING) || // Apalling
(str++, r <= RATING_VERYPOOR) || // Very Poor
@@ -200,7 +200,7 @@ public:
(str++, true); // Outstanding
SetDParam(2, str);
- if (this->town->exclusivity == p->index) { // red icon for player with exclusive rights
+ if (this->town->exclusivity == c->index) { // red icon for company with exclusive rights
DrawSprite(SPR_BLOT, PALETTE_TO_RED, 18, y);
}
@@ -243,7 +243,7 @@ public:
if (!IsInsideMM(y, 0, 5)) return;
- y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, this->town), y + this->vscroll.pos - 1);
+ y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_company, this->town), y + this->vscroll.pos - 1);
if (y >= 0) {
this->sel_index = y;
this->SetDirty();
@@ -780,7 +780,7 @@ static const WindowDesc _scen_edit_town_gen_desc = {
void ShowBuildTownWindow()
{
- if (_game_mode != GM_EDITOR && !IsValidPlayerID(_current_player)) return;
+ if (_game_mode != GM_EDITOR && !IsValidCompanyID(_current_company)) return;
AllocateWindowDescFront<ScenarioEditorTownGenerationWindow>(&_scen_edit_town_gen_desc, 0);
}
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index fa31605ae..5ec65ce3d 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -655,7 +655,7 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 fla
v->x_pos = x;
v->y_pos = y;
v->z_pos = GetSlopeZ(x, y);
- v->owner = _current_player;
+ v->owner = _current_company;
v->u.rail.track = TRACK_BIT_DEPOT;
v->vehstatus = VS_HIDDEN | VS_DEFPAL;
@@ -692,10 +692,10 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 fla
UpdateTrainGroupID(v->First());
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
- if (IsLocalPlayer()) {
+ if (IsLocalCompany()) {
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Train window
}
- GetPlayer(_current_player)->num_engines[engine]++;
+ GetCompany(_current_company)->num_engines[engine]++;
}
}
@@ -759,14 +759,14 @@ static void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool buildin
*/
CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- /* Check if the engine-type is valid (for the player) */
- if (!IsEngineBuildable(p1, VEH_TRAIN, _current_player)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE);
+ /* Check if the engine-type is valid (for the company) */
+ if (!IsEngineBuildable(p1, VEH_TRAIN, _current_company)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE);
/* Check if the train is actually being built in a depot belonging
- * to the player. Doesn't matter if only the cost is queried */
+ * to the company. Doesn't matter if only the cost is queried */
if (!(flags & DC_QUERY_COST)) {
if (!IsRailDepotTile(tile)) return CMD_ERROR;
- if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
+ if (!IsTileOwner(tile, _current_company)) return CMD_ERROR;
}
const RailVehicleInfo *rvi = RailVehInfo(p1);
@@ -807,7 +807,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
v->unitnumber = unit_num;
v->direction = DiagDirToDir(dir);
v->tile = tile;
- v->owner = _current_player;
+ v->owner = _current_company;
v->x_pos = x;
v->y_pos = y;
v->z_pos = GetSlopeZ(x, y);
@@ -874,11 +874,11 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
InvalidateWindow(WC_COMPANY, v->owner);
- if (IsLocalPlayer()) {
+ if (IsLocalCompany()) {
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Train window
}
- GetPlayer(_current_player)->num_engines[p1]++;
+ GetCompany(_current_company)->num_engines[p1]++;
}
}
@@ -1450,7 +1450,7 @@ CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
new_f->CopyVehicleConfigAndStatistics(first);
/* If we deleted a window then open a new one for the 'new' train */
- if (IsLocalPlayer() && w != NULL) ShowVehicleViewWindow(new_f);
+ if (IsLocalCompany() && w != NULL) ShowVehicleViewWindow(new_f);
}
} else {
/* We are selling a free wagon, and construct a new train at the same time.
@@ -2110,7 +2110,7 @@ CommandCost CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
struct TrainFindDepotData {
uint best_length;
TileIndex tile;
- PlayerID owner;
+ Owner owner;
/**
* true if reversing is necessary for the train to get to this depot
* This value is unused when new depot finding and NPF are both disabled
@@ -2227,7 +2227,7 @@ CommandCost CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32
if (p2 & DEPOT_MASS_SEND) {
/* Mass goto depot requested */
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
- return SendAllVehiclesToDepot(VEH_TRAIN, flags, p2 & DEPOT_SERVICE, _current_player, (p2 & VLW_MASK), p1);
+ return SendAllVehiclesToDepot(VEH_TRAIN, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
}
if (!IsValidVehicleID(p1)) return CMD_ERROR;
@@ -2916,7 +2916,7 @@ static Track ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir
/* it is first time the problem occurred, set the "path not found" flag */
SetBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
/* and notify user about the event */
- if (_settings_client.gui.lost_train_warn && v->owner == _local_player) {
+ if (_settings_client.gui.lost_train_warn && v->owner == _local_company) {
SetDParam(0, v->unitnumber);
AddNewsItem(
STR_TRAIN_IS_LOST,
@@ -3272,7 +3272,7 @@ static void TrainEnterStation(Vehicle *v, StationID station)
SetDParam(0, st->index);
AddNewsItem(
STR_8801_CITIZENS_CELEBRATE_FIRST,
- v->owner == _local_player ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
+ v->owner == _local_company ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
v->index,
st->index
);
@@ -4254,7 +4254,7 @@ static void TrainLocoHandler(Vehicle *v, bool mode)
if (HasBit(v->u.rail.flags, VRF_TRAIN_STUCK) && v->load_unload_time_rem > 2 * _settings_game.pf.wait_for_pbs_path * DAY_TICKS) {
/* Show message to player. */
- if (_settings_client.gui.lost_train_warn && v->owner == _local_player) {
+ if (_settings_client.gui.lost_train_warn && v->owner == _local_company) {
SetDParam(0, v->unitnumber);
AddNewsItem(
STR_TRAIN_IS_STUCK,
@@ -4401,7 +4401,7 @@ void Train::OnNewDay()
this->profit_this_year -= cost.GetCost();
this->running_ticks = 0;
- SubtractMoneyFromPlayerFract(this->owner, cost);
+ SubtractMoneyFromCompanyFract(this->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
InvalidateWindowClasses(WC_TRAINS_LIST);
@@ -4419,7 +4419,7 @@ void TrainsYearlyLoop()
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
/* show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
- if (_settings_client.gui.train_income_warn && v->owner == _local_player && v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
+ if (_settings_client.gui.train_income_warn && v->owner == _local_company && v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
SetDParam(1, v->GetDisplayProfitThisYear());
SetDParam(0, v->unitnumber);
AddNewsItem(
diff --git a/src/transparency.h b/src/transparency.h
index efac5bfea..71073b75b 100644
--- a/src/transparency.h
+++ b/src/transparency.h
@@ -17,7 +17,7 @@ enum TransparencyOption {
TO_TREES, ///< trees
TO_HOUSES, ///< town buildings
TO_INDUSTRIES, ///< industries
- TO_BUILDINGS, ///< player buildings - depots, stations, HQ, ...
+ TO_BUILDINGS, ///< company buildings - depots, stations, HQ, ...
TO_BRIDGES, ///< bridges
TO_STRUCTURES, ///< unmovable structures
TO_CATENARY, ///< catenary
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index 12f5f90aa..feff1c4ee 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -24,7 +24,7 @@ class TransparenciesWindow : public Window
TTW_WIDGET_TREES, ///< Make trees transparent
TTW_WIDGET_HOUSES, ///< Make houses transparent
TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent
- TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent
+ TTW_WIDGET_BUILDINGS, ///< Make company buildings and structures transparent
TTW_WIDGET_BRIDGES, ///< Make bridges transparent
TTW_WIDGET_STRUCTURES, ///< Make unmovable structures transparent
TTW_WIDGET_CATENARY, ///< Make catenary transparent
@@ -99,7 +99,7 @@ static const Widget _transparency_widgets[] = {
{WWT_STICKYBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 207, 218, 0, 13, STR_NULL, STR_STICKY_BUTTON},
/* transparency widgets:
- * transparent signs, trees, houses, industries, player's buildings, bridges, unmovable structures, catenary and loading indicators */
+ * transparent signs, trees, houses, industries, company's buildings, bridges, unmovable structures, catenary and loading indicators */
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 21, 14, 35, SPR_IMG_SIGN, STR_TRANSPARENT_SIGNS_DESC},
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 22, 43, 14, 35, SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_DESC},
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 44, 65, 14, 35, SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_DESC},
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 07da7b56f..7f30f977d 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -390,7 +390,7 @@ CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
}
- if (_game_mode != GM_EDITOR && IsValidPlayerID(_current_player)) {
+ if (_game_mode != GM_EDITOR && IsValidCompanyID(_current_company)) {
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
}
@@ -533,7 +533,7 @@ static CommandCost ClearTile_Trees(TileIndex tile, byte flags)
{
uint num;
- if (IsValidPlayerID(_current_player)) {
+ if (IsValidCompanyID(_current_company)) {
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
}
@@ -754,7 +754,7 @@ static TrackStatus GetTileTrackStatus_Trees(TileIndex tile, TransportType mode,
return 0;
}
-static void ChangeTileOwner_Trees(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Trees(TileIndex tile, Owner old_owner, Owner new_owner)
{
/* not used */
}
diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp
index 460549c4d..a310628fe 100644
--- a/src/tree_gui.cpp
+++ b/src/tree_gui.cpp
@@ -180,6 +180,6 @@ static const WindowDesc _build_trees_desc = {
void ShowBuildTreesToolbar()
{
- if (_game_mode != GM_EDITOR && !IsValidPlayerID(_current_player)) return;
+ if (_game_mode != GM_EDITOR && !IsValidCompanyID(_current_company)) return;
AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
}
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 914625237..c5869fce9 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -222,7 +222,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p
switch (transport_type) {
case TRANSPORT_ROAD:
roadtypes = (RoadTypes)GB(p2, 8, 3);
- if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_player, roadtypes)) return CMD_ERROR;
+ if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_company, roadtypes)) return CMD_ERROR;
break;
case TRANSPORT_RAIL:
@@ -304,8 +304,8 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p
return_cmd_error(STR_1007_ALREADY_BUILT);
}
- /* Do not allow replacing another player's bridges. */
- if (!IsTileOwner(tile_start, _current_player) && !IsTileOwner(tile_start, OWNER_TOWN)) {
+ /* Do not allow replacing another company's bridges. */
+ if (!IsTileOwner(tile_start, _current_company) && !IsTileOwner(tile_start, OWNER_TOWN)) {
return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER);
}
@@ -318,7 +318,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p
} else {
/* Build a new bridge. */
- bool allow_on_slopes = (!_is_old_ai_player && _settings_game.construction.build_on_slopes && transport_type != TRANSPORT_WATER);
+ bool allow_on_slopes = (!_is_old_ai_company && _settings_game.construction.build_on_slopes && transport_type != TRANSPORT_WATER);
/* Try and clear the start landscape */
ret = DoCommand(tile_start, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -364,7 +364,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p
/* do the drill? */
if (flags & DC_EXEC) {
DiagDirection dir = AxisToDiagDir(direction);
- Owner owner = (replace_bridge && IsTileOwner(tile_start, OWNER_TOWN)) ? OWNER_TOWN : _current_player;
+ Owner owner = (replace_bridge && IsTileOwner(tile_start, OWNER_TOWN)) ? OWNER_TOWN : _current_company;
switch (transport_type) {
case TRANSPORT_RAIL:
@@ -443,7 +443,7 @@ not_valid_below:;
if (flags & DC_EXEC && transport_type == TRANSPORT_RAIL) {
Track track = AxisToTrack(direction);
- AddSideToSignalBuffer(tile_start, INVALID_DIAGDIR, _current_player);
+ AddSideToSignalBuffer(tile_start, INVALID_DIAGDIR, _current_company);
YapfNotifyTrackLayoutChange(tile_start, track);
}
@@ -451,10 +451,10 @@ not_valid_below:;
* It's unnecessary to execute this command every time for every bridge. So it is done only
* and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated
*/
- if (!(flags & DC_QUERY_COST) || (IsValidPlayerID(_current_player) && GetPlayer(_current_player)->is_ai)) {
+ if (!(flags & DC_QUERY_COST) || (IsValidCompanyID(_current_company) && GetCompany(_current_company)->is_ai)) {
bridge_len += 2; // begin and end tiles/ramps
- if (IsValidPlayerID(_current_player) && !_is_old_ai_player)
+ if (IsValidCompanyID(_current_company) && !_is_old_ai_company)
bridge_len = CalcBridgeLenCostFactor(bridge_len);
cost.AddCost((int64)bridge_len * _price.build_bridge * GetBridgeSpec(bridge_type)->price >> 8);
@@ -491,7 +491,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32
if (!ValParamRailtype((RailType)p1)) return CMD_ERROR;
} else {
const RoadTypes rts = (RoadTypes)GB(p1, 0, 3);
- if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR;
+ if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_company, rts)) return CMD_ERROR;
}
start_tileh = GetTileSlope(start_tile, &start_z);
@@ -571,13 +571,13 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32
if (flags & DC_EXEC) {
if (transport_type == TRANSPORT_RAIL) {
- MakeRailTunnel(start_tile, _current_player, direction, (RailType)GB(p1, 0, 4));
- MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4));
- AddSideToSignalBuffer(start_tile, INVALID_DIAGDIR, _current_player);
+ MakeRailTunnel(start_tile, _current_company, direction, (RailType)GB(p1, 0, 4));
+ MakeRailTunnel(end_tile, _current_company, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4));
+ AddSideToSignalBuffer(start_tile, INVALID_DIAGDIR, _current_company);
YapfNotifyTrackLayoutChange(start_tile, DiagDirToDiagTrack(direction));
} else {
- MakeRoadTunnel(start_tile, _current_player, direction, (RoadTypes)GB(p1, 0, 3));
- MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 3));
+ MakeRoadTunnel(start_tile, _current_company, direction, (RoadTypes)GB(p1, 0, 3));
+ MakeRoadTunnel(end_tile, _current_company, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 3));
}
}
@@ -588,7 +588,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32
static inline bool CheckAllowRemoveTunnelBridge(TileIndex tile)
{
/* Floods can remove anything as well as the scenario editor */
- if (_current_player == OWNER_WATER || _game_mode == GM_EDITOR) return true;
+ if (_current_company == OWNER_WATER || _game_mode == GM_EDITOR) return true;
/* Obviously if the bridge/tunnel belongs to us, or no-one, we can remove it */
if (CheckTileOwnership(tile) || IsTileOwner(tile, OWNER_NONE)) return true;
/* Otherwise we can only remove town-owned stuff with extra patch-settings, or cheat */
@@ -1295,12 +1295,12 @@ static TrackStatus GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType
return CombineTrackStatus(TrackBitsToTrackdirBits(DiagDirToDiagTrackBits(dir)), TRACKDIR_BIT_NONE);
}
-static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_TunnelBridge(TileIndex tile, Owner old_owner, Owner new_owner)
{
- if (!IsTileOwner(tile, old_player)) return;
+ if (!IsTileOwner(tile, old_owner)) return;
- if (new_player != PLAYER_SPECTATOR) {
- SetTileOwner(tile, new_player);
+ if (new_owner != INVALID_OWNER) {
+ SetTileOwner(tile, new_owner);
} else {
if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR))) {
/* When clearing the bridge/tunnel failed there are still vehicles on/in
diff --git a/src/unmovable.h b/src/unmovable.h
index a1db81723..ebcaa7513 100644
--- a/src/unmovable.h
+++ b/src/unmovable.h
@@ -5,6 +5,6 @@
#ifndef UNMOVABLE_H
#define UNMOVABLE_H
-void UpdateCompanyHQ(Player *p, uint score);
+void UpdateCompanyHQ(Company *c, uint score);
#endif /* UNMOVABLE_H */
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 9e8a8ad93..7bf37a414 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -36,33 +36,33 @@
/** Destroy a HQ.
* During normal gameplay you can only implicitely destroy a HQ when you are
* rebuilding it. Otherwise, only water can destroy it.
- * @param pid Player requesting the destruction of his HQ
+ * @param cid Company requesting the destruction of his HQ
* @param flags docommand flags of calling function
* @return cost of the operation
*/
-static CommandCost DestroyCompanyHQ(PlayerID pid, uint32 flags)
+static CommandCost DestroyCompanyHQ(CompanyID cid, uint32 flags)
{
- Player *p = GetPlayer(pid);
+ Company *c = GetCompany(cid);
if (flags & DC_EXEC) {
- TileIndex t = p->location_of_HQ;
+ TileIndex t = c->location_of_HQ;
DoClearSquare(t + TileDiffXY(0, 0));
DoClearSquare(t + TileDiffXY(0, 1));
DoClearSquare(t + TileDiffXY(1, 0));
DoClearSquare(t + TileDiffXY(1, 1));
- p->location_of_HQ = 0; // reset HQ position
- InvalidateWindow(WC_COMPANY, pid);
+ c->location_of_HQ = 0; // reset HQ position
+ InvalidateWindow(WC_COMPANY, cid);
}
/* cost of relocating company is 1% of company value */
- return CommandCost(EXPENSES_PROPERTY, CalculateCompanyValue(p) / 100);
+ return CommandCost(EXPENSES_PROPERTY, CalculateCompanyValue(c) / 100);
}
-void UpdateCompanyHQ(Player *p, uint score)
+void UpdateCompanyHQ(Company *c, uint score)
{
byte val;
- TileIndex tile = p->location_of_HQ;
+ TileIndex tile = c->location_of_HQ;
if (tile == 0) return;
@@ -90,25 +90,25 @@ extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags
*/
CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- Player *p = GetPlayer(_current_player);
+ Company *c = GetCompany(_current_company);
CommandCost cost(EXPENSES_PROPERTY);
cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
if (CmdFailed(cost)) return cost;
- if (p->location_of_HQ != 0) { // Moving HQ
- cost.AddCost(DestroyCompanyHQ(_current_player, flags));
+ if (c->location_of_HQ != 0) { // Moving HQ
+ cost.AddCost(DestroyCompanyHQ(_current_company, flags));
}
if (flags & DC_EXEC) {
- int score = UpdateCompanyRatingAndValue(p, false);
+ int score = UpdateCompanyRatingAndValue(c, false);
- p->location_of_HQ = tile;
+ c->location_of_HQ = tile;
- MakeCompanyHQ(tile, _current_player);
+ MakeCompanyHQ(tile, _current_company);
- UpdateCompanyHQ(p, score);
- InvalidateWindow(WC_COMPANY, p->index);
+ UpdateCompanyHQ(c, score);
+ InvalidateWindow(WC_COMPANY, c->index);
}
return cost;
@@ -116,7 +116,7 @@ CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
/** Purchase a land area. Actually you only purchase one tile, so
* the name is a bit confusing ;p
- * @param tile the tile the player is purchasing
+ * @param tile the tile the company is purchasing
* @param flags for this command type
* @param p1 unused
* @param p2 unused
@@ -126,7 +126,7 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32
{
CommandCost cost(EXPENSES_CONSTRUCTION);
- if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) {
+ if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_company)) {
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
}
@@ -134,7 +134,7 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32
if (CmdFailed(cost)) return CMD_ERROR;
if (flags & DC_EXEC) {
- MakeOwnedLand(tile, _current_player);
+ MakeOwnedLand(tile, _current_company);
MarkTileDirtyByTile(tile);
}
@@ -143,7 +143,7 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32
/** Sell a land area. Actually you only sell one tile, so
* the name is a bit confusing ;p
- * @param tile the tile the player is selling
+ * @param tile the tile the company is selling
* @param flags for this command type
* @param p1 unused
* @param p2 unused
@@ -152,7 +152,7 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32
CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (!IsOwnedLandTile(tile)) return CMD_ERROR;
- if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
+ if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) return CMD_ERROR;
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
@@ -192,14 +192,14 @@ static void DrawTile_Unmovable(TileInfo *ti)
if (IsInvisibilitySet(TO_STRUCTURES)) break;
- AddSortableSpriteToDraw(SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, IsTransparencySet(TO_STRUCTURES));
+ AddSortableSpriteToDraw(SPR_STATUE_COMPANY, COMPANY_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, IsTransparencySet(TO_STRUCTURES));
break;
case UNMOVABLE_OWNED_LAND:
DrawClearLandTile(ti, 0);
AddSortableSpriteToDraw(
- SPR_BOUGHT_LAND, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)),
+ SPR_BOUGHT_LAND, COMPANY_SPRITE_COLOR(GetTileOwner(ti->tile)),
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2)
);
DrawBridgeMiddle(ti);
@@ -209,7 +209,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
assert(IsCompanyHQ(ti->tile));
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
- SpriteID palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
+ SpriteID palette = COMPANY_SPRITE_COLOR(GetTileOwner(ti->tile));
const DrawTileSprites *t = &_unmovable_display_datas[GetCompanyHQSection(ti->tile)];
DrawGroundSprite(t->ground.sprite, palette);
@@ -251,7 +251,7 @@ static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh)
static CommandCost ClearTile_Unmovable(TileIndex tile, byte flags)
{
if (IsCompanyHQ(tile)) {
- if (_current_player == OWNER_WATER) {
+ if (_current_company == OWNER_WATER) {
return DestroyCompanyHQ(GetTileOwner(tile), DC_EXEC);
} else {
return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
@@ -263,7 +263,7 @@ static CommandCost ClearTile_Unmovable(TileIndex tile, byte flags)
}
/* checks if you're allowed to remove unmovable things */
- if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
+ if (_game_mode != GM_EDITOR && _current_company != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
if (IsStatue(tile)) {
@@ -357,7 +357,7 @@ static TrackStatus GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mo
static void ClickTile_Unmovable(TileIndex tile)
{
- if (IsCompanyHQ(tile)) ShowPlayerCompany(GetTileOwner(tile));
+ if (IsCompanyHQ(tile)) ShowCompany(GetTileOwner(tile));
}
@@ -433,20 +433,20 @@ void GenerateUnmovables()
}
}
-static void ChangeTileOwner_Unmovable(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Unmovable(TileIndex tile, Owner old_owner, Owner new_owner)
{
- if (!IsTileOwner(tile, old_player)) return;
+ if (!IsTileOwner(tile, old_owner)) return;
- if (IsOwnedLand(tile) && new_player != PLAYER_SPECTATOR) {
- SetTileOwner(tile, new_player);
+ if (IsOwnedLand(tile) && new_owner != INVALID_OWNER) {
+ SetTileOwner(tile, new_owner);
} else if (IsStatueTile(tile)) {
TownID town = GetStatueTownID(tile);
Town *t = GetTown(town);
- ClrBit(t->statues, old_player);
- if (new_player != PLAYER_SPECTATOR && !HasBit(t->statues, new_player)) {
+ ClrBit(t->statues, old_owner);
+ if (new_owner != INVALID_OWNER && !HasBit(t->statues, new_owner)) {
/* Transfer ownership to the new company */
- SetBit(t->statues, new_player);
- SetTileOwner(tile, new_player);
+ SetBit(t->statues, new_owner);
+ SetTileOwner(tile, new_owner);
} else {
DoClearSquare(tile);
}
diff --git a/src/variables.h b/src/variables.h
index 0304195f2..c69d400fa 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -27,7 +27,7 @@ VARDEF uint32 _cur_town_ctr;
/* Frequency iterator at the same place */
VARDEF uint32 _cur_town_iter;
-VARDEF uint _cur_player_tick_index;
+VARDEF uint _cur_company_tick_index;
VARDEF uint _next_competitor_start;
/* Determines how often to run the tree loop */
@@ -44,7 +44,7 @@ VARDEF int _palette_animation_counter;
VARDEF uint32 _frame_counter;
VARDEF uint32 _realtime_tick;
-VARDEF bool _is_old_ai_player; // current player is an oldAI player? (enables a lot of cheats..)
+VARDEF bool _is_old_ai_company; // current company is an oldAI company? (enables a lot of cheats..)
VARDEF bool _do_autosave;
VARDEF int _autosave_ctr;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 660406016..c060ea9af 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -101,16 +101,16 @@ DEFINE_OLD_POOL_GENERIC(Vehicle, Vehicle)
* @param *p The vehicle owner
* @return true if the vehicle is old enough for replacement
*/
-bool Vehicle::NeedsAutorenewing(const Player *p) const
+bool Vehicle::NeedsAutorenewing(const Company *c) const
{
- /* We can always generate the Player pointer when we have the vehicle.
- * However this takes time and since the Player pointer is often present
+ /* We can always generate the Company pointer when we have the vehicle.
+ * However this takes time and since the Company pointer is often present
* when this function is called then it's faster to pass the pointer as an
* argument rather than finding it again. */
- assert(p == GetPlayer(this->owner));
+ assert(c == GetCompany(this->owner));
- if (!p->engine_renew) return false;
- if (this->age - this->max_age < (p->engine_renew_months * 30)) return false;
+ if (!c->engine_renew) return false;
+ if (this->age - this->max_age < (c->engine_renew_months * 30)) return false;
if (this->age == 0) return false; // rail cars don't age and lacks a max age
return true;
@@ -131,7 +131,7 @@ bool Vehicle::NeedsServicing() const
if (_settings_game.order.no_servicing_if_no_breakdowns && _settings_game.difficulty.vehicle_breakdowns == 0) {
/* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off.
* Note: If servicing is enabled, we postpone replacement till next service. */
- return EngineHasReplacementForPlayer(GetPlayer(this->owner), this->engine_type, this->group_id);
+ return EngineHasReplacementForCompany(GetCompany(this->owner), this->engine_type, this->group_id);
}
return _settings_game.vehicle.servint_ispercent ?
@@ -619,7 +619,7 @@ uint CountVehiclesInChain(const Vehicle* v)
return count;
}
-/** Check if a vehicle is counted in num_engines in each player struct
+/** Check if a vehicle is counted in num_engines in each company struct
* @param *v Vehicle to test
* @return true if the vehicle is counted in num_engines
*/
@@ -632,7 +632,7 @@ bool IsEngineCountable(const Vehicle *v)
!IsRearDualheaded(v); // rear parts of multiheaded engines
case VEH_ROAD: return IsRoadVehFront(v);
case VEH_SHIP: return true;
- default: return false; // Only count player buildable vehicles
+ default: return false; // Only count company buildable vehicles
}
}
@@ -647,8 +647,8 @@ void Vehicle::PreDestructor()
}
if (IsEngineCountable(this)) {
- GetPlayer(this->owner)->num_engines[this->engine_type]--;
- if (this->owner == _local_player) InvalidateAutoreplaceWindow(this->engine_type, this->group_id);
+ GetCompany(this->owner)->num_engines[this->engine_type]--;
+ if (this->owner == _local_company) InvalidateAutoreplaceWindow(this->engine_type, this->group_id);
if (IsValidGroupID(this->group_id)) GetGroup(this->group_id)->num_engines[this->engine_type]--;
if (this->IsPrimaryVehicle()) DecreaseGroupNumVehicle(this->group_id);
@@ -781,8 +781,8 @@ void CallVehicleTicks()
v = _first_veh_in_depot_list;
if (v != NULL) {
while (v != NULL) {
- /* Autoreplace needs the current player set as the vehicle owner */
- _current_player = v->owner;
+ /* Autoreplace needs the current company set as the vehicle owner */
+ _current_company = v->owner;
/* Buffer v->depot_list and clear it.
* Autoreplace might clear this so it has to be buffered. */
@@ -802,13 +802,13 @@ void CallVehicleTicks()
int y = v->y_pos;
int z = v->z_pos;
- const Player *p = GetPlayer(_current_player);
- SubtractMoneyFromPlayer(CommandCost(EXPENSES_NEW_VEHICLES, (Money)p->engine_renew_money));
+ const Company *c = GetCompany(_current_company);
+ SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, (Money)c->engine_renew_money));
CommandCost res = DoCommand(0, v->index, 0, DC_EXEC, CMD_AUTOREPLACE_VEHICLE);
if (res.Succeeded()) v = NULL; // no longer valid
- SubtractMoneyFromPlayer(CommandCost(EXPENSES_NEW_VEHICLES, -(Money)p->engine_renew_money));
+ SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, -(Money)c->engine_renew_money));
- if (IsLocalPlayer()) {
+ if (IsLocalCompany()) {
if (res.Succeeded()) {
ShowCostOrIncomeAnimation(x, y, z, res.GetCost());
} else {
@@ -839,7 +839,7 @@ void CallVehicleTicks()
v = w;
}
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
}
}
@@ -1069,10 +1069,10 @@ static const StringID _vehicle_type_names[4] = {
static void ShowVehicleGettingOld(Vehicle *v, StringID msg)
{
- if (v->owner != _local_player) return;
+ if (v->owner != _local_company) return;
/* Do not show getting-old message if autorenew is active (and it can replace the vehicle) */
- if (GetPlayer(v->owner)->engine_renew && GetEngine(v->engine_type)->player_avail != 0) return;
+ if (GetCompany(v->owner)->engine_renew && GetEngine(v->engine_type)->company_avail != 0) return;
SetDParam(0, _vehicle_type_names[v->type]);
SetDParam(1, v->unitnumber);
@@ -1189,7 +1189,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uin
uint32 id = p1;
uint16 window_type = p2 & VLW_MASK;
- GenerateVehicleSortList(&list, vehicle_type, _current_player, id, window_type);
+ GenerateVehicleSortList(&list, vehicle_type, _current_company, id, window_type);
} else {
/* Get the list of vehicles in the depot */
BuildDepotVehicleList(vehicle_type, tile, &list, NULL);
@@ -1271,7 +1271,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uin
VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
bool all_or_nothing = HasBit(p2, 0);
- if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
+ if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
/* Get the list of vehicles in the depot */
BuildDepotVehicleList(vehicle_type, tile, &list, &list, true);
@@ -1463,8 +1463,8 @@ CommandCost CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
/* Since we can't estimate the cost of cloning a vehicle accurately we must
- * check whether the player has enough money manually. */
- if (!CheckPlayerHasMoney(total_cost)) {
+ * check whether the company has enough money manually. */
+ if (!CheckCompanyHasMoney(total_cost)) {
if (flags & DC_EXEC) {
/* The vehicle has already been bought, so now it must be sold again. */
DoCommand(w_front->tile, w_front->index, 1, flags, GetCmdSellVeh(w_front));
@@ -1480,11 +1480,11 @@ CommandCost CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param type type of vehicle
* @param flags the flags used for DoCommand()
* @param service should the vehicles only get service in the depots
- * @param owner PlayerID of owner of the vehicles to send
+ * @param owner owner of the vehicles to send
* @param vlw_flag tells what kind of list requested the goto depot
* @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
*/
-CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
+CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, Owner owner, uint16 vlw_flag, uint32 id)
{
VehicleList list;
@@ -1603,18 +1603,18 @@ void VehicleEnterDepot(Vehicle *v)
v->current_order.MakeDummy();
if (t.IsRefit()) {
- _current_player = v->owner;
+ _current_company = v->owner;
CommandCost cost = DoCommand(v->tile, v->index, t.GetRefitCargo() | t.GetRefitSubtype() << 8, DC_EXEC, GetCmdRefitVeh(v));
if (CmdFailed(cost)) {
v->leave_depot_instantly = false; // We ensure that the vehicle stays in the depot
- if (v->owner == _local_player) {
+ if (v->owner == _local_company) {
/* Notify the user that we stopped the vehicle */
SetDParam(0, _vehicle_type_names[v->type]);
SetDParam(1, v->unitnumber);
AddNewsItem(STR_ORDER_REFIT_FAILED, NS_ADVICE, v->index, 0);
}
- } else if (v->owner == _local_player && cost.GetCost() != 0) {
+ } else if (v->owner == _local_company && cost.GetCost() != 0) {
ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
}
}
@@ -1626,7 +1626,7 @@ void VehicleEnterDepot(Vehicle *v)
} else if (t.GetDepotActionType() & ODATFB_HALT) {
/* Force depot visit */
v->vehstatus |= VS_STOPPED;
- if (v->owner == _local_player) {
+ if (v->owner == _local_company) {
StringID string;
switch (v->type) {
@@ -1912,7 +1912,7 @@ UnitID GetFreeUnitNumber(VehicleType type)
/* Fill the cache */
FOR_ALL_VEHICLES(u) {
- if (u->type == type && u->owner == _current_player && u->unitnumber != 0 && u->unitnumber <= max)
+ if (u->type == type && u->owner == _current_company && u->unitnumber != 0 && u->unitnumber <= max)
cache[u->unitnumber] = true;
}
@@ -1936,9 +1936,9 @@ UnitID GetFreeUnitNumber(VehicleType type)
*/
bool CanBuildVehicleInfrastructure(VehicleType type)
{
- assert(IsPlayerBuildableVehicleType(type));
+ assert(IsCompanyBuildableVehicleType(type));
- if (!IsValidPlayerID(_current_player)) return false;
+ if (!IsValidCompanyID(_current_company)) return false;
if (_settings_client.gui.always_build_infrastructure) return true;
UnitID max;
@@ -1955,7 +1955,7 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
/* Can we actually build the vehicle type? */
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, type) {
- if (HasBit(e->player_avail, _local_player)) return true;
+ if (HasBit(e->company_avail, _local_company)) return true;
}
return false;
}
@@ -1963,22 +1963,22 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
/* We should be able to build infrastructure when we have the actual vehicle type */
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (v->owner == _local_player && v->type == type) return true;
+ if (v->owner == _local_company && v->type == type) return true;
}
return false;
}
-const Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v)
+const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v)
{
- const Player *p = GetPlayer(player);
+ const Company *c = GetCompany(company);
LiveryScheme scheme = LS_DEFAULT;
CargoID cargo_type = v == NULL ? (CargoID)CT_INVALID : v->cargo_type;
/* The default livery is always available for use, but its in_use flag determines
* whether any _other_ liveries are in use. */
- if (p->livery[LS_DEFAULT].in_use && (_settings_client.gui.liveries == 2 || (_settings_client.gui.liveries == 1 && player == _local_player))) {
+ if (c->livery[LS_DEFAULT].in_use && (_settings_client.gui.liveries == 2 || (_settings_client.gui.liveries == 1 && company == _local_company))) {
/* Determine the livery scheme to use */
switch (GetEngine(engine_type)->type) {
default: NOT_REACHED();
@@ -2051,14 +2051,14 @@ const Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID pa
}
/* Switch back to the default scheme if the resolved scheme is not in use */
- if (!p->livery[scheme].in_use) scheme = LS_DEFAULT;
+ if (!c->livery[scheme].in_use) scheme = LS_DEFAULT;
}
- return &p->livery[scheme];
+ return &c->livery[scheme];
}
-static SpriteID GetEngineColourMap(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v)
+static SpriteID GetEngineColourMap(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v)
{
SpriteID map = (v != NULL) ? v->colormap : PAL_NONE;
@@ -2086,7 +2086,7 @@ static SpriteID GetEngineColourMap(EngineID engine_type, PlayerID player, Engine
if (map == PAL_NONE) map = twocc ? (SpriteID)SPR_2CCMAP_BASE : (SpriteID)PALETTE_RECOLOR_START;
- const Livery *livery = GetEngineLivery(engine_type, player, parent_engine_type, v);
+ const Livery *livery = GetEngineLivery(engine_type, company, parent_engine_type, v);
map += livery->colour1;
if (twocc) map += livery->colour2 * 16;
@@ -2096,9 +2096,9 @@ static SpriteID GetEngineColourMap(EngineID engine_type, PlayerID player, Engine
return map;
}
-SpriteID GetEnginePalette(EngineID engine_type, PlayerID player)
+SpriteID GetEnginePalette(EngineID engine_type, CompanyID company)
{
- return GetEngineColourMap(engine_type, player, INVALID_ENGINE, NULL);
+ return GetEngineColourMap(engine_type, company, INVALID_ENGINE, NULL);
}
SpriteID GetVehiclePalette(const Vehicle *v)
@@ -2440,7 +2440,7 @@ void Load_VEHS()
SlObject(v, GetVehicleDescription(vtype));
- if (_cargo_count != 0 && IsPlayerBuildableVehicleType(v)) {
+ if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v)) {
/* Don't construct the packet with station here, because that'll fail with old savegames */
CargoPacket *cp = new CargoPacket();
cp->source = _cargo_source;
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index d0bc4188c..d3368d2fc 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -256,7 +256,7 @@ public:
byte z_pos;
DirectionByte direction; // facing
- PlayerByte owner; // which player owns the vehicle?
+ OwnerByte owner; // which company owns the vehicle?
byte spritenum; // currently displayed sprite index
// 0xfd == custom sprite, 0xfe == custom second head sprite
// 0xff == reserved for another custom sprite
@@ -532,7 +532,7 @@ public:
this->service_interval = src->service_interval;
}
- bool NeedsAutorenewing(const Player *p) const;
+ bool NeedsAutorenewing(const Company *c) const;
/**
* Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement.
diff --git a/src/vehicle_func.h b/src/vehicle_func.h
index ec679776d..6b0c36930 100644
--- a/src/vehicle_func.h
+++ b/src/vehicle_func.h
@@ -68,7 +68,7 @@ void TrainConsistChanged(Vehicle *v, bool same_length);
void TrainPowerChanged(Vehicle *v);
Money GetTrainRunningCost(const Vehicle *v);
-CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
+CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, Owner owner, uint16 vlw_flag, uint32 id);
void VehicleEnterDepot(Vehicle *v);
bool CanBuildVehicleInfrastructure(VehicleType type);
@@ -86,7 +86,7 @@ struct GetNewVehiclePosResult {
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v);
Direction GetDirectionTowards(const Vehicle *v, int x, int y);
-static inline bool IsPlayerBuildableVehicleType(VehicleType type)
+static inline bool IsCompanyBuildableVehicleType(VehicleType type)
{
switch (type) {
case VEH_TRAIN:
@@ -99,20 +99,20 @@ static inline bool IsPlayerBuildableVehicleType(VehicleType type)
}
}
-static inline bool IsPlayerBuildableVehicleType(const BaseVehicle *v)
+static inline bool IsCompanyBuildableVehicleType(const BaseVehicle *v)
{
- return IsPlayerBuildableVehicleType(v->type);
+ return IsCompanyBuildableVehicleType(v->type);
}
-const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v);
+const struct Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v);
/**
* Get the colour map for an engine. This used for unbuilt engines in the user interface.
* @param engine_type ID of engine
- * @param player ID of player
+ * @param company ID of company
* @return A ready-to-use palette modifier
*/
-SpriteID GetEnginePalette(EngineID engine_type, PlayerID player);
+SpriteID GetEnginePalette(EngineID engine_type, CompanyID company);
/**
* Get the colour map for a vehicle.
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 5f9045a82..79c21d62a 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -90,11 +90,11 @@ const StringID BaseVehicleListWindow::vehicle_sorter_names[] = {
INVALID_STRING_ID
};
-void BaseVehicleListWindow::BuildVehicleList(PlayerID owner, uint16 index, uint16 window_type)
+void BaseVehicleListWindow::BuildVehicleList(Owner owner, uint16 index, uint16 window_type)
{
if (!this->vehicles.NeedRebuild()) return;
- DEBUG(misc, 3, "Building vehicle list for player %d at station %d", owner, index);
+ DEBUG(misc, 3, "Building vehicle list for company %d at station %d", owner, index);
GenerateVehicleSortList(&this->vehicles, this->vehicle_type, owner, index, window_type);
@@ -684,7 +684,7 @@ enum VehicleListWindowWidgets {
VLW_WIDGET_EMPTY_TOP_RIGHT,
VLW_WIDGET_LIST,
VLW_WIDGET_SCROLLBAR,
- VLW_WIDGET_OTHER_PLAYER_FILLER,
+ VLW_WIDGET_OTHER_COMPANY_FILLER,
VLW_WIDGET_AVAILABLE_VEHICLES,
VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN,
VLW_WIDGET_STOP_ALL,
@@ -702,7 +702,7 @@ static const Widget _vehicle_list_widgets[] = {
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 248, 259, 14, 25, 0x0, STR_NULL},
{ WWT_MATRIX, RESIZE_RB, COLOUR_GREY, 0, 247, 26, 181, 0x0, STR_NULL},
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 248, 259, 26, 181, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
- /* Widget to be shown for other players hiding the following 6 widgets */
+ /* Widget to be shown for other companies hiding the following 6 widgets */
{ WWT_PANEL, RESIZE_RTB, COLOUR_GREY, 0, 247, 182, 193, 0x0, STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 105, 182, 193, 0x0, STR_AVAILABLE_ENGINES_TIP},
@@ -795,7 +795,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(int x, VehicleID selected_vehic
* Window for the (old) vehicle listing.
*
* bitmask for w->window_number
- * 0-7 PlayerID (owner)
+ * 0-7 CompanyID (owner)
* 8-10 window type (use flags in vehicle_gui.h)
* 11-15 vehicle type (using VEH_, but can be compressed to fewer bytes if needed)
* 16-31 StationID or OrderID depending on window type (bit 8-10)
@@ -805,15 +805,15 @@ struct VehicleListWindow : public BaseVehicleListWindow {
VehicleListWindow(const WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number)
{
uint16 window_type = this->window_number & VLW_MASK;
- PlayerID player = (PlayerID)GB(this->window_number, 0, 8);
+ CompanyID company = (CompanyID)GB(this->window_number, 0, 8);
this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
- this->caption_color = player;
+ this->caption_color = company;
/* Hide the widgets that we will not use in this window
* Some windows contains actions only fit for the owner */
- if (player == _local_player) {
- this->HideWidget(VLW_WIDGET_OTHER_PLAYER_FILLER);
+ if (company == _local_company) {
+ this->HideWidget(VLW_WIDGET_OTHER_COMPANY_FILLER);
this->SetWidgetDisabledState(VLW_WIDGET_AVAILABLE_VEHICLES, window_type != VLW_STANDARD);
} else {
this->SetWidgetsHiddenState(true,
@@ -937,7 +937,7 @@ struct VehicleListWindow : public BaseVehicleListWindow {
virtual void OnPaint()
{
int x = 2;
- const PlayerID owner = (PlayerID)this->caption_color;
+ const Owner owner = (Owner)this->caption_color;
const uint16 window_type = this->window_number & VLW_MASK;
const uint16 index = GB(this->window_number, 16, 16);
@@ -1103,9 +1103,9 @@ struct VehicleListWindow : public BaseVehicleListWindow {
if (_pause_game != 0) return;
if (this->vehicles.NeedResort()) {
StationID station = ((this->window_number & VLW_MASK) == VLW_STATION_LIST) ? GB(this->window_number, 16, 16) : INVALID_STATION;
- PlayerID owner = (PlayerID)this->caption_color;
+ Owner owner = (Owner)this->caption_color;
- DEBUG(misc, 3, "Periodic resort %d list player %d at station %d", this->vehicle_type, owner, station);
+ DEBUG(misc, 3, "Periodic resort %d list company %d at station %d", this->vehicle_type, owner, station);
this->SetDirty();
}
}
@@ -1139,26 +1139,26 @@ static WindowDesc _vehicle_list_desc = {
_vehicle_list_widgets,
};
-static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number)
+static void ShowVehicleListWindowLocal(CompanyID company, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number)
{
- if (!IsValidPlayerID(player)) return;
+ if (!IsValidCompanyID(company)) return;
_vehicle_list_desc.cls = GetWindowClassForVehicleType(vehicle_type);
- WindowNumber num = (unique_number << 16) | (vehicle_type << 11) | VLW_flag | player;
+ WindowNumber num = (unique_number << 16) | (vehicle_type << 11) | VLW_flag | company;
AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_desc, num);
}
-void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type)
+void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type)
{
/* If _settings_client.gui.advanced_vehicle_list > 1, display the Advanced list
- * if _settings_client.gui.advanced_vehicle_list == 1, display Advanced list only for local player
+ * if _settings_client.gui.advanced_vehicle_list == 1, display Advanced list only for local company
* if _ctrl_pressed, do the opposite action (Advanced list x Normal list)
*/
- if ((_settings_client.gui.advanced_vehicle_list > (uint)(player != _local_player)) != _ctrl_pressed) {
- ShowPlayerGroup(player, vehicle_type);
+ if ((_settings_client.gui.advanced_vehicle_list > (uint)(company != _local_company)) != _ctrl_pressed) {
+ ShowCompanyGroup(company, vehicle_type);
} else {
- ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0);
+ ShowVehicleListWindowLocal(company, VLW_STANDARD, vehicle_type, 0);
}
}
@@ -1173,12 +1173,12 @@ void ShowVehicleListWindow(const Vehicle *v)
ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->FirstShared()->index);
}
-void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station)
+void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station)
{
- ShowVehicleListWindowLocal(player, VLW_STATION_LIST, vehicle_type, station);
+ ShowVehicleListWindowLocal(company, VLW_STATION_LIST, vehicle_type, station);
}
-void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile)
+void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile)
{
uint16 depot_airport_index;
@@ -1189,7 +1189,7 @@ void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex
if (depot == NULL) return; // no depot to show
depot_airport_index = depot->index;
}
- ShowVehicleListWindowLocal(player, VLW_DEPOT_LIST, vehicle_type, depot_airport_index);
+ ShowVehicleListWindowLocal(company, VLW_DEPOT_LIST, vehicle_type, depot_airport_index);
}
@@ -1381,7 +1381,7 @@ struct VehicleDetailsWindow : Window {
const Vehicle *v = GetVehicle(this->window_number);
byte det_tab = this->tab;
- this->SetWidgetDisabledState(VLD_WIDGET_RENAME_VEHICLE, v->owner != _local_player);
+ this->SetWidgetDisabledState(VLD_WIDGET_RENAME_VEHICLE, v->owner != _local_company);
if (v->type == VEH_TRAIN) {
this->DisableWidget(det_tab + VLD_WIDGET_DETAILS_CARGO_CARRIED);
@@ -1843,21 +1843,21 @@ struct VehicleViewWindow : Window {
const Vehicle *v = GetVehicle(this->window_number);
StringID str;
- bool is_localplayer = v->owner == _local_player;
+ bool is_localcompany = v->owner == _local_company;
bool refitable_and_stopped_in_depot = IsVehicleRefitable(v);
- this->SetWidgetDisabledState(VVW_WIDGET_GOTO_DEPOT, !is_localplayer);
+ this->SetWidgetDisabledState(VVW_WIDGET_GOTO_DEPOT, !is_localcompany);
this->SetWidgetDisabledState(VVW_WIDGET_REFIT_VEH,
- !refitable_and_stopped_in_depot || !is_localplayer);
- this->SetWidgetDisabledState(VVW_WIDGET_CLONE_VEH, !is_localplayer);
+ !refitable_and_stopped_in_depot || !is_localcompany);
+ this->SetWidgetDisabledState(VVW_WIDGET_CLONE_VEH, !is_localcompany);
if (v->type == VEH_TRAIN) {
- this->SetWidgetDisabledState(VVW_WIDGET_FORCE_PROCEED, !is_localplayer);
- this->SetWidgetDisabledState(VVW_WIDGET_TURN_AROUND, !is_localplayer);
+ this->SetWidgetDisabledState(VVW_WIDGET_FORCE_PROCEED, !is_localcompany);
+ this->SetWidgetDisabledState(VVW_WIDGET_TURN_AROUND, !is_localcompany);
/* Cargo refit button is disabled, until we know we can enable it below. */
- if (is_localplayer) {
+ if (is_localcompany) {
/* See if any vehicle can be refitted */
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
if (EngInfo(u->engine_type)->refit_mask != 0 ||
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index dc740975c..8bc87b6a7 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -65,9 +65,9 @@ uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine);
void ShowVehicleListWindow(const Vehicle *v);
void ShowVehicleListWindow(const Waypoint *wp);
-void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type);
-void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station);
-void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile);
+void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
+void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
+void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
/* ChangeVehicleViewWindow() moves all windows for one vehicle to another vehicle.
@@ -82,7 +82,7 @@ static inline uint GetVehicleListHeight(VehicleType type)
/** Get WindowClass for vehicle list of given vehicle type
* @param vt vehicle type to check
* @return corresponding window class
- * @note works only for player buildable vehicle types
+ * @note works only for company buildable vehicle types
*/
static inline WindowClass GetWindowClassForVehicleType(VehicleType vt)
{
diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h
index 311c648b9..a9ebad0e7 100644
--- a/src/vehicle_gui_base.h
+++ b/src/vehicle_gui_base.h
@@ -32,7 +32,7 @@ struct BaseVehicleListWindow: public Window {
void DrawVehicleListItems(int x, VehicleID selected_vehicle);
void SortVehicleList();
- void BuildVehicleList(PlayerID owner, uint16 index, uint16 window_type);
+ void BuildVehicleList(Owner owner, uint16 index, uint16 window_type);
};
struct Sorting {
diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp
index 62125d0db..c6d487bf5 100644
--- a/src/vehiclelist.cpp
+++ b/src/vehiclelist.cpp
@@ -61,7 +61,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
* Generate a list of vehicles based on window type.
* @param list Pointer to list to add vehicles to
* @param type Type of vehicle
- * @param owner Player to generate list for
+ * @param owner Company to generate list for
* @param index This parameter has different meanings depending on window_type
* <ul>
* <li>VLW_STATION_LIST: index of station to generate a list for</li>
@@ -73,7 +73,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
* </ul>
* @param window_type The type of window the list is for, using the VLW_ flags in vehicle_gui.h
*/
-void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner, uint32 index, uint16 window_type)
+void GenerateVehicleSortList(VehicleList *list, VehicleType type, Owner owner, uint32 index, uint16 window_type)
{
list->Clear();
diff --git a/src/vehiclelist.h b/src/vehiclelist.h
index 2635d493c..662cbec7b 100644
--- a/src/vehiclelist.h
+++ b/src/vehiclelist.h
@@ -9,7 +9,7 @@
typedef SmallVector<const Vehicle *, 32> VehicleList;
-void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
+void GenerateVehicleSortList(VehicleList *list, VehicleType type, Owner owner, uint32 index, uint16 window_type);
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons = false);
#endif /* VEHICLELIST_H */
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index 6577bd6b7..89cec2df9 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -260,8 +260,8 @@ void VideoDriver_Dedicated::MainLoop()
// Load the dedicated server stuff
_is_network_server = true;
_network_dedicated = true;
- _network_playas = PLAYER_SPECTATOR;
- _local_player = PLAYER_SPECTATOR;
+ _network_playas = COMPANY_SPECTATOR;
+ _local_company = COMPANY_SPECTATOR;
/* If SwitchMode is SM_LOAD, it means that the user used the '-g' options */
if (_switch_mode != SM_LOAD) {
diff --git a/src/viewport.cpp b/src/viewport.cpp
index ae7df8a6e..a4d9de0d4 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1068,7 +1068,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
static void AddStation(const Station *st, StringID str, uint16 width)
{
- AddStringToDraw(st->sign.left + 1, st->sign.top + 1, str, st->index, st->facilities, (st->owner == OWNER_NONE || st->facilities == 0) ? 0xE : _player_colors[st->owner], width);
+ AddStringToDraw(st->sign.left + 1, st->sign.top + 1, str, st->index, st->facilities, (st->owner == OWNER_NONE || st->facilities == 0) ? 0xE : _company_colours[st->owner], width);
}
@@ -1132,7 +1132,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
static void AddSign(const Sign *si, StringID str, uint16 width)
{
- AddStringToDraw(si->sign.left + 1, si->sign.top + 1, str, si->index, 0, (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner], width);
+ AddStringToDraw(si->sign.left + 1, si->sign.top + 1, str, si->index, 0, (si->owner == OWNER_NONE) ? 14 : _company_colours[si->owner], width);
}
@@ -1861,8 +1861,8 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
{
const Sign *si;
- /* Signs are turned off, or they are transparent and invisibility is ON, or player is a spectator */
- if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
+ /* Signs are turned off, or they are transparent and invisibility is ON, or company is a spectator */
+ if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS) || _current_company == COMPANY_SPECTATOR) return false;
switch (vp->zoom) {
case ZOOM_LVL_NORMAL:
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 95ba515bf..ae728f546 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -224,8 +224,8 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
Depot *depot = new Depot(tile);
depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
- MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1);
- MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2);
+ MakeShipDepot(tile, _current_company, DEPOT_NORTH, axis, wc1);
+ MakeShipDepot(tile2, _current_company, DEPOT_SOUTH, axis, wc2);
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(tile2);
}
@@ -314,7 +314,7 @@ static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 fla
}
if (flags & DC_EXEC) {
- MakeLock(tile, _current_player, dir, wc_lower, wc_upper);
+ MakeLock(tile, _current_company, dir, wc_lower, wc_upper);
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(tile - delta);
MarkTileDirtyByTile(tile + delta);
@@ -418,7 +418,7 @@ CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} else if (p2 == 2) {
MakeRiver(tile, Random());
} else {
- MakeCanal(tile, _current_player, Random());
+ MakeCanal(tile, _current_company, Random());
}
MarkTileDirtyByTile(tile);
MarkCanalsAndRiversAroundDirty(tile);
@@ -482,7 +482,7 @@ static CommandCost ClearTile_Water(TileIndex tile, byte flags)
};
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
- if (_current_player == OWNER_WATER) return CMD_ERROR;
+ if (_current_company == OWNER_WATER) return CMD_ERROR;
/* move to the middle tile.. */
return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[GetSection(tile)]), flags);
}
@@ -741,7 +741,7 @@ static void DrawTile_Water(TileInfo *ti)
case WATER_TILE_DEPOT:
DrawWaterClassGround(ti);
- DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0, false);
+ DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], COMPANY_SPRITE_COLOR(GetTileOwner(ti->tile)), 0, false);
break;
}
}
@@ -754,7 +754,7 @@ void DrawShipDepotSprite(int x, int y, int image)
for (; wdts->delta_x != 0x80; wdts++) {
Point pt = RemapCoords(wdts->delta_x, wdts->delta_y, wdts->delta_z);
- DrawSprite(wdts->image, PLAYER_SPRITE_COLOR(_local_player), x + pt.x, y + pt.y);
+ DrawSprite(wdts->image, COMPANY_SPRITE_COLOR(_local_company), x + pt.x, y + pt.y);
}
}
@@ -993,7 +993,7 @@ static void DoFloodTile(TileIndex target)
bool flooded = false; // Will be set to true if something is changed.
- _current_player = OWNER_WATER;
+ _current_company = OWNER_WATER;
Slope tileh = GetTileSlope(target, NULL);
if (tileh != SLOPE_FLAT) {
@@ -1045,7 +1045,7 @@ static void DoFloodTile(TileIndex target)
UpdateSignalsInBuffer();
}
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
}
/**
@@ -1053,7 +1053,7 @@ static void DoFloodTile(TileIndex target)
*/
static void DoDryUp(TileIndex tile)
{
- _current_player = OWNER_WATER;
+ _current_company = OWNER_WATER;
switch (GetTileType(tile)) {
case MP_RAILWAY:
@@ -1089,7 +1089,7 @@ static void DoDryUp(TileIndex tile)
default: NOT_REACHED();
}
- _current_player = OWNER_NONE;
+ _current_company = OWNER_NONE;
}
/**
@@ -1213,12 +1213,12 @@ static void ClickTile_Water(TileIndex tile)
}
}
-static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID new_player)
+static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_owner)
{
- if (!IsTileOwner(tile, old_player)) return;
+ if (!IsTileOwner(tile, old_owner)) return;
- if (new_player != PLAYER_SPECTATOR) {
- SetTileOwner(tile, new_player);
+ if (new_owner != INVALID_OWNER) {
+ SetTileOwner(tile, new_owner);
return;
}
@@ -1227,7 +1227,7 @@ static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID
/* Set owner of canals and locks ... and also canal under dock there was before.
* Check if the new owner after removing depot isn't OWNER_WATER. */
- if (IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE);
+ if (IsTileOwner(tile, old_owner)) SetTileOwner(tile, OWNER_NONE);
}
static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
diff --git a/src/waypoint.cpp b/src/waypoint.cpp
index f455dde5f..ecf8bbb6e 100644
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -144,7 +144,7 @@ static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
uint thres = 8;
FOR_ALL_WAYPOINTS(wp) {
- if (wp->deleted && (wp->owner == OWNER_NONE || wp->owner == _current_player)) {
+ if (wp->deleted && (wp->owner == OWNER_NONE || wp->owner == _current_company)) {
uint cur_dist = DistanceManhattan(tile, wp->xy);
if (cur_dist < thres) {
@@ -310,7 +310,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
/* Make sure it's a waypoint */
if (!IsRailWaypointTile(tile) ||
- (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) ||
+ (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) ||
!EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
diff --git a/src/waypoint.h b/src/waypoint.h
index 2692ad5ea..a4afbba43 100644
--- a/src/waypoint.h
+++ b/src/waypoint.h
@@ -25,7 +25,7 @@ struct Waypoint : PoolItem<Waypoint, WaypointID, &_Waypoint_pool> {
ViewportSign sign; ///< Dimensions of sign (not saved)
Date build_date; ///< Date of construction
- PlayerByte owner; ///< Whom this waypoint belongs to
+ OwnerByte owner; ///< Whom this waypoint belongs to
byte stat_id; ///< ID of waypoint within the waypoint class (not saved)
uint32 grfid; ///< ID of GRF file
diff --git a/src/widget.cpp b/src/widget.cpp
index dda7854cd..4ae7497c1 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -476,7 +476,7 @@ void Window::DrawWidgets() const
DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, wi->color, (this->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
if (this->caption_color != 0xFF) {
- GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_player_colors[this->caption_color]][4]);
+ GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[this->caption_color]][4]);
}
DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top + 2, wi->data, TC_FROMSTRING);
diff --git a/src/window.cpp b/src/window.cpp
index 3d7bdf5c0..abf66042c 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -483,11 +483,11 @@ restart_search:
}
}
-/** Delete all windows of a player. We identify windows of a player
- * by looking at the caption colour. If it is equal to the player ID
- * then we say the window belongs to the player and should be deleted
- * @param id PlayerID player identifier */
-void DeletePlayerWindows(PlayerID id)
+/** Delete all windows of a company. We identify windows of a company
+ * by looking at the caption colour. If it is equal to the company ID
+ * then we say the window belongs to the company and should be deleted
+ * @param id company identifier */
+void DeleteCompanyWindows(CompanyID id)
{
Window* const *wz;
@@ -503,26 +503,26 @@ restart_search:
}
}
- /* Also delete the player specific windows, that don't have a player-colour */
+ /* Also delete the company specific windows, that don't have a company-colour */
DeleteWindowById(WC_BUY_COMPANY, id);
}
-/** Change the owner of all the windows one player can take over from another
- * player in the case of a company merger. Do not change ownership of windows
+/** Change the owner of all the windows one company can take over from another
+ * company in the case of a company merger. Do not change ownership of windows
* that need to be deleted once takeover is complete
- * @param old_player PlayerID of original owner of the window
- * @param new_player PlayerID of the new owner of the window */
-void ChangeWindowOwner(PlayerID old_player, PlayerID new_player)
+ * @param old_owner original owner of the window
+ * @param new_owner the new owner of the window */
+void ChangeWindowOwner(Owner old_owner, Owner new_owner)
{
Window* const *wz;
FOR_ALL_WINDOWS(wz) {
Window *w = *wz;
- if (w->caption_color != old_player) continue;
+ if (w->caption_color != old_owner) continue;
switch (w->window_class) {
- case WC_PLAYER_COLOR:
+ case WC_COMPANY_COLOR:
case WC_FINANCES:
case WC_STATION_LIST:
case WC_TRAINS_LIST:
@@ -534,7 +534,7 @@ void ChangeWindowOwner(PlayerID old_player, PlayerID new_player)
continue;
default:
- w->caption_color = new_player;
+ w->caption_color = new_owner;
break;
}
}
@@ -1635,12 +1635,12 @@ void HandleKeypress(uint32 raw_key)
* During the generation of the world, there might be
* another thread that is currently building for example
* a road. To not interfere with those tasks, we should
- * NOT change the _current_player here.
+ * NOT change the _current_company here.
*
* This is not necessary either, as the only events that
* can be handled are the 'close application' events
*/
- if (!IsGeneratingWorld()) _current_player = _local_player;
+ if (!IsGeneratingWorld()) _current_company = _local_company;
/* Setup event */
uint16 key = GB(raw_key, 0, 16);
@@ -1914,12 +1914,12 @@ void HandleMouseEvents()
* During the generation of the world, there might be
* another thread that is currently building for example
* a road. To not interfere with those tasks, we should
- * NOT change the _current_player here.
+ * NOT change the _current_company here.
*
* This is not necessary either, as the only events that
* can be handled are the 'close application' events
*/
- if (!IsGeneratingWorld()) _current_player = _local_player;
+ if (!IsGeneratingWorld()) _current_company = _local_company;
/* Mouse event? */
MouseClick click = MC_NONE;
diff --git a/src/window_func.h b/src/window_func.h
index 0f396f3d2..f60ce517a 100644
--- a/src/window_func.h
+++ b/src/window_func.h
@@ -11,7 +11,7 @@
void SetWindowDirty(const Window *w);
Window *FindWindowById(WindowClass cls, WindowNumber number);
-void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
+void ChangeWindowOwner(Owner old_owner, Owner new_owner);
void ResizeWindow(Window *w, int x, int y);
int PositionMainToolbar(Window *w);
diff --git a/src/window_gui.h b/src/window_gui.h
index 0a58add42..2824f337f 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -214,7 +214,7 @@ public:
Scrollbar vscroll2; ///< Second vertical scroll bar
ResizeInfo resize; ///< Resize information
- byte caption_color; ///< Background color of the window caption, contains PlayerID
+ byte caption_color; ///< Background color of the window caption, contains CompanyID
ViewportData *viewport; ///< Pointer to viewport data, if present
Widget *widget; ///< Widgets of the window
diff --git a/src/window_type.h b/src/window_type.h
index 0150f64da..04f03ad68 100644
--- a/src/window_type.h
+++ b/src/window_type.h
@@ -40,7 +40,7 @@ enum WindowClass {
WC_BUILD_DEPOT,
WC_COMPANY,
WC_FINANCES,
- WC_PLAYER_COLOR,
+ WC_COMPANY_COLOR,
WC_QUERY_STRING,
WC_SAVELOAD,
WC_SELECT_GAME,
@@ -49,7 +49,7 @@ enum WindowClass {
WC_OPERATING_PROFIT,
WC_TOOLTIPS,
WC_INDUSTRY_VIEW,
- WC_PLAYER_FACE,
+ WC_COMPANY_MANAGER_FACE,
WC_LAND_INFO,
WC_TOWN_AUTHORITY,
WC_SUBSIDIES_LIST,
diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp
index 16d405eea..e990424b6 100644
--- a/src/yapf/follow_track.hpp
+++ b/src/yapf/follow_track.hpp
@@ -288,7 +288,7 @@ protected:
m_err = EC_NO_WAY;
return false;
}
- // don't try to enter other player's depots
+ // don't try to enter other company's depots
if (GetTileOwner(m_new_tile) != m_veh_owner) {
m_err = EC_OWNER;
return false;
diff --git a/src/yapf/yapf_base.hpp b/src/yapf/yapf_base.hpp
index f09a97d61..418a36d9f 100644
--- a/src/yapf/yapf_base.hpp
+++ b/src/yapf/yapf_base.hpp
@@ -91,7 +91,7 @@ protected:
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
public:
- /// return current settings (can be custom - player based - but later)
+ /// return current settings (can be custom - company based - but later)
FORCEINLINE const YAPFSettings& PfGetSettings() const
{
return *m_settings;
diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp
index a048ebfd4..da5d82a5c 100644
--- a/src/yapf/yapf_destrail.hpp
+++ b/src/yapf/yapf_destrail.hpp
@@ -139,13 +139,13 @@ public:
Waypoint *wp = GetWaypoint(v->current_order.GetDestination());
if (wp == NULL) {
/* Invalid waypoint in orders! */
- DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, player %d)", v->current_order.GetDestination(), v->unitnumber, (PlayerID)v->owner);
+ DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, company %d)", v->current_order.GetDestination(), v->unitnumber, (CompanyID)v->owner);
break;
}
m_destTile = wp->xy;
if (m_destTile != v->dest_tile) {
/* Something is wrong with orders! */
- DEBUG(yapf, 0, "Invalid v->dest_tile == 0x%04X (train %d, player %d)", v->dest_tile, v->unitnumber, (PlayerID)v->owner);
+ DEBUG(yapf, 0, "Invalid v->dest_tile == 0x%04X (train %d, company %d)", v->dest_tile, v->unitnumber, (CompanyID)v->owner);
}
m_dest_station_id = INVALID_STATION;
m_destTrackdirs = TrackToTrackdirBits(AxisToTrack(GetWaypointAxis(wp->xy)));