to share the information that seem to me important , for future devs .
One thing that we want to know is :
WHAT THE SERVER IS DOING IN HIS MAIN LOOP ?
Netserver.cpp , line 384 :
//Server loop
while (keeprun) {
//int nb;
UpdateTime();
if (_Universe->numPlayers() > 0)
ExecuteDirector();
//Check a key press
//keyset.setReadAlwaysTrue( 0);
//this->checkKey( keyset);
//Check received communications
checkMsg( _sock_set );
if (acctserver && acct_con)
//Listen for account server answers
checkAcctMsg( _sock_set );
//And send to it the login request we received
//Then send clients confirmations or errors
curtime = getNewTime();
if (acctserver && !acct_con && (curtime-reconnect_time) > periodrecon) {
std::string netbuf;
reconnect_time = curtime+periodrecon;
//We previously lost connection to account server
//We try to reconnect
if (acct_sock)
delete acct_sock;
acct_sock = new VsnetHTTPSocket( acctsrv, _sock_set );
if ( acct_sock->valid() ) {
LI i;
int j = 0;
COUT<<">>> Reconnected accountserver on socket "<<*acct_sock<<" done."<<endl;
//Send a list of ingame clients
//Build a buffer with number of clients and client serials
//Put first the number of clients
//netbuf.addShort( nbclients);
addSimpleChar( netbuf, ACCT_RESYNC );
for (j = 0, i = allClients.begin(); i != allClients.end(); i++, j++)
//Add the current client's serial to the buffer
addSimpleString( netbuf, (*i)->callsign );
//Passing NULL to AddressIP arg because between servers -> only TCP
//Use the serial packet's field to send the number of clients
if ( !acct_sock->sendstr( netbuf ) )
COUT<<"Failure to resync, SOCKET was : "<<*acct_sock<<endl;
} else {
cerr<<">>> Reconnection to account server failed."<<endl;
}
}
//See if we have some timed out clients and disconnect them
this->checkTimedoutClients_udp();
//Remove all clients to be disconnected
LI j;
for (j = discList.begin(); j != discList.end(); j++)
disconnect( (*j), __FILE__, PSEUDO__LINE__( 328 ) );
discList.clear();
//Remove all clients that logged out
for (j = logoutList.begin(); j != logoutList.end(); j++)
this->logout( (*j) );
logoutList.clear();
/****** VS STUFF TO DO ***********/
//UPDATE STAR SYSTEM -> TO INTEGRATE WITH NETWORKING
//PROCESS JUMPS -> MAKE UNITS CHANGE THEIR STAR SYSTEM
//NETFIXME: Why was StarSystem->Update() commented out?
unsigned int i;
/*
* static float nonactivesystemtime = XMLSupport::parse_float (vs_config->getVariable ("physics","InactiveSystemTime",".3"));
* static unsigned int numrunningsystems = XMLSupport::parse_int (vs_config->getVariable ("physics","NumRunningSystems","4"));
* float systime=nonactivesystemtime;
*/
for (i = 0; i < _Universe->star_system.size(); i++)
//NETFIXME: No Director for you!
_Universe->star_system->Update( 1, true /*need to run python serverside*/ );
StarSystem::ProcessPendingJumps();
/************ VS STUFF TO DO *********************/
if (snapchanged && (curtime-snaptime) > NETWORK_ATOM) {
//COUT<<"SENDING SNAPSHOT ----------"<<end;
//If planet time we send planet and nebula info
if ( (curtime-planettime) > PLANET_ATOM ) {
zonemgr->broadcastSnapshots( true );
planettime = curtime;
}
//Otherwise we just send ships/bases... info
else {
zonemgr->broadcastSnapshots( false );
}
snapchanged = 0;
snaptime = curtime;
}
sendNewUnitQueue();
//Check for automatic server status save time (in seconds)
//curtime = getNewTime();
if ( (curtime-savetime) > SAVE_ATOM ) {
//Not implemented
cout<<">>> Saving server status... Time="<<curtime<<endl;
this->save();
savetime = curtime;
cout<<"<<< Finished saving."<<endl;
}
_sock_set.waste_time( 0, 10000 );
}
I was wondering why i had a crash with my llama when i tried to jump out the atlantis's system ... So it seem that as today , all the MMO is limited to one system .
( that need confirmation , but my experience + the code comments should be enough to
understand the situation )
Perhaps you have noticed that in the same thread ( this loop ) , are made the communications between server and client AND the account server .
I think this design should be discussed , with multithreading in mind ...
The account server ( python ) is not multithreaded :
In socketserver.py
def serve_forever(self, poll_interval=0.5):
"""Handle one request at a time until shutdown.
Even if the connections are non-blocking , i wonder how much the game is affected by
that situation .
My opinion is that for an MMo , the " checkAcctMsg( _sock_set );" should be in a separate thread .