mirror of https://github.com/OpenTTD/OpenTTD
(svn r14718) -Change: remove some direct network core variable accesses from non-network locations.
parent
f49cc67f83
commit
94e7f41a9d
|
@ -821,7 +821,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
/* A new company could not be created, revert to being a spectator */
|
/* A new company could not be created, revert to being a spectator */
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
if (_network_server) {
|
if (_network_server) {
|
||||||
NetworkClientInfo *ci = &_network_client_info[cid];
|
NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(cid);
|
||||||
ci->client_playas = COMPANY_SPECTATOR;
|
ci->client_playas = COMPANY_SPECTATOR;
|
||||||
NetworkUpdateClientInfo(ci->client_id);
|
NetworkUpdateClientInfo(ci->client_id);
|
||||||
} else if (_local_company == COMPANY_SPECTATOR) {
|
} else if (_local_company == COMPANY_SPECTATOR) {
|
||||||
|
@ -857,7 +857,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
|
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
|
||||||
* server-side in network_server.c:838, function
|
* server-side in network_server.c:838, function
|
||||||
* DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
* DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
||||||
NetworkClientInfo *ci = &_network_client_info[cid];
|
NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(cid);
|
||||||
ci->client_playas = c->index;
|
ci->client_playas = c->index;
|
||||||
NetworkUpdateClientInfo(ci->client_id);
|
NetworkUpdateClientInfo(ci->client_id);
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,21 @@ static ClientID _network_client_id = CLIENT_ID_FIRST;
|
||||||
/* Some externs / forwards */
|
/* Some externs / forwards */
|
||||||
extern void StateGameLoop();
|
extern void StateGameLoop();
|
||||||
|
|
||||||
// Function that looks up the CI for a given client-identifier
|
/**
|
||||||
|
* Return the CI given it's raw index
|
||||||
|
* @param index the index to search for
|
||||||
|
* @return return a pointer to the corresponding NetworkClientInfo struct
|
||||||
|
*/
|
||||||
|
NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index)
|
||||||
|
{
|
||||||
|
return &_network_client_info[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the CI given it's client-identifier
|
||||||
|
* @param client_id the ClientID to search for
|
||||||
|
* @return return a pointer to the corresponding NetworkClientInfo struct or NULL when not found
|
||||||
|
*/
|
||||||
NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id)
|
NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id)
|
||||||
{
|
{
|
||||||
NetworkClientInfo *ci;
|
NetworkClientInfo *ci;
|
||||||
|
@ -112,9 +126,11 @@ NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the CI for a given IP
|
/**
|
||||||
|
* Return the CI for a given IP
|
||||||
* @param ip IP of the client we are looking for. This must be in string-format
|
* @param ip IP of the client we are looking for. This must be in string-format
|
||||||
* @return return a pointer to the corresponding NetworkClientInfo struct or NULL on failure */
|
* @return return a pointer to the corresponding NetworkClientInfo struct or NULL when not found
|
||||||
|
*/
|
||||||
NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip)
|
NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip)
|
||||||
{
|
{
|
||||||
NetworkClientInfo *ci;
|
NetworkClientInfo *ci;
|
||||||
|
@ -127,7 +143,11 @@ NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function that looks up the CS for a given client-identifier
|
/**
|
||||||
|
* Return the client state given it's client-identifier
|
||||||
|
* @param client_id the ClientID to search for
|
||||||
|
* @return return a pointer to the corresponding NetworkTCPSocketHandler struct or NULL when not found
|
||||||
|
*/
|
||||||
NetworkTCPSocketHandler *NetworkFindClientStateFromClientID(ClientID client_id)
|
NetworkTCPSocketHandler *NetworkFindClientStateFromClientID(ClientID client_id)
|
||||||
{
|
{
|
||||||
NetworkTCPSocketHandler *cs;
|
NetworkTCPSocketHandler *cs;
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "../console_type.h"
|
#include "../console_type.h"
|
||||||
|
|
||||||
extern NetworkServerGameInfo _network_game_info;
|
extern NetworkServerGameInfo _network_game_info;
|
||||||
extern NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
|
|
||||||
extern NetworkCompanyState *_network_company_states;
|
extern NetworkCompanyState *_network_company_states;
|
||||||
|
|
||||||
extern ClientID _network_own_client_id;
|
extern ClientID _network_own_client_id;
|
||||||
|
@ -51,6 +50,7 @@ void NetworkServerChangeOwner(Owner current_owner, Owner new_owner);
|
||||||
void NetworkServerShowStatusToConsole();
|
void NetworkServerShowStatusToConsole();
|
||||||
bool NetworkServerStart();
|
bool NetworkServerStart();
|
||||||
|
|
||||||
|
NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index);
|
||||||
NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id);
|
NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id);
|
||||||
NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip);
|
NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip);
|
||||||
const char* GetClientIP(const NetworkClientInfo *ci);
|
const char* GetClientIP(const NetworkClientInfo *ci);
|
||||||
|
|
|
@ -91,6 +91,8 @@ enum NetworkLanguage {
|
||||||
NETLANG_COUNT
|
NETLANG_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
|
||||||
|
|
||||||
extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
|
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
|
extern uint32 _frame_counter_max; // To where we may go with our clients
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue