- added the first draft of joining games in progress

This commit is contained in:
Mark Vejvoda 2013-02-15 18:25:10 +00:00
parent fb6cff0ed1
commit 9d19ff2b57
26 changed files with 1027 additions and 117 deletions

View File

@ -406,6 +406,8 @@ std::pair<CommandResult,string> Commander::tryGiveCommand(const Selection *selec
//get command type //get command type
const CommandType *commandType= unit->computeCommandType(pos, targetUnit); const CommandType *commandType= unit->computeCommandType(pos, targetUnit);
//printf("In [%s::%s Line: %d] commandType = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,commandType);
//give commands //give commands
if(commandType != NULL) { if(commandType != NULL) {
int targetId= targetUnit==NULL? Unit::invalidId: targetUnit->getId(); int targetId= targetUnit==NULL? Unit::invalidId: targetUnit->getId();
@ -420,6 +422,7 @@ std::pair<CommandResult,string> Commander::tryGiveCommand(const Selection *selec
-1, tryQueue, cst_None, -1, unitCommandGroupId); -1, tryQueue, cst_None, -1, unitCommandGroupId);
resultCur= pushNetworkCommand(&networkCommand); resultCur= pushNetworkCommand(&networkCommand);
} }
//printf("In [%s::%s Line: %d] canSubmitCommand = %d resultCur.first = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,canSubmitCommand,resultCur.first);
results.push_back(resultCur); results.push_back(resultCur);
} }
else if(unit->isMeetingPointSettable() == true) { else if(unit->isMeetingPointSettable() == true) {
@ -435,6 +438,7 @@ std::pair<CommandResult,string> Commander::tryGiveCommand(const Selection *selec
} }
} }
result = computeResult(results); result = computeResult(results);
//printf("In [%s::%s Line: %d] result.first = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,result.first);
} }
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] result = %d\n",__FILE__,__FUNCTION__,__LINE__,result); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] result = %d\n",__FILE__,__FUNCTION__,__LINE__,result);
@ -544,9 +548,11 @@ std::pair<CommandResult,string> Commander::pushNetworkCommand(const NetworkComma
//calculate the result of the command //calculate the result of the command
if(unit != NULL && networkCommand->getNetworkCommandType() == nctGiveCommand) { if(unit != NULL && networkCommand->getNetworkCommandType() == nctGiveCommand) {
//printf("In [%s::%s Line: %d] result.first = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,result.first);
Command* command= buildCommand(networkCommand); Command* command= buildCommand(networkCommand);
result= unit->checkCommand(command); result= unit->checkCommand(command);
delete command; delete command;
//printf("In [%s::%s Line: %d] result.first = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,result.first);
} }
return result; return result;
} }
@ -847,6 +853,8 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
NetworkMessageQuit networkMessageQuit; NetworkMessageQuit networkMessageQuit;
slot->sendMessage(&networkMessageQuit); slot->sendMessage(&networkMessageQuit);
sleep(5); sleep(5);
//printf("Sending nctDisconnectNetworkPlayer\n");
slot->close(); slot->close();
} }
} }

View File

@ -153,6 +153,7 @@ Game::Game() : ProgramState(NULL) {
loadGameNode = NULL; loadGameNode = NULL;
lastworldFrameCountForReplay = -1; lastworldFrameCountForReplay = -1;
lastNetworkPlayerConnectionCheck = time(NULL); lastNetworkPlayerConnectionCheck = time(NULL);
inJoinGameLoading = false;
fadeMusicMilliseconds = Config::getInstance().getInt("GameStartStopFadeSoundMilliseconds",intToStr(fadeMusicMilliseconds).c_str()); fadeMusicMilliseconds = Config::getInstance().getInt("GameStartStopFadeSoundMilliseconds",intToStr(fadeMusicMilliseconds).c_str());
@ -251,6 +252,8 @@ void Game::resetMembers() {
lastNetworkPlayerConnectionCheck = time(NULL); lastNetworkPlayerConnectionCheck = time(NULL);
inJoinGameLoading = false;
fadeMusicMilliseconds = Config::getInstance().getInt("GameStartStopFadeSoundMilliseconds",intToStr(fadeMusicMilliseconds).c_str()); fadeMusicMilliseconds = Config::getInstance().getInt("GameStartStopFadeSoundMilliseconds",intToStr(fadeMusicMilliseconds).c_str());
GAME_STATS_DUMP_INTERVAL = Config::getInstance().getInt("GameStatsDumpIntervalSeconds",intToStr(GAME_STATS_DUMP_INTERVAL).c_str()); GAME_STATS_DUMP_INTERVAL = Config::getInstance().getInt("GameStatsDumpIntervalSeconds",intToStr(GAME_STATS_DUMP_INTERVAL).c_str());
@ -1199,6 +1202,23 @@ void Game::init(bool initForPreviewOnly) {
} }
else { else {
gui.loadGame(loadGameNode,&world); gui.loadGame(loadGameNode,&world);
if(inJoinGameLoading == true) {
gameCamera.init(map->getW(), map->getH());
// camera default height calculation
if(map->getCameraHeight()>0 && gameCamera.getCalculatedDefault()<map->getCameraHeight()){
gameCamera.setCalculatedDefault(map->getCameraHeight());
}
else if(gameCamera.getCalculatedDefault()<map->getMaxMapHeight()+13.0f){
gameCamera.setCalculatedDefault(map->getMaxMapHeight()+13.0f);
}
if(world.getThisFaction() != NULL) {
const Vec2i &v= map->getStartLocation(world.getThisFaction()->getStartLocationIndex());
gameCamera.setPos(Vec2f(v.x, v.y));
}
}
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -1229,7 +1249,12 @@ void Game::init(bool initForPreviewOnly) {
aiInterfaces.resize(world.getFactionCount()); aiInterfaces.resize(world.getFactionCount());
for(int i=0; i < world.getFactionCount(); ++i) { for(int i=0; i < world.getFactionCount(); ++i) {
Faction *faction= world.getFaction(i); Faction *faction= world.getFaction(i);
//printf("Controltype = %d for index = %d\n",faction->getControlType(),i);
if(faction->getCpuControl(enableServerControlledAI,isNetworkGame,role) == true) { if(faction->getCpuControl(enableServerControlledAI,isNetworkGame,role) == true) {
//printf("** Loading AI player for Controltype = %d for index = %d\n",faction->getControlType(),i);
aiInterfaces[i]= new AiInterface(*this, i, faction->getTeam()); aiInterfaces[i]= new AiInterface(*this, i, faction->getTeam());
if(loadGameNode != NULL) { if(loadGameNode != NULL) {
aiInterfaces[i]->loadGame(loadGameNode,faction); aiInterfaces[i]->loadGame(loadGameNode,faction);
@ -1563,6 +1588,71 @@ void Game::update() {
perfList.push_back(perfBuf); perfList.push_back(perfBuf);
} }
if(role == nrServer) {
ServerInterface *server = NetworkManager::getInstance().getServerInterface();
if(server->getPauseForInGameConnection() == true && paused == false) {
//printf("================= Switching player pausing game\n");
for(int i = 0; i < world.getFactionCount(); ++i) {
Faction *faction = world.getFaction(i);
//printf("Switching player check %d from: %d connected: %d, startindex = %d, connected #2: %d\n",i,faction->getControlType(),server->isClientConnected(faction->getStartLocationIndex()),faction->getStartLocationIndex(),server->isClientConnected(i));
//printf("Slot: %d faction name: %s\n",i,faction->getType()->getName().c_str());
if( faction->getControlType() != ctNetwork &&
faction->getControlType() != ctHuman &&
server->isClientConnected(faction->getStartLocationIndex()) == true) {
//printf("Switching player %d from: %d to %d\n",i,faction->getControlType(),ctNetwork);
//printf("Slot: %d faction name: %s GS faction: %s\n",i,faction->getType()->getName().c_str(),server->gameSettings.getFactionTypeName(i).c_str());
server->gameSettings.setFactionControl(i,ctNetwork);
ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex());
server->gameSettings.setNetworkPlayerName(i,slot->getName());
this->gameSettings.setFactionControl(i,ctNetwork);
this->gameSettings.setNetworkPlayerName(i,server->gameSettings.getNetworkPlayerName(i));
}
}
//printf("#1 Data synch: lmap %u ltile: %d ltech: %u\n",gameSettings.getMapCRC(),gameSettings.getTilesetCRC(),gameSettings.getTechCRC());
//printf("#2 Data synch: lmap %u ltile: %d ltech: %u\n",server->gameSettings.getMapCRC(),server->gameSettings.getTilesetCRC(),server->gameSettings.getTechCRC());
server->broadcastGameSetup(&server->gameSettings,true);
server->setPauseForInGameConnection(false);
}
else if(server->getStartInGameConnectionLaunch() == true) {
//printf("^^^ getStartInGameConnectionLaunch triggered!\n");
server->setStartInGameConnectionLaunch(false);
for(int i = 0; i < world.getFactionCount(); ++i) {
Faction *faction = world.getFaction(i);
ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex());
if(slot != NULL && slot->getJoinGameInProgress() == true) {
//printf("$$$ signalling client to start game!\n");
this->gameSettings.setFactionControl(i,ctNetwork);
this->gameSettings.setNetworkPlayerName(i,server->gameSettings.getNetworkPlayerName(i));
//printf("START Purging AI player for index: %d\n",i);
masterController.clearSlaves(true);
delete aiInterfaces[i];
aiInterfaces[i] = NULL;
//printf("END Purging AI player for index: %d\n",i);
commander.tryPauseGame();
}
}
}
else if(server->getUnPauseForInGameConnection() == true && paused == true) {
//printf("^^^ getUnPauseForInGameConnection triggered!\n");
server->setUnPauseForInGameConnection(false);
commander.tryResumeGame();
}
}
// Check to see if we are playing a network game and if any players // Check to see if we are playing a network game and if any players
// have disconnected? // have disconnected?
ReplaceDisconnectedNetworkPlayersWithAI(isNetworkGame, role); ReplaceDisconnectedNetworkPlayersWithAI(isNetworkGame, role);
@ -4923,6 +5013,43 @@ void Game::setPaused(bool value,bool forceAllowPauseStateChange) {
else { else {
console.addLine(lang.get("GamePaused")); console.addLine(lang.get("GamePaused"));
paused= true; paused= true;
NetworkManager &networkManager= NetworkManager::getInstance();
NetworkRole role = networkManager.getNetworkRole();
if(role == nrServer) {
bool saveNetworkGame = false;
ServerInterface *server = NetworkManager::getInstance().getServerInterface();
for(int i = 0; i < world.getFactionCount(); ++i) {
Faction *faction = world.getFaction(i);
ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex());
if(slot != NULL && slot->getJoinGameInProgress() == true) {
saveNetworkGame = true;
break;
}
}
if(saveNetworkGame == true) {
//printf("Saved network game to disk\n");
string file = this->saveGame(GameConstants::saveGameFileDefault,"temp/");
char szBuf[8096]="";
Lang &lang= Lang::getInstance();
snprintf(szBuf,8096,lang.get("GameSaved","",true).c_str(),file.c_str());
console.addLine(szBuf);
for(int i = 0; i < world.getFactionCount(); ++i) {
Faction *faction = world.getFaction(i);
ConnectionSlot *slot = server->getSlot(faction->getStartLocationIndex());
if(slot != NULL && slot->getJoinGameInProgress() == true) {
NetworkMessageReady networkMessageReady(0);
slot->sendMessage(&networkMessageReady);
}
}
}
}
} }
//printf("setPaused new paused = %d\n",paused); //printf("setPaused new paused = %d\n",paused);
} }
@ -5165,7 +5292,7 @@ void Game::saveGame(){
config.save(); config.save();
} }
string Game::saveGame(string name) { string Game::saveGame(string name, string path) {
Config &config= Config::getInstance(); Config &config= Config::getInstance();
// auto name file if using saved file pattern string // auto name file if using saved file pattern string
if(name == GameConstants::saveGameFilePattern) { if(name == GameConstants::saveGameFilePattern) {
@ -5190,7 +5317,7 @@ string Game::saveGame(string name) {
} }
// Save the file now // Save the file now
string saveGameFile = "saved/" + name; string saveGameFile = path + name;
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") { if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
saveGameFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + saveGameFile; saveGameFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + saveGameFile;
} }
@ -5408,11 +5535,11 @@ string Game::saveGame(string name) {
return saveGameFile; return saveGameFile;
} }
void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) { void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode,const GameSettings *joinGameSettings) {
Config &config= Config::getInstance(); Config &config= Config::getInstance();
// This condition will re-play all the commands from a replay file // This condition will re-play all the commands from a replay file
// INSTEAD of saving from a saved game. // INSTEAD of saving from a saved game.
if(config.getBool("SaveCommandsForReplay","false") == true) { if(joinGameSettings == NULL && config.getBool("SaveCommandsForReplay","false") == true) {
XmlTree xmlTreeReplay(XML_RAPIDXML_ENGINE); XmlTree xmlTreeReplay(XML_RAPIDXML_ENGINE);
std::map<string,string> mapExtraTagReplacementValues; std::map<string,string> mapExtraTagReplacementValues;
xmlTreeReplay.load(name + ".replay", Properties::getTagReplacementValues(&mapExtraTagReplacementValues),true); xmlTreeReplay.load(name + ".replay", Properties::getTagReplacementValues(&mapExtraTagReplacementValues),true);
@ -5499,22 +5626,69 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) {
XmlNode *gameNode = rootNode->getChild("Game"); XmlNode *gameNode = rootNode->getChild("Game");
GameSettings newGameSettings; GameSettings newGameSettings;
newGameSettings.loadGame(gameNode); if(joinGameSettings != NULL) {
//printf("Loading scenario [%s]\n",newGameSettings.getScenarioDir().c_str()); newGameSettings = *joinGameSettings;
if(newGameSettings.getScenarioDir() != "" && fileExists(newGameSettings.getScenarioDir()) == false) {
newGameSettings.setScenarioDir(Scenario::getScenarioPath(Config::getInstance().getPathListForType(ptScenarios),newGameSettings.getScenario()));
//printf("Loading scenario #2 [%s]\n",newGameSettings.getScenarioDir().c_str()); XmlNode *worldNode = gameNode->getChild("World");
//gui.loadGame(loadGameNode,&world);
XmlNode *guiNode = gameNode->getChild("Gui");
XmlNode *selectionNode = guiNode->getChild("Selection");
NetworkManager &networkManager= NetworkManager::getInstance();
NetworkRole role = networkManager.getNetworkRole();
ClientInterface *clientInterface = dynamic_cast<ClientInterface *>(networkManager.getClientInterface());
for(int i= 0; i<newGameSettings.getFactionCount(); ++i) {
//replace by network
if(newGameSettings.getFactionControl(i)==ctHuman) {
newGameSettings.setFactionControl(i, ctNetwork);
}
//set the faction index
if(newGameSettings.getStartLocationIndex(i) == clientInterface->getPlayerIndex()) {
newGameSettings.setThisFactionIndex(i);
newGameSettings.setFactionControl(i, ctNetwork);
worldNode->getAttribute("thisFactionIndex")->setValue(intToStr(i));
worldNode->getAttribute("thisTeamIndex")->setValue(intToStr(newGameSettings.getTeam(i)));
XmlNode *factionNode = worldNode->getChild("Faction",i);
factionNode->getAttribute("thisFaction")->setValue(intToStr(i));
factionNode->getAttribute("control")->setValue(intToStr(ctNetwork));
selectionNode->getAttribute("factionIndex")->setValue(intToStr(i));
selectionNode->getAttribute("teamIndex")->setValue(intToStr(newGameSettings.getTeam(i)));
}
else {
//XmlNode *factionNode = worldNode->getChild("Faction",i);
//if(factionNode->hasAttribute("control") == true) {
// factionNode->getAttribute("control")->setValue(intToStr(ctNetwork));
//}
}
}
}
else {
newGameSettings.loadGame(gameNode);
//printf("Loading scenario [%s]\n",newGameSettings.getScenarioDir().c_str());
if(newGameSettings.getScenarioDir() != "" && fileExists(newGameSettings.getScenarioDir()) == false) {
newGameSettings.setScenarioDir(Scenario::getScenarioPath(Config::getInstance().getPathListForType(ptScenarios),newGameSettings.getScenario()));
//printf("Loading scenario #2 [%s]\n",newGameSettings.getScenarioDir().c_str());
}
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Game settings loaded\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Game settings loaded\n");
NetworkManager &networkManager= NetworkManager::getInstance(); if(joinGameSettings == NULL) {
networkManager.end(); NetworkManager &networkManager= NetworkManager::getInstance();
networkManager.init(nrServer,true); networkManager.end();
networkManager.init(nrServer,true);
}
Game *newGame = new Game(programPtr, &newGameSettings, isMasterserverMode); Game *newGame = new Game(programPtr, &newGameSettings, isMasterserverMode);
newGame->loadGameNode = gameNode; newGame->loadGameNode = gameNode;
newGame->inJoinGameLoading = (joinGameSettings != NULL);
// newGame->mouse2d = gameNode->getAttribute("mouse2d")->getIntValue(); // newGame->mouse2d = gameNode->getAttribute("mouse2d")->getIntValue();
// int mouseX; // int mouseX;
@ -5594,19 +5768,21 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) {
newGame->withRainEffect = gameNode->getAttribute("withRainEffect")->getIntValue() != 0; newGame->withRainEffect = gameNode->getAttribute("withRainEffect")->getIntValue() != 0;
//Program *program; //Program *program;
if(gameNode->hasChild("unitHighlightList") == true) { if(joinGameSettings == NULL) {
XmlNode *unitHighlightListNode = gameNode->getChild("unitHighlightList"); if(gameNode->hasChild("unitHighlightList") == true) {
vector<XmlNode *> infoNodeList = unitHighlightListNode->getChildList("info"); XmlNode *unitHighlightListNode = gameNode->getChild("unitHighlightList");
for(unsigned int i = 0; i < infoNodeList.size(); ++i) { vector<XmlNode *> infoNodeList = unitHighlightListNode->getChildList("info");
XmlNode *infoNode = infoNodeList[i]; for(unsigned int i = 0; i < infoNodeList.size(); ++i) {
XmlNode *infoNode = infoNodeList[i];
int unitId = infoNode->getAttribute("radius")->getIntValue(); int unitId = infoNode->getAttribute("radius")->getIntValue();
HighlightSpecialUnitInfo info; HighlightSpecialUnitInfo info;
info.radius = infoNode->getAttribute("radius")->getFloatValue(); info.radius = infoNode->getAttribute("radius")->getFloatValue();
info.thickness = infoNode->getAttribute("thickness")->getFloatValue(); info.thickness = infoNode->getAttribute("thickness")->getFloatValue();
info.color = Vec4f::strToVec4(infoNode->getAttribute("color")->getValue()); info.color = Vec4f::strToVec4(infoNode->getAttribute("color")->getValue());
newGame->unitHighlightList[unitId] = info; newGame->unitHighlightList[unitId] = info;
}
} }
} }
@ -5642,8 +5818,9 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) {
//time_t lastMasterServerGameStatsDump; //time_t lastMasterServerGameStatsDump;
//gameNode->addAttribute("lastMasterServerGameStatsDump",intToStr(lastMasterServerGameStatsDump), mapTagReplacements); //gameNode->addAttribute("lastMasterServerGameStatsDump",intToStr(lastMasterServerGameStatsDump), mapTagReplacements);
if(joinGameSettings == NULL) {
newGame->gameCamera.loadGame(gameNode); newGame->gameCamera.loadGame(gameNode);
}
const XmlNode *worldNode = gameNode->getChild("World"); const XmlNode *worldNode = gameNode->getChild("World");
newGame->world.loadGame(worldNode); newGame->world.loadGame(worldNode);

View File

@ -193,6 +193,8 @@ private:
MasterSlaveThreadController masterController; MasterSlaveThreadController masterController;
bool inJoinGameLoading;
public: public:
Game(); Game();
Game(Program *program, const GameSettings *gameSettings, bool masterserverMode); Game(Program *program, const GameSettings *gameSettings, bool masterserverMode);
@ -297,8 +299,8 @@ public:
void stopStreamingVideo(const string &playVideo); void stopStreamingVideo(const string &playVideo);
void stopAllVideo(); void stopAllVideo();
string saveGame(string name); string saveGame(string name, string path="saved/");
static void loadGame(string name,Program *programPtr,bool isMasterserverMode); static void loadGame(string name,Program *programPtr,bool isMasterserverMode, const GameSettings *joinGameSettings=NULL);
void addNetworkCommandToReplayList(NetworkCommand* networkCommand,int worldFrameCount); void addNetworkCommandToReplayList(NetworkCommand* networkCommand,int worldFrameCount);

View File

@ -63,8 +63,8 @@ public:
enum FlagTypes1 { enum FlagTypes1 {
ft1_none = 0x00, ft1_none = 0x00,
ft1_show_map_resources = 0x01, ft1_show_map_resources = 0x01,
ft1_allow_team_switching = 0x02 ft1_allow_team_switching = 0x02,
//ft1_xx = 0x04, ft1_allow_in_game_joining = 0x04
//ft1_xx = 0x08, //ft1_xx = 0x08,
//ft1_xx = 0x10, //ft1_xx = 0x10,
}; };
@ -305,6 +305,21 @@ public:
return startLocationIndex[factionIndex]; return startLocationIndex[factionIndex];
} }
int getFactionIndexForStartLocation(int startIndex) const {
if(startIndex < 0 || startIndex >= GameConstants::maxPlayers) {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s] Invalid startIndex = %d\n",__FUNCTION__,startIndex);
throw megaglest_runtime_error(szBuf);
}
for(unsigned int i =0; i < GameConstants::maxPlayers; ++i) {
if(startLocationIndex[i] == startIndex) {
return i;
}
}
return -1;
}
int getMapFilterIndex() const {return mapFilterIndex;} int getMapFilterIndex() const {return mapFilterIndex;}
bool getDefaultUnits() const {return defaultUnits;} bool getDefaultUnits() const {return defaultUnits;}

View File

@ -447,6 +447,7 @@ void Gui::giveDefaultOrders(int x, int y) {
console->addStdMessage("InvalidPosition"); console->addStdMessage("InvalidPosition");
return; return;
} }
//printf("In [%s::%s Line: %d] targetUnit = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,targetUnit);
giveDefaultOrders(targetPos.x,targetPos.y,targetUnit,true); giveDefaultOrders(targetPos.x,targetPos.y,targetUnit,true);
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
@ -465,6 +466,8 @@ void Gui::giveDefaultOrders(int x, int y,const Unit *targetUnit, bool paintMouse
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
std::pair<CommandResult,string> result= commander->tryGiveCommand(&selection, targetPos, targetUnit, queueKeyDown); std::pair<CommandResult,string> result= commander->tryGiveCommand(&selection, targetPos, targetUnit, queueKeyDown);
//printf("In [%s::%s Line: %d] selected units = %d result.first = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,selection.getCount(),result.first);
//graphical result //graphical result
addOrdersResultToConsole(activeCommandClass, result); addOrdersResultToConsole(activeCommandClass, result);
if(result.first == crSuccess || result.first == crSomeFailed) { if(result.first == crSuccess || result.first == crSomeFailed) {

View File

@ -77,6 +77,10 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
getMissingTilesetFromFTPServerInProgress = false; getMissingTilesetFromFTPServerInProgress = false;
getMissingTechtreeFromFTPServer = ""; getMissingTechtreeFromFTPServer = "";
getMissingTechtreeFromFTPServerInProgress = false; getMissingTechtreeFromFTPServerInProgress = false;
getInProgressSavedGameFromFTPServer = "";
getInProgressSavedGameFromFTPServerInProgress = false;
readyToJoinInProgressGame = false;
lastCheckedCRCTilesetName = ""; lastCheckedCRCTilesetName = "";
lastCheckedCRCTechtreeName = ""; lastCheckedCRCTechtreeName = "";
lastCheckedCRCMapName = ""; lastCheckedCRCMapName = "";
@ -537,10 +541,26 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
string fileArchiveExtractCommandParameters = config.getString("FileArchiveExtractCommandParameters",""); string fileArchiveExtractCommandParameters = config.getString("FileArchiveExtractCommandParameters","");
int32 fileArchiveExtractCommandSuccessResult = config.getInt("FileArchiveExtractCommandSuccessResult","0"); int32 fileArchiveExtractCommandSuccessResult = config.getInt("FileArchiveExtractCommandSuccessResult","0");
// Get path to temp files
string tempFilePath = "temp/";
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
tempFilePath = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + tempFilePath;
}
else {
string userData = config.getString("UserData_Root","");
if(userData != "") {
endPathWithSlash(userData);
}
tempFilePath = userData + tempFilePath;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Temp files path [%s]\n",tempFilePath.c_str());
ftpClientThread = new FTPClientThread(portNumber,serverUrl, ftpClientThread = new FTPClientThread(portNumber,serverUrl,
mapsPath,tilesetsPath,techtreesPath,scenariosPath, mapsPath,tilesetsPath,techtreesPath,scenariosPath,
this,fileArchiveExtension,fileArchiveExtractCommand, this,fileArchiveExtension,fileArchiveExtractCommand,
fileArchiveExtractCommandParameters,fileArchiveExtractCommandSuccessResult); fileArchiveExtractCommandParameters,
fileArchiveExtractCommandSuccessResult,
tempFilePath);
ftpClientThread->start(); ftpClientThread->start();
} }
// Start http meta data thread // Start http meta data thread
@ -549,6 +569,23 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
modHttpServerThread->setUniqueID(mutexOwnerId); modHttpServerThread->setUniqueID(mutexOwnerId);
modHttpServerThread->start(); modHttpServerThread->start();
ClientInterface *clientInterface = networkManager.getClientInterface();
if(clientInterface != NULL && clientInterface->getJoinGameInProgress() == true) {
Lang &lang= Lang::getInstance();
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
for(unsigned int i = 0; i < languageList.size(); ++i) {
char szMsg[8096]="";
if(lang.hasString("JoinPlayerToCurrentGameWelcome",languageList[i]) == true) {
snprintf(szMsg,8096,lang.get("JoinPlayerToCurrentGameWelcome",languageList[i]).c_str(),getHumanPlayerName().c_str());
}
else {
snprintf(szMsg,8096,"Player: %s has connected to the game and would like to join.",getHumanPlayerName().c_str());
}
bool localEcho = lang.isLanguageLocal(languageList[i]);
clientInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
}
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -1294,6 +1331,9 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
getMissingTilesetFromFTPServer = ""; getMissingTilesetFromFTPServer = "";
getMissingTechtreeFromFTPServer = ""; getMissingTechtreeFromFTPServer = "";
getInProgressSavedGameFromFTPServer = "";
getInProgressSavedGameFromFTPServerInProgress = false;
ClientInterface *clientInterface = networkManager.getClientInterface(); ClientInterface *clientInterface = networkManager.getClientInterface();
string serverUrl = clientInterface->getServerIpAddress(); string serverUrl = clientInterface->getServerIpAddress();
//int portNumber = config.getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str()); //int portNumber = config.getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
@ -1342,10 +1382,26 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
string fileArchiveExtractCommandParameters = config.getString("FileArchiveExtractCommandParameters",""); string fileArchiveExtractCommandParameters = config.getString("FileArchiveExtractCommandParameters","");
int32 fileArchiveExtractCommandSuccessResult = config.getInt("FileArchiveExtractCommandSuccessResult","0"); int32 fileArchiveExtractCommandSuccessResult = config.getInt("FileArchiveExtractCommandSuccessResult","0");
// Get path to temp files
string tempFilePath = "temp/";
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
tempFilePath = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + tempFilePath;
}
else {
string userData = config.getString("UserData_Root","");
if(userData != "") {
endPathWithSlash(userData);
}
tempFilePath = userData + tempFilePath;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Temp files path [%s]\n",tempFilePath.c_str());
ftpClientThread = new FTPClientThread(portNumber,serverUrl, ftpClientThread = new FTPClientThread(portNumber,serverUrl,
mapsPath,tilesetsPath,techtreesPath,scenariosPath, mapsPath,tilesetsPath,techtreesPath,scenariosPath,
this,fileArchiveExtension,fileArchiveExtractCommand, this,fileArchiveExtension,fileArchiveExtractCommand,
fileArchiveExtractCommandParameters,fileArchiveExtractCommandSuccessResult); fileArchiveExtractCommandParameters,
fileArchiveExtractCommandSuccessResult,
tempFilePath);
ftpClientThread->start(); ftpClientThread->start();
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
@ -1539,6 +1595,15 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
//printf("#1 admin key [%d] client key [%d]\n",settings->getMasterserver_admin(),clientInterface->getSessionKey()); //printf("#1 admin key [%d] client key [%d]\n",settings->getMasterserver_admin(),clientInterface->getSessionKey());
mouseClickAdmin(x, y, mouseButton,advanceToItemStartingWith); mouseClickAdmin(x, y, mouseButton,advanceToItemStartingWith);
} }
else if(clientInterface != NULL && clientInterface->getJoinGameInProgress() == true) {
if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
PlayNow(true);
return;
}
}
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
@ -1795,8 +1860,44 @@ void MenuStateConnectedGame::PlayNow(bool saveGame) {
//printf("Client sending map [%s] admin key [%d]\n",gameSettings.getMap().c_str(),gameSettings.getMasterserver_admin()); //printf("Client sending map [%s] admin key [%d]\n",gameSettings.getMap().c_str(),gameSettings.getMasterserver_admin());
broadCastGameSettingsToHeadlessServer(needToBroadcastServerSettings); //printf("Tell server we want to join!\n");
clientInterface->broadcastGameStart(&gameSettings);
//if(readyToJoinInProgressGame == true) {
if(clientInterface->getJoinGameInProgress() == true) {
Lang &lang= Lang::getInstance();
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
for(unsigned int i = 0; i < languageList.size(); ++i) {
char szMsg[8096]="";
if(lang.hasString("JoinPlayerToCurrentGameLaunch",languageList[i]) == true) {
snprintf(szMsg,8096,lang.get("JoinPlayerToCurrentGameLaunch",languageList[i]).c_str(),getHumanPlayerName().c_str());
}
else {
snprintf(szMsg,8096,"Player: %s is about to join the game, please wait...",getHumanPlayerName().c_str());
}
bool localEcho = lang.isLanguageLocal(languageList[i]);
clientInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
}
// string saveGameFile = "temp/" + string(GameConstants::saveGameFileDefault);
// if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
// saveGameFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + saveGameFile;
// }
// else {
// string userData = Config::getInstance().getString("UserData_Root","");
// if(userData != "") {
// endPathWithSlash(userData);
// }
// saveGameFile = userData + saveGameFile;
// }
clientInterface->broadcastGameStart(&gameSettings);
//Game::loadGame(saveGameFile,program,false,&gameSettings);
return;
}
else {
broadCastGameSettingsToHeadlessServer(needToBroadcastServerSettings);
clientInterface->broadcastGameStart(&gameSettings);
}
} }
string MenuStateConnectedGame::getCurrentMapFile() { string MenuStateConnectedGame::getCurrentMapFile() {
@ -2562,7 +2663,8 @@ void MenuStateConnectedGame::update() {
broadCastGameSettingsToHeadlessServer(false); broadCastGameSettingsToHeadlessServer(false);
listBoxMap.setEditable(isHeadlessAdmin()); listBoxMap.setEditable(isHeadlessAdmin());
buttonPlayNow.setVisible(isHeadlessAdmin()); buttonPlayNow.setVisible(isHeadlessAdmin() ||
clientInterface->getJoinGameInProgress() == true);
buttonRestoreLastSettings.setVisible(isHeadlessAdmin()); buttonRestoreLastSettings.setVisible(isHeadlessAdmin());
listBoxTechTree.setEditable(isHeadlessAdmin()); listBoxTechTree.setEditable(isHeadlessAdmin());
listBoxTileset.setEditable(isHeadlessAdmin()); listBoxTileset.setEditable(isHeadlessAdmin());
@ -2597,7 +2699,7 @@ void MenuStateConnectedGame::update() {
clientInterface->updateLobby(); clientInterface->updateLobby();
if(clientInterface->isConnected() && if(clientInterface->isConnected() && clientInterface->getPausedForInGameJoin() == false &&
pingCount >= 3 && clientInterface->getLastPingLag() >= (GameConstants::networkPingInterval * 3)) { pingCount >= 3 && clientInterface->getLastPingLag() >= (GameConstants::networkPingInterval * 3)) {
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
if(fileFTPProgressList.empty() == true) { if(fileFTPProgressList.empty() == true) {
@ -2756,6 +2858,9 @@ void MenuStateConnectedGame::update() {
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nmapCRC [%d] gameSettings->getMapCRC() [%d]\ntilesetCRC [%d] gameSettings->getTilesetCRC() [%d]\ntechCRC [%d] gameSettings->getTechCRC() [%d]\n",mapCRC,gameSettings->getMapCRC(),tilesetCRC,gameSettings->getTilesetCRC(),techCRC,gameSettings->getTechCRC()); //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nmapCRC [%d] gameSettings->getMapCRC() [%d]\ntilesetCRC [%d] gameSettings->getTilesetCRC() [%d]\ntechCRC [%d] gameSettings->getTechCRC() [%d]\n",mapCRC,gameSettings->getMapCRC(),tilesetCRC,gameSettings->getTilesetCRC(),techCRC,gameSettings->getTechCRC());
if(dataSynchMismatch == true) { if(dataSynchMismatch == true) {
//printf("Data not synched: lmap %u rmap: %u ltile: %d rtile: %u ltech: %u rtech: %u\n",mapCRC,gameSettings->getMapCRC(),tilesetCRC,gameSettings->getTilesetCRC(),techCRC,gameSettings->getTechCRC());
string labelSynch = lang.get("DataNotSynchedTitle"); string labelSynch = lang.get("DataNotSynchedTitle");
if(mapCRC != 0 && mapCRC != gameSettings->getMapCRC() && if(mapCRC != 0 && mapCRC != gameSettings->getMapCRC() &&
@ -3079,6 +3184,56 @@ void MenuStateConnectedGame::update() {
bool errorOnMissingData = (clientInterface->getAllowGameDataSynchCheck() == false); bool errorOnMissingData = (clientInterface->getAllowGameDataSynchCheck() == false);
GameSettings *gameSettings = clientInterface->getGameSettingsPtr(); GameSettings *gameSettings = clientInterface->getGameSettingsPtr();
setupUIFromGameSettings(gameSettings, errorOnMissingData); setupUIFromGameSettings(gameSettings, errorOnMissingData);
// // check if we are joining an in progress game
// if(clientInterface->getJoinGameInProgress() == true &&
// clientInterface->getReadyForInGameJoin() == true &&
// ftpClientThread != NULL) {
//
// if(ftpClientThread != NULL) ftpClientThread->addTempFileToRequests(GameConstants::saveGameFileDefault);
// MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
// fileFTPProgressList[getInProgressSavedGameFromFTPServer] = pair<int,string>(0,"");
// safeMutexFTPProgress.ReleaseLock();
// }
}
// check if we are joining an in progress game
if(clientInterface->getJoinGameInProgress() == true &&
clientInterface->getReadyForInGameJoin() == true &&
ftpClientThread != NULL) {
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
if(readyToJoinInProgressGame == false) {
if(getInProgressSavedGameFromFTPServer == "") {
ftpClientThread->addTempFileToRequests(GameConstants::saveGameFileDefault);
getInProgressSavedGameFromFTPServer = GameConstants::saveGameFileDefault;
fileFTPProgressList[getInProgressSavedGameFromFTPServer] = pair<int,string>(0,"");
}
safeMutexFTPProgress.ReleaseLock();
}
else {
safeMutexFTPProgress.ReleaseLock();
string saveGameFile = "temp/" + string(GameConstants::saveGameFileDefault);
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
saveGameFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + saveGameFile;
}
else {
string userData = Config::getInstance().getString("UserData_Root","");
if(userData != "") {
endPathWithSlash(userData);
}
saveGameFile = userData + saveGameFile;
}
//clientInterface->broadcastGameStart(&gameSettings);
GameSettings gameSettings = *clientInterface->getGameSettings();
loadGameSettings(&gameSettings);
Game::loadGame(saveGameFile,program,false,&gameSettings);
return;
}
} }
//update lobby //update lobby
@ -3980,6 +4135,62 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
console.addLine(result.second,true); console.addLine(result.second,true);
} }
} }
else if(type == ftp_cct_TempFile) {
getInProgressSavedGameFromFTPServerInProgress = false;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] result = %d [%s]\n",itemName.c_str(),result.first,result.second.c_str());
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
fileFTPProgressList.erase(itemName);
safeMutexFTPProgress.ReleaseLock();
NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface();
const GameSettings *gameSettings = clientInterface->getGameSettings();
if(result.first == ftp_crt_SUCCESS) {
Lang &lang= Lang::getInstance();
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
for(unsigned int i = 0; i < languageList.size(); ++i) {
char szMsg[8096]="";
if(lang.hasString("JoinPlayerToCurrentGameSuccessDownload",languageList[i]) == true) {
snprintf(szMsg,8096,lang.get("JoinPlayerToCurrentGameSuccessDownload",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str());
}
else {
snprintf(szMsg,8096,"Player: %s SUCCESSFULLY downloaded the saved game: %s",getHumanPlayerName().c_str(),itemName.c_str());
}
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
}
readyToJoinInProgressGame = true;
}
else {
curl_version_info_data *curlVersion= curl_version_info(CURLVERSION_NOW);
Lang &lang= Lang::getInstance();
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
for(unsigned int i = 0; i < languageList.size(); ++i) {
char szMsg[8096]="";
if(lang.hasString("JoinPlayerToCurrentGameFailDownload",languageList[i]) == true) {
snprintf(szMsg,8096,lang.get("JoinPlayerToCurrentGameFailDownload",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
}
else {
snprintf(szMsg,8096,"Player: %s FAILED to download the saved game: [%s] using CURL version [%s]",getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
}
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
if(result.first == ftp_crt_HOST_NOT_ACCEPTING) {
if(lang.hasString("HostNotAcceptingDataConnections",languageList[i]) == true) {
clientInterface->sendTextMessage(lang.get("HostNotAcceptingDataConnections",languageList[i]),-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
}
else {
clientInterface->sendTextMessage("*Warning* the host is not accepting data connections.",-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
}
}
}
console.addLine(result.second,true);
}
}
} }
void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings, bool errorOnMissingData) { void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings, bool errorOnMissingData) {
@ -4299,8 +4510,10 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
listBoxControls[i].setSelectedItemIndex(ctClosed); listBoxControls[i].setSelectedItemIndex(ctClosed);
if(isHeadlessAdmin() == false) { if(isHeadlessAdmin() == false) {
listBoxFactions[i].setEditable(false); if(clientInterface->getJoinGameInProgress() == false) {
listBoxTeams[i].setEditable(false); listBoxFactions[i].setEditable(false);
listBoxTeams[i].setEditable(false);
}
} }
labelPlayerStatus[i].setText(""); labelPlayerStatus[i].setText("");
@ -4395,8 +4608,10 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
listBoxControls[slot].setSelectedItemIndex(ctHuman); listBoxControls[slot].setSelectedItemIndex(ctHuman);
} }
if(checkBoxScenario.getValue() == false) { if(checkBoxScenario.getValue() == false) {
listBoxFactions[slot].setEditable(true); if(clientInterface->getJoinGameInProgress() == false) {
listBoxTeams[slot].setEditable(true); listBoxFactions[slot].setEditable(true);
listBoxTeams[slot].setEditable(true);
}
} }
if(labelPlayerNames[slot].getText() == "" && if(labelPlayerNames[slot].getText() == "" &&

View File

@ -177,6 +177,10 @@ private:
string getMissingTechtreeFromFTPServer; string getMissingTechtreeFromFTPServer;
bool getMissingTechtreeFromFTPServerInProgress; bool getMissingTechtreeFromFTPServerInProgress;
string getInProgressSavedGameFromFTPServer;
bool getInProgressSavedGameFromFTPServerInProgress;
bool readyToJoinInProgressGame;
string lastCheckedCRCTilesetName; string lastCheckedCRCTilesetName;
string lastCheckedCRCTechtreeName; string lastCheckedCRCTechtreeName;
string lastCheckedCRCMapName; string lastCheckedCRCMapName;
@ -212,7 +216,6 @@ private:
bool enableScenarioTexturePreview; bool enableScenarioTexturePreview;
Texture2D *scenarioLogoTexture; Texture2D *scenarioLogoTexture;
bool needToBroadcastServerSettings; bool needToBroadcastServerSettings;
time_t broadcastServerSettingsDelayTimer; time_t broadcastServerSettingsDelayTimer;
int lastGameSettingsReceivedCount; int lastGameSettingsReceivedCount;

View File

@ -325,11 +325,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
labelEnableSwitchTeamMode.init(xoffset+310, aHeadPos+45, 80); labelEnableSwitchTeamMode.init(xoffset+310, aHeadPos+45, 80);
labelEnableSwitchTeamMode.setText(lang.get("EnableSwitchTeamMode")); labelEnableSwitchTeamMode.setText(lang.get("EnableSwitchTeamMode"));
// listBoxEnableSwitchTeamMode.registerGraphicComponent(containerName,"listBoxEnableSwitchTeamMode");
// listBoxEnableSwitchTeamMode.init(xoffset+310, aPos+45, 80);
// listBoxEnableSwitchTeamMode.pushBackItem(lang.get("Yes"));
// listBoxEnableSwitchTeamMode.pushBackItem(lang.get("No"));
// listBoxEnableSwitchTeamMode.setSelectedItemIndex(1);
checkBoxEnableSwitchTeamMode.registerGraphicComponent(containerName,"checkBoxEnableSwitchTeamMode"); checkBoxEnableSwitchTeamMode.registerGraphicComponent(containerName,"checkBoxEnableSwitchTeamMode");
checkBoxEnableSwitchTeamMode.init(xoffset+310, aPos+45); checkBoxEnableSwitchTeamMode.init(xoffset+310, aPos+45);
checkBoxEnableSwitchTeamMode.setValue(false); checkBoxEnableSwitchTeamMode.setValue(false);
@ -345,6 +340,14 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
} }
listBoxAISwitchTeamAcceptPercent.setSelectedItem(intToStr(30)); listBoxAISwitchTeamAcceptPercent.setSelectedItem(intToStr(30));
labelAllowInGameJoinPlayer.registerGraphicComponent(containerName,"labelAllowInGameJoinPlayer");
labelAllowInGameJoinPlayer.init(xoffset+410, 670, 80);
labelAllowInGameJoinPlayer.setText(lang.get("AllowInGameJoinPlayer"));
checkBoxAllowInGameJoinPlayer.registerGraphicComponent(containerName,"checkBoxAllowInGameJoinPlayer");
checkBoxAllowInGameJoinPlayer.init(xoffset+600, 670);
checkBoxAllowInGameJoinPlayer.setValue(false);
// Which Pathfinder // Which Pathfinder
//labelPathFinderType.registerGraphicComponent(containerName,"labelPathFinderType"); //labelPathFinderType.registerGraphicComponent(containerName,"labelPathFinderType");
//labelPathFinderType.init(xoffset+650, aHeadPos, 80); //labelPathFinderType.init(xoffset+650, aHeadPos, 80);
@ -798,6 +801,8 @@ void MenuStateCustomGame::reloadUI() {
// Allow Switch Team Mode // Allow Switch Team Mode
labelEnableSwitchTeamMode.setText(lang.get("EnableSwitchTeamMode")); labelEnableSwitchTeamMode.setText(lang.get("EnableSwitchTeamMode"));
labelAllowInGameJoinPlayer.setText(lang.get("AllowInGameJoinPlayer"));
//listBoxData.clear(); //listBoxData.clear();
//listBoxData.push_back(lang.get("Yes")); //listBoxData.push_back(lang.get("Yes"));
//listBoxData.push_back(lang.get("No")); //listBoxData.push_back(lang.get("No"));
@ -1131,6 +1136,22 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
lastSetChangedGameSettings = time(NULL); lastSetChangedGameSettings = time(NULL);
} }
} }
else if (checkBoxAllowInGameJoinPlayer.mouseClick(x, y)) {
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
if(checkBoxPublishServer.getValue() == true) {
needToRepublishToMasterserver = true;
}
if(hasNetworkGameSettings() == true)
{
needToSetChangedGameSettings = true;
lastSetChangedGameSettings = time(NULL);
}
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
serverInterface->setAllowInGameConnections(checkBoxAllowInGameJoinPlayer.getValue() == true);
}
else if (checkBoxAdvanced.getValue() == 1 && checkBoxEnableSwitchTeamMode.mouseClick(x, y)) { else if (checkBoxAdvanced.getValue() == 1 && checkBoxEnableSwitchTeamMode.mouseClick(x, y)) {
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
@ -1811,6 +1832,8 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms) {
//labelPathFinderType.mouseMove(x, y); //labelPathFinderType.mouseMove(x, y);
//listBoxPathFinderType.mouseMove(x, y); //listBoxPathFinderType.mouseMove(x, y);
} }
checkBoxAllowInGameJoinPlayer.mouseMove(x, y);
listBoxTileset.mouseMove(x, y); listBoxTileset.mouseMove(x, y);
listBoxMapFilter.mouseMove(x, y); listBoxMapFilter.mouseMove(x, y);
listBoxTechTree.mouseMove(x, y); listBoxTechTree.mouseMove(x, y);
@ -2015,6 +2038,9 @@ void MenuStateCustomGame::render() {
renderer.renderListBox(&listBoxAISwitchTeamAcceptPercent); renderer.renderListBox(&listBoxAISwitchTeamAcceptPercent);
renderer.renderListBox(&listBoxFallbackCpuMultiplier); renderer.renderListBox(&listBoxFallbackCpuMultiplier);
} }
renderer.renderLabel(&labelAllowInGameJoinPlayer);
renderer.renderCheckBox(&checkBoxAllowInGameJoinPlayer);
renderer.renderLabel(&labelTileset); renderer.renderLabel(&labelTileset);
renderer.renderLabel(&labelMapFilter); renderer.renderLabel(&labelMapFilter);
renderer.renderLabel(&labelTechTree); renderer.renderLabel(&labelTechTree);
@ -3174,6 +3200,16 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
gameSettings->setAiAcceptSwitchTeamPercentChance(strToInt(listBoxAISwitchTeamAcceptPercent.getSelectedItem())); gameSettings->setAiAcceptSwitchTeamPercentChance(strToInt(listBoxAISwitchTeamAcceptPercent.getSelectedItem()));
gameSettings->setFallbackCpuMultiplier(listBoxFallbackCpuMultiplier.getSelectedItemIndex()); gameSettings->setFallbackCpuMultiplier(listBoxFallbackCpuMultiplier.getSelectedItemIndex());
if(checkBoxAllowInGameJoinPlayer.getValue() == true) {
valueFlags1 |= ft1_allow_in_game_joining;
gameSettings->setFlagTypes1(valueFlags1);
}
else {
valueFlags1 &= ~ft1_allow_in_game_joining;
gameSettings->setFlagTypes1(valueFlags1);
}
// First save Used slots // First save Used slots
//for(int i=0; i<mapInfo.players; ++i) //for(int i=0; i<mapInfo.players; ++i)
int AIPlayerCount = 0; int AIPlayerCount = 0;
@ -3321,7 +3357,8 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
gameSettings->setNetworkFramePeriod(config.getInt("NetworkSendFrameCount","20")); gameSettings->setNetworkFramePeriod(config.getInt("NetworkSendFrameCount","20"));
gameSettings->setNetworkPauseGameForLaggedClients(((checkBoxNetworkPauseGameForLaggedClients.getValue() == true))); gameSettings->setNetworkPauseGameForLaggedClients(((checkBoxNetworkPauseGameForLaggedClients.getValue() == true)));
if(hasNetworkGameSettings() == true) { //if(hasNetworkGameSettings() == true) {
{
if( gameSettings->getTileset() != "") { if( gameSettings->getTileset() != "") {
if(lastCheckedCRCTilesetName != gameSettings->getTileset()) { if(lastCheckedCRCTilesetName != gameSettings->getTileset()) {
//console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]"); //console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]");
@ -3588,6 +3625,12 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
listBoxAISwitchTeamAcceptPercent.setSelectedItem(intToStr(gameSettings.getAiAcceptSwitchTeamPercentChance())); listBoxAISwitchTeamAcceptPercent.setSelectedItem(intToStr(gameSettings.getAiAcceptSwitchTeamPercentChance()));
listBoxFallbackCpuMultiplier.setSelectedItemIndex(gameSettings.getFallbackCpuMultiplier()); listBoxFallbackCpuMultiplier.setSelectedItemIndex(gameSettings.getFallbackCpuMultiplier());
checkBoxAllowInGameJoinPlayer.setValue((gameSettings.getFlagTypes1() & ft1_allow_in_game_joining) == ft1_allow_in_game_joining ? true : false);
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
if(serverInterface != NULL) {
serverInterface->setAllowInGameConnections(checkBoxAllowInGameJoinPlayer.getValue() == true);
}
//listBoxPathFinderType.setSelectedItemIndex(gameSettings.getPathFinderType()); //listBoxPathFinderType.setSelectedItemIndex(gameSettings.getPathFinderType());
//listBoxEnableServerControlledAI.setSelectedItem(gameSettings.getEnableServerControlledAI() == true ? lang.get("Yes") : lang.get("No")); //listBoxEnableServerControlledAI.setSelectedItem(gameSettings.getEnableServerControlledAI() == true ? lang.get("Yes") : lang.get("No"));

View File

@ -127,6 +127,9 @@ private:
GraphicLabel labelFallbackCpuMultiplier; GraphicLabel labelFallbackCpuMultiplier;
GraphicListBox listBoxFallbackCpuMultiplier; GraphicListBox listBoxFallbackCpuMultiplier;
GraphicLabel labelAllowInGameJoinPlayer;
GraphicCheckBox checkBoxAllowInGameJoinPlayer;
GraphicCheckBox checkBoxScenario; GraphicCheckBox checkBoxScenario;
GraphicLabel labelScenario; GraphicLabel labelScenario;
GraphicListBox listBoxScenario; GraphicListBox listBoxScenario;

View File

@ -305,11 +305,26 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
console.setOnlyChatMessagesInStoredLines(false); console.setOnlyChatMessagesInStoredLines(false);
// Get path to temp files
string tempFilePath = "temp/";
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
tempFilePath = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + tempFilePath;
}
else {
string userData = config.getString("UserData_Root","");
if(userData != "") {
endPathWithSlash(userData);
}
tempFilePath = userData + tempFilePath;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Temp files path [%s]\n",tempFilePath.c_str());
ftpClientThread = new FTPClientThread(-1,"", ftpClientThread = new FTPClientThread(-1,"",
mapsPath,tilesetsPath,techtreesPath,scenariosPath, mapsPath,tilesetsPath,techtreesPath,scenariosPath,
this,fileArchiveExtension,fileArchiveExtractCommand, this,fileArchiveExtension,fileArchiveExtractCommand,
fileArchiveExtractCommandParameters, fileArchiveExtractCommandParameters,
fileArchiveExtractCommandSuccessResult); fileArchiveExtractCommandSuccessResult,
tempFilePath);
ftpClientThread->start(); ftpClientThread->start();

View File

@ -52,10 +52,13 @@ ClientInterface::ClientInterface() : GameNetworkInterface() {
networkCommandListThread = NULL; networkCommandListThread = NULL;
cachedPendingCommandsIndex = 0; cachedPendingCommandsIndex = 0;
pausedForInGameJoin = false;
readyForInGameJoin = false;
clientSocket= NULL; clientSocket= NULL;
sessionKey = 0; sessionKey = 0;
launchGame= false; launchGame= false;
introDone= false; introDone= false;
joinGameInProgress = false;
playerIndex= -1; playerIndex= -1;
setGameSettingsReceived(false); setGameSettingsReceived(false);
gotIntro = false; gotIntro = false;
@ -248,6 +251,9 @@ void ClientInterface::updateLobby() {
playerIndex= networkMessageIntro.getPlayerIndex(); playerIndex= networkMessageIntro.getPlayerIndex();
serverName= networkMessageIntro.getName(); serverName= networkMessageIntro.getName();
serverFTPPort = networkMessageIntro.getFtpPort(); serverFTPPort = networkMessageIntro.getFtpPort();
joinGameInProgress = networkMessageIntro.getGameInProgress();
//printf("Client got intro playerIndex = %d\n",playerIndex);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageIntro, networkMessageIntro.getGameState() = %d, versionString [%s], sessionKey = %d, playerIndex = %d, serverFTPPort = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkMessageIntro.getGameState(),versionString.c_str(),sessionKey,playerIndex,serverFTPPort); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageIntro, networkMessageIntro.getGameState() = %d, versionString [%s], sessionKey = %d, playerIndex = %d, serverFTPPort = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkMessageIntro.getGameState(),versionString.c_str(),sessionKey,playerIndex,serverFTPPort);
@ -309,9 +315,12 @@ void ClientInterface::updateLobby() {
nmgstOk, nmgstOk,
this->getSocket()->getConnectedIPAddress(), this->getSocket()->getConnectedIPAddress(),
serverFTPPort, serverFTPPort,
lang.getLanguage()); lang.getLanguage(),
networkMessageIntro.getGameInProgress());
sendMessage(&sendNetworkMessageIntro); sendMessage(&sendNetworkMessageIntro);
//printf("Got intro sending client details to server\n");
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(clientSocket == NULL || clientSocket->isConnected() == false) { if(clientSocket == NULL || clientSocket->isConnected() == false) {
@ -574,9 +583,14 @@ void ClientInterface::updateLobby() {
networkMessageLaunch.buildGameSettings(&gameSettings); networkMessageLaunch.buildGameSettings(&gameSettings);
//printf("Client got game settings playerIndex = %d lookingfor match...\n",playerIndex);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got networkMessageLaunch.getMessageType() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got networkMessageLaunch.getMessageType() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType());
//replace server player by network //replace server player by network
for(int i= 0; i<gameSettings.getFactionCount(); ++i) { for(int i= 0; i<gameSettings.getFactionCount(); ++i) {
//printf("Faction = %d start location = %d faction name = %s\n",i,gameSettings.getStartLocationIndex(i),gameSettings.getFactionTypeName(i).c_str());
//replace by network //replace by network
if(gameSettings.getFactionControl(i)==ctHuman) { if(gameSettings.getFactionControl(i)==ctHuman) {
gameSettings.setFactionControl(i, ctNetwork); gameSettings.setFactionControl(i, ctNetwork);
@ -585,6 +599,8 @@ void ClientInterface::updateLobby() {
//set the faction index //set the faction index
if(gameSettings.getStartLocationIndex(i) == playerIndex) { if(gameSettings.getStartLocationIndex(i) == playerIndex) {
gameSettings.setThisFactionIndex(i); gameSettings.setThisFactionIndex(i);
//printf("Client got game settings playerIndex = %d factionIndex = %d control = %d name = %s\n",playerIndex,i,gameSettings.getFactionControl(i),gameSettings.getFactionTypeName(i).c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] gameSettings.getThisFactionIndex(i) = %d, playerIndex = %d, i = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,gameSettings.getThisFactionIndex(),playerIndex,i); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] gameSettings.getThisFactionIndex(i) = %d, playerIndex = %d, i = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,gameSettings.getThisFactionIndex(),playerIndex,i);
} }
} }
@ -608,6 +624,30 @@ void ClientInterface::updateLobby() {
} }
} }
break; break;
case nmtReady:
{
NetworkMessageReady networkMessageReady;
if(receiveMessage(&networkMessageReady)) {
this->readyForInGameJoin = true;
}
break;
}
case nmtCommandList:
{
int waitCount = 0;
//make sure we read the message
time_t receiveTimeElapsed = time(NULL);
NetworkMessageCommandList networkMessageCommandList;
bool gotCmd = receiveMessage(&networkMessageCommandList);
if(gotCmd == false) {
throw megaglest_runtime_error("error retrieving nmtCommandList returned false!");
}
pausedForInGameJoin = true;
}
break;
default: default:
{ {
string sErr = string(extractFileFromDirectoryPath(__FILE__).c_str()) + "::" + string(__FUNCTION__) + " Unexpected network message: " + intToStr(networkMessageType); string sErr = string(extractFileFromDirectoryPath(__FILE__).c_str()) + "::" + string(__FUNCTION__) + " Unexpected network message: " + intToStr(networkMessageType);
@ -955,6 +995,9 @@ bool ClientInterface::isMasterServerAdminOverride() {
void ClientInterface::waitUntilReady(Checksum* checksum) { void ClientInterface::waitUntilReady(Checksum* checksum) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
bool signalServerWhenReadyToStartJoinedGame = readyForInGameJoin;
pausedForInGameJoin = false;
readyForInGameJoin = false;
Logger &logger= Logger::getInstance(); Logger &logger= Logger::getInstance();
Chrono chrono; Chrono chrono;
@ -1038,6 +1081,16 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
} }
} }
else if(networkMessageType == nmtCommandList) {
int waitCount = 0;
//make sure we read the message
time_t receiveTimeElapsed = time(NULL);
NetworkMessageCommandList networkMessageCommandList;
bool gotCmd = receiveMessage(&networkMessageCommandList);
if(gotCmd == false) {
throw megaglest_runtime_error("error retrieving nmtCommandList returned false!");
}
}
else if(networkMessageType == nmtInvalid) { else if(networkMessageType == nmtInvalid) {
if(chrono.getMillis() > readyWaitTimeout) { if(chrono.getMillis() > readyWaitTimeout) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -1188,7 +1241,7 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//check checksum //check checksum
if(networkMessageReady.getChecksum() != checksum->getSum()) { if(joinGameInProgress == false && networkMessageReady.getChecksum() != checksum->getSum()) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
@ -1265,6 +1318,13 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
return; return;
} }
//printf("Client signalServerWhenReadyToStartJoinedGame = %d\n",signalServerWhenReadyToStartJoinedGame);
if(signalServerWhenReadyToStartJoinedGame == true) {
NetworkMessageReady networkMessageReady;
sendMessage(&networkMessageReady);
}
joinGameInProgress = false;
// delay the start a bit, so clients have more room to get messages // delay the start a bit, so clients have more room to get messages
// This is to ensure clients don't start ahead of the server and thus // This is to ensure clients don't start ahead of the server and thus
// constantly freeze because they are waiting for the server to catch up // constantly freeze because they are waiting for the server to catch up

View File

@ -49,6 +49,7 @@ private:
int gameSettingsReceivedCount; int gameSettingsReceivedCount;
time_t connectedTime; time_t connectedTime;
bool gotIntro; bool gotIntro;
bool joinGameInProgress;
Ip ip; Ip ip;
int port; int port;
@ -65,6 +66,8 @@ private:
Mutex *networkCommandListThreadAccessor; Mutex *networkCommandListThreadAccessor;
std::map<int,Commands> cachedPendingCommands; //commands ready to be given std::map<int,Commands> cachedPendingCommands; //commands ready to be given
uint64 cachedPendingCommandsIndex; uint64 cachedPendingCommandsIndex;
bool pausedForInGameJoin;
bool readyForInGameJoin;
public: public:
ClientInterface(); ClientInterface();
@ -74,6 +77,11 @@ public:
//virtual const Socket* getSocket() const {return clientSocket;} //virtual const Socket* getSocket() const {return clientSocket;}
virtual void close(); virtual void close();
bool getJoinGameInProgress() const { return joinGameInProgress; }
bool getPausedForInGameJoin() const { return pausedForInGameJoin; }
bool getReadyForInGameJoin() const { return readyForInGameJoin; }
//message processing //message processing
virtual void update(); virtual void update();
virtual void updateLobby(); virtual void updateLobby();

View File

@ -272,6 +272,8 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
this->lastReceiveCommandListTime = 0; this->lastReceiveCommandListTime = 0;
this->receivedNetworkGameStatus = false; this->receivedNetworkGameStatus = false;
this->canAcceptConnections = true; this->canAcceptConnections = true;
this->skipLagCheck = false;
this->joinGameInProgress = false;
this->setSocket(NULL); this->setSocket(NULL);
this->slotThreadWorker = NULL; this->slotThreadWorker = NULL;
@ -298,6 +300,7 @@ ConnectionSlot::~ConnectionSlot() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] START\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] START\n",__FILE__,__FUNCTION__,__LINE__);
//printf("Deleting connection slot\n");
close(); close();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -324,23 +327,44 @@ ConnectionSlot::~ConnectionSlot() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
} }
void ConnectionSlot::setReady() {
this->ready= true;
this->skipLagCheck = false;
this->joinGameInProgress = false;
}
void ConnectionSlot::updateSlot(ConnectionSlotEvent *event) { void ConnectionSlot::updateSlot(ConnectionSlotEvent *event) {
Chrono chrono; Chrono chrono;
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start(); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
if(serverInterface->getGameHasBeenInitiated() == true &&
serverInterface->getAllowInGameConnections() == true) {
//printf("Checking updateSlot event = %p\n",event);
}
if(event != NULL) { if(event != NULL) {
bool &socketTriggered = event->socketTriggered; bool &socketTriggered = event->socketTriggered;
bool checkForNewClients = (serverInterface->getGameHasBeenInitiated() == false); bool checkForNewClients =
(serverInterface->getGameHasBeenInitiated() == false ||
serverInterface->getAllowInGameConnections() == true);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] MUTEX LOCK held for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] MUTEX LOCK held for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
if(serverInterface->getGameHasBeenInitiated() == true &&
serverInterface->getAllowInGameConnections() == true) {
//printf("Checking for new client connection on slot, checkForNewClients: %d this->canAcceptConnections: %d\n",checkForNewClients,this->canAcceptConnections);
}
if((serverInterface->getGameHasBeenInitiated() == false || if((serverInterface->getGameHasBeenInitiated() == false ||
serverInterface->getAllowInGameConnections() == true ||
//(this->getSocket() != NULL && socketTriggered == true))) { //(this->getSocket() != NULL && socketTriggered == true))) {
socketTriggered == true)) { socketTriggered == true)) {
if(socketTriggered == true || if(socketTriggered == true ||
(serverInterface->getGameHasBeenInitiated() == false && this->isConnected() == false)) { ((serverInterface->getGameHasBeenInitiated() == false ||
serverInterface->getAllowInGameConnections() == true) &&
this->isConnected() == false)) {
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] MUTEX LOCK held for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] MUTEX LOCK held for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
@ -381,6 +405,11 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(networkGameDataSynchCheckOkTech) networkGameDataSynchCheckOkTech = false; if(networkGameDataSynchCheckOkTech) networkGameDataSynchCheckOkTech = false;
this->setReceivedDataSynchCheck(false); this->setReceivedDataSynchCheck(false);
if(serverInterface->getGameHasBeenInitiated() == true &&
serverInterface->getAllowInGameConnections() == true) {
//printf("Checking for new client connection on slot, checkForNewClients: %d this->canAcceptConnections: %d\n",checkForNewClients,this->canAcceptConnections);
}
// Is the listener socket ready to be read? // Is the listener socket ready to be read?
if(checkForNewClients == true && this->canAcceptConnections == true) { if(checkForNewClients == true && this->canAcceptConnections == true) {
@ -395,6 +424,11 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
if(serverInterface->getGameHasBeenInitiated() == true &&
serverInterface->getAllowInGameConnections() == true) {
//printf("Checking for new client connection on slot, hasData: %d\n",hasData);
}
if(hasData == true) { if(hasData == true) {
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
@ -451,8 +485,16 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex);
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
//if(serverInterface->getGameHasBeenInitiated() == true &&
// serverInterface->getAllowInGameConnections() == true) {
//printf("Got Client connection on slot!\n");
//}
} }
else { else {
//printf("Did not get new socket!\n");
close(); close();
return; return;
} }
@ -486,12 +528,15 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
nmgstNoSlots, nmgstNoSlots,
0, 0,
ServerSocket::getFTPServerPort(), ServerSocket::getFTPServerPort(),
""); "",
serverInterface->getGameHasBeenInitiated());
sendMessage(&networkMessageIntro); sendMessage(&networkMessageIntro);
//} //}
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
//printf("No open slots available\n");
close(); close();
} }
else { else {
@ -506,7 +551,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
nmgstOk, nmgstOk,
0, 0,
ServerSocket::getFTPServerPort(), ServerSocket::getFTPServerPort(),
""); "",
serverInterface->getGameHasBeenInitiated());
sendMessage(&networkMessageIntro); sendMessage(&networkMessageIntro);
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
@ -807,6 +853,18 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
NetworkMessageSynchNetworkGameData networkMessageSynchNetworkGameData(serverInterface->getGameSettings()); NetworkMessageSynchNetworkGameData networkMessageSynchNetworkGameData(serverInterface->getGameSettings());
sendMessage(&networkMessageSynchNetworkGameData); sendMessage(&networkMessageSynchNetworkGameData);
} }
if(serverInterface->getGameHasBeenInitiated() == true &&
serverInterface->getAllowInGameConnections() == true) {
//printf("Sent intro to client connection on slot!\n");
this->skipLagCheck = true;
this->joinGameInProgress = true;
serverInterface->setPauseForInGameConnection(true);
//printf("Got intro from client sending game settings..\n");
}
} }
} }
else { else {
@ -823,7 +881,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
{ {
if(gotIntro == true) { if(gotIntro == true) {
if(this->serverInterface->getGameSettings() == NULL || if(this->serverInterface->getGameSettings() == NULL ||
sessionKey != this->serverInterface->getGameSettings()->getMasterserver_admin()) { (joinGameInProgress == false && sessionKey != this->serverInterface->getGameSettings()->getMasterserver_admin())) {
string playerNameStr = name; string playerNameStr = name;
string sErr = "Client has invalid admin sessionid for player [" + playerNameStr + "]"; string sErr = "Client has invalid admin sessionid for player [" + playerNameStr + "]";
printf("%s\n",sErr.c_str()); printf("%s\n",sErr.c_str());
@ -837,6 +895,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(receiveMessage(&networkMessageLaunch)) { if(receiveMessage(&networkMessageLaunch)) {
if(networkMessageLaunch.getMessageType() == nmtLaunch) { if(networkMessageLaunch.getMessageType() == nmtLaunch) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtLaunch\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtLaunch\n",__FILE__,__FUNCTION__,__LINE__);
//printf("Got launch request from client joinGameInProgress = %d!\n",joinGameInProgress);
} }
else if(networkMessageLaunch.getMessageType() == nmtBroadCastSetup) { else if(networkMessageLaunch.getMessageType() == nmtBroadCastSetup) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtBroadCastSetup\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtBroadCastSetup\n",__FILE__,__FUNCTION__,__LINE__);
@ -850,7 +910,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
} }
int minHeadLessPlayersRequired = Config::getInstance().getInt("MinHeadlessPlayersRequired","2"); int minHeadLessPlayersRequired = Config::getInstance().getInt("MinHeadlessPlayersRequired","2");
if(networkMessageLaunch.getMessageType() == nmtLaunch && if(joinGameInProgress == false && networkMessageLaunch.getMessageType() == nmtLaunch &&
ready == false && ready == false &&
this->serverInterface->getConnectedSlotCount(true) < minHeadLessPlayersRequired) { this->serverInterface->getConnectedSlotCount(true) < minHeadLessPlayersRequired) {
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
@ -876,18 +936,33 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
} }
} }
else { else {
GameSettings gameSettingsBuffer; if(joinGameInProgress == false) {
networkMessageLaunch.buildGameSettings(&gameSettingsBuffer); GameSettings gameSettingsBuffer;
networkMessageLaunch.buildGameSettings(&gameSettingsBuffer);
//printf("Connection slot got networkMessageLaunch.getMessageType() = %d, got map [%s]\n",networkMessageLaunch.getMessageType(),gameSettings.getMap().c_str()); //printf("Connection slot got networkMessageLaunch.getMessageType() = %d, got map [%s]\n",networkMessageLaunch.getMessageType(),gameSettings.getMap().c_str());
//printf("\n\n\n\n=====Connection slot got settings:\n%s\n",gameSettings.toString().c_str()); //printf("\n\n\n\n=====Connection slot got settings:\n%s\n",gameSettings.toString().c_str());
//this->serverInterface->setGameSettings(&gameSettingsBuffer,false); //this->serverInterface->setGameSettings(&gameSettingsBuffer,false);
this->serverInterface->broadcastGameSetup(&gameSettingsBuffer, true); this->serverInterface->broadcastGameSetup(&gameSettingsBuffer, true);
}
if(networkMessageLaunch.getMessageType() == nmtLaunch) { if(joinGameInProgress == false && networkMessageLaunch.getMessageType() == nmtLaunch) {
this->serverInterface->setMasterserverAdminRequestLaunch(true); this->serverInterface->setMasterserverAdminRequestLaunch(true);
} }
else if(joinGameInProgress == true && networkMessageLaunch.getMessageType() == nmtLaunch) {
//printf("!!! setStartInGameConnectionLaunch for client joinGameInProgress = %d!\n",joinGameInProgress);
//GameSettings gameSettingsBuffer;
//networkMessageLaunch.buildGameSettings(&gameSettingsBuffer);
int factionIndex = this->serverInterface->gameSettings.getFactionIndexForStartLocation(playerIndex);
this->serverInterface->gameSettings.setFactionControl(factionIndex,ctNetwork);
this->serverInterface->gameSettings.setNetworkPlayerName(factionIndex,this->name);
this->serverInterface->broadcastGameSetup(&this->serverInterface->gameSettings, true);
this->serverInterface->setStartInGameConnectionLaunch(true);
}
} }
} }
else { else {
@ -1141,7 +1216,25 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
} }
case nmtReady: case nmtReady:
{ {
NetworkMessageReady networkMessageReady;
this->receiveMessage(&networkMessageReady);
// its simply ignored here. Probably we are starting a game // its simply ignored here. Probably we are starting a game
//printf("Got ready message from client slot joinGameInProgress = %d\n",joinGameInProgress);
if(joinGameInProgress == true) {
NetworkMessageReady networkMessageReady(0);
this->sendMessage(&networkMessageReady);
this->currentFrameCount = serverInterface->getCurrentFrameCount();
this->currentLagCount = 0;
this->lastReceiveCommandListTime = time(NULL);
this->setReady();
}
// unpause the game
else {
serverInterface->setUnPauseForInGameConnection(true);
}
break; break;
} }
case nmtLoadingStatusMessage: case nmtLoadingStatusMessage:
@ -1177,7 +1270,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(this->serverInterface->getGameStartTime() > 0 && if(this->serverInterface->getGameStartTime() > 0 &&
difftime((long int)time(NULL),this->serverInterface->getGameStartTime()) >= LAG_CHECK_GRACE_PERIOD) { difftime((long int)time(NULL),this->serverInterface->getGameStartTime()) >= LAG_CHECK_GRACE_PERIOD) {
if(this->isConnected() == true) { if(this->isConnected() == true && this->gotIntro == true && this->skipLagCheck == false) {
double clientLag = this->serverInterface->getCurrentFrameCount() - this->getCurrentFrameCount(); double clientLag = this->serverInterface->getCurrentFrameCount() - this->getCurrentFrameCount();
double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0); double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0);
double clientLagTime = difftime((long int)time(NULL),this->getLastReceiveCommandListTime()); double clientLagTime = difftime((long int)time(NULL),this->getLastReceiveCommandListTime());
@ -1213,6 +1306,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
else { else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] calling close...\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] calling close...\n",__FILE__,__FUNCTION__,__LINE__);
//printf("Closing connection slot socketInfo.first = %d\n",socketInfo.first);
close(); close();
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
@ -1237,6 +1332,8 @@ void ConnectionSlot::validateConnection() {
if(this->isConnected() == true && if(this->isConnected() == true &&
gotIntro == false && connectedTime > 0 && gotIntro == false && connectedTime > 0 &&
difftime((long int)time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) { difftime((long int)time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) {
//printf("Closing connection slot timed out!\n");
close(); close();
} }
} }
@ -1244,6 +1341,15 @@ void ConnectionSlot::validateConnection() {
void ConnectionSlot::close() { void ConnectionSlot::close() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//if(serverInterface->getAllowInGameConnections() == true) {
//printf("Closing connection slot!\n");
//}
this->gotIntro = false;
this->skipLagCheck = false;
this->joinGameInProgress = false;
this->ready= true;
if(this->slotThreadWorker != NULL) { if(this->slotThreadWorker != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
this->slotThreadWorker->setAllEventsCompleted(); this->slotThreadWorker->setAllEventsCompleted();

View File

@ -122,6 +122,8 @@ private:
bool receivedNetworkGameStatus; bool receivedNetworkGameStatus;
time_t connectedTime; time_t connectedTime;
bool gotIntro; bool gotIntro;
bool skipLagCheck;
bool joinGameInProgress;
Mutex *mutexCloseConnection; Mutex *mutexCloseConnection;
@ -144,6 +146,9 @@ public:
ConnectionSlot(ServerInterface* serverInterface, int playerIndex); ConnectionSlot(ServerInterface* serverInterface, int playerIndex);
~ConnectionSlot(); ~ConnectionSlot();
bool getSkipLagCheck() const { return skipLagCheck; }
bool getJoinGameInProgress() const { return joinGameInProgress; }
ConnectionSlotThread *getWorkerThread() { return slotThreadWorker; } ConnectionSlotThread *getWorkerThread() { return slotThreadWorker; }
void update(bool checkForNewClients,int lockedSlotIndex); void update(bool checkForNewClients,int lockedSlotIndex);
@ -152,7 +157,7 @@ public:
uint32 getConnectedRemoteIPAddress() const { return connectedRemoteIPAddress; } uint32 getConnectedRemoteIPAddress() const { return connectedRemoteIPAddress; }
void setReady() {ready= true;} void setReady();
const string &getName() const {return name;} const string &getName() const {return name;}
void setName(string value) {name = value;} void setName(string value) {name = value;}
bool isReady() const {return ready;} bool isReady() const {return ready;}

View File

@ -111,6 +111,7 @@ NetworkMessageIntro::NetworkMessageIntro() {
data.gameState = nmgstInvalid; data.gameState = nmgstInvalid;
data.externalIp = 0; data.externalIp = 0;
data.ftpPort = 0; data.ftpPort = 0;
data.gameInProgress = 0;
} }
NetworkMessageIntro::NetworkMessageIntro(int32 sessionId,const string &versionString, NetworkMessageIntro::NetworkMessageIntro(int32 sessionId,const string &versionString,
@ -118,7 +119,8 @@ NetworkMessageIntro::NetworkMessageIntro(int32 sessionId,const string &versionSt
NetworkGameStateType gameState, NetworkGameStateType gameState,
uint32 externalIp, uint32 externalIp,
uint32 ftpPort, uint32 ftpPort,
const string &playerLanguage) { const string &playerLanguage,
int gameInProgress) {
data.messageType = nmtIntro; data.messageType = nmtIntro;
data.sessionId = sessionId; data.sessionId = sessionId;
data.versionString = versionString; data.versionString = versionString;
@ -128,10 +130,11 @@ NetworkMessageIntro::NetworkMessageIntro(int32 sessionId,const string &versionSt
data.externalIp = externalIp; data.externalIp = externalIp;
data.ftpPort = ftpPort; data.ftpPort = ftpPort;
data.language = playerLanguage; data.language = playerLanguage;
data.gameInProgress = gameInProgress;
} }
const char * NetworkMessageIntro::getPackedMessageFormat() const { const char * NetworkMessageIntro::getPackedMessageFormat() const {
return "cl128s32shcLL60s"; return "cl128s32shcLL60sc";
} }
unsigned int NetworkMessageIntro::getPackedSize() { unsigned int NetworkMessageIntro::getPackedSize() {
@ -148,7 +151,8 @@ unsigned int NetworkMessageIntro::getPackedSize() {
packedData.gameState, packedData.gameState,
packedData.externalIp, packedData.externalIp,
packedData.ftpPort, packedData.ftpPort,
packedData.language.getBuffer()); packedData.language.getBuffer(),
data.gameInProgress);
delete [] buf; delete [] buf;
} }
return result; return result;
@ -164,7 +168,8 @@ void NetworkMessageIntro::unpackMessage(unsigned char *buf) {
&data.gameState, &data.gameState,
&data.externalIp, &data.externalIp,
&data.ftpPort, &data.ftpPort,
data.language.getBuffer()); data.language.getBuffer(),
&data.gameInProgress);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] unpacked data:\n%s\n",__FUNCTION__,this->toString().c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s] unpacked data:\n%s\n",__FUNCTION__,this->toString().c_str());
} }
@ -181,7 +186,8 @@ unsigned char * NetworkMessageIntro::packMessage() {
data.gameState, data.gameState,
data.externalIp, data.externalIp,
data.ftpPort, data.ftpPort,
data.language.getBuffer()); data.language.getBuffer(),
data.gameInProgress);
return buf; return buf;
} }
@ -195,6 +201,7 @@ string NetworkMessageIntro::toString() const {
result += " externalIp = " + uIntToStr(data.externalIp); result += " externalIp = " + uIntToStr(data.externalIp);
result += " ftpPort = " + uIntToStr(data.ftpPort); result += " ftpPort = " + uIntToStr(data.ftpPort);
result += " language = " + data.language.getString(); result += " language = " + data.language.getString();
result += " gameInProgress = " + uIntToStr(data.gameInProgress);
return result; return result;
} }
@ -246,6 +253,8 @@ void NetworkMessageIntro::toEndian() {
data.gameState = Shared::PlatformByteOrder::toCommonEndian(data.gameState); data.gameState = Shared::PlatformByteOrder::toCommonEndian(data.gameState);
data.externalIp = Shared::PlatformByteOrder::toCommonEndian(data.externalIp); data.externalIp = Shared::PlatformByteOrder::toCommonEndian(data.externalIp);
data.ftpPort = Shared::PlatformByteOrder::toCommonEndian(data.ftpPort); data.ftpPort = Shared::PlatformByteOrder::toCommonEndian(data.ftpPort);
data.gameInProgress = Shared::PlatformByteOrder::toCommonEndian(data.gameInProgress);
} }
} }
void NetworkMessageIntro::fromEndian() { void NetworkMessageIntro::fromEndian() {
@ -257,6 +266,8 @@ void NetworkMessageIntro::fromEndian() {
data.gameState = Shared::PlatformByteOrder::fromCommonEndian(data.gameState); data.gameState = Shared::PlatformByteOrder::fromCommonEndian(data.gameState);
data.externalIp = Shared::PlatformByteOrder::fromCommonEndian(data.externalIp); data.externalIp = Shared::PlatformByteOrder::fromCommonEndian(data.externalIp);
data.ftpPort = Shared::PlatformByteOrder::fromCommonEndian(data.ftpPort); data.ftpPort = Shared::PlatformByteOrder::fromCommonEndian(data.ftpPort);
data.gameInProgress = Shared::PlatformByteOrder::fromCommonEndian(data.gameInProgress);
} }
} }

View File

@ -110,6 +110,7 @@ private:
uint32 externalIp; uint32 externalIp;
uint32 ftpPort; uint32 ftpPort;
NetworkString<maxLanguageStringSize> language; NetworkString<maxLanguageStringSize> language;
int8 gameInProgress;
}; };
void toEndian(); void toEndian();
void fromEndian(); void fromEndian();
@ -123,7 +124,8 @@ public:
NetworkMessageIntro(); NetworkMessageIntro();
NetworkMessageIntro(int32 sessionId, const string &versionString, NetworkMessageIntro(int32 sessionId, const string &versionString,
const string &name, int playerIndex, NetworkGameStateType gameState, const string &name, int playerIndex, NetworkGameStateType gameState,
uint32 externalIp, uint32 ftpPort, const string &playerLanguage); uint32 externalIp, uint32 ftpPort, const string &playerLanguage,
int gameInProgress);
virtual const char * getPackedMessageFormat() const; virtual const char * getPackedMessageFormat() const;
@ -142,6 +144,7 @@ public:
uint32 getExternalIp() const { return data.externalIp;} uint32 getExternalIp() const { return data.externalIp;}
uint32 getFtpPort() const { return data.ftpPort; } uint32 getFtpPort() const { return data.ftpPort; }
string getPlayerLanguage() const { return data.language.getString(); } string getPlayerLanguage() const { return data.language.getString(); }
uint8 getGameInProgress() const { return data.gameInProgress; }
virtual bool receive(Socket* socket); virtual bool receive(Socket* socket);
virtual void send(Socket* socket); virtual void send(Socket* socket);

View File

@ -51,6 +51,10 @@ const int MASTERSERVER_HEARTBEAT_GAME_STATUS_SECONDS = 30;
ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() { ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
allowInGameConnections = false;
pauseForInGameConnection = false;
unPauseForInGameConnection = false;
serverSynchAccessor = new Mutex(); serverSynchAccessor = new Mutex();
for(int i= 0; i < GameConstants::maxPlayers; ++i) { for(int i= 0; i < GameConstants::maxPlayers; ++i) {
slotAccessorMutexes[i] = new Mutex(); slotAccessorMutexes[i] = new Mutex();
@ -74,6 +78,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
inBroadcastMessage = false; inBroadcastMessage = false;
lastGlobalLagCheckTime = 0; lastGlobalLagCheckTime = 0;
masterserverAdminRequestLaunch = false; masterserverAdminRequestLaunch = false;
startInGameConnectionLaunch = false;
// This is an admin port listening only on the localhost intended to // This is an admin port listening only on the localhost intended to
// give current connection status info // give current connection status info
@ -196,10 +201,24 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
bool allowInternetTilesetFileTransfers = Config::getInstance().getBool("EnableFTPServerInternetTilesetXfer","true"); bool allowInternetTilesetFileTransfers = Config::getInstance().getBool("EnableFTPServerInternetTilesetXfer","true");
bool allowInternetTechtreeFileTransfers = Config::getInstance().getBool("EnableFTPServerInternetTechtreeXfer","true"); bool allowInternetTechtreeFileTransfers = Config::getInstance().getBool("EnableFTPServerInternetTechtreeXfer","true");
// Get path to temp files
string tempFilePath = "temp/";
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
tempFilePath = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + tempFilePath;
}
else {
string userData = config.getString("UserData_Root","");
if(userData != "") {
endPathWithSlash(userData);
}
tempFilePath = userData + tempFilePath;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Temp files path [%s]\n",tempFilePath.c_str());
ftpServer = new FTPServerThread(mapsPath,tilesetsPath,techtreesPath, ftpServer = new FTPServerThread(mapsPath,tilesetsPath,techtreesPath,
publishEnabled, publishEnabled,allowInternetTilesetFileTransfers,
allowInternetTilesetFileTransfers, allowInternetTechtreeFileTransfers, allowInternetTechtreeFileTransfers,portNumber,GameConstants::maxPlayers,
portNumber,GameConstants::maxPlayers,this); this,tempFilePath);
ftpServer->start(); ftpServer->start();
} }
@ -466,6 +485,9 @@ bool ServerInterface::switchSlot(int fromPlayerIndex, int toPlayerIndex) {
} }
void ServerInterface::removeSlot(int playerIndex, int lockedSlotIndex) { void ServerInterface::removeSlot(int playerIndex, int lockedSlotIndex) {
//printf("Removing connection slot!\n");
Lang &lang= Lang::getInstance(); 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); 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 safeMutex(serverSynchAccessor,CODE_AT_LINE);
@ -683,7 +705,9 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
// } // }
// } // }
if(alreadyInLagCheck == true) { if(alreadyInLagCheck == true ||
(connectionSlot != NULL && (connectionSlot->getSkipLagCheck() == true ||
connectionSlot->getConnectHasHandshaked() == false))) {
return clientLagExceededOrWarned; return clientLagExceededOrWarned;
} }
@ -768,6 +792,8 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
if(gameSettings.getNetworkPauseGameForLaggedClients() == false || if(gameSettings.getNetworkPauseGameForLaggedClients() == false ||
(maxFrameCountLagAllowedEver > 0 && clientLagCount > maxFrameCountLagAllowedEver) || (maxFrameCountLagAllowedEver > 0 && clientLagCount > maxFrameCountLagAllowedEver) ||
(maxClientLagTimeAllowedEver > 0 && clientLagTime > maxClientLagTimeAllowedEver)) { (maxClientLagTimeAllowedEver > 0 && clientLagTime > maxClientLagTimeAllowedEver)) {
//printf("Closing connection slot lagged out!\n");
connectionSlot->close(); connectionSlot->close();
} }
@ -841,6 +867,10 @@ void ServerInterface::updateSocketTriggeredList(std::map<PLATFORM_SOCKET,bool> &
if(Socket::isSocketValid(&clientSocket) == true) { if(Socket::isSocketValid(&clientSocket) == true) {
socketTriggeredList[clientSocket] = false; socketTriggeredList[clientSocket] = false;
} }
else if(this->getGameHasBeenInitiated() == true &&
this->getAllowInGameConnections() == true) {
socketTriggeredList[clientSocket] = false;
}
} }
} }
} }
@ -879,6 +909,8 @@ void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool>
std::map<int,ConnectionSlotEvent> &eventList, std::map<int,ConnectionSlotEvent> &eventList,
std::map<int,bool> & mapSlotSignalledList) { std::map<int,bool> & mapSlotSignalledList) {
//printf("====================================In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //printf("====================================In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//printf("Signal clients get new data\n");
const bool newThreadManager = Config::getInstance().getBool("EnableNewThreadManager","false"); const bool newThreadManager = Config::getInstance().getBool("EnableNewThreadManager","false");
if(newThreadManager == true) { if(newThreadManager == true) {
masterController.clearSlaves(true); masterController.clearSlaves(true);
@ -894,6 +926,11 @@ void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool>
if(Socket::isSocketValid(&clientSocket)) { if(Socket::isSocketValid(&clientSocket)) {
socketTriggered = socketTriggeredList[clientSocket]; socketTriggered = socketTriggeredList[clientSocket];
} }
else if(this->getGameHasBeenInitiated() == true &&
this->getAllowInGameConnections() == true) {
socketTriggeredList[clientSocket] = true;
socketTriggered = socketTriggeredList[clientSocket];
}
} }
ConnectionSlotEvent &event = eventList[i]; ConnectionSlotEvent &event = eventList[i];
event.eventType = eReceiveSocketData; event.eventType = eReceiveSocketData;
@ -927,6 +964,11 @@ void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool>
if(Socket::isSocketValid(&clientSocket)) { if(Socket::isSocketValid(&clientSocket)) {
socketTriggered = socketTriggeredList[clientSocket]; socketTriggered = socketTriggeredList[clientSocket];
} }
else if(this->getGameHasBeenInitiated() == true &&
this->getAllowInGameConnections() == true) {
socketTriggeredList[clientSocket] = true;
socketTriggered = socketTriggeredList[clientSocket];
}
} }
ConnectionSlotEvent &event = eventList[i]; ConnectionSlotEvent &event = eventList[i];
mapSlotSignalledList[i] = signalClientReceiveCommands(connectionSlot,i,socketTriggered,event); mapSlotSignalledList[i] = signalClientReceiveCommands(connectionSlot,i,socketTriggered,event);
@ -1369,17 +1411,24 @@ void ServerInterface::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
if(gameHasBeenInitiated == false || socketTriggeredList.empty() == false) { if(gameHasBeenInitiated == false ||
this->getAllowInGameConnections() == true ||
socketTriggeredList.empty() == false) {
//printf("\nServerInterface::update -- E\n"); //printf("\nServerInterface::update -- E\n");
std::map<int,ConnectionSlotEvent> eventList; std::map<int,ConnectionSlotEvent> eventList;
bool hasData = Socket::hasDataToRead(socketTriggeredList); bool hasData = Socket::hasDataToRead(socketTriggeredList);
if(this->getGameHasBeenInitiated() == true &&
this->getAllowInGameConnections() == true) {
//printf("Checking for new client connections socketTriggeredList.size(): %d hasData: %d\n",socketTriggeredList.size(),hasData);
}
if(hasData) if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] hasData == true\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__); if(hasData) if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] hasData == true\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
if(gameHasBeenInitiated == false || hasData == true) { if(gameHasBeenInitiated == false || hasData == true || this->getAllowInGameConnections() == true) {
std::map<int,bool> mapSlotSignalledList; std::map<int,bool> mapSlotSignalledList;
// Step #1 tell all connection slot worker threads to receive socket data // Step #1 tell all connection slot worker threads to receive socket data
@ -2101,20 +2150,37 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) {
if(useInGameBlockingClientSockets == true) { if(useInGameBlockingClientSockets == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
for(int i= 0; i < GameConstants::maxPlayers; ++i) { for(int i= 0; i < GameConstants::maxPlayers; ++i) {
int factionIndex = gameSettings->getFactionIndexForStartLocation(i);
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i)); MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
ConnectionSlot *connectionSlot= slots[i]; ConnectionSlot *connectionSlot= slots[i];
if(connectionSlot != NULL && connectionSlot->isConnected()) { if(connectionSlot != NULL && connectionSlot->isConnected()) {
connectionSlot->getSocket()->setBlock(true); connectionSlot->getSocket()->setBlock(true);
} }
// Open slots for joining in progress game
else if(gameSettings->getFactionControl(factionIndex) != ctClosed && gameSettings->getFactionControl(factionIndex) != ctHuman) {
if(allowInGameConnections == true) {
//printf("Opening slot for in game connections for slot: %d, faction: %d\n",i,factionIndex);
if(connectionSlot == NULL) {
addSlot(i);
connectionSlot = slots[i];
}
connectionSlot->setCanAcceptConnections(true);
}
}
} }
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] needToRepublishToMasterserver = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,needToRepublishToMasterserver); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] needToRepublishToMasterserver = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,needToRepublishToMasterserver);
serverSocket.stopBroadCastThread(); if(allowInGameConnections == false) {
serverSocket.stopBroadCastThread();
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] needToRepublishToMasterserver = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,needToRepublishToMasterserver); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] needToRepublishToMasterserver = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,needToRepublishToMasterserver);
this->gameSettings = *gameSettings;
//printf("#1 Data synch: lmap %u ltile: %d ltech: %u\n",gameSettings->getMapCRC(),gameSettings->getTilesetCRC(),gameSettings->getTechCRC());
NetworkMessageLaunch networkMessageLaunch(gameSettings,nmtLaunch); NetworkMessageLaunch networkMessageLaunch(gameSettings,nmtLaunch);
broadcastMessage(&networkMessageLaunch); broadcastMessage(&networkMessageLaunch);
@ -2126,10 +2192,12 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ftpServer = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ftpServer); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ftpServer = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ftpServer);
if(ftpServer != NULL) { if(allowInGameConnections == false) {
ftpServer->shutdownAndWait(); if(ftpServer != NULL) {
delete ftpServer; ftpServer->shutdownAndWait();
ftpServer = NULL; delete ftpServer;
ftpServer = NULL;
}
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] needToRepublishToMasterserver = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,needToRepublishToMasterserver); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] needToRepublishToMasterserver = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,needToRepublishToMasterserver);
@ -2145,10 +2213,12 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) {
} }
} }
if(ftpServer != NULL) { if(allowInGameConnections == false) {
ftpServer->shutdownAndWait(); if(ftpServer != NULL) {
delete ftpServer; ftpServer->shutdownAndWait();
ftpServer = NULL; delete ftpServer;
ftpServer = NULL;
}
} }
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -2205,7 +2275,11 @@ void ServerInterface::broadcastMessage(NetworkMessage *networkMessage, int exclu
if(gameHasBeenInitiated == true && connectionSlot->isConnected() == false) { if(gameHasBeenInitiated == true && connectionSlot->isConnected() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 before removeSlot for slot# %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 before removeSlot for slot# %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i);
//safeMutexSlot.ReleaseLock(); //safeMutexSlot.ReleaseLock();
removeSlot(i,i);
if(this->getAllowInGameConnections() == false) {
//printf("Removing connection slot from broadcastMessage #1!\n");
removeSlot(i,i);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 after removeSlot for slot# %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 after removeSlot for slot# %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i);
} }
} }
@ -2213,7 +2287,11 @@ void ServerInterface::broadcastMessage(NetworkMessage *networkMessage, int exclu
connectionSlot != NULL && connectionSlot->isConnected() == false) { connectionSlot != NULL && connectionSlot->isConnected() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 before removeSlot for slot# %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 before removeSlot for slot# %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i);
//safeMutexSlot.ReleaseLock(); //safeMutexSlot.ReleaseLock();
removeSlot(i,i);
if(this->getAllowInGameConnections() == false) {
//printf("Removing connection slot from broadcastMessage #2!\n");
removeSlot(i,i);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 after removeSlot for slot# %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 after removeSlot for slot# %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i);
} }
} }
@ -2258,7 +2336,10 @@ void ServerInterface::broadcastMessageToConnectedClients(NetworkMessage *network
} }
void ServerInterface::updateListen() { void ServerInterface::updateListen() {
if(gameHasBeenInitiated == true){ //if(this->getAllowInGameConnections() == true) {
//printf("updateListen() #1!\n");
//}
if(gameHasBeenInitiated == true && this->getAllowInGameConnections() == false) {
return; return;
} }
int openSlotCount = 0; int openSlotCount = 0;
@ -2271,6 +2352,10 @@ void ServerInterface::updateListen() {
} }
} }
//if(this->getAllowInGameConnections() == true) {
//printf("updateListen() #2: %d!\n",openSlotCount);
//}
serverSocket.listen(openSlotCount); serverSocket.listen(openSlotCount);
} }
@ -2737,6 +2822,10 @@ void ServerInterface::notifyBadClientConnectAttempt(string ipAddress) {
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(this->getAllowInGameConnections() == true) {
printf("notifyBadClientConnectAttempt() #1: %s!\n",ipAddress.c_str());
}
if(addToBlockedClientsList == true) { if(addToBlockedClientsList == true) {
serverSocket.addIPAddressToBlockedList(ipAddress); serverSocket.addIPAddressToBlockedList(ipAddress);
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);

View File

@ -95,6 +95,11 @@ private:
ServerSocket *serverSocketAdmin; ServerSocket *serverSocketAdmin;
MasterSlaveThreadController masterController; MasterSlaveThreadController masterController;
bool allowInGameConnections;
bool pauseForInGameConnection;
bool startInGameConnectionLaunch;
bool unPauseForInGameConnection;
public: public:
ServerInterface(bool publishEnabled); ServerInterface(bool publishEnabled);
virtual ~ServerInterface(); virtual ~ServerInterface();
@ -107,6 +112,18 @@ public:
time_t getGameStartTime() const { return gameStartTime; } time_t getGameStartTime() const { return gameStartTime; }
bool getAllowInGameConnections() const { return allowInGameConnections; }
void setAllowInGameConnections(bool value) { allowInGameConnections = value; }
bool getStartInGameConnectionLaunch() const { return startInGameConnectionLaunch; }
void setStartInGameConnectionLaunch(bool value) { startInGameConnectionLaunch = value; }
bool getPauseForInGameConnection() const { return pauseForInGameConnection; }
void setPauseForInGameConnection(bool value) { pauseForInGameConnection = value; }
bool getUnPauseForInGameConnection() const { return unPauseForInGameConnection; }
void setUnPauseForInGameConnection(bool value) { unPauseForInGameConnection = value; }
virtual void close(); virtual void close();
virtual void update(); virtual void update();
virtual void updateLobby() { }; virtual void updateLobby() { };
@ -223,8 +240,10 @@ public:
virtual void saveGame(XmlNode *rootNode); virtual void saveGame(XmlNode *rootNode);
private:
void broadcastMessage(NetworkMessage *networkMessage, int excludeSlot = -1, int lockedSlotIndex = -1); void broadcastMessage(NetworkMessage *networkMessage, int excludeSlot = -1, int lockedSlotIndex = -1);
private:
void broadcastMessageToConnectedClients(NetworkMessage *networkMessage, int excludeSlot = -1); void broadcastMessageToConnectedClients(NetworkMessage *networkMessage, int excludeSlot = -1);
bool shouldDiscardNetworkMessage(NetworkMessageType networkMessageType, ConnectionSlot *connectionSlot); bool shouldDiscardNetworkMessage(NetworkMessageType networkMessageType, ConnectionSlot *connectionSlot);
void updateSlot(ConnectionSlotEvent *event); void updateSlot(ConnectionSlotEvent *event);
@ -244,7 +263,6 @@ protected:
void dispatchPendingUnMarkCellMessages(std::vector <string> &errorMsgList); void dispatchPendingUnMarkCellMessages(std::vector <string> &errorMsgList);
void dispatchPendingHighlightCellMessages(std::vector <string> &errorMsgList); void dispatchPendingHighlightCellMessages(std::vector <string> &errorMsgList);
void shutdownMasterserverPublishThread(); void shutdownMasterserverPublishThread();
}; };

View File

@ -2108,6 +2108,8 @@ void Faction::loadGame(const XmlNode *rootNode, int factionIndex,GameSettings *s
thisFaction = factionNode->getAttribute("thisFaction")->getIntValue() != 0; thisFaction = factionNode->getAttribute("thisFaction")->getIntValue() != 0;
// bool factionDisconnectHandled; // bool factionDisconnectHandled;
//printf("**LOAD FACTION thisFaction = %d\n",thisFaction);
// for(std::map<Vec2i,int>::iterator iterMap = cacheResourceTargetList.begin(); // for(std::map<Vec2i,int>::iterator iterMap = cacheResourceTargetList.begin();
// iterMap != cacheResourceTargetList.end(); ++iterMap) { // iterMap != cacheResourceTargetList.end(); ++iterMap) {
// XmlNode *cacheResourceTargetListNode = factionNode->addChild("cacheResourceTargetList"); // XmlNode *cacheResourceTargetListNode = factionNode->addChild("cacheResourceTargetList");

View File

@ -3064,6 +3064,8 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
} }
else { else {
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailUndefined; result.first = crFailUndefined;
return result; return result;
} }
@ -3072,6 +3074,8 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
//if pos is not inside the world (if comand has not a pos, pos is (0, 0) and is inside world //if pos is not inside the world (if comand has not a pos, pos is (0, 0) and is inside world
if(map->isInside(command->getPos()) == false) { if(map->isInside(command->getPos()) == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__, __LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__, __LINE__);
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailUndefined; result.first = crFailUndefined;
return result; return result;
} }
@ -3086,6 +3090,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
const ProducibleType *produced= command->getCommandType()->getProduced(); const ProducibleType *produced= command->getCommandType()->getProduced();
if(produced != NULL) { if(produced != NULL) {
if(ignoreCheckCommand == false && faction->reqsOk(produced) == false) { if(ignoreCheckCommand == false && faction->reqsOk(produced) == false) {
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
//printf("To produce this unit you need:\n%s\n",produced->getUnitAndUpgradeReqDesc().c_str()); //printf("To produce this unit you need:\n%s\n",produced->getUnitAndUpgradeReqDesc().c_str());
result.first = crFailReqs; result.first = crFailReqs;
@ -3097,6 +3102,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
if(ignoreCheckCommand == false && if(ignoreCheckCommand == false &&
faction->checkCosts(produced,command->getCommandType()) == false) { faction->checkCosts(produced,command->getCommandType()) == false) {
//printf("To produce this unit you need:\n%s\n",produced->getResourceReqDesc().c_str()); //printf("To produce this unit you need:\n%s\n",produced->getResourceReqDesc().c_str());
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailRes; result.first = crFailRes;
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
result.second = " - " + lang.get("Reqs") + " : " + produced->getResourceReqDesc(false); result.second = " - " + lang.get("Reqs") + " : " + produced->getResourceReqDesc(false);
@ -3116,6 +3122,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
if(faction->reqsOk(builtUnit) == false) { if(faction->reqsOk(builtUnit) == false) {
//printf("To build this unit you need:\n%s\n",builtUnit->getUnitAndUpgradeReqDesc().c_str()); //printf("To build this unit you need:\n%s\n",builtUnit->getUnitAndUpgradeReqDesc().c_str());
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailReqs; result.first = crFailReqs;
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getUnitAndUpgradeReqDesc(false); result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getUnitAndUpgradeReqDesc(false);
@ -3123,6 +3130,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
} }
if(faction->checkCosts(builtUnit,NULL) == false) { if(faction->checkCosts(builtUnit,NULL) == false) {
//printf("To build this unit you need:\n%s\n",builtUnit->getResourceReqDesc().c_str()); //printf("To build this unit you need:\n%s\n",builtUnit->getResourceReqDesc().c_str());
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailRes; result.first = crFailRes;
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getResourceReqDesc(false); result.second = " - " + lang.get("Reqs") + " : " + builtUnit->getResourceReqDesc(false);
@ -3141,6 +3149,7 @@ std::pair<CommandResult,string> Unit::checkCommand(Command *command) const {
if(faction->getUpgradeManager()->isUpgradingOrUpgraded(uct->getProducedUpgrade())){ if(faction->getUpgradeManager()->isUpgradingOrUpgraded(uct->getProducedUpgrade())){
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__, __LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__, __LINE__);
//printf("In [%s::%s Line: %d] command = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,command);
result.first = crFailUndefined; result.first = crFailUndefined;
return result; return result;
} }

View File

@ -1731,6 +1731,8 @@ void World::initFactionTypes(GameSettings *gs) {
} }
//create stats //create stats
//printf("World gs->getThisFactionIndex() = %d\n",gs->getThisFactionIndex());
stats.init(gs->getFactionCount(), gs->getThisFactionIndex(), gs->getDescription(),gs->getTech()); stats.init(gs->getFactionCount(), gs->getThisFactionIndex(), gs->getDescription(),gs->getTech());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -1784,6 +1786,8 @@ void World::initFactionTypes(GameSettings *gs) {
// int frameCount; // int frameCount;
frameCount = loadWorldNode->getAttribute("frameCount")->getIntValue(); frameCount = loadWorldNode->getAttribute("frameCount")->getIntValue();
//printf("**LOAD World thisFactionIndex = %d\n",thisFactionIndex);
MutexSafeWrapper safeMutex(&mutexFactionNextUnitId,string(__FILE__) + "_" + intToStr(__LINE__)); MutexSafeWrapper safeMutex(&mutexFactionNextUnitId,string(__FILE__) + "_" + intToStr(__LINE__));
// std::map<int,int> mapFactionNextUnitId; // std::map<int,int> mapFactionNextUnitId;
// for(std::map<int,int>::iterator iterMap = mapFactionNextUnitId.begin(); // for(std::map<int,int>::iterator iterMap = mapFactionNextUnitId.begin();

View File

@ -40,8 +40,9 @@ enum FTP_Client_CallbackType {
ftp_cct_Techtree = 2, ftp_cct_Techtree = 2,
ftp_cct_Scenario = 3, ftp_cct_Scenario = 3,
ftp_cct_File = 4, ftp_cct_File = 4,
ftp_cct_DownloadProgress = 5, ftp_cct_TempFile = 5,
ftp_cct_ExtractProgress = 6 ftp_cct_DownloadProgress = 6,
ftp_cct_ExtractProgress = 7
}; };
class FTPClientCallbackInterface { class FTPClientCallbackInterface {
@ -72,6 +73,7 @@ protected:
std::pair<string,string> tilesetsPath; std::pair<string,string> tilesetsPath;
std::pair<string,string> techtreesPath; std::pair<string,string> techtreesPath;
std::pair<string,string> scenariosPath; std::pair<string,string> scenariosPath;
string tempFilesPath;
Mutex mutexMapFileList; Mutex mutexMapFileList;
vector<pair<string,string> > mapFileList; vector<pair<string,string> > mapFileList;
@ -88,6 +90,9 @@ protected:
Mutex mutexFileList; Mutex mutexFileList;
vector<pair<string,string> > fileList; vector<pair<string,string> > fileList;
Mutex mutexTempFileList;
vector<pair<string,string> > tempFileList;
void getMapFromServer(pair<string,string> mapFilename); void getMapFromServer(pair<string,string> mapFilename);
pair<FTP_Client_ResultType,string> getMapFromServer(pair<string,string> mapFileName, string ftpUser, string ftpUserPassword); pair<FTP_Client_ResultType,string> getMapFromServer(pair<string,string> mapFileName, string ftpUser, string ftpUserPassword);
@ -103,6 +108,9 @@ protected:
void getFileFromServer(pair<string,string> fileName); void getFileFromServer(pair<string,string> fileName);
pair<FTP_Client_ResultType,string> getFileInternalFromServer(pair<string,string> fileName); pair<FTP_Client_ResultType,string> getFileInternalFromServer(pair<string,string> fileName);
void getTempFileFromServer(pair<string,string> fileName);
pair<FTP_Client_ResultType,string> getTempFileInternalFromServer(pair<string,string> fileName);
Mutex mutexProgressMutex; Mutex mutexProgressMutex;
string fileArchiveExtension; string fileArchiveExtension;
@ -130,7 +138,8 @@ public:
string fileArchiveExtension, string fileArchiveExtension,
string fileArchiveExtractCommand, string fileArchiveExtractCommand,
string fileArchiveExtractCommandParameters, string fileArchiveExtractCommandParameters,
int fileArchiveExtractCommandSuccessResult); int fileArchiveExtractCommandSuccessResult,
string tempFilesPath);
virtual void execute(); virtual void execute();
virtual void signalQuit(); virtual void signalQuit();
virtual bool shutdownAndWait(); virtual bool shutdownAndWait();
@ -140,6 +149,7 @@ public:
void addTechtreeToRequests(string techtreeName,string URL=""); void addTechtreeToRequests(string techtreeName,string URL="");
void addScenarioToRequests(string fileName,string URL=""); void addScenarioToRequests(string fileName,string URL="");
void addFileToRequests(string fileName,string URL=""); void addFileToRequests(string fileName,string URL="");
void addTempFileToRequests(string fileName,string URL="");
FTPClientCallbackInterface * getCallBackObject(); FTPClientCallbackInterface * getCallBackObject();
void setCallBackObject(FTPClientCallbackInterface *value); void setCallBackObject(FTPClientCallbackInterface *value);

View File

@ -39,6 +39,7 @@ protected:
std::pair<string,string> mapsPath; std::pair<string,string> mapsPath;
std::pair<string,string> tilesetsPath; std::pair<string,string> tilesetsPath;
std::pair<string,string> techtreesPath; std::pair<string,string> techtreesPath;
string tempFilesPath;
int portNumber; int portNumber;
int maxPlayers; int maxPlayers;
@ -54,7 +55,8 @@ public:
std::pair<string,string> tilesetsPath, std::pair<string,string> techtreesPath, std::pair<string,string> tilesetsPath, std::pair<string,string> techtreesPath,
bool internetEnabledFlag, bool internetEnabledFlag,
bool allowInternetTilesetFileTransfers, bool allowInternetTechtreeFileTransfers, bool allowInternetTilesetFileTransfers, bool allowInternetTechtreeFileTransfers,
int portNumber,int maxPlayers, FTPClientValidationInterface *ftpValidationIntf); int portNumber,int maxPlayers, FTPClientValidationInterface *ftpValidationIntf,
string tempFilesPath);
~FTPServerThread(); ~FTPServerThread();
virtual void execute(); virtual void execute();
virtual void signalQuit(); virtual void signalQuit();

View File

@ -25,14 +25,16 @@ using namespace Shared::PlatformCommon;
namespace Shared { namespace PlatformCommon { namespace Shared { namespace PlatformCommon {
const char *FTP_MAPS_CUSTOM_USERNAME = "maps_custom"; static const char *FTP_MAPS_CUSTOM_USERNAME = "maps_custom";
const char *FTP_MAPS_USERNAME = "maps"; static const char *FTP_MAPS_USERNAME = "maps";
const char *FTP_TILESETS_CUSTOM_USERNAME = "tilesets_custom"; static const char *FTP_TILESETS_CUSTOM_USERNAME = "tilesets_custom";
const char *FTP_TILESETS_USERNAME = "tilesets"; static const char *FTP_TILESETS_USERNAME = "tilesets";
const char *FTP_TECHTREES_CUSTOM_USERNAME = "techtrees_custom"; static const char *FTP_TECHTREES_CUSTOM_USERNAME = "techtrees_custom";
const char *FTP_TECHTREES_USERNAME = "techtrees"; static const char *FTP_TECHTREES_USERNAME = "techtrees";
const char *FTP_COMMON_PASSWORD = "mg_ftp_server"; static const char *FTP_TEMPFILES_USERNAME = "temp";
static const char *FTP_COMMON_PASSWORD = "mg_ftp_server";
/* /*
* This is an example showing how to get a single file from an FTP server. * This is an example showing how to get a single file from an FTP server.
@ -237,7 +239,8 @@ FTPClientThread::FTPClientThread(int portNumber, string serverUrl,
string fileArchiveExtension, string fileArchiveExtension,
string fileArchiveExtractCommand, string fileArchiveExtractCommand,
string fileArchiveExtractCommandParameters, string fileArchiveExtractCommandParameters,
int fileArchiveExtractCommandSuccessResult) : BaseThread() { int fileArchiveExtractCommandSuccessResult,
string tempFilesPath) : BaseThread() {
this->portNumber = portNumber; this->portNumber = portNumber;
this->serverUrl = serverUrl; this->serverUrl = serverUrl;
this->mapsPath = mapsPath; this->mapsPath = mapsPath;
@ -251,6 +254,7 @@ FTPClientThread::FTPClientThread(int portNumber, string serverUrl,
this->fileArchiveExtractCommand = fileArchiveExtractCommand; this->fileArchiveExtractCommand = fileArchiveExtractCommand;
this->fileArchiveExtractCommandParameters = fileArchiveExtractCommandParameters; this->fileArchiveExtractCommandParameters = fileArchiveExtractCommandParameters;
this->fileArchiveExtractCommandSuccessResult = fileArchiveExtractCommandSuccessResult; this->fileArchiveExtractCommandSuccessResult = fileArchiveExtractCommandSuccessResult;
this->tempFilesPath = tempFilesPath;
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line %d] Using FTP port #: %d, serverUrl [%s]\n",__FILE__,__FUNCTION__,__LINE__,portNumber,serverUrl.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line %d] Using FTP port #: %d, serverUrl [%s]\n",__FILE__,__FUNCTION__,__LINE__,portNumber,serverUrl.c_str());
} }
@ -449,6 +453,16 @@ void FTPClientThread::addFileToRequests(string fileName,string URL) {
} }
} }
void FTPClientThread::addTempFileToRequests(string fileName,string URL) {
std::pair<string,string> item = make_pair(fileName,URL);
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexTempFileList,mutexOwnerId);
mutexTempFileList.setOwnerId(mutexOwnerId);
if(std::find(tempFileList.begin(),tempFileList.end(),item) == tempFileList.end()) {
tempFileList.push_back(item);
}
}
void FTPClientThread::getTilesetFromServer(pair<string,string> tileSetName) { void FTPClientThread::getTilesetFromServer(pair<string,string> tileSetName) {
bool findArchive = executeShellCommand( bool findArchive = executeShellCommand(
this->fileArchiveExtractCommand, this->fileArchiveExtractCommand,
@ -840,6 +854,58 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getFileInternalFromServer(p
return result; return result;
} }
void FTPClientThread::getTempFileFromServer(pair<string,string> fileName) {
pair<FTP_Client_ResultType,string> result = make_pair(ftp_crt_FAIL,"");
bool findArchive = true;
string ext = extractExtension(fileName.first);
if(("." + ext) == this->fileArchiveExtension) {
findArchive = executeShellCommand(
this->fileArchiveExtractCommand,
this->fileArchiveExtractCommandSuccessResult);
}
if(findArchive == true) {
result = getTempFileInternalFromServer(fileName);
}
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(this->getProgressMutex(),mutexOwnerId);
this->getProgressMutex()->setOwnerId(mutexOwnerId);
if(this->pCBObject != NULL) {
this->pCBObject->FTPClient_CallbackEvent(fileName.first,ftp_cct_TempFile,result,NULL);
}
}
pair<FTP_Client_ResultType,string> FTPClientThread::getTempFileInternalFromServer(pair<string,string> fileName) {
string destFile = fileName.first;
string destFileSaveAs = fileName.first;
string remotePath = fileName.second;
pair<FTP_Client_ResultType,string> result = getFileFromServer(ftp_cct_TempFile,
fileName,remotePath, destFileSaveAs, FTP_TEMPFILES_USERNAME, FTP_COMMON_PASSWORD);
// Extract the archive
if(result.first == ftp_crt_SUCCESS) {
string ext = extractExtension(destFileSaveAs);
if(("." + ext) == fileArchiveExtension) {
string destRootArchiveFolder = extractDirectoryPathFromFile(destFileSaveAs);
string extractCmd = getFullFileArchiveExtractCommand(
this->fileArchiveExtractCommand,
this->fileArchiveExtractCommandParameters,
destRootArchiveFolder,
destFileSaveAs);
if(executeShellCommand(extractCmd,this->fileArchiveExtractCommandSuccessResult) == false) {
result.first = ftp_crt_FAIL;
result.second = "failed to extract archive!";
}
}
}
return result;
}
pair<FTP_Client_ResultType,string> FTPClientThread::getFileFromServer(FTP_Client_CallbackType downloadType, pair<FTP_Client_ResultType,string> FTPClientThread::getFileFromServer(FTP_Client_CallbackType downloadType,
pair<string,string> fileNameTitle, pair<string,string> fileNameTitle,
string remotePath, string destFileSaveAs, string remotePath, string destFileSaveAs,
@ -1104,6 +1170,20 @@ void FTPClientThread::execute() {
safeMutex5.ReleaseLock(); safeMutex5.ReleaseLock();
} }
static string mutexOwnerId6 = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex6(&mutexTempFileList,mutexOwnerId6);
mutexTempFileList.setOwnerId(mutexOwnerId6);
if(tempFileList.size() > 0) {
pair<string,string> file = tempFileList[0];
tempFileList.erase(tempFileList.begin() + 0);
safeMutex6.ReleaseLock();
getTempFileFromServer(file);
}
else {
safeMutex5.ReleaseLock();
}
if(this->getQuitStatus() == false) { if(this->getQuitStatus() == false) {
sleep(25); sleep(25);
} }

View File

@ -26,6 +26,17 @@ using namespace Shared::PlatformCommon;
namespace Shared { namespace PlatformCommon { namespace Shared { namespace PlatformCommon {
static const char *FTP_MAPS_CUSTOM_USERNAME = "maps_custom";
static const char *FTP_MAPS_USERNAME = "maps";
static const char *FTP_TILESETS_CUSTOM_USERNAME = "tilesets_custom";
static const char *FTP_TILESETS_USERNAME = "tilesets";
static const char *FTP_TECHTREES_CUSTOM_USERNAME = "techtrees_custom";
static const char *FTP_TECHTREES_USERNAME = "techtrees";
static const char *FTP_TEMPFILES_USERNAME = "temp";
static const char *FTP_COMMON_PASSWORD = "mg_ftp_server";
static std::map<uint32,uint32> clientToFTPServerList; static std::map<uint32,uint32> clientToFTPServerList;
FTPClientValidationInterface * FTPServerThread::ftpValidationIntf = NULL; FTPClientValidationInterface * FTPServerThread::ftpValidationIntf = NULL;
@ -62,7 +73,7 @@ FTPServerThread::FTPServerThread(std::pair<string,string> mapsPath,
bool internetEnabledFlag, bool internetEnabledFlag,
bool allowInternetTilesetFileTransfers, bool allowInternetTechtreeFileTransfers, bool allowInternetTilesetFileTransfers, bool allowInternetTechtreeFileTransfers,
int portNumber, int maxPlayers, int portNumber, int maxPlayers,
FTPClientValidationInterface *ftpValidationIntf) : BaseThread() { FTPClientValidationInterface *ftpValidationIntf, string tempFilesPath) : BaseThread() {
this->mapsPath = mapsPath; this->mapsPath = mapsPath;
this->tilesetsPath = tilesetsPath; this->tilesetsPath = tilesetsPath;
this->techtreesPath = techtreesPath; this->techtreesPath = techtreesPath;
@ -72,6 +83,7 @@ FTPServerThread::FTPServerThread(std::pair<string,string> mapsPath,
this->portNumber = portNumber; this->portNumber = portNumber;
this->maxPlayers = maxPlayers; this->maxPlayers = maxPlayers;
this->ftpValidationIntf = ftpValidationIntf; this->ftpValidationIntf = ftpValidationIntf;
this->tempFilesPath = tempFilesPath;
ftpInit(&FindExternalFTPServerIp,&UPNP_Tools::AddUPNPPortForward,&UPNP_Tools::RemoveUPNPPortForward, ftpInit(&FindExternalFTPServerIp,&UPNP_Tools::AddUPNPPortForward,&UPNP_Tools::RemoveUPNPPortForward,
&isValidClientType, &isClientAllowedToGetFile); &isValidClientType, &isClientAllowedToGetFile);
@ -131,18 +143,18 @@ void FTPServerThread::setInternetEnabled(bool value, bool forceChange) {
if(this->allowInternetTilesetFileTransfers == true) { if(this->allowInternetTilesetFileTransfers == true) {
if(tilesetsPath.first != "") { if(tilesetsPath.first != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.first.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.first.c_str());
ftpCreateAccount("tilesets", "mg_ftp_server", tilesetsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_TILESETS_USERNAME, FTP_COMMON_PASSWORD, tilesetsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(tilesetsPath.second != "") { if(tilesetsPath.second != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.second.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.second.c_str());
ftpCreateAccount("tilesets_custom", "mg_ftp_server", tilesetsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_TILESETS_CUSTOM_USERNAME, FTP_COMMON_PASSWORD, tilesetsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users created\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users created\n");
} }
else { else {
ftpDeleteAccount("tilesets"); ftpDeleteAccount(FTP_TILESETS_USERNAME);
ftpDeleteAccount("tilesets_custom"); ftpDeleteAccount(FTP_TILESETS_CUSTOM_USERNAME);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users deleted\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users deleted\n");
} }
@ -151,18 +163,18 @@ void FTPServerThread::setInternetEnabled(bool value, bool forceChange) {
// Setup FTP Users and permissions for tilesets // Setup FTP Users and permissions for tilesets
if(techtreesPath.first != "") { if(techtreesPath.first != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.first.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.first.c_str());
ftpCreateAccount("techtrees", "mg_ftp_server", techtreesPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_TECHTREES_USERNAME, FTP_COMMON_PASSWORD, techtreesPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(techtreesPath.second != "") { if(techtreesPath.second != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.second.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.second.c_str());
ftpCreateAccount("techtrees_custom", "mg_ftp_server", techtreesPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_TECHTREES_CUSTOM_USERNAME, FTP_COMMON_PASSWORD, techtreesPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users created\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users created\n");
} }
else { else {
ftpDeleteAccount("techtrees"); ftpDeleteAccount(FTP_TECHTREES_USERNAME);
ftpDeleteAccount("techtrees_custom"); ftpDeleteAccount(FTP_TECHTREES_CUSTOM_USERNAME);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users deleted\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users deleted\n");
} }
@ -170,11 +182,11 @@ void FTPServerThread::setInternetEnabled(bool value, bool forceChange) {
else { else {
if(tilesetsPath.first != "") { if(tilesetsPath.first != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.first.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.first.c_str());
ftpCreateAccount("tilesets", "mg_ftp_server", tilesetsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_TILESETS_USERNAME, FTP_COMMON_PASSWORD, tilesetsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(tilesetsPath.second != "") { if(tilesetsPath.second != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.second.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tilesetsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,tilesetsPath.second.c_str());
ftpCreateAccount("tilesets_custom", "mg_ftp_server", tilesetsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_TILESETS_CUSTOM_USERNAME, FTP_COMMON_PASSWORD, tilesetsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users created\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, tilesets users created\n");
@ -182,11 +194,11 @@ void FTPServerThread::setInternetEnabled(bool value, bool forceChange) {
// Setup FTP Users and permissions for tilesets // Setup FTP Users and permissions for tilesets
if(techtreesPath.first != "") { if(techtreesPath.first != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.first.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.first.c_str());
ftpCreateAccount("techtrees", "mg_ftp_server", techtreesPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_TECHTREES_USERNAME, FTP_COMMON_PASSWORD, techtreesPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(techtreesPath.second != "") { if(techtreesPath.second != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.second.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] techtreesPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,techtreesPath.second.c_str());
ftpCreateAccount("techtrees_custom", "mg_ftp_server", techtreesPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_TECHTREES_CUSTOM_USERNAME, FTP_COMMON_PASSWORD, techtreesPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users created\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread, techtrees users created\n");
@ -212,11 +224,16 @@ void FTPServerThread::execute() {
// Setup FTP Users and permissions for maps // Setup FTP Users and permissions for maps
if(mapsPath.first != "") { if(mapsPath.first != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] mapsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,mapsPath.first.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] mapsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,mapsPath.first.c_str());
ftpCreateAccount("maps", "mg_ftp_server", mapsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_MAPS_USERNAME, FTP_COMMON_PASSWORD, mapsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
if(mapsPath.second != "") { if(mapsPath.second != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] mapsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,mapsPath.second.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] mapsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,mapsPath.second.c_str());
ftpCreateAccount("maps_custom", "mg_ftp_server", mapsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR); ftpCreateAccount(FTP_MAPS_CUSTOM_USERNAME, FTP_COMMON_PASSWORD, mapsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
}
if(tempFilesPath != "") {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] tempFilesPath [%s]\n",__FILE__,__FUNCTION__,__LINE__,tempFilesPath.c_str());
ftpCreateAccount(FTP_TEMPFILES_USERNAME, FTP_COMMON_PASSWORD, tempFilesPath.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
} }
/* /*

View File

@ -948,6 +948,8 @@ Socket::~Socket() {
} }
void Socket::disconnectSocket() { void Socket::disconnectSocket() {
//printf("Socket disconnecting\n");
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START closing socket = %d...\n",__FILE__,__FUNCTION__,sock); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START closing socket = %d...\n",__FILE__,__FUNCTION__,sock);
if(isSocketValid() == true) { if(isSocketValid() == true) {