summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network_client.cpp8
-rw-r--r--src/network/network_gui.cpp6
-rw-r--r--src/network/network_server.cpp28
4 files changed, 22 insertions, 22 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index cd0b91408..e824f4406 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -341,7 +341,7 @@ static uint NetworkCountPlayers()
FOR_ALL_CLIENTS(cs) {
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayer(ci->client_playas)) count++;
+ if (IsValidPlayerID(ci->client_playas)) count++;
}
return count;
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 0b52e0169..5a3c7dab6 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -367,7 +367,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
if (total == 0) return NETWORK_RECV_STATUS_CLOSE_QUERY;
current = (Owner)p->Recv_uint8();
- if (!IsValidPlayer(current)) return NETWORK_RECV_STATUS_CLOSE_QUERY;
+ if (!IsValidPlayerID(current)) 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();
@@ -624,7 +624,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
/* 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 || !IsValidPlayer(_network_playas) ||
+ if (_network_playas == PLAYER_NEW_COMPANY || !IsValidPlayerID(_network_playas) ||
!GetPlayer(_network_playas)->is_active) {
SetLocalPlayer(PLAYER_SPECTATOR);
@@ -737,10 +737,10 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CHAT)
/* For speaking to company or giving money, we need the player-name */
case NETWORK_ACTION_GIVE_MONEY:
- if (!IsValidPlayer(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
+ if (!IsValidPlayerID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
/* fallthrough */
case NETWORK_ACTION_CHAT_COMPANY: {
- StringID str = IsValidPlayer(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
+ StringID str = IsValidPlayerID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);
GetString(name, str, lastof(name));
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 418be8beb..e238b94e2 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1296,7 +1296,7 @@ struct NetworkClientListPopupWindow : Window {
this->proc[i++] = &ClientList_SpeakToClient;
}
- if (IsValidPlayer(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) {
+ if (IsValidPlayerID(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) {
GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY, lastof(this->action[i]));
this->proc[i++] = &ClientList_SpeakToCompany;
}
@@ -1305,7 +1305,7 @@ struct NetworkClientListPopupWindow : Window {
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 (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas) && _settings_game.economy.give_money) {
+ if (IsValidPlayerID(_network_playas) && IsValidPlayerID(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;
}
@@ -1494,7 +1494,7 @@ struct NetworkClientListWindow : Window
}
/* Filter out spectators */
- if (IsValidPlayer(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
+ if (IsValidPlayerID(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
DoDrawString(ci->client_name, 81, y, colour);
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 3905d0bae..21c179877 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -621,7 +621,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 (IsValidPlayer(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
+ if (IsValidPlayerID(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
} else {
SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
@@ -677,7 +677,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
}
break;
default: /* Join another company (companies 1-8 (index 0-7)) */
- if (!IsValidPlayer(playas)) {
+ if (!IsValidPlayerID(playas)) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH);
return;
}
@@ -701,7 +701,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 (IsValidPlayer(playas)) _network_player_info[playas].months_empty = 0;
+ if (IsValidPlayerID(playas)) _network_player_info[playas].months_empty = 0;
if (_grfconfig == NULL) {
RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)(cs, NULL);
@@ -729,7 +729,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayer(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
+ if (IsValidPlayerID(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
return;
}
@@ -841,7 +841,7 @@ static bool CheckCommandFlags(const CommandPacket *cp, const NetworkClientInfo *
return false;
}
- if (cp->cmd != CMD_PLAYER_CTRL && !IsValidPlayer(cp->player) && ci->client_index != NETWORK_SERVER_INDEX) {
+ 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));
return false;
}
@@ -1125,7 +1125,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
if (ci != NULL && show_local) {
if (from_index == NETWORK_SERVER_INDEX) {
char name[NETWORK_NAME_LENGTH];
- StringID str = IsValidPlayer(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
+ StringID str = IsValidPlayerID(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);
@@ -1185,7 +1185,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD)
p->Recv_string(password, sizeof(password));
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayer(ci->client_playas)) {
+ if (IsValidPlayerID(ci->client_playas)) {
ttd_strlcpy(_network_player_info[ci->client_playas].password, password, sizeof(_network_player_info[0].password));
}
}
@@ -1337,7 +1337,7 @@ void NetworkPopulateCompanyInfo()
// Go through all vehicles and count the type of vehicles
FOR_ALL_VEHICLES(v) {
- if (!IsValidPlayer(v->owner) || !v->IsPrimaryVehicle()) continue;
+ if (!IsValidPlayerID(v->owner) || !v->IsPrimaryVehicle()) continue;
byte type = 0;
switch (v->type) {
case VEH_TRAIN: type = 0; break;
@@ -1351,7 +1351,7 @@ void NetworkPopulateCompanyInfo()
// Go through all stations and count the types of stations
FOR_ALL_STATIONS(s) {
- if (IsValidPlayer(s->owner)) {
+ if (IsValidPlayerID(s->owner)) {
NetworkPlayerInfo *npi = &_network_player_info[s->owner];
if (s->facilities & FACIL_TRAIN) npi->num_station[0]++;
@@ -1364,7 +1364,7 @@ void NetworkPopulateCompanyInfo()
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
// Register local player (if not dedicated)
- if (ci != NULL && IsValidPlayer(ci->client_playas))
+ 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));
FOR_ALL_CLIENTS(cs) {
@@ -1373,7 +1373,7 @@ void NetworkPopulateCompanyInfo()
NetworkGetClientName(client_name, sizeof(client_name), cs);
ci = DEREF_CLIENT_INFO(cs);
- if (ci != NULL && IsValidPlayer(ci->client_playas)) {
+ 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));
}
@@ -1425,12 +1425,12 @@ static void NetworkAutoCleanCompanies()
/* Detect the active companies */
FOR_ALL_CLIENTS(cs) {
ci = DEREF_CLIENT_INFO(cs);
- if (IsValidPlayer(ci->client_playas)) clients_in_company[ci->client_playas] = true;
+ if (IsValidPlayerID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
}
if (!_network_dedicated) {
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
- if (IsValidPlayer(ci->client_playas)) clients_in_company[ci->client_playas] = true;
+ if (IsValidPlayerID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
}
/* Go through all the comapnies */
@@ -1669,7 +1669,7 @@ 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 + (IsValidPlayer(ci->client_playas) ? 1 : 0),
+ ci->client_playas + (IsValidPlayerID(ci->client_playas) ? 1 : 0),
GetPlayerIP(ci), ci->unique_id);
}
}