Add prefixes to enum values and fix style issues
parent
6ee0db6fec
commit
c91f8b1d25
|
@ -34,6 +34,25 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
#include "main.h" // for g_settings
|
#include "main.h" // for g_settings
|
||||||
|
|
||||||
|
const char *ClientInterface::statenames[] = {
|
||||||
|
"Invalid",
|
||||||
|
"Disconnecting",
|
||||||
|
"Denied",
|
||||||
|
"Created",
|
||||||
|
"InitSent",
|
||||||
|
"InitDone",
|
||||||
|
"DefinitionsSent",
|
||||||
|
"Active"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::string ClientInterface::state2Name(ClientState state)
|
||||||
|
{
|
||||||
|
return statenames[state];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RemoteClient::GetNextBlocks(
|
void RemoteClient::GetNextBlocks(
|
||||||
ServerEnvironment *env,
|
ServerEnvironment *env,
|
||||||
EmergeManager * emerge,
|
EmergeManager * emerge,
|
||||||
|
@ -402,50 +421,42 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
|
||||||
std::ostringstream myerror;
|
std::ostringstream myerror;
|
||||||
switch (m_state)
|
switch (m_state)
|
||||||
{
|
{
|
||||||
case Invalid:
|
case CS_Invalid:
|
||||||
//intentionally do nothing
|
//intentionally do nothing
|
||||||
break;
|
break;
|
||||||
|
case CS_Created:
|
||||||
case Created:
|
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case Init:
|
case CSE_Init:
|
||||||
m_state = InitSent;
|
m_state = CS_InitSent;
|
||||||
break;
|
break;
|
||||||
|
case CSE_Disconnect:
|
||||||
case Disconnect:
|
m_state = CS_Disconnecting;
|
||||||
m_state = Disconnecting;
|
|
||||||
break;
|
break;
|
||||||
|
case CSE_SetDenied:
|
||||||
case SetDenied:
|
m_state = CS_Denied;
|
||||||
m_state = Denied;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* GotInit2 SetDefinitionsSent SetMediaSent */
|
/* GotInit2 SetDefinitionsSent SetMediaSent */
|
||||||
default:
|
default:
|
||||||
myerror << "Created: Invalid client state transition! " << event;
|
myerror << "Created: Invalid client state transition! " << event;
|
||||||
throw ClientStateError(myerror.str());
|
throw ClientStateError(myerror.str());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CS_Denied:
|
||||||
case Denied:
|
|
||||||
/* don't do anything if in denied state */
|
/* don't do anything if in denied state */
|
||||||
break;
|
break;
|
||||||
|
case CS_InitSent:
|
||||||
case InitSent:
|
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case GotInit2:
|
case CSE_GotInit2:
|
||||||
confirmSerializationVersion();
|
confirmSerializationVersion();
|
||||||
m_state = InitDone;
|
m_state = CS_InitDone;
|
||||||
break;
|
break;
|
||||||
|
case CSE_Disconnect:
|
||||||
case Disconnect:
|
m_state = CS_Disconnecting;
|
||||||
m_state = Disconnecting;
|
|
||||||
break;
|
break;
|
||||||
|
case CSE_SetDenied:
|
||||||
case SetDenied:
|
m_state = CS_Denied;
|
||||||
m_state = Denied;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Init SetDefinitionsSent SetMediaSent */
|
/* Init SetDefinitionsSent SetMediaSent */
|
||||||
|
@ -455,19 +466,17 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InitDone:
|
case CS_InitDone:
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case SetDefinitionsSent:
|
case CSE_SetDefinitionsSent:
|
||||||
m_state = DefinitionsSent;
|
m_state = CS_DefinitionsSent;
|
||||||
break;
|
break;
|
||||||
|
case CSE_Disconnect:
|
||||||
case Disconnect:
|
m_state = CS_Disconnecting;
|
||||||
m_state = Disconnecting;
|
|
||||||
break;
|
break;
|
||||||
|
case CSE_SetDenied:
|
||||||
case SetDenied:
|
m_state = CS_Denied;
|
||||||
m_state = Denied;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Init GotInit2 SetMediaSent */
|
/* Init GotInit2 SetMediaSent */
|
||||||
|
@ -476,40 +485,33 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
|
||||||
throw ClientStateError(myerror.str());
|
throw ClientStateError(myerror.str());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CS_DefinitionsSent:
|
||||||
case DefinitionsSent:
|
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case SetClientReady:
|
case CSE_SetClientReady:
|
||||||
m_state = Active;
|
m_state = CS_Active;
|
||||||
break;
|
break;
|
||||||
|
case CSE_Disconnect:
|
||||||
case Disconnect:
|
m_state = CS_Disconnecting;
|
||||||
m_state = Disconnecting;
|
|
||||||
break;
|
break;
|
||||||
|
case CSE_SetDenied:
|
||||||
case SetDenied:
|
m_state = CS_Denied;
|
||||||
m_state = Denied;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Init GotInit2 SetDefinitionsSent */
|
/* Init GotInit2 SetDefinitionsSent */
|
||||||
default:
|
default:
|
||||||
myerror << "DefinitionsSent: Invalid client state transition! " << event;
|
myerror << "DefinitionsSent: Invalid client state transition! " << event;
|
||||||
throw ClientStateError(myerror.str());
|
throw ClientStateError(myerror.str());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CS_Active:
|
||||||
case Active:
|
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case SetDenied:
|
case CSE_SetDenied:
|
||||||
m_state = Denied;
|
m_state = CS_Denied;
|
||||||
break;
|
break;
|
||||||
|
case CSE_Disconnect:
|
||||||
case Disconnect:
|
m_state = CS_Disconnecting;
|
||||||
m_state = Disconnecting;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Init GotInit2 SetDefinitionsSent SetMediaSent SetDenied */
|
/* Init GotInit2 SetDefinitionsSent SetMediaSent SetDenied */
|
||||||
default:
|
default:
|
||||||
myerror << "Active: Invalid client state transition! " << event;
|
myerror << "Active: Invalid client state transition! " << event;
|
||||||
|
@ -517,8 +519,7 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CS_Disconnecting:
|
||||||
case Disconnecting:
|
|
||||||
/* we are already disconnecting */
|
/* we are already disconnecting */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -680,7 +681,7 @@ ClientState ClientInterface::getClientState(u16 peer_id)
|
||||||
// The client may not exist; clients are immediately removed if their
|
// The client may not exist; clients are immediately removed if their
|
||||||
// access is denied, and this event occurs later then.
|
// access is denied, and this event occurs later then.
|
||||||
if(n == m_clients.end())
|
if(n == m_clients.end())
|
||||||
return Invalid;
|
return CS_Invalid;
|
||||||
|
|
||||||
return n->second->getState();
|
return n->second->getState();
|
||||||
}
|
}
|
||||||
|
@ -762,7 +763,9 @@ void ClientInterface::event(u16 peer_id, ClientStateEvent event)
|
||||||
n->second->notifyEvent(event);
|
n->second->notifyEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((event == SetClientReady) || (event == Disconnect) || (event == SetDenied))
|
if ((event == CSE_SetClientReady) ||
|
||||||
|
(event == CSE_Disconnect) ||
|
||||||
|
(event == CSE_SetDenied))
|
||||||
{
|
{
|
||||||
UpdatePlayerList();
|
UpdatePlayerList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,35 +145,24 @@ namespace con {
|
||||||
|
|
||||||
enum ClientState
|
enum ClientState
|
||||||
{
|
{
|
||||||
Invalid,
|
CS_Invalid,
|
||||||
Disconnecting,
|
CS_Disconnecting,
|
||||||
Denied,
|
CS_Denied,
|
||||||
Created,
|
CS_Created,
|
||||||
InitSent,
|
CS_InitSent,
|
||||||
InitDone,
|
CS_InitDone,
|
||||||
DefinitionsSent,
|
CS_DefinitionsSent,
|
||||||
Active
|
CS_Active
|
||||||
};
|
|
||||||
|
|
||||||
static const char* statenames[] = {
|
|
||||||
"Invalid",
|
|
||||||
"Disconnecting",
|
|
||||||
"Denied",
|
|
||||||
"Created",
|
|
||||||
"InitSent",
|
|
||||||
"InitDone",
|
|
||||||
"DefinitionsSent",
|
|
||||||
"Active"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ClientStateEvent
|
enum ClientStateEvent
|
||||||
{
|
{
|
||||||
Init,
|
CSE_Init,
|
||||||
GotInit2,
|
CSE_GotInit2,
|
||||||
SetDenied,
|
CSE_SetDenied,
|
||||||
SetDefinitionsSent,
|
CSE_SetDefinitionsSent,
|
||||||
SetClientReady,
|
CSE_SetClientReady,
|
||||||
Disconnect
|
CSE_Disconnect
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -217,7 +206,7 @@ public:
|
||||||
net_proto_version(0),
|
net_proto_version(0),
|
||||||
m_time_from_building(9999),
|
m_time_from_building(9999),
|
||||||
m_pending_serialization_version(SER_FMT_VER_INVALID),
|
m_pending_serialization_version(SER_FMT_VER_INVALID),
|
||||||
m_state(Created),
|
m_state(CS_Created),
|
||||||
m_nearest_unsent_d(0),
|
m_nearest_unsent_d(0),
|
||||||
m_nearest_unsent_reset_timer(0.0),
|
m_nearest_unsent_reset_timer(0.0),
|
||||||
m_excess_gotblocks(0),
|
m_excess_gotblocks(0),
|
||||||
|
@ -390,7 +379,7 @@ public:
|
||||||
void step(float dtime);
|
void step(float dtime);
|
||||||
|
|
||||||
/* get list of active client id's */
|
/* get list of active client id's */
|
||||||
std::list<u16> getClientIDs(ClientState min_state=Active);
|
std::list<u16> getClientIDs(ClientState min_state=CS_Active);
|
||||||
|
|
||||||
/* get list of client player names */
|
/* get list of client player names */
|
||||||
std::vector<std::string> getPlayerNames();
|
std::vector<std::string> getPlayerNames();
|
||||||
|
@ -408,10 +397,10 @@ public:
|
||||||
void CreateClient(u16 peer_id);
|
void CreateClient(u16 peer_id);
|
||||||
|
|
||||||
/* get a client by peer_id */
|
/* get a client by peer_id */
|
||||||
RemoteClient* getClientNoEx(u16 peer_id, ClientState state_min=Active);
|
RemoteClient* getClientNoEx(u16 peer_id, ClientState state_min=CS_Active);
|
||||||
|
|
||||||
/* get client by peer_id (make sure you have list lock before!*/
|
/* get client by peer_id (make sure you have list lock before!*/
|
||||||
RemoteClient* lockedGetClientNoEx(u16 peer_id, ClientState state_min=Active);
|
RemoteClient* lockedGetClientNoEx(u16 peer_id, ClientState state_min=CS_Active);
|
||||||
|
|
||||||
/* get state of client by id*/
|
/* get state of client by id*/
|
||||||
ClientState getClientState(u16 peer_id);
|
ClientState getClientState(u16 peer_id);
|
||||||
|
@ -432,10 +421,7 @@ public:
|
||||||
void setEnv(ServerEnvironment* env)
|
void setEnv(ServerEnvironment* env)
|
||||||
{ assert(m_env == 0); m_env = env; }
|
{ assert(m_env == 0); m_env = env; }
|
||||||
|
|
||||||
static std::string state2Name(ClientState state) {
|
static std::string state2Name(ClientState state);
|
||||||
assert((int) state < CI_ARRAYSIZE(statenames));
|
|
||||||
return statenames[state];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//TODO find way to avoid this functions
|
//TODO find way to avoid this functions
|
||||||
|
@ -463,6 +449,8 @@ private:
|
||||||
JMutex m_env_mutex;
|
JMutex m_env_mutex;
|
||||||
|
|
||||||
float m_print_info_timer;
|
float m_print_info_timer;
|
||||||
|
|
||||||
|
static const char *statenames[];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1000,7 +1000,7 @@ UDPPeer::UDPPeer(u16 a_id, Address a_address, Connection* connection) :
|
||||||
|
|
||||||
bool UDPPeer::getAddress(MTProtocols type,Address& toset)
|
bool UDPPeer::getAddress(MTProtocols type,Address& toset)
|
||||||
{
|
{
|
||||||
if ((type == UDP) || (type == MINETEST_RELIABLE_UDP) || (type == PRIMARY))
|
if ((type == MTP_UDP) || (type == MTP_MINETEST_RELIABLE_UDP) || (type == MTP_PRIMARY))
|
||||||
{
|
{
|
||||||
toset = address;
|
toset = address;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1526,7 +1526,7 @@ bool ConnectionSendThread::rawSendAsPacket(u16 peer_id, u8 channelnum,
|
||||||
|
|
||||||
SharedBuffer<u8> reliable = makeReliablePacket(data, seqnum);
|
SharedBuffer<u8> reliable = makeReliablePacket(data, seqnum);
|
||||||
Address peer_address;
|
Address peer_address;
|
||||||
peer->getAddress(MINETEST_RELIABLE_UDP,peer_address);
|
peer->getAddress(MTP_MINETEST_RELIABLE_UDP, peer_address);
|
||||||
|
|
||||||
// Add base headers and make a packet
|
// Add base headers and make a packet
|
||||||
BufferedPacket p = con::makePacket(peer_address, reliable,
|
BufferedPacket p = con::makePacket(peer_address, reliable,
|
||||||
|
@ -1556,7 +1556,7 @@ bool ConnectionSendThread::rawSendAsPacket(u16 peer_id, u8 channelnum,
|
||||||
{
|
{
|
||||||
Address peer_address;
|
Address peer_address;
|
||||||
|
|
||||||
if (peer->getAddress(UDP,peer_address))
|
if (peer->getAddress(MTP_UDP, peer_address))
|
||||||
{
|
{
|
||||||
// Add base headers and make a packet
|
// Add base headers and make a packet
|
||||||
BufferedPacket p = con::makePacket(peer_address, data,
|
BufferedPacket p = con::makePacket(peer_address, data,
|
||||||
|
@ -2165,7 +2165,7 @@ void ConnectionReceiveThread::receive()
|
||||||
/* The peer was not found in our lists. Add it. */
|
/* The peer was not found in our lists. Add it. */
|
||||||
if(peer_id == PEER_ID_INEXISTENT)
|
if(peer_id == PEER_ID_INEXISTENT)
|
||||||
{
|
{
|
||||||
peer_id = m_connection->createPeer(sender,MINETEST_RELIABLE_UDP,0);
|
peer_id = m_connection->createPeer(sender, MTP_MINETEST_RELIABLE_UDP, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerHelper peer = m_connection->getPeerNoEx(peer_id);
|
PeerHelper peer = m_connection->getPeerNoEx(peer_id);
|
||||||
|
@ -2181,7 +2181,7 @@ void ConnectionReceiveThread::receive()
|
||||||
|
|
||||||
Address peer_address;
|
Address peer_address;
|
||||||
|
|
||||||
if (peer->getAddress(UDP,peer_address)) {
|
if (peer->getAddress(MTP_UDP, peer_address)) {
|
||||||
if (peer_address != sender) {
|
if (peer_address != sender) {
|
||||||
LOG(derr_con<<m_connection->getDesc()
|
LOG(derr_con<<m_connection->getDesc()
|
||||||
<<m_connection->getDesc()
|
<<m_connection->getDesc()
|
||||||
|
@ -2469,7 +2469,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
||||||
{
|
{
|
||||||
Address peer_address;
|
Address peer_address;
|
||||||
|
|
||||||
if (peer->getAddress(UDP,peer_address)) {
|
if (peer->getAddress(MTP_UDP, peer_address)) {
|
||||||
|
|
||||||
// We have to create a packet again for buffering
|
// We have to create a packet again for buffering
|
||||||
// This isn't actually too bad an idea.
|
// This isn't actually too bad an idea.
|
||||||
|
@ -2552,7 +2552,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
||||||
Address peer_address;
|
Address peer_address;
|
||||||
|
|
||||||
// this is a reliable packet so we have a udp address for sure
|
// this is a reliable packet so we have a udp address for sure
|
||||||
peer->getAddress(MINETEST_RELIABLE_UDP,peer_address);
|
peer->getAddress(MTP_MINETEST_RELIABLE_UDP, peer_address);
|
||||||
// This one comes later, buffer it.
|
// This one comes later, buffer it.
|
||||||
// Actually we have to make a packet to buffer one.
|
// Actually we have to make a packet to buffer one.
|
||||||
// Well, we have all the ingredients, so just do it.
|
// Well, we have all the ingredients, so just do it.
|
||||||
|
@ -2754,10 +2754,10 @@ u16 Connection::lookupPeer(Address& sender)
|
||||||
|
|
||||||
Address tocheck;
|
Address tocheck;
|
||||||
|
|
||||||
if ((peer->getAddress(MINETEST_RELIABLE_UDP,tocheck)) && (tocheck == sender))
|
if ((peer->getAddress(MTP_MINETEST_RELIABLE_UDP, tocheck)) && (tocheck == sender))
|
||||||
return peer->id;
|
return peer->id;
|
||||||
|
|
||||||
if ((peer->getAddress(UDP,tocheck)) && (tocheck == sender))
|
if ((peer->getAddress(MTP_UDP, tocheck)) && (tocheck == sender))
|
||||||
return peer->id;
|
return peer->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2791,7 +2791,7 @@ bool Connection::deletePeer(u16 peer_id, bool timeout)
|
||||||
|
|
||||||
Address peer_address;
|
Address peer_address;
|
||||||
//any peer has a primary address this never fails!
|
//any peer has a primary address this never fails!
|
||||||
peer->getAddress(PRIMARY,peer_address);
|
peer->getAddress(MTP_PRIMARY, peer_address);
|
||||||
// Create event
|
// Create event
|
||||||
ConnectionEvent e;
|
ConnectionEvent e;
|
||||||
e.peerRemoved(peer_id, timeout, peer_address);
|
e.peerRemoved(peer_id, timeout, peer_address);
|
||||||
|
@ -2930,7 +2930,7 @@ Address Connection::GetPeerAddress(u16 peer_id)
|
||||||
if (!peer)
|
if (!peer)
|
||||||
throw PeerNotFoundException("No address for peer found!");
|
throw PeerNotFoundException("No address for peer found!");
|
||||||
Address peer_address;
|
Address peer_address;
|
||||||
peer->getAddress(PRIMARY,peer_address);
|
peer->getAddress(MTP_PRIMARY, peer_address);
|
||||||
return peer_address;
|
return peer_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,9 +120,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum MTProtocols {
|
typedef enum MTProtocols {
|
||||||
PRIMARY,
|
MTP_PRIMARY,
|
||||||
UDP,
|
MTP_UDP,
|
||||||
MINETEST_RELIABLE_UDP
|
MTP_MINETEST_RELIABLE_UDP
|
||||||
} MTProtocols;
|
} MTProtocols;
|
||||||
|
|
||||||
#define SEQNUM_MAX 65535
|
#define SEQNUM_MAX 65535
|
||||||
|
|
|
@ -714,7 +714,7 @@ void Server::AsyncRunStep(bool initial_step)
|
||||||
|
|
||||||
// If definitions and textures have not been sent, don't
|
// If definitions and textures have not been sent, don't
|
||||||
// send objects either
|
// send objects either
|
||||||
if (client->getState() < DefinitionsSent)
|
if (client->getState() < CS_DefinitionsSent)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Player *player = m_env->getPlayer(client->peer_id);
|
Player *player = m_env->getPlayer(client->peer_id);
|
||||||
|
@ -1169,7 +1169,7 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
|
||||||
std::string playername = "";
|
std::string playername = "";
|
||||||
PlayerSAO *playersao = NULL;
|
PlayerSAO *playersao = NULL;
|
||||||
m_clients.Lock();
|
m_clients.Lock();
|
||||||
RemoteClient* client = m_clients.lockedGetClientNoEx(peer_id,InitDone);
|
RemoteClient* client = m_clients.lockedGetClientNoEx(peer_id, CS_InitDone);
|
||||||
if (client != NULL) {
|
if (client != NULL) {
|
||||||
playername = client->getName();
|
playername = client->getName();
|
||||||
playersao = emergePlayer(playername.c_str(), peer_id);
|
playersao = emergePlayer(playername.c_str(), peer_id);
|
||||||
|
@ -1320,10 +1320,10 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
if(datasize < 2+1+PLAYERNAME_SIZE)
|
if(datasize < 2+1+PLAYERNAME_SIZE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RemoteClient* client = getClient(peer_id,Created);
|
RemoteClient* client = getClient(peer_id, CS_Created);
|
||||||
|
|
||||||
// If net_proto_version is set, this client has already been handled
|
// If net_proto_version is set, this client has already been handled
|
||||||
if(client->getState() > Created)
|
if(client->getState() > CS_Created)
|
||||||
{
|
{
|
||||||
verbosestream<<"Server: Ignoring multiple TOSERVER_INITs from "
|
verbosestream<<"Server: Ignoring multiple TOSERVER_INITs from "
|
||||||
<<addr_s<<" (peer_id="<<peer_id<<")"<<std::endl;
|
<<addr_s<<" (peer_id="<<peer_id<<")"<<std::endl;
|
||||||
|
@ -1522,7 +1522,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
|
|
||||||
// Enforce user limit.
|
// Enforce user limit.
|
||||||
// Don't enforce for users that have some admin right
|
// Don't enforce for users that have some admin right
|
||||||
if(m_clients.getClientIDs(Created).size() >= g_settings->getU16("max_users") &&
|
if(m_clients.getClientIDs(CS_Created).size() >= g_settings->getU16("max_users") &&
|
||||||
!checkPriv(playername, "server") &&
|
!checkPriv(playername, "server") &&
|
||||||
!checkPriv(playername, "ban") &&
|
!checkPriv(playername, "ban") &&
|
||||||
!checkPriv(playername, "privs") &&
|
!checkPriv(playername, "privs") &&
|
||||||
|
@ -1605,7 +1605,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
|
|
||||||
// Send as reliable
|
// Send as reliable
|
||||||
m_clients.send(peer_id, 0, reply, true);
|
m_clients.send(peer_id, 0, reply, true);
|
||||||
m_clients.event(peer_id, Init);
|
m_clients.event(peer_id, CSE_Init);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1617,7 +1617,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
verbosestream<<"Server: Got TOSERVER_INIT2 from "
|
verbosestream<<"Server: Got TOSERVER_INIT2 from "
|
||||||
<<peer_id<<std::endl;
|
<<peer_id<<std::endl;
|
||||||
|
|
||||||
m_clients.event(peer_id, GotInit2);
|
m_clients.event(peer_id, CSE_GotInit2);
|
||||||
u16 protocol_version = m_clients.getProtocolVersion(peer_id);
|
u16 protocol_version = m_clients.getProtocolVersion(peer_id);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1651,7 +1651,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
// Send node definitions
|
// Send node definitions
|
||||||
SendNodeDef(peer_id, m_nodedef, protocol_version);
|
SendNodeDef(peer_id, m_nodedef, protocol_version);
|
||||||
|
|
||||||
m_clients.event(peer_id, SetDefinitionsSent);
|
m_clients.event(peer_id, CSE_SetDefinitionsSent);
|
||||||
|
|
||||||
// Send media announcement
|
// Send media announcement
|
||||||
sendMediaAnnouncement(peer_id);
|
sendMediaAnnouncement(peer_id);
|
||||||
|
@ -1666,7 +1666,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
|
|
||||||
///// begin compatibility code
|
///// begin compatibility code
|
||||||
if (protocol_version <= 22) {
|
if (protocol_version <= 22) {
|
||||||
m_clients.event(peer_id, SetClientReady);
|
m_clients.event(peer_id, CSE_SetClientReady);
|
||||||
m_script->on_joinplayer(playersao);
|
m_script->on_joinplayer(playersao);
|
||||||
}
|
}
|
||||||
///// end compatibility code
|
///// end compatibility code
|
||||||
|
@ -1681,8 +1681,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 peer_ser_ver = getClient(peer_id,InitDone)->serialization_version;
|
u8 peer_ser_ver = getClient(peer_id, CS_InitDone)->serialization_version;
|
||||||
u16 peer_proto_ver = getClient(peer_id,InitDone)->net_proto_version;
|
u16 peer_proto_ver = getClient(peer_id, CS_InitDone)->net_proto_version;
|
||||||
|
|
||||||
if(peer_ser_ver == SER_FMT_VER_INVALID)
|
if(peer_ser_ver == SER_FMT_VER_INVALID)
|
||||||
{
|
{
|
||||||
|
@ -1746,7 +1746,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
data[2], data[3], data[4],
|
data[2], data[3], data[4],
|
||||||
std::string((char*) &data[8],(u16) data[6]));
|
std::string((char*) &data[8],(u16) data[6]));
|
||||||
|
|
||||||
m_clients.event(peer_id, SetClientReady);
|
m_clients.event(peer_id, CSE_SetClientReady);
|
||||||
m_script->on_joinplayer(playersao);
|
m_script->on_joinplayer(playersao);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1778,7 +1778,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_clients.getClientState(peer_id) < Active)
|
if (m_clients.getClientState(peer_id) < CS_Active)
|
||||||
{
|
{
|
||||||
if (command == TOSERVER_PLAYERPOS) return;
|
if (command == TOSERVER_PLAYERPOS) return;
|
||||||
|
|
||||||
|
@ -2837,7 +2837,7 @@ void Server::deletingPeer(con::Peer *peer, bool timeout)
|
||||||
verbosestream<<"Server::deletingPeer(): peer->id="
|
verbosestream<<"Server::deletingPeer(): peer->id="
|
||||||
<<peer->id<<", timeout="<<timeout<<std::endl;
|
<<peer->id<<", timeout="<<timeout<<std::endl;
|
||||||
|
|
||||||
m_clients.event(peer->id,Disconnect);
|
m_clients.event(peer->id, CSE_Disconnect);
|
||||||
con::PeerChange c;
|
con::PeerChange c;
|
||||||
c.type = con::PEER_REMOVED;
|
c.type = con::PEER_REMOVED;
|
||||||
c.peer_id = peer->id;
|
c.peer_id = peer->id;
|
||||||
|
@ -2866,7 +2866,7 @@ bool Server::getClientInfo(
|
||||||
{
|
{
|
||||||
*state = m_clients.getClientState(peer_id);
|
*state = m_clients.getClientState(peer_id);
|
||||||
m_clients.Lock();
|
m_clients.Lock();
|
||||||
RemoteClient* client = m_clients.lockedGetClientNoEx(peer_id,Invalid);
|
RemoteClient* client = m_clients.lockedGetClientNoEx(peer_id, CS_Invalid);
|
||||||
|
|
||||||
if (client == NULL) {
|
if (client == NULL) {
|
||||||
m_clients.Unlock();
|
m_clients.Unlock();
|
||||||
|
@ -3841,7 +3841,7 @@ void Server::SendBlocks(float dtime)
|
||||||
i = clients.begin();
|
i = clients.begin();
|
||||||
i != clients.end(); ++i)
|
i != clients.end(); ++i)
|
||||||
{
|
{
|
||||||
RemoteClient *client = m_clients.lockedGetClientNoEx(*i,Active);
|
RemoteClient *client = m_clients.lockedGetClientNoEx(*i, CS_Active);
|
||||||
|
|
||||||
if (client == NULL)
|
if (client == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -3877,7 +3877,7 @@ void Server::SendBlocks(float dtime)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteClient *client = m_clients.lockedGetClientNoEx(q.peer_id,Active);
|
RemoteClient *client = m_clients.lockedGetClientNoEx(q.peer_id, CS_Active);
|
||||||
|
|
||||||
if(!client)
|
if(!client)
|
||||||
continue;
|
continue;
|
||||||
|
@ -4268,7 +4268,7 @@ void Server::DenyAccess(u16 peer_id, const std::wstring &reason)
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
SendAccessDenied(peer_id, reason);
|
SendAccessDenied(peer_id, reason);
|
||||||
m_clients.event(peer_id,SetDenied);
|
m_clients.event(peer_id, CSE_SetDenied);
|
||||||
m_con.DisconnectPeer(peer_id);
|
m_con.DisconnectPeer(peer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -432,8 +432,8 @@ private:
|
||||||
void UpdateCrafting(u16 peer_id);
|
void UpdateCrafting(u16 peer_id);
|
||||||
|
|
||||||
// When called, connection mutex should be locked
|
// When called, connection mutex should be locked
|
||||||
RemoteClient* getClient(u16 peer_id,ClientState state_min=Active);
|
RemoteClient* getClient(u16 peer_id,ClientState state_min=CS_Active);
|
||||||
RemoteClient* getClientNoEx(u16 peer_id,ClientState state_min=Active);
|
RemoteClient* getClientNoEx(u16 peer_id,ClientState state_min=CS_Active);
|
||||||
|
|
||||||
// When called, environment mutex should be locked
|
// When called, environment mutex should be locked
|
||||||
std::string getPlayerName(u16 peer_id);
|
std::string getPlayerName(u16 peer_id);
|
||||||
|
|
Loading…
Reference in New Issue