- better masterserver thread management during game play (do not start the thread for non published games)

This commit is contained in:
Mark Vejvoda 2010-10-24 05:52:21 +00:00
parent 477679d139
commit bbc8f96327
3 changed files with 14 additions and 11 deletions

View File

@ -269,7 +269,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
const Vec2i finalPos= computeNearestFreePos(unit, targetPos);
//if arrived
/*
if(finalPos == unit->getPos()) {
Command *command= unit->getCurrCommand();
if(command == NULL || command->getPos() != unit->getPos()) {
@ -286,7 +285,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
return tsArrived;
}
}
*/
//path find algorithm

View File

@ -331,7 +331,7 @@ void Commander::updateNetwork() {
for(int i= 0; i < gameNetworkInterface->getPendingCommandCount(); ++i){
giveNetworkCommand(gameNetworkInterface->getPendingCommand(i));
}
if(perfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] giveNetworkCommand took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,perfTimer.getMillis());
if(perfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] giveNetworkCommand took %lld msecs, PendingCommandCount = %d\n",__FILE__,__FUNCTION__,__LINE__,perfTimer.getMillis(),gameNetworkInterface->getPendingCommandCount());
gameNetworkInterface->clearPendingCommands();
}
}
@ -387,11 +387,11 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
{
Unit* unit= world->findUnitById(networkCommand->getUnitId());
//exec ute command, if unit is still alive
if(unit!=NULL) {
switch(networkCommand->getNetworkCommandType()){
//execute command, if unit is still alive
if(unit != NULL) {
switch(networkCommand->getNetworkCommandType()) {
case nctGiveCommand:{
assert(networkCommand->getCommandTypeId()!=CommandType::invalidId);
assert(networkCommand->getCommandTypeId() != CommandType::invalidId);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] found nctGiveCommand networkCommand->getUnitId() = %d\n",__FILE__,__FUNCTION__,__LINE__,networkCommand->getUnitId());

View File

@ -104,9 +104,12 @@ ServerInterface::~ServerInterface() {
delete publishToMasterserverThread;
publishToMasterserverThread = NULL;
safeMutex.ReleaseLock();
// This triggers a gameOver message to be sent to the masterserver
lastMasterserverHeartbeatTime = 0;
simpleTask();
if(needToRepublishToMasterserver == true) {
simpleTask();
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -1079,9 +1082,11 @@ bool ServerInterface::launchGame(const GameSettings* gameSettings) {
publishToMasterserverThread = NULL;
lastMasterserverHeartbeatTime = 0;
publishToMasterserverThread = new SimpleTaskThread(this,0,25);
publishToMasterserverThread->setUniqueID(__FILE__);
publishToMasterserverThread->start();
if(needToRepublishToMasterserver == true) {
publishToMasterserverThread = new SimpleTaskThread(this,0,25);
publishToMasterserverThread->setUniqueID(__FILE__);
publishToMasterserverThread->start();
}
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);