mirror of
https://github.com/glest/glest-source.git
synced 2025-09-24 22:51:27 +02:00
- bugfix for slot not re-opening after disconnect when required
This commit is contained in:
@@ -924,6 +924,17 @@ void Game::load() {
|
||||
}
|
||||
|
||||
void Game::load(int loadTypes) {
|
||||
bool showPerfStats = Config::getInstance().getBool("ShowPerfStats","false");
|
||||
Chrono chronoPerf;
|
||||
if(showPerfStats) chronoPerf.start();
|
||||
char perfBuf[8096]="";
|
||||
std::vector<string> perfList;
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
std::map<string,vector<pair<string, string> > > loadedFileList;
|
||||
originalDisplayMsgCallback = NetworkInterface::getDisplayMessageFunction();
|
||||
NetworkInterface::setDisplayMessageFunction(ErrorDisplayMessage);
|
||||
@@ -943,33 +954,32 @@ void Game::load(int loadTypes) {
|
||||
string data_path= getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
// loadHints
|
||||
|
||||
if(data_path != ""){
|
||||
endPathWithSlash(data_path);
|
||||
}
|
||||
if(data_path != ""){
|
||||
endPathWithSlash(data_path);
|
||||
}
|
||||
|
||||
string user_data_path = config.getString("UserData_Root","");
|
||||
if(user_data_path != "") {
|
||||
endPathWithSlash(user_data_path);
|
||||
}
|
||||
|
||||
string englishFile=getGameCustomCoreDataPath(data_path, "data/lang/hint/hint_"+Lang::getInstance().getDefaultLanguage()+".lng");
|
||||
string languageFile=getGameCustomCoreDataPath(data_path, "data/lang/hint/hint_"+ Lang::getInstance().getLanguage() +".lng");
|
||||
string languageFileUserData=user_data_path + "data/lang/hint/hint_"+ Lang::getInstance().getLanguage() +".lng";
|
||||
|
||||
if(fileExists(languageFileUserData) == true){
|
||||
languageFile=languageFileUserData;
|
||||
}
|
||||
if(fileExists(languageFile) == false){
|
||||
// if there is no language specific file use english instead
|
||||
languageFile=englishFile;
|
||||
}
|
||||
if(fileExists(englishFile) == false){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] file [%s] not found\n",__FILE__,__FUNCTION__,__LINE__,englishFile.c_str());
|
||||
} else {
|
||||
logger.loadGameHints(englishFile,languageFile,true);
|
||||
}
|
||||
string user_data_path = config.getString("UserData_Root","");
|
||||
if(user_data_path != "") {
|
||||
endPathWithSlash(user_data_path);
|
||||
}
|
||||
|
||||
string englishFile=getGameCustomCoreDataPath(data_path, "data/lang/hint/hint_"+Lang::getInstance().getDefaultLanguage()+".lng");
|
||||
string languageFile=getGameCustomCoreDataPath(data_path, "data/lang/hint/hint_"+ Lang::getInstance().getLanguage() +".lng");
|
||||
string languageFileUserData=user_data_path + "data/lang/hint/hint_"+ Lang::getInstance().getLanguage() +".lng";
|
||||
|
||||
if(fileExists(languageFileUserData) == true){
|
||||
languageFile=languageFileUserData;
|
||||
}
|
||||
if(fileExists(languageFile) == false){
|
||||
// if there is no language specific file use english instead
|
||||
languageFile=englishFile;
|
||||
}
|
||||
if(fileExists(englishFile) == false){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] file [%s] not found\n",__FILE__,__FUNCTION__,__LINE__,englishFile.c_str());
|
||||
}
|
||||
else {
|
||||
logger.loadGameHints(englishFile,languageFile,true);
|
||||
}
|
||||
|
||||
if((loadTypes & lgt_FactionPreview) == lgt_FactionPreview) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
@@ -979,7 +989,10 @@ void Game::load(int loadTypes) {
|
||||
SDL_PumpEvents();
|
||||
}
|
||||
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
loadHudTexture(&gameSettings);
|
||||
|
||||
@@ -1000,6 +1013,11 @@ void Game::load(int loadTypes) {
|
||||
}
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
//throw megaglest_runtime_error("Test!");
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -1010,6 +1028,11 @@ void Game::load(int loadTypes) {
|
||||
tilesetName, &checksum, loadedFileList);
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
// give CPU time to update other things to avoid apperance of hanging
|
||||
sleep(0);
|
||||
Shared::Platform::Window::handleEvent();
|
||||
@@ -1024,6 +1047,11 @@ void Game::load(int loadTypes) {
|
||||
factions.insert(gameSettings.getFactionTypeName(i));
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
if((loadTypes & lgt_TechTree) == lgt_TechTree) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -1048,6 +1076,11 @@ void Game::load(int loadTypes) {
|
||||
*/
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
// give CPU time to update other things to avoid apperance of hanging
|
||||
sleep(0);
|
||||
Shared::Platform::Window::handleEvent();
|
||||
@@ -1061,6 +1094,11 @@ void Game::load(int loadTypes) {
|
||||
world.loadMap(Map::getMapPath(mapName,scenarioDir), &checksum);
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
// give CPU time to update other things to avoid apperance of hanging
|
||||
sleep(0);
|
||||
Shared::Platform::Window::handleEvent();
|
||||
@@ -1079,12 +1117,23 @@ void Game::load(int loadTypes) {
|
||||
}
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
// give CPU time to update other things to avoid apperance of hanging
|
||||
sleep(0);
|
||||
SDL_PumpEvents();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//good_fpu_control_registers(NULL,extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(showPerfStats && chronoPerf.getMillis() >= 50) {
|
||||
for(unsigned int x = 0; x < perfList.size(); ++x) {
|
||||
printf("%s",perfList[x].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Game::init() {
|
||||
@@ -1092,6 +1141,17 @@ void Game::init() {
|
||||
}
|
||||
|
||||
void Game::init(bool initForPreviewOnly) {
|
||||
bool showPerfStats = Config::getInstance().getBool("ShowPerfStats","false");
|
||||
Chrono chronoPerf;
|
||||
if(showPerfStats) chronoPerf.start();
|
||||
char perfBuf[8096]="";
|
||||
std::vector<string> perfList;
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] initForPreviewOnly = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,initForPreviewOnly);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
@@ -1162,6 +1222,11 @@ void Game::init(bool initForPreviewOnly) {
|
||||
}
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
if(loadGameNode != NULL) {
|
||||
//world.getMapPtr()->loadGame(loadGameNode,&world);
|
||||
}
|
||||
@@ -1186,6 +1251,11 @@ void Game::init(bool initForPreviewOnly) {
|
||||
console.clearStoredLines();
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
if(this->loadGameNode == NULL) {
|
||||
gameCamera.init(map->getW(), map->getH());
|
||||
|
||||
@@ -1223,6 +1293,11 @@ void Game::init(bool initForPreviewOnly) {
|
||||
}
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
NetworkRole role = nrIdle;
|
||||
@@ -1275,6 +1350,11 @@ void Game::init(bool initForPreviewOnly) {
|
||||
masterController.setSlaves(slaveThreadList);
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
// give CPU time to update other things to avoid apperance of hanging
|
||||
@@ -1311,6 +1391,11 @@ void Game::init(bool initForPreviewOnly) {
|
||||
renderer.manageDeferredParticleSystems();
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
//init renderer state
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Initializing renderer\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
||||
logger.add(Lang::getInstance().get("LogScreenGameLoadingInitRenderer","",true), true);
|
||||
@@ -1319,6 +1404,11 @@ void Game::init(bool initForPreviewOnly) {
|
||||
renderer.initGame(this,this->getGameCameraPtr());
|
||||
//printf("After renderer.initGame\n");
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
for(int i=0; i < world.getFactionCount(); ++i) {
|
||||
Faction *faction= world.getFaction(i);
|
||||
if(faction != NULL) {
|
||||
@@ -1326,6 +1416,11 @@ void Game::init(bool initForPreviewOnly) {
|
||||
}
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
if(initForPreviewOnly == false) {
|
||||
//good_fpu_control_registers(NULL,extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -1387,6 +1482,11 @@ void Game::init(bool initForPreviewOnly) {
|
||||
logger.add(Lang::getInstance().get("LogScreenGameLoadingLaunchGame","",true));
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
//throw "test";
|
||||
|
||||
logger.setCancelLoadingEnabled(false);
|
||||
@@ -1404,6 +1504,12 @@ void Game::init(bool initForPreviewOnly) {
|
||||
world.getStats()->setPersonalityType(i, faction->getPersonalityType());
|
||||
}
|
||||
}
|
||||
|
||||
if(showPerfStats) {
|
||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||
perfList.push_back(perfBuf);
|
||||
}
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
@@ -1412,6 +1518,12 @@ void Game::init(bool initForPreviewOnly) {
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== START GAME ==== getCurrentPixelByteCount() = %llu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled) SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== START GAME ====\n");
|
||||
|
||||
if(showPerfStats && chronoPerf.getMillis() >= 50) {
|
||||
for(unsigned int x = 0; x < perfList.size(); ++x) {
|
||||
printf("%s",perfList[x].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== update ====================
|
||||
|
@@ -1364,6 +1364,7 @@ void ConnectionSlot::setJoinGameInProgressFlags() {
|
||||
void ConnectionSlot::close() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//printf("Closing slot for playerIndex = %d\n",playerIndex);
|
||||
//if(serverInterface->getAllowInGameConnections() == true) {
|
||||
//printf("Closing connection slot!\n");
|
||||
//}
|
||||
@@ -1371,7 +1372,8 @@ void ConnectionSlot::close() {
|
||||
this->gotIntro = false;
|
||||
this->skipLagCheck = false;
|
||||
this->joinGameInProgress = false;
|
||||
this->ready= true;
|
||||
this->ready= false;
|
||||
this->connectedTime = 0;
|
||||
|
||||
if(this->slotThreadWorker != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@@ -1389,14 +1391,16 @@ void ConnectionSlot::close() {
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//printf("Closing slot for playerIndex = %d updateServerListener = %d ready = %d\n",playerIndex,updateServerListener,ready);
|
||||
|
||||
if(updateServerListener == true && ready == false) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
serverInterface->updateListen();
|
||||
}
|
||||
|
||||
ready = false;
|
||||
gotIntro = false;
|
||||
connectedTime = 0;
|
||||
//ready = false;
|
||||
//gotIntro = false;
|
||||
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
||||
}
|
||||
|
@@ -399,6 +399,8 @@ void ServerInterface::addClientToServerIPAddress(uint32 clientIp, uint32 ServerI
|
||||
}
|
||||
|
||||
void ServerInterface::addSlot(int playerIndex) {
|
||||
//printf("Adding slot for playerIndex = %d, serverSocket.isPortBound() = %d\n",playerIndex,serverSocket.isPortBound());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//assert(playerIndex >= 0 && playerIndex < GameConstants::maxPlayers);
|
||||
if(playerIndex < 0 || playerIndex >= GameConstants::maxPlayers) {
|
||||
@@ -433,6 +435,66 @@ void ServerInterface::addSlot(int playerIndex) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void ServerInterface::removeSlot(int playerIndex, int lockedSlotIndex) {
|
||||
//printf("Removing slot for playerIndex = %d, serverSocket.isPortBound() = %d\n",playerIndex,serverSocket.isPortBound());
|
||||
//printf("Removing connection slot!\n");
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
|
||||
MutexSafeWrapper safeMutexSlot(NULL,CODE_AT_LINE_X(playerIndex));
|
||||
if(playerIndex != lockedSlotIndex) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
safeMutexSlot.setMutex(slotAccessorMutexes[playerIndex],CODE_AT_LINE_X(playerIndex));
|
||||
}
|
||||
ConnectionSlot *slot = slots[playerIndex];
|
||||
bool notifyDisconnect = false;
|
||||
vector<string> msgList;
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
if(slot != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
|
||||
if(slot->getLastReceiveCommandListTime() > 0) {
|
||||
char szBuf[4096] = "";
|
||||
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string msgTemplate = "Player %s, disconnected from the game.";
|
||||
if(lang.hasString("PlayerDisconnected",languageList[i]) == true) {
|
||||
msgTemplate = lang.get("PlayerDisconnected",languageList[i]);
|
||||
}
|
||||
#ifdef WIN32
|
||||
_snprintf(szBuf,4095,msgTemplate.c_str(),slot->getName().c_str());
|
||||
#else
|
||||
snprintf(szBuf,4095,msgTemplate.c_str(),slot->getName().c_str());
|
||||
#endif
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,szBuf);
|
||||
|
||||
msgList.push_back(szBuf);
|
||||
}
|
||||
|
||||
notifyDisconnect = true;
|
||||
}
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
slots[playerIndex]= NULL;
|
||||
safeMutexSlot.ReleaseLock();
|
||||
safeMutex.ReleaseLock();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
delete slot;
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
updateListen();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
if(notifyDisconnect == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
||||
bool localEcho = lang.isLanguageLocal(languageList[j]);
|
||||
queueTextMessage(msgList[j],-1, localEcho, languageList[j]);
|
||||
}
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
}
|
||||
|
||||
bool ServerInterface::switchSlot(int fromPlayerIndex, int toPlayerIndex) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
bool result = false;
|
||||
@@ -493,66 +555,6 @@ bool ServerInterface::switchSlot(int fromPlayerIndex, int toPlayerIndex) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void ServerInterface::removeSlot(int playerIndex, int lockedSlotIndex) {
|
||||
|
||||
//printf("Removing connection slot!\n");
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
|
||||
MutexSafeWrapper safeMutexSlot(NULL,CODE_AT_LINE_X(playerIndex));
|
||||
if(playerIndex != lockedSlotIndex) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
safeMutexSlot.setMutex(slotAccessorMutexes[playerIndex],CODE_AT_LINE_X(playerIndex));
|
||||
}
|
||||
ConnectionSlot *slot = slots[playerIndex];
|
||||
bool notifyDisconnect = false;
|
||||
vector<string> msgList;
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
if(slot != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
|
||||
if(slot->getLastReceiveCommandListTime() > 0) {
|
||||
char szBuf[4096] = "";
|
||||
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string msgTemplate = "Player %s, disconnected from the game.";
|
||||
if(lang.hasString("PlayerDisconnected",languageList[i]) == true) {
|
||||
msgTemplate = lang.get("PlayerDisconnected",languageList[i]);
|
||||
}
|
||||
#ifdef WIN32
|
||||
_snprintf(szBuf,4095,msgTemplate.c_str(),slot->getName().c_str());
|
||||
#else
|
||||
snprintf(szBuf,4095,msgTemplate.c_str(),slot->getName().c_str());
|
||||
#endif
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,szBuf);
|
||||
|
||||
msgList.push_back(szBuf);
|
||||
}
|
||||
|
||||
notifyDisconnect = true;
|
||||
}
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
slots[playerIndex]= NULL;
|
||||
safeMutexSlot.ReleaseLock();
|
||||
safeMutex.ReleaseLock();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
delete slot;
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
updateListen();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
if(notifyDisconnect == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
||||
bool localEcho = lang.isLanguageLocal(languageList[j]);
|
||||
queueTextMessage(msgList[j],-1, localEcho, languageList[j]);
|
||||
}
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
}
|
||||
|
||||
ConnectionSlot *ServerInterface::getSlot(int playerIndex) {
|
||||
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[playerIndex],CODE_AT_LINE_X(i));
|
||||
ConnectionSlot *result = slots[playerIndex];
|
||||
|
Reference in New Issue
Block a user