- better masterserver thread management during game play (do not start the thread for non published games)
This commit is contained in:
parent
477679d139
commit
bbc8f96327
|
@ -269,7 +269,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
const Vec2i finalPos= computeNearestFreePos(unit, targetPos);
|
const Vec2i finalPos= computeNearestFreePos(unit, targetPos);
|
||||||
|
|
||||||
//if arrived
|
//if arrived
|
||||||
/*
|
|
||||||
if(finalPos == unit->getPos()) {
|
if(finalPos == unit->getPos()) {
|
||||||
Command *command= unit->getCurrCommand();
|
Command *command= unit->getCurrCommand();
|
||||||
if(command == NULL || command->getPos() != unit->getPos()) {
|
if(command == NULL || command->getPos() != unit->getPos()) {
|
||||||
|
@ -286,7 +285,6 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
return tsArrived;
|
return tsArrived;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
//path find algorithm
|
//path find algorithm
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ void Commander::updateNetwork() {
|
||||||
for(int i= 0; i < gameNetworkInterface->getPendingCommandCount(); ++i){
|
for(int i= 0; i < gameNetworkInterface->getPendingCommandCount(); ++i){
|
||||||
giveNetworkCommand(gameNetworkInterface->getPendingCommand(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();
|
gameNetworkInterface->clearPendingCommands();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,11 +387,11 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
|
||||||
{
|
{
|
||||||
Unit* unit= world->findUnitById(networkCommand->getUnitId());
|
Unit* unit= world->findUnitById(networkCommand->getUnitId());
|
||||||
|
|
||||||
//exec ute command, if unit is still alive
|
//execute command, if unit is still alive
|
||||||
if(unit!=NULL) {
|
if(unit != NULL) {
|
||||||
switch(networkCommand->getNetworkCommandType()){
|
switch(networkCommand->getNetworkCommandType()) {
|
||||||
case nctGiveCommand:{
|
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());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] found nctGiveCommand networkCommand->getUnitId() = %d\n",__FILE__,__FUNCTION__,__LINE__,networkCommand->getUnitId());
|
||||||
|
|
||||||
|
|
|
@ -104,9 +104,12 @@ ServerInterface::~ServerInterface() {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
// This triggers a gameOver message to be sent to the masterserver
|
// This triggers a gameOver message to be sent to the masterserver
|
||||||
lastMasterserverHeartbeatTime = 0;
|
lastMasterserverHeartbeatTime = 0;
|
||||||
simpleTask();
|
if(needToRepublishToMasterserver == true) {
|
||||||
|
simpleTask();
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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;
|
publishToMasterserverThread = NULL;
|
||||||
|
|
||||||
lastMasterserverHeartbeatTime = 0;
|
lastMasterserverHeartbeatTime = 0;
|
||||||
publishToMasterserverThread = new SimpleTaskThread(this,0,25);
|
if(needToRepublishToMasterserver == true) {
|
||||||
publishToMasterserverThread->setUniqueID(__FILE__);
|
publishToMasterserverThread = new SimpleTaskThread(this,0,25);
|
||||||
publishToMasterserverThread->start();
|
publishToMasterserverThread->setUniqueID(__FILE__);
|
||||||
|
publishToMasterserverThread->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user