- Added tileset and map CRC check in the network lobby

- numerous bugfixes
This commit is contained in:
Mark Vejvoda 2011-01-09 04:49:21 +00:00
parent 2e60d3e0a8
commit 1c78fca0fb
28 changed files with 440 additions and 249 deletions

View File

@ -34,7 +34,7 @@ enum FlagTypes1 {
}; };
class GameSettings{ class GameSettings {
private: private:
string description; string description;
string map; string map;
@ -69,8 +69,11 @@ private:
uint32 flagTypes1; uint32 flagTypes1;
public: int32 mapCRC;
int32 tilesetCRC;
int32 techCRC;
public:
GameSettings() { GameSettings() {
thisFactionIndex = 0; thisFactionIndex = 0;
@ -92,6 +95,10 @@ public:
} }
flagTypes1 = ft1_none; flagTypes1 = ft1_none;
mapCRC = 0;
tilesetCRC = 0;
techCRC = 0;
} }
// default copy constructor will do fine, and will maintain itself ;) // default copy constructor will do fine, and will maintain itself ;)
@ -147,6 +154,10 @@ public:
PathFinderType getPathFinderType() const { return pathFinderType; } PathFinderType getPathFinderType() const { return pathFinderType; }
uint32 getFlagTypes1() const { return flagTypes1;} uint32 getFlagTypes1() const { return flagTypes1;}
int32 getMapCRC() const { return mapCRC; }
int32 getTilesetCRC() const { return tilesetCRC; }
int32 getTechCRC() const { return techCRC; }
//set //set
void setDescription(const string& description) {this->description= description;} void setDescription(const string& description) {this->description= description;}
void setMap(const string& map) {this->map= map;} void setMap(const string& map) {this->map= map;}
@ -177,8 +188,13 @@ public:
void setNetworkFramePeriod(int value) {this->networkFramePeriod = value; } void setNetworkFramePeriod(int value) {this->networkFramePeriod = value; }
void setNetworkPauseGameForLaggedClients(bool value) {this->networkPauseGameForLaggedClients = value; } void setNetworkPauseGameForLaggedClients(bool value) {this->networkPauseGameForLaggedClients = value; }
void setPathFinderType(PathFinderType value) {this->pathFinderType = value; } void setPathFinderType(PathFinderType value) {this->pathFinderType = value; }
void setFlagTypes1(uint32 value) {this->flagTypes1 = value; } void setFlagTypes1(uint32 value) {this->flagTypes1 = value; }
void setMapCRC(int32 value) { mapCRC = value; }
void setTilesetCRC(int32 value) { tilesetCRC = value; }
void setTechCRC(int32 value) { techCRC = value; }
string toString() const { string toString() const {
string result = ""; string result = "";
@ -214,6 +230,9 @@ public:
result += "networkPauseGameForLaggedClients = " + intToStr(networkPauseGameForLaggedClients) + "\n"; result += "networkPauseGameForLaggedClients = " + intToStr(networkPauseGameForLaggedClients) + "\n";
result += "pathFinderType = " + intToStr(pathFinderType) + "\n"; result += "pathFinderType = " + intToStr(pathFinderType) + "\n";
result += "flagTypes1 = " + intToStr(flagTypes1) + "\n"; result += "flagTypes1 = " + intToStr(flagTypes1) + "\n";
result += "mapCRC = " + intToStr(mapCRC) + "\n";
result += "tilesetCRC = " + intToStr(tilesetCRC) + "\n";
result += "techCRC = " + intToStr(techCRC) + "\n";
return result; return result;
} }

View File

@ -119,6 +119,12 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
labelInfo.setText(""); labelInfo.setText("");
labelInfo.setFont(CoreData::getInstance().getMenuFontBig()); labelInfo.setFont(CoreData::getInstance().getMenuFontBig());
timerLabelFlash = time(NULL);
labelDataSynchInfo.registerGraphicComponent(containerName,"labelDataSynchInfo");
labelDataSynchInfo.init(30, networkHeadPos-60);
labelDataSynchInfo.setText("");
labelDataSynchInfo.setFont(CoreData::getInstance().getMenuFontBig());
//create //create
buttonDisconnect.registerGraphicComponent(containerName,"buttonDisconnect"); buttonDisconnect.registerGraphicComponent(containerName,"buttonDisconnect");
buttonDisconnect.init(450, 180, 125); buttonDisconnect.init(450, 180, 125);
@ -720,6 +726,17 @@ void MenuStateConnectedGame::render() {
renderer.renderLabel(&labelStatus); renderer.renderLabel(&labelStatus);
renderer.renderLabel(&labelInfo); renderer.renderLabel(&labelInfo);
if(difftime(time(NULL),timerLabelFlash) < 1) {
renderer.renderLabel(&labelDataSynchInfo,&RED);
}
else {
renderer.renderLabel(&labelDataSynchInfo,&WHITE);
if(difftime(time(NULL),timerLabelFlash) > 2) {
timerLabelFlash = time(NULL);
}
}
renderer.renderLabel(&labelMap); renderer.renderLabel(&labelMap);
renderer.renderLabel(&labelFogOfWar); renderer.renderLabel(&labelFogOfWar);
renderer.renderLabel(&labelAllowObservers); renderer.renderLabel(&labelAllowObservers);
@ -845,12 +862,85 @@ void MenuStateConnectedGame::update() {
if(clientInterface->getAllowDownloadDataSynch() == false) { if(clientInterface->getAllowDownloadDataSynch() == false) {
string label = lang.get("ConnectedToServer"); string label = lang.get("ConnectedToServer");
if(!clientInterface->getServerName().empty()) { if(clientInterface->getServerName().empty() == false) {
label = label + " " + clientInterface->getServerName(); label = label + " " + clientInterface->getServerName();
} }
label = label + ", " + clientInterface->getVersionString(); label = label + ", " + clientInterface->getVersionString();
if(clientInterface->getAllowGameDataSynchCheck() == false) {
Config &config = Config::getInstance();
const GameSettings *gameSettings = clientInterface->getGameSettings();
int32 tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
// Test data synch
//tilesetCRC++;
//int32 techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL);
Checksum checksum;
string file = Map::getMapPath(gameSettings->getMap(),"",false);
checksum.addFile(file);
int32 mapCRC = checksum.getSum();
bool dataSynchMismatch = (mapCRC != gameSettings->getMapCRC() || tilesetCRC != gameSettings->getTilesetCRC());
//printf("\nmapCRC [%d] gameSettings->getMapCRC() [%d] tilesetCRC [%d] gameSettings->getTilesetCRC() [%d]\n",mapCRC,gameSettings->getMapCRC(),tilesetCRC,gameSettings->getTilesetCRC());
if(dataSynchMismatch == true) {
string labelSynch = "Game data synch mismatch for:";
if(mapCRC != gameSettings->getMapCRC()) {
labelSynch = labelSynch + " map";
if(updateDataSynchDetailText == true &&
lastMapDataSynchError != "map CRC mismatch, " + listBoxMap.getSelectedItem()) {
lastMapDataSynchError = "map CRC mismatch, " + listBoxMap.getSelectedItem();
clientInterface->sendTextMessage(lastMapDataSynchError,-1,true);
}
}
if(tilesetCRC != gameSettings->getTilesetCRC()) {
labelSynch = labelSynch + " tileset";
if(updateDataSynchDetailText == true &&
lastTileDataSynchError != "tileset CRC mismatch, " + listBoxTileset.getSelectedItem()) {
lastTileDataSynchError = "tileset CRC mismatch, " + listBoxTileset.getSelectedItem();
clientInterface->sendTextMessage(lastTileDataSynchError,-1,true);
}
}
/*
if(clientInterface->getNetworkGameDataSynchCheckOkTech() == false) {
labelSynch = labelSynch + " techtree";
if(updateDataSynchDetailText == true) {
string report = clientInterface->getNetworkGameDataSynchCheckTechMismatchReport();
if(lastTechtreeDataSynchError != "techtree CRC mismatch" + report) {
lastTechtreeDataSynchError = "techtree CRC mismatch" + report;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] report: %s\n",__FILE__,__FUNCTION__,__LINE__,report.c_str());
clientInterface->sendTextMessage("techtree CRC mismatch",-1,true);
vector<string> reportLineTokens;
Tokenize(report,reportLineTokens,"\n");
for(int reportLine = 0; reportLine < reportLineTokens.size(); ++reportLine) {
clientInterface->sendTextMessage(reportLineTokens[reportLine],-1,true);
}
}
}
}
*/
//if(clientInterface->getReceivedDataSynchCheck() == true) {
updateDataSynchDetailText = false;
//}
labelDataSynchInfo.setText(labelSynch);
}
else {
labelDataSynchInfo.setText("");
}
}
if(clientInterface->getAllowGameDataSynchCheck() == true && if(clientInterface->getAllowGameDataSynchCheck() == true &&
clientInterface->getNetworkGameDataSynchCheckOk() == false) { clientInterface->getNetworkGameDataSynchCheckOk() == false) {
label = label + " -synch mismatch for:"; label = label + " -synch mismatch for:";
@ -984,7 +1074,6 @@ void MenuStateConnectedGame::update() {
//process network messages //process network messages
if(clientInterface != NULL && clientInterface->isConnected()) { if(clientInterface != NULL && clientInterface->isConnected()) {
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if(chrono.getMillis() > 0) chrono.start(); if(chrono.getMillis() > 0) chrono.start();
@ -1233,7 +1322,6 @@ void MenuStateConnectedGame::update() {
//update lobby //update lobby
clientInterface= NetworkManager::getInstance().getClientInterface(); clientInterface= NetworkManager::getInstance().getClientInterface();
if(clientInterface != NULL && clientInterface->isConnected()) { if(clientInterface != NULL && clientInterface->isConnected()) {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] clientInterface = %p\n",__FILE__,__FUNCTION__,__LINE__,clientInterface);
clientInterface->updateLobby(); clientInterface->updateLobby();
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -1243,16 +1331,12 @@ void MenuStateConnectedGame::update() {
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if(chrono.getMillis() > 0) chrono.start(); if(chrono.getMillis() > 0) chrono.start();
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
clientInterface= NetworkManager::getInstance().getClientInterface(); clientInterface= NetworkManager::getInstance().getClientInterface();
if(clientInterface != NULL && clientInterface->isConnected()) { if(clientInterface != NULL && clientInterface->isConnected()) {
if( initialSettingsReceivedFromServer == true && if( initialSettingsReceivedFromServer == true &&
clientInterface->getIntroDone() == true && clientInterface->getIntroDone() == true &&
(switchSetupRequestFlagType & ssrft_NetworkPlayerName) == ssrft_NetworkPlayerName) { (switchSetupRequestFlagType & ssrft_NetworkPlayerName) == ssrft_NetworkPlayerName) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] getHumanPlayerName() = [%s], clientInterface->getGameSettings()->getThisFactionIndex() = %d\n",__FILE__,__FUNCTION__,__LINE__,getHumanPlayerName().c_str(),clientInterface->getGameSettings()->getThisFactionIndex()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] getHumanPlayerName() = [%s], clientInterface->getGameSettings()->getThisFactionIndex() = %d\n",__FILE__,__FUNCTION__,__LINE__,getHumanPlayerName().c_str(),clientInterface->getGameSettings()->getThisFactionIndex());
//needToSetChangedGameSettings = false;
//lastSetChangedGameSettings = time(NULL);
clientInterface->sendSwitchSetupRequest("",clientInterface->getPlayerIndex(),-1,-1,getHumanPlayerName(),switchSetupRequestFlagType); clientInterface->sendSwitchSetupRequest("",clientInterface->getPlayerIndex(),-1,-1,getHumanPlayerName(),switchSetupRequestFlagType);
switchSetupRequestFlagType=ssrft_None; switchSetupRequestFlagType=ssrft_None;

View File

@ -97,6 +97,9 @@ private:
GraphicLabel *activeInputLabel; GraphicLabel *activeInputLabel;
time_t timerLabelFlash;
GraphicLabel labelDataSynchInfo;
MapInfo mapInfo; MapInfo mapInfo;
bool needToSetChangedGameSettings; bool needToSetChangedGameSettings;

View File

@ -2111,16 +2111,19 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
gameSettings->setFactionCount(factionCount); gameSettings->setFactionCount(factionCount);
Config &config = Config::getInstance(); Config &config = Config::getInstance();
//gameSettings->setEnableServerControlledAI(listBoxEnableServerControlledAI.getSelectedItemIndex() == 0);
gameSettings->setEnableServerControlledAI(config.getBool("ServerControlledAI","true")); gameSettings->setEnableServerControlledAI(config.getBool("ServerControlledAI","true"));
//gameSettings->setNetworkFramePeriod((listBoxNetworkFramePeriod.getSelectedItemIndex()+1)*10);
gameSettings->setNetworkFramePeriod(config.getInt("NetworkSendFrameCount","20")); gameSettings->setNetworkFramePeriod(config.getInt("NetworkSendFrameCount","20"));
gameSettings->setNetworkPauseGameForLaggedClients(((listBoxNetworkPauseGameForLaggedClients.getSelectedItemIndex() != 0))); gameSettings->setNetworkPauseGameForLaggedClients(((listBoxNetworkPauseGameForLaggedClients.getSelectedItemIndex() != 0)));
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTileset() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTileset().c_str());
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTech() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTech().c_str()); int32 tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getMap() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getMap().c_str()); gameSettings->setTilesetCRC(tilesetCRC);
//int32 techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL);
Checksum checksum;
string file = Map::getMapPath(gameSettings->getMap(),"",false);
checksum.addFile(file);
int32 mapCRC = checksum.getSum();
gameSettings->setMapCRC(mapCRC);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
} }

View File

@ -37,62 +37,48 @@ namespace Glest{ namespace Game{
// class NetworkMessage // class NetworkMessage
// ===================================================== // =====================================================
bool NetworkMessage::peek(Socket* socket, void* data, int dataSize) bool NetworkMessage::peek(Socket* socket, void* data, int dataSize) {
{
if(socket != NULL) { if(socket != NULL) {
int ipeekdatalen = socket->getDataToRead(); int ipeekdatalen = socket->getDataToRead();
if(ipeekdatalen >= dataSize) if(ipeekdatalen >= dataSize) {
{ if(socket->peek(data, dataSize)!=dataSize) {
if(socket->peek(data, dataSize)!=dataSize) if(socket != NULL && socket->getSocketId() > 0) {
{
if(socket != NULL && socket->getSocketId() > 0)
{
throw runtime_error("Error peeking NetworkMessage"); throw runtime_error("Error peeking NetworkMessage");
} }
else else {
{
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d socket has been disconnected\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d socket has been disconnected\n",__FILE__,__FUNCTION__,__LINE__);
} }
} }
else else {
{
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] dataSize = %d\n",__FILE__,__FUNCTION__,dataSize); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] dataSize = %d\n",__FILE__,__FUNCTION__,dataSize);
} }
return true; return true;
} }
else else {
{
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] socket->getDataToRead() returned %d\n",__FILE__,__FUNCTION__,ipeekdatalen); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] socket->getDataToRead() returned %d\n",__FILE__,__FUNCTION__,ipeekdatalen);
} }
} }
return false; return false;
} }
bool NetworkMessage::receive(Socket* socket, void* data, int dataSize) bool NetworkMessage::receive(Socket* socket, void* data, int dataSize) {
{
if(socket != NULL) { if(socket != NULL) {
int ipeekdatalen = socket->getDataToRead(); int ipeekdatalen = socket->getDataToRead();
if(ipeekdatalen >= dataSize) if(ipeekdatalen >= dataSize) {
{ if(socket->receive(data, dataSize)!=dataSize) {
if(socket->receive(data, dataSize)!=dataSize) if(socket != NULL && socket->getSocketId() > 0) {
{
if(socket != NULL && socket->getSocketId() > 0)
{
throw runtime_error("Error receiving NetworkMessage"); throw runtime_error("Error receiving NetworkMessage");
} }
else else {
{
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] socket has been disconnected\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] socket has been disconnected\n",__FILE__,__FUNCTION__);
} }
} }
else else {
{
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] dataSize = %d\n",__FILE__,__FUNCTION__,dataSize); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] dataSize = %d\n",__FILE__,__FUNCTION__,dataSize);
} }
return true; return true;
} }
else else {
{
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] socket->getDataToRead() returned %d\n",__FILE__,__FUNCTION__,ipeekdatalen); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] socket->getDataToRead() returned %d\n",__FILE__,__FUNCTION__,ipeekdatalen);
} }
} }
@ -189,11 +175,11 @@ void NetworkMessagePing::send(Socket* socket) const{
// class NetworkMessageReady // class NetworkMessageReady
// ===================================================== // =====================================================
NetworkMessageReady::NetworkMessageReady(){ NetworkMessageReady::NetworkMessageReady() {
data.messageType= nmtReady; data.messageType= nmtReady;
} }
NetworkMessageReady::NetworkMessageReady(int32 checksum){ NetworkMessageReady::NetworkMessageReady(int32 checksum) {
data.messageType= nmtReady; data.messageType= nmtReady;
data.checksum= checksum; data.checksum= checksum;
} }
@ -202,7 +188,7 @@ bool NetworkMessageReady::receive(Socket* socket){
return NetworkMessage::receive(socket, &data, sizeof(data)); return NetworkMessage::receive(socket, &data, sizeof(data));
} }
void NetworkMessageReady::send(Socket* socket) const{ void NetworkMessageReady::send(Socket* socket) const {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] nmtReady\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] nmtReady\n",__FILE__,__FUNCTION__,__LINE__);
assert(data.messageType==nmtReady); assert(data.messageType==nmtReady);
NetworkMessage::send(socket, &data, sizeof(data)); NetworkMessage::send(socket, &data, sizeof(data));
@ -212,13 +198,17 @@ void NetworkMessageReady::send(Socket* socket) const{
// class NetworkMessageLaunch // class NetworkMessageLaunch
// ===================================================== // =====================================================
NetworkMessageLaunch::NetworkMessageLaunch(){ NetworkMessageLaunch::NetworkMessageLaunch() {
data.messageType=-1; data.messageType=-1;
} }
NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8 messageType){ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8 messageType) {
data.messageType=messageType; data.messageType=messageType;
data.mapCRC = gameSettings->getMapCRC();
data.tilesetCRC = gameSettings->getTilesetCRC();
data.techCRC = gameSettings->getTechCRC();
data.description= gameSettings->getDescription(); data.description= gameSettings->getDescription();
data.map= gameSettings->getMap(); data.map= gameSettings->getMap();
data.tileset= gameSettings->getTileset(); data.tileset= gameSettings->getTileset();
@ -237,7 +227,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
data.pathFinderType = gameSettings->getPathFinderType(); data.pathFinderType = gameSettings->getPathFinderType();
data.flagTypes1 = gameSettings->getFlagTypes1(); data.flagTypes1 = gameSettings->getFlagTypes1();
for(int i= 0; i<data.factionCount; ++i){ for(int i= 0; i<data.factionCount; ++i) {
data.factionTypeNames[i]= gameSettings->getFactionTypeName(i); data.factionTypeNames[i]= gameSettings->getFactionTypeName(i);
data.networkPlayerNames[i]= gameSettings->getNetworkPlayerName(i); data.networkPlayerNames[i]= gameSettings->getNetworkPlayerName(i);
data.factionControls[i]= gameSettings->getFactionControl(i); data.factionControls[i]= gameSettings->getFactionControl(i);
@ -247,7 +237,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
} }
} }
void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const {
gameSettings->setDescription(data.description.getString()); gameSettings->setDescription(data.description.getString());
gameSettings->setMap(data.map.getString()); gameSettings->setMap(data.map.getString());
gameSettings->setTileset(data.tileset.getString()); gameSettings->setTileset(data.tileset.getString());
@ -267,7 +257,11 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{
gameSettings->setPathFinderType(static_cast<PathFinderType>(data.pathFinderType)); gameSettings->setPathFinderType(static_cast<PathFinderType>(data.pathFinderType));
gameSettings->setFlagTypes1(data.flagTypes1); gameSettings->setFlagTypes1(data.flagTypes1);
for(int i= 0; i<data.factionCount; ++i){ gameSettings->setMapCRC(data.mapCRC);
gameSettings->setTilesetCRC(data.tilesetCRC);
gameSettings->setTechCRC(data.techCRC);
for(int i= 0; i<data.factionCount; ++i) {
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString()); gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
gameSettings->setNetworkPlayerName(i,data.networkPlayerNames[i].getString()); gameSettings->setNetworkPlayerName(i,data.networkPlayerNames[i].getString());
gameSettings->setFactionControl(i, static_cast<ControlType>(data.factionControls[i])); gameSettings->setFactionControl(i, static_cast<ControlType>(data.factionControls[i]));
@ -277,7 +271,7 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{
} }
} }
bool NetworkMessageLaunch::receive(Socket* socket){ bool NetworkMessageLaunch::receive(Socket* socket) {
bool result = NetworkMessage::receive(socket, &data, sizeof(data)); bool result = NetworkMessage::receive(socket, &data, sizeof(data));
data.description.nullTerminate(); data.description.nullTerminate();
data.map.nullTerminate(); data.map.nullTerminate();

View File

@ -181,7 +181,7 @@ public:
// ===================================================== // =====================================================
#pragma pack(push, 1) #pragma pack(push, 1)
class NetworkMessageLaunch: public NetworkMessage{ class NetworkMessageLaunch: public NetworkMessage {
private: private:
static const int maxStringSize= 256; static const int maxStringSize= 256;
static const int maxSmallStringSize= 60; static const int maxSmallStringSize= 60;
@ -195,6 +195,9 @@ private:
NetworkString<maxSmallStringSize> tech; NetworkString<maxSmallStringSize> tech;
NetworkString<maxSmallStringSize> factionTypeNames[GameConstants::maxPlayers]; //faction names NetworkString<maxSmallStringSize> factionTypeNames[GameConstants::maxPlayers]; //faction names
NetworkString<maxSmallStringSize> networkPlayerNames[GameConstants::maxPlayers]; //networkPlayerNames NetworkString<maxSmallStringSize> networkPlayerNames[GameConstants::maxPlayers]; //networkPlayerNames
int32 mapCRC;
int32 tilesetCRC;
int32 techCRC;
int8 factionControls[GameConstants::maxPlayers]; int8 factionControls[GameConstants::maxPlayers];
int8 resourceMultiplierIndex[GameConstants::maxPlayers]; int8 resourceMultiplierIndex[GameConstants::maxPlayers];
@ -226,6 +229,10 @@ public:
void buildGameSettings(GameSettings *gameSettings) const; void buildGameSettings(GameSettings *gameSettings) const;
int getMessageType() const { return data.messageType; } int getMessageType() const { return data.messageType; }
int getMapCRC() const { return data.mapCRC; }
int getTilesetCRC() const { return data.tilesetCRC; }
int getTechCRC() const { return data.techCRC; }
virtual bool receive(Socket* socket); virtual bool receive(Socket* socket);
virtual void send(Socket* socket) const; virtual void send(Socket* socket) const;
}; };
@ -240,7 +247,7 @@ public:
//const int32 commandListHeaderSize = 6; //const int32 commandListHeaderSize = 6;
#pragma pack(push, 1) #pragma pack(push, 1)
class NetworkMessageCommandList: public NetworkMessage{ class NetworkMessageCommandList: public NetworkMessage {
private: private:
static const int maxCommandCount = 2496; // can be as large as 65535 static const int maxCommandCount = 2496; // can be as large as 65535

View File

@ -3,16 +3,16 @@
// //
// Copyright (C) 2001-2008 Martio Figueroa // Copyright (C) 2001-2008 Martio Figueroa
// //
// You can redistribute this code and/or modify it under // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the // by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version // License, or (at your option) any later version
// ============================================================== // ==============================================================
#include "faction_type.h" #include "faction_type.h"
#include "logger.h" #include "logger.h"
#include "util.h" #include "util.h"
#include "xml_parser.h" #include "xml_parser.h"
#include "tech_tree.h" #include "tech_tree.h"
#include "resource.h" #include "resource.h"
@ -27,7 +27,7 @@ using namespace Shared::Xml;
namespace Glest{ namespace Game{ namespace Glest{ namespace Game{
// ====================================================== // ======================================================
// Class FactionType // Class FactionType
// ====================================================== // ======================================================
FactionType::FactionType(){ FactionType::FactionType(){
@ -36,7 +36,7 @@ FactionType::FactionType(){
} }
//load a faction, given a directory //load a faction, given a directory
void FactionType::load(const string &dir, const TechTree *techTree, Checksum* checksum){ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* checksum,Checksum *techtreeChecksum) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -59,7 +59,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
for(int i=0; i<unitTypes.size(); ++i) { for(int i=0; i<unitTypes.size(); ++i) {
string str= dir + "/units/" + unitFilenames[i]; string str= dir + "/units/" + unitFilenames[i];
unitTypes[i].preLoad(str); unitTypes[i].preLoad(str);
SDL_PumpEvents(); SDL_PumpEvents();
} }
@ -79,7 +79,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
try{ try{
for(int i = 0; i < unitTypes.size(); ++i) { for(int i = 0; i < unitTypes.size(); ++i) {
string str= dir + "/units/" + unitTypes[i].getName(); string str= dir + "/units/" + unitTypes[i].getName();
unitTypes[i].load(i, str, techTree, this, checksum); unitTypes[i].load(i, str, techTree, this, checksum,techtreeChecksum);
SDL_PumpEvents(); SDL_PumpEvents();
} }
@ -93,7 +93,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
try{ try{
for(int i = 0; i < upgradeTypes.size(); ++i) { for(int i = 0; i < upgradeTypes.size(); ++i) {
string str= dir + "/upgrades/" + upgradeTypes[i].getName(); string str= dir + "/upgrades/" + upgradeTypes[i].getName();
upgradeTypes[i].load(str, techTree, this, checksum); upgradeTypes[i].load(str, techTree, this, checksum,techtreeChecksum);
SDL_PumpEvents(); SDL_PumpEvents();
} }
@ -105,7 +105,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
//open xml file //open xml file
string path= dir+"/"+name+".xml"; string path= dir+"/"+name+".xml";
checksum->addFile(path); checksum->addFile(path);
techtreeChecksum->addFile(path);
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(path); xmlTree.load(path);
@ -494,9 +495,9 @@ std::vector<std::string> FactionType::validateFactionTypeUpgradeTypes() {
return results; return results;
} }
// ==================== get ==================== // ==================== get ====================
const UnitType *FactionType::getUnitType(const string &name) const{ const UnitType *FactionType::getUnitType(const string &name) const{
for(int i=0; i<unitTypes.size();i++){ for(int i=0; i<unitTypes.size();i++){
if(unitTypes[i].getName()==name){ if(unitTypes[i].getName()==name){
return &unitTypes[i]; return &unitTypes[i];
@ -511,7 +512,7 @@ const UnitType *FactionType::getUnitType(const string &name) const{
throw runtime_error("Unit not found: "+name); throw runtime_error("Unit not found: "+name);
} }
const UpgradeType *FactionType::getUpgradeType(const string &name) const{ const UpgradeType *FactionType::getUpgradeType(const string &name) const{
for(int i=0; i<upgradeTypes.size();i++){ for(int i=0; i<upgradeTypes.size();i++){
if(upgradeTypes[i].getName()==name){ if(upgradeTypes[i].getName()==name){
return &upgradeTypes[i]; return &upgradeTypes[i];

View File

@ -3,9 +3,9 @@
// //
// Copyright (C) 2001-2008 Martio Figueroa // Copyright (C) 2001-2008 Martio Figueroa
// //
// You can redistribute this code and/or modify it under // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the // by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version // License, or (at your option) any later version
// ============================================================== // ==============================================================
@ -30,7 +30,7 @@ namespace Glest{ namespace Game{
class FactionType{ class FactionType{
private: private:
typedef pair<const UnitType*, int> PairPUnitTypeInt; typedef pair<const UnitType*, int> PairPUnitTypeInt;
typedef vector<UnitType> UnitTypes; typedef vector<UnitType> UnitTypes;
typedef vector<UpgradeType> UpgradeTypes; typedef vector<UpgradeType> UpgradeTypes;
typedef vector<PairPUnitTypeInt> StartingUnits; typedef vector<PairPUnitTypeInt> StartingUnits;
typedef vector<Resource> Resources; typedef vector<Resource> Resources;
@ -47,7 +47,7 @@ private:
public: public:
//init //init
FactionType(); FactionType();
void load(const string &dir, const TechTree *techTree, Checksum* checksum); void load(const string &dir, const TechTree *techTree, Checksum* checksum,Checksum *techtreeChecksum);
~FactionType(); ~FactionType();
//get //get
@ -60,9 +60,9 @@ public:
int getStartingUnitCount() const {return startingUnits.size();} int getStartingUnitCount() const {return startingUnits.size();}
const UnitType *getStartingUnit(int i) const {return startingUnits[i].first;} const UnitType *getStartingUnit(int i) const {return startingUnits[i].first;}
int getStartingUnitAmount(int i) const {return startingUnits[i].second;} int getStartingUnitAmount(int i) const {return startingUnits[i].second;}
const UnitType *getUnitType(const string &name) const; const UnitType *getUnitType(const string &name) const;
const UpgradeType *getUpgradeType(const string &name) const; const UpgradeType *getUpgradeType(const string &name) const;
int getStartingResourceAmount(const ResourceType *resourceType) const; int getStartingResourceAmount(const ResourceType *resourceType) const;
FactionPersonalityType getPersonalityType() const { return personalityType;} FactionPersonalityType getPersonalityType() const { return personalityType;}

View File

@ -38,7 +38,7 @@ ResourceType::ResourceType() {
model = NULL; model = NULL;
} }
void ResourceType::load(const string &dir, Checksum* checksum){ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum) {
string path, str; string path, str;
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
@ -51,7 +51,8 @@ void ResourceType::load(const string &dir, Checksum* checksum){
Logger::getInstance().add("Resource type: "+ formatString(name), true); Logger::getInstance().add("Resource type: "+ formatString(name), true);
path= dir+"/"+name+".xml"; path= dir+"/"+name+".xml";
checksum->addFile(path); checksum->addFile(path);
techtreeChecksum->addFile(path);
//tree //tree
XmlTree xmlTree; XmlTree xmlTree;

View File

@ -48,7 +48,7 @@ private:
public: public:
ResourceType(); ResourceType();
void load(const string &dir, Checksum* checksum); void load(const string &dir, Checksum* checksum,Checksum *techtreeChecksum);
//get //get
int getClass() const {return resourceClass;} int getClass() const {return resourceClass;}

View File

@ -31,17 +31,19 @@ namespace Glest{ namespace Game{
// class TechTree // class TechTree
// ===================================================== // =====================================================
void TechTree::loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum* checksum) { Checksum TechTree::loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum* checksum) {
Checksum techtreeChecksum;
for(int idx = 0; idx < pathList.size(); idx++) { for(int idx = 0; idx < pathList.size(); idx++) {
string path = pathList[idx] + "/" + techName; string path = pathList[idx] + "/" + techName;
if(isdir(path.c_str()) == true) { if(isdir(path.c_str()) == true) {
load(path, factions, checksum); load(path, factions, checksum, &techtreeChecksum);
break; break;
} }
} }
return techtreeChecksum;
} }
void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum) { void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum, Checksum *techtreeChecksum) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
string str; string str;
@ -59,7 +61,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
for(int i=0; i<filenames.size(); ++i){ for(int i=0; i<filenames.size(); ++i){
str=dir+"/resources/"+filenames[i]; str=dir+"/resources/"+filenames[i];
resourceTypes[i].load(str, checksum); resourceTypes[i].load(str, checksum, &checksumValue);
SDL_PumpEvents(); SDL_PumpEvents();
} }
@ -82,7 +84,8 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
XmlTree xmlTree; XmlTree xmlTree;
string path= dir+"/"+lastDir(dir)+".xml"; string path= dir+"/"+lastDir(dir)+".xml";
checksum->addFile(path); checksum->addFile(path);
checksumValue.addFile(path);
xmlTree.load(path); xmlTree.load(path);
const XmlNode *techTreeNode= xmlTree.getRootNode(); const XmlNode *techTreeNode= xmlTree.getRootNode();
@ -133,7 +136,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
//SDL_PumpEvents(); //SDL_PumpEvents();
//load factions //load factions
str= dir+"/factions/*."; str = dir + "/factions/*.";
try{ try{
factionTypes.resize(factions.size()); factionTypes.resize(factions.size());
@ -147,7 +150,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
logger.setState(szBuf); logger.setState(szBuf);
str=dir+"/factions/" + factionName; str=dir+"/factions/" + factionName;
factionTypes[i++].load(str, this, checksum); factionTypes[i++].load(str, this, checksum,&checksumValue);
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
@ -157,12 +160,16 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
catch(const exception &e){ catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading Faction Types: "+ dir + "\n" + e.what()); throw runtime_error("Error loading Faction Types: "+ dir + "\n" + e.what());
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(techtreeChecksum != NULL) {
*techtreeChecksum = checksumValue;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
TechTree::~TechTree(){ TechTree::~TechTree() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Logger::getInstance().add("Tech tree", true); Logger::getInstance().add("Tech tree", true);
} }

View File

@ -42,11 +42,13 @@ private:
ArmorTypes armorTypes; ArmorTypes armorTypes;
AttackTypes attackTypes; AttackTypes attackTypes;
DamageMultiplierTable damageMultiplierTable; DamageMultiplierTable damageMultiplierTable;
Checksum checksumValue;
public: public:
void loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum* checksum); Checksum loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum* checksum);
void load(const string &dir, set<string> &factions, Checksum* checksum); void load(const string &dir, set<string> &factions, Checksum* checksum,Checksum *techtreeChecksum);
~TechTree(); ~TechTree();
Checksum * getChecksumValue() { return &checksumValue; }
//get //get
int getResourceTypeCount() const {return resourceTypes.size();} int getResourceTypeCount() const {return resourceTypes.size();}

View File

@ -101,7 +101,7 @@ void UnitType::preLoad(const string &dir){
name= lastDir(dir); name= lastDir(dir);
} }
void UnitType::load(int id,const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum){ void UnitType::load(int id,const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum,Checksum* techtreeChecksum) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -114,7 +114,8 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
Logger::getInstance().add("Unit type: " + formatString(name), true); Logger::getInstance().add("Unit type: " + formatString(name), true);
//file load //file load
checksum->addFile(path); checksum->addFile(path);
techtreeChecksum->addFile(path);
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(path); xmlTree.load(path);
@ -146,7 +147,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
if(parametersNode->hasChild("max-unit-count")){ if(parametersNode->hasChild("max-unit-count")){
maxUnitCount= parametersNode->getChild("max-unit-count")->getAttribute("value")->getIntValue(); maxUnitCount= parametersNode->getChild("max-unit-count")->getAttribute("value")->getIntValue();
} }
//armor //armor
armor= parametersNode->getChild("armor")->getAttribute("value")->getIntValue(); armor= parametersNode->getChild("armor")->getAttribute("value")->getIntValue();
@ -679,7 +680,7 @@ string UnitType::getReqDesc() const{
return ProducibleType::getReqDesc(); return ProducibleType::getReqDesc();
else else
return ProducibleType::getReqDesc()+"\nLimits: "+resultTxt; return ProducibleType::getReqDesc()+"\nLimits: "+resultTxt;
} }
std::string UnitType::toString() const { std::string UnitType::toString() const {
std::string result = ""; std::string result = "";
@ -690,7 +691,7 @@ std::string UnitType::toString() const {
result += " maxEp = " + intToStr(maxEp); result += " maxEp = " + intToStr(maxEp);
result += " epRegeneration = " + intToStr(epRegeneration); result += " epRegeneration = " + intToStr(epRegeneration);
result += " maxUnitCount = " + intToStr(getMaxUnitCount()); result += " maxUnitCount = " + intToStr(getMaxUnitCount());
for(int i = 0; i < fieldCount; i++) { for(int i = 0; i < fieldCount; i++) {
result += " fields index = " + intToStr(i) + " value = " + intToStr(fields[i]); result += " fields index = " + intToStr(i) + " value = " + intToStr(fields[i]);

View File

@ -89,8 +89,8 @@ private:
int maxEp; int maxEp;
int epRegeneration; int epRegeneration;
int maxUnitCount; int maxUnitCount;
///@todo remove fields, multiple fields are not supported by the engine ///@todo remove fields, multiple fields are not supported by the engine
bool fields[fieldCount]; //fields: land, sea or air bool fields[fieldCount]; //fields: land, sea or air
Field field; Field field;
@ -134,7 +134,7 @@ public:
UnitType(); UnitType();
virtual ~UnitType(); virtual ~UnitType();
void preLoad(const string &dir); void preLoad(const string &dir);
void load(int id, const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum); void load(int id, const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum, Checksum* techtreeChecksum);
//get //get
int getId() const {return id;} int getId() const {return id;}
@ -205,7 +205,7 @@ public:
//other //other
virtual string getReqDesc() const; virtual string getReqDesc() const;
std::string toString() const; std::string toString() const;
private: private:

View File

@ -3,9 +3,9 @@
// //
// Copyright (C) 2001-2008 Martio Figueroa // Copyright (C) 2001-2008 Martio Figueroa
// //
// You can redistribute this code and/or modify it under // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the // by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version // License, or (at your option) any later version
// ============================================================== // ==============================================================
@ -14,7 +14,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include "unit_type.h" #include "unit_type.h"
#include "util.h" #include "util.h"
#include "logger.h" #include "logger.h"
#include "lang.h" #include "lang.h"
@ -35,29 +35,30 @@ namespace Glest{ namespace Game{
// class UpgradeType // class UpgradeType
// ===================================================== // =====================================================
// ==================== get ==================== // ==================== get ====================
bool UpgradeType::isAffected(const UnitType *unitType) const{ bool UpgradeType::isAffected(const UnitType *unitType) const{
return find(effects.begin(), effects.end(), unitType)!=effects.end(); return find(effects.begin(), effects.end(), unitType)!=effects.end();
} }
// ==================== misc ==================== // ==================== misc ====================
void UpgradeType::preLoad(const string &dir){ void UpgradeType::preLoad(const string &dir){
name=lastDir(dir); name=lastDir(dir);
} }
void UpgradeType::load(const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum){ void UpgradeType::load(const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum, Checksum* techtreeChecksum) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
string path; string path;
Logger::getInstance().add("Upgrade type: "+ formatString(name), true); Logger::getInstance().add("Upgrade type: "+ formatString(name), true);
path=dir+"/"+name+".xml"; path = dir + "/" + name + ".xml";
try{ try{
checksum->addFile(path); checksum->addFile(path);
techtreeChecksum->addFile(path);
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(path); xmlTree.load(path);
@ -76,7 +77,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const Factio
//upgrade time //upgrade time
const XmlNode *upgradeTimeNode= upgradeNode->getChild("time"); const XmlNode *upgradeTimeNode= upgradeNode->getChild("time");
productionTime= upgradeTimeNode->getAttribute("value")->getIntValue(); productionTime= upgradeTimeNode->getAttribute("value")->getIntValue();
//unit requirements //unit requirements
const XmlNode *unitRequirementsNode= upgradeNode->getChild("unit-requirements"); const XmlNode *unitRequirementsNode= upgradeNode->getChild("unit-requirements");
for(int i=0; i<unitRequirementsNode->getChildCount(); ++i){ for(int i=0; i<unitRequirementsNode->getChildCount(); ++i){
@ -120,7 +121,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const Factio
armor= upgradeNode->getChild("armor")->getAttribute("value")->getIntValue(); armor= upgradeNode->getChild("armor")->getAttribute("value")->getIntValue();
moveSpeed= upgradeNode->getChild("move-speed")->getAttribute("value")->getIntValue(); moveSpeed= upgradeNode->getChild("move-speed")->getAttribute("value")->getIntValue();
prodSpeed= upgradeNode->getChild("production-speed")->getAttribute("value")->getIntValue(); prodSpeed= upgradeNode->getChild("production-speed")->getAttribute("value")->getIntValue();
} }
catch(const exception &e){ catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
@ -131,7 +132,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const Factio
} }
string UpgradeType::getReqDesc() const{ string UpgradeType::getReqDesc() const{
string str; string str;
int i; int i;
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
@ -141,9 +142,9 @@ string UpgradeType::getReqDesc() const{
str+= "\n"+ lang.get("Upgrades")+":\n"; str+= "\n"+ lang.get("Upgrades")+":\n";
for(i=0; i<getEffectCount(); ++i){ for(i=0; i<getEffectCount(); ++i){
str+= getEffect(i)->getName()+"\n"; str+= getEffect(i)->getName()+"\n";
} }
} }
if(maxHp!=0){ if(maxHp!=0){
str+= lang.get("Hp")+" +"+intToStr(maxHp); str+= lang.get("Hp")+" +"+intToStr(maxHp);
} }
@ -157,7 +158,7 @@ string UpgradeType::getReqDesc() const{
str+= lang.get("AttackStrenght")+" +"+intToStr(attackStrength)+"\n"; str+= lang.get("AttackStrenght")+" +"+intToStr(attackStrength)+"\n";
} }
if(attackRange!=0){ if(attackRange!=0){
str+= lang.get("AttackDistance")+" +"+intToStr(attackRange)+"\n"; str+= lang.get("AttackDistance")+" +"+intToStr(attackRange)+"\n";
} }
if(armor!=0){ if(armor!=0){
str+= lang.get("Armor")+" +"+intToStr(armor)+"\n"; str+= lang.get("Armor")+" +"+intToStr(armor)+"\n";
@ -175,7 +176,7 @@ string UpgradeType::getReqDesc() const{
// =============================== // ===============================
// class TotalUpgrade // class TotalUpgrade
// =============================== // ===============================
TotalUpgrade::TotalUpgrade(){ TotalUpgrade::TotalUpgrade(){

View File

@ -3,9 +3,9 @@
// //
// Copyright (C) 2001-2008 Martio Figueroa // Copyright (C) 2001-2008 Martio Figueroa
// //
// You can redistribute this code and/or modify it under // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the // by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version // License, or (at your option) any later version
// ============================================================== // ==============================================================
@ -27,7 +27,7 @@ class FactionType;
class UnitType; class UnitType;
// =============================== // ===============================
// class UpgradeTypeBase // class UpgradeTypeBase
// =============================== // ===============================
class UpgradeTypeBase{ class UpgradeTypeBase{
@ -39,7 +39,7 @@ protected:
int attackStrength; int attackStrength;
int attackRange; int attackRange;
int moveSpeed; int moveSpeed;
int prodSpeed; int prodSpeed;
public: public:
int getMaxHp() const {return maxHp;} int getMaxHp() const {return maxHp;}
@ -68,28 +68,28 @@ public:
}; };
// =============================== // ===============================
// class UpgradeType // class UpgradeType
// =============================== // ===============================
class UpgradeType: public UpgradeTypeBase, public ProducibleType{ class UpgradeType: public UpgradeTypeBase, public ProducibleType{
private: private:
vector<const UnitType*> effects; vector<const UnitType*> effects;
public: public:
void preLoad(const string &dir); void preLoad(const string &dir);
void load(const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum); void load(const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum, Checksum* techtreeChecksum);
//get all //get all
int getEffectCount() const {return effects.size();} int getEffectCount() const {return effects.size();}
const UnitType * getEffect(int i) const {return effects[i];} const UnitType * getEffect(int i) const {return effects[i];}
bool isAffected(const UnitType *unitType) const; bool isAffected(const UnitType *unitType) const;
//other methods //other methods
virtual string getReqDesc() const; virtual string getReqDesc() const;
}; };
// =============================== // ===============================
// class TotalUpgrade // class TotalUpgrade
// =============================== // ===============================
class TotalUpgrade: public UpgradeTypeBase{ class TotalUpgrade: public UpgradeTypeBase{
@ -97,7 +97,7 @@ public:
TotalUpgrade(); TotalUpgrade();
void reset(); void reset();
void sum(const UpgradeType *ut); void sum(const UpgradeType *ut);
void incLevel(const UnitType *ut); void incLevel(const UnitType *ut);
}; };

View File

@ -155,7 +155,9 @@ Vec2i Map::getStartLocation(int locationIndex) const {
return startLocations[locationIndex]; return startLocations[locationIndex];
} }
void Map::load(const string &path, TechTree *techTree, Tileset *tileset) { Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
Checksum mapChecksum;
struct MapFileHeader{ struct MapFileHeader{
int32 version; int32 version;
int32 maxPlayers; int32 maxPlayers;
@ -169,9 +171,10 @@ void Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
}; };
try{ try{
FILE *f= fopen(path.c_str(), "rb"); FILE *f = fopen(path.c_str(), "rb");
if(f!=NULL){ if(f != NULL) {
mapChecksum.addFile(path);
checksumValue.addFile(path);
//read header //read header
MapFileHeader header; MapFileHeader header;
size_t readBytes = fread(&header, sizeof(MapFileHeader), 1, f); size_t readBytes = fread(&header, sizeof(MapFileHeader), 1, f);
@ -196,22 +199,21 @@ void Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
//start locations //start locations
startLocations= new Vec2i[maxPlayers]; startLocations= new Vec2i[maxPlayers];
for(int i=0; i<maxPlayers; ++i) { for(int i=0; i < maxPlayers; ++i) {
int x, y; int x=0, y=0;
readBytes = fread(&x, sizeof(int32), 1, f); readBytes = fread(&x, sizeof(int32), 1, f);
readBytes = fread(&y, sizeof(int32), 1, f); readBytes = fread(&y, sizeof(int32), 1, f);
startLocations[i]= Vec2i(x, y)*cellScale; startLocations[i]= Vec2i(x, y)*cellScale;
} }
//cells //cells
cells= new Cell[getCellArraySize()]; cells= new Cell[getCellArraySize()];
surfaceCells= new SurfaceCell[getSurfaceCellArraySize()]; surfaceCells= new SurfaceCell[getSurfaceCellArraySize()];
//read heightmap //read heightmap
for(int j=0; j<surfaceH; ++j){ for(int j = 0; j < surfaceH; ++j) {
for(int i=0; i<surfaceW; ++i){ for(int i = 0; i < surfaceW; ++i) {
float32 alt; float32 alt=0;
readBytes = fread(&alt, sizeof(float32), 1, f); readBytes = fread(&alt, sizeof(float32), 1, f);
SurfaceCell *sc= getSurfaceCell(i, j); SurfaceCell *sc= getSurfaceCell(i, j);
sc->setVertex(Vec3f(i*mapScale, alt / heightFactor, j*mapScale)); sc->setVertex(Vec3f(i*mapScale, alt / heightFactor, j*mapScale));
@ -219,30 +221,30 @@ void Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
} }
//read surfaces //read surfaces
for(int j=0; j<surfaceH; ++j){ for(int j = 0; j < surfaceH; ++j) {
for(int i=0; i<surfaceW; ++i){ for(int i = 0; i < surfaceW; ++i) {
int8 surf; int8 surf=0;
readBytes = fread(&surf, sizeof(int8), 1, f); readBytes = fread(&surf, sizeof(int8), 1, f);
getSurfaceCell(i, j)->setSurfaceType(surf-1); getSurfaceCell(i, j)->setSurfaceType(surf-1);
} }
} }
//read objects and resources //read objects and resources
for(int j=0; j<h; j+= cellScale){ for(int j = 0; j < h; j += cellScale) {
for(int i=0; i<w; i+= cellScale){ for(int i = 0; i < w; i += cellScale) {
int8 objNumber; int8 objNumber=0;
readBytes = fread(&objNumber, sizeof(int8), 1, f); readBytes = fread(&objNumber, sizeof(int8), 1, f);
SurfaceCell *sc= getSurfaceCell(toSurfCoords(Vec2i(i, j))); SurfaceCell *sc= getSurfaceCell(toSurfCoords(Vec2i(i, j)));
if(objNumber==0){ if(objNumber == 0) {
sc->setObject(NULL); sc->setObject(NULL);
} }
else if(objNumber <= Tileset::objCount){ else if(objNumber <= Tileset::objCount) {
Object *o= new Object(tileset->getObjectType(objNumber-1), sc->getVertex(),Vec2i(i, j)); Object *o= new Object(tileset->getObjectType(objNumber-1), sc->getVertex(),Vec2i(i, j));
sc->setObject(o); sc->setObject(o);
for(int k=0; k<techTree->getResourceTypeCount(); ++k){ for(int k = 0; k < techTree->getResourceTypeCount(); ++k) {
const ResourceType *rt= techTree->getResourceType(k); const ResourceType *rt= techTree->getResourceType(k);
if(rt->getClass()==rcTileset && rt->getTilesetObject()==objNumber){ if(rt->getClass() == rcTileset && rt->getTilesetObject() == objNumber){
o->setResource(rt, Vec2i(i, j)); o->setResource(rt, Vec2i(i, j));
} }
} }
@ -265,6 +267,8 @@ void Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading map: "+ path+ "\n"+ e.what()); throw runtime_error("Error loading map: "+ path+ "\n"+ e.what());
} }
return mapChecksum;
} }
void Map::init() { void Map::init() {

View File

@ -45,7 +45,7 @@ class GameSettings;
/// A map cell that holds info about units present on it /// A map cell that holds info about units present on it
// ===================================================== // =====================================================
class Cell{ class Cell {
private: private:
Unit *units[fieldCount]; //units on this cell Unit *units[fieldCount]; //units on this cell
Unit *unitsWithEmptyCellMap[fieldCount]; //units with an empty cellmap on this cell Unit *unitsWithEmptyCellMap[fieldCount]; //units with an empty cellmap on this cell
@ -76,7 +76,7 @@ public:
// A heightmap cell, each surface cell is composed by more than one Cell // A heightmap cell, each surface cell is composed by more than one Cell
// ===================================================== // =====================================================
class SurfaceCell{ class SurfaceCell {
private: private:
//geometry //geometry
Vec3f vertex; Vec3f vertex;
@ -147,7 +147,7 @@ public:
/// Represents the game map (and loads it from a gbm file) /// Represents the game map (and loads it from a gbm file)
// ===================================================== // =====================================================
class Map{ class Map {
public: public:
static const int cellScale; //number of cells per surfaceCell static const int cellScale; //number of cells per surfaceCell
static const int mapScale; //horizontal scale of surface static const int mapScale; //horizontal scale of surface
@ -163,7 +163,8 @@ private:
int maxPlayers; int maxPlayers;
Cell *cells; Cell *cells;
SurfaceCell *surfaceCells; SurfaceCell *surfaceCells;
Vec2i *startLocations; Vec2i *startLocations;
Checksum checksumValue;
private: private:
Map(Map&); Map(Map&);
@ -171,10 +172,11 @@ private:
public: public:
Map(); Map();
~Map(); ~Map();
Checksum * getChecksumValue() { return &checksumValue; }
void init(); void init();
void load(const string &path, TechTree *techTree, Tileset *tileset); Checksum load(const string &path, TechTree *techTree, Tileset *tileset);
//get //get
Cell *getCell(int x, int y) const; Cell *getCell(int x, int y) const;

View File

@ -30,14 +30,18 @@ namespace Glest{ namespace Game{
// class Scenario // class Scenario
// ===================================================== // =====================================================
Scenario::~Scenario(){ Scenario::~Scenario() {
} }
void Scenario::load(const string &path){ Checksum Scenario::load(const string &path) {
try{ Checksum scenarioChecksum;
try {
scenarioChecksum.addFile(path);
checksumValue.addFile(path);
string name= cutLastExt(lastDir(path)); string name= cutLastExt(lastDir(path));
Logger::getInstance().add("Scenario: "+formatString(name), true); Logger::getInstance().add("Scenario: " + formatString(name), true);
//parse xml //parse xml
XmlTree xmlTree; XmlTree xmlTree;
@ -52,10 +56,12 @@ void Scenario::load(const string &path){
} }
} }
//Exception handling (conversions and so on); //Exception handling (conversions and so on);
catch(const exception &e){ catch(const exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error: " + path + "\n" + e.what()); throw runtime_error("Error: " + path + "\n" + e.what());
} }
return scenarioChecksum;
} }
int Scenario::getScenarioPathIndex(const vector<string> dirList, const string &scenarioName) { int Scenario::getScenarioPathIndex(const vector<string> dirList, const string &scenarioName) {
@ -85,7 +91,7 @@ string Scenario::getScenarioPath(const vector<string> dirList, const string &sce
scenarioFile = ""; scenarioFile = "";
} }
} }
return scenarioFile; return scenarioFile;
} }

View File

@ -14,22 +14,24 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "xml_parser.h" #include "xml_parser.h"
#include "checksum.h"
#include "leak_dumper.h" #include "leak_dumper.h"
using std::string; using std::string;
using std::vector; using std::vector;
using std::pair; using std::pair;
using Shared::Xml::XmlNode; using Shared::Xml::XmlNode;
using namespace Shared::Util;
namespace Glest{ namespace Game{ namespace Glest { namespace Game {
// ===================================================== // =====================================================
// class Script // class Script
// ===================================================== // =====================================================
class Script{ class Script {
private: private:
string name; string name;
string code; string code;
@ -45,16 +47,18 @@ public:
// class Scenario // class Scenario
// ===================================================== // =====================================================
class Scenario{ class Scenario {
private: private:
typedef pair<string, string> NameScriptPair; typedef pair<string, string> NameScriptPair;
typedef vector<Script> Scripts; typedef vector<Script> Scripts;
Scripts scripts; Scripts scripts;
Checksum checksumValue;
public: public:
~Scenario(); ~Scenario();
void load(const string &path); Checksum load(const string &path);
Checksum * getChecksumValue() { return &checksumValue; }
int getScriptCount() const {return scripts.size();} int getScriptCount() const {return scripts.size();}
const Script* getScript(int i) const {return &scripts[i];} const Script* getScript(int i) const {return &scripts[i];}

View File

@ -90,18 +90,20 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode){
// class Tileset // class Tileset
// ===================================================== // =====================================================
void Tileset::loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum) { Checksum Tileset::loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum) {
Checksum tilesetChecksum;
for(int idx = 0; idx < pathList.size(); idx++) { for(int idx = 0; idx < pathList.size(); idx++) {
const string path = pathList[idx] + "/" + tilesetName; const string path = pathList[idx] + "/" + tilesetName;
if(isdir(path.c_str()) == true) { if(isdir(path.c_str()) == true) {
load(path, checksum); load(path, checksum, &tilesetChecksum);
break; break;
} }
} }
return tilesetChecksum;
} }
void Tileset::load(const string &dir, Checksum *checksum){ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
random.init(time(NULL)); random.init(time(NULL));
@ -109,9 +111,11 @@ void Tileset::load(const string &dir, Checksum *checksum){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
string name= lastDir(dir); string name= lastDir(dir);
string path= dir+"/"+name+".xml"; string path= dir + "/" + name + ".xml";
checksum->addFile(path); checksum->addFile(path);
tilesetChecksum->addFile(path);
checksumValue.addFile(path);
try { try {
Logger::getInstance().add("Tileset: "+formatString(name), true); Logger::getInstance().add("Tileset: "+formatString(name), true);
@ -262,7 +266,7 @@ void Tileset::load(const string &dir, Checksum *checksum){
} }
} }
Tileset::~Tileset(){ Tileset::~Tileset() {
Logger::getInstance().add("Tileset", true); Logger::getInstance().add("Tileset", true);
} }

View File

@ -126,12 +126,14 @@ private:
Vec3f moonLightColor; Vec3f moonLightColor;
Weather weather; Weather weather;
AmbientSounds ambientSounds; AmbientSounds ambientSounds;
Checksum checksumValue;
public: public:
~Tileset(); ~Tileset();
void loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum); Checksum loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum);
void load(const string &dir, Checksum *checksum); void load(const string &dir, Checksum *checksum, Checksum *tilesetChecksum);
Checksum * getChecksumValue() { return &checksumValue; }
//get //get
const SurfaceAtlas *getSurfaceAtlas() const {return &surfaceAtlas;} const SurfaceAtlas *getSurfaceAtlas() const {return &surfaceAtlas;}

View File

@ -181,39 +181,40 @@ void World::init(Game *game, bool createUnits){
} }
//load tileset //load tileset
void World::loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum) { Checksum World::loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum) {
Checksum tilsetChecksum;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
tileset.loadTileset(pathList, tilesetName, checksum); tilsetChecksum = tileset.loadTileset(pathList, tilesetName, checksum);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
timeFlow.init(&tileset); timeFlow.init(&tileset);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return tilsetChecksum;
} }
void World::loadTileset(const string &dir, Checksum *checksum){ Checksum World::loadTileset(const string &dir, Checksum *checksum) {
Checksum tilesetChecksum;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
tileset.load(dir, checksum); tileset.load(dir, checksum, &tilesetChecksum);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
timeFlow.init(&tileset); timeFlow.init(&tileset);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return tilesetChecksum;
} }
//load tech //load tech
void World::loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum *checksum){ Checksum World::loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum *checksum) {
Checksum techtreeChecksum;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
/*
std::map<string,TechTree *> &techCache = Shared::PlatformCommon::CacheManager::getCachedItem< std::map<string,TechTree *> >("techCache");
if(techCache.find(techName) != techCache.end()) {
techTree = new TechTree();
*techTree = *techCache[techName];
return;
}
*/
techTree = new TechTree(); techTree = new TechTree();
techTree->loadTech(pathList, techName, factions, checksum); techtreeChecksum = techTree->loadTech(pathList, techName, factions, checksum);
return techtreeChecksum;
//techCache[techName] = techTree;
} }
std::vector<std::string> World::validateFactionTypes() { std::vector<std::string> World::validateFactionTypes() {
@ -225,20 +226,25 @@ std::vector<std::string> World::validateResourceTypes() {
} }
//load map //load map
void World::loadMap(const string &path, Checksum *checksum){ Checksum World::loadMap(const string &path, Checksum *checksum) {
Checksum mapChecksum;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
checksum->addFile(path); checksum->addFile(path);
map.load(path, techTree, &tileset); mapChecksum = map.load(path, techTree, &tileset);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return mapChecksum;
} }
//load map //load map
void World::loadScenario(const string &path, Checksum *checksum){ Checksum World::loadScenario(const string &path, Checksum *checksum) {
Checksum scenarioChecksum;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
checksum->addFile(path); checksum->addFile(path);
scenario.load(path);
scenarioChecksum = scenario.load(path);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return scenarioChecksum;
} }
// ==================== misc ==================== // ==================== misc ====================

View File

@ -168,11 +168,11 @@ public:
//init & load //init & load
void init(Game *game, bool createUnits); void init(Game *game, bool createUnits);
void loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum); Checksum loadTileset(const vector<string> pathList, const string &tilesetName, Checksum* checksum);
void loadTileset(const string &dir, Checksum* checksum); Checksum loadTileset(const string &dir, Checksum* checksum);
void loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum* checksum); Checksum loadTech(const vector<string> pathList, const string &techName, set<string> &factions, Checksum* checksum);
void loadMap(const string &path, Checksum* checksum); Checksum loadMap(const string &path, Checksum* checksum);
void loadScenario(const string &path, Checksum* checksum); Checksum loadScenario(const string &path, Checksum* checksum);
//misc //misc
void update(); void update();

View File

@ -42,7 +42,7 @@ void ftpInit(ftpFindExternalFTPServerIpType cb1, ftpAddUPNPPortForwardType cb2,
int ftpCreateAccount(const char* name, const char* passw, const char* root, int accRights); int ftpCreateAccount(const char* name, const char* passw, const char* root, int accRights);
int ftpStart(int portNumber); int ftpStart(int portNumber);
int ftpShutdown(void); int ftpShutdown(void);
void ftpExecute(void); int ftpExecute(void);
int ftpState(void); int ftpState(void);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -137,21 +137,22 @@ int ftpState(void)
* all received control-strings are dispatched to the command-module. * all received control-strings are dispatched to the command-module.
* Note, the function blocks if there is nothing to do. * Note, the function blocks if there is nothing to do.
*/ */
void ftpExecute(void) int ftpExecute(void)
{ {
int n; int processedWork=0;
int socksRdy; int n=0;
ftpSession_S *pSession; int socksRdy=0;
int sessionId; ftpSession_S *pSession=NULL;
int activeJobs; int sessionId=0;
int activeJobs=0;
activeJobs = ftpGetActiveTransCnt(); // are there any active transmitions? activeJobs = ftpGetActiveTransCnt(); // are there any active transmitions?
for(n = 0; (activeJobs > 0) && (n < MAX_CONNECTIONS); n++) for(n = 0; (activeJobs > 0) && (n < MAX_CONNECTIONS); n++)
{ {
pSession = ftpGetSession(n); pSession = ftpGetSession(n);
if(pSession->activeTrans.op) // has this session an active transmition? if(pSession->activeTrans.op) // has this session an active transmition?
{ {
processedWork = 1;
ftpExecTransmission(n); // do the job ftpExecTransmission(n); // do the job
activeJobs--; activeJobs--;
} }
@ -162,7 +163,8 @@ void ftpExecute(void)
//else //else
// socksRdy = ftpSelect(FALSE); // socksRdy = ftpSelect(FALSE);
if(socksRdy > 0) if(socksRdy > 0)
{ {
processedWork = 1;
if(ftpTestSocket(server)) // server listner-socket signaled? if(ftpTestSocket(server)) // server listner-socket signaled?
{ {
socket_t clientSocket; socket_t clientSocket;
@ -222,7 +224,9 @@ if(VERBOSE_MODE_ENABLED) printf("Connection refused; Session limit reached.\n");
} }
} }
} }
} }
return processedWork;
} }

View File

@ -128,8 +128,10 @@ void FTPServerThread::execute() {
*/ */
ftpStart(portNumber); ftpStart(portNumber);
while(this->getQuitStatus() == false) { while(this->getQuitStatus() == false) {
ftpExecute(); int processedWork = ftpExecute();
//sleep(25); if(processedWork == 0) {
sleep(25);
}
} }
ftpShutdown(); ftpShutdown();

View File

@ -1016,6 +1016,8 @@ int Socket::getDataToRead(bool wantImmediateReply) {
int Socket::send(const void *data, int dataSize) { int Socket::send(const void *data, int dataSize) {
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
const int MAX_SEND_WAIT_SECONDS = 3;
int bytesSent= 0; int bytesSent= 0;
if(isSocketValid() == true) { if(isSocketValid() == true) {
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -1048,12 +1050,11 @@ int Socket::send(const void *data, int dataSize) {
int attemptCount = 0; int attemptCount = 0;
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= 5)) { (difftime(time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) {
attemptCount++; attemptCount++;
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
{ if(isConnected() == true) {
//if(Socket::isWritable(true) == true) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data);
MutexSafeWrapper safeMutex(&dataSynchAccessor); MutexSafeWrapper safeMutex(&dataSynchAccessor);
@ -1063,7 +1064,15 @@ int Socket::send(const void *data, int dataSize) {
bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL); bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL);
#endif #endif
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #2 EAGAIN during send, trying again returned: %d\n",__FILE__,__FUNCTION__,bytesSent); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during send, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent);
}
else {
int iErr = getLastSocketError();
disconnectSocket();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] DISCONNECTED SOCKET error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,bytesSent,getLastSocketErrorFormattedText(&iErr).c_str());
break;
} }
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
} }
@ -1077,12 +1086,11 @@ int Socket::send(const void *data, int dataSize) {
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while(((bytesSent > 0 && totalBytesSent < dataSize) || while(((bytesSent > 0 && totalBytesSent < dataSize) ||
(bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN)) && (bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN)) &&
(difftime(time(NULL),tStartTimer) <= 5)) { (difftime(time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) {
attemptCount++; attemptCount++;
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, totalBytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,totalBytesSent); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, totalBytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,totalBytesSent);
{ if(isConnected() == true) {
//if(bytesSent > 0 || Socket::isWritable(true) == true) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data);
MutexSafeWrapper safeMutex(&dataSynchAccessor); MutexSafeWrapper safeMutex(&dataSynchAccessor);
@ -1097,6 +1105,14 @@ int Socket::send(const void *data, int dataSize) {
} }
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] retry send returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] retry send returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent);
} }
else {
int iErr = getLastSocketError();
disconnectSocket();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText(&iErr).c_str());
break;
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
} }
@ -1115,17 +1131,18 @@ int Socket::send(const void *data, int dataSize) {
int iErr = getLastSocketError(); int iErr = getLastSocketError();
disconnectSocket(); disconnectSocket();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] DISCONNECTED SOCKET error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,bytesSent,getLastSocketErrorFormattedText(&iErr).c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText(&iErr).c_str());
//throwException(szBuf); //throwException(szBuf);
} }
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] sock = %d, bytesSent = %d\n",__FILE__,__FUNCTION__,sock,bytesSent); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] sock = %d, bytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,sock,bytesSent);
return static_cast<int>(bytesSent); return static_cast<int>(bytesSent);
} }
int Socket::receive(void *data, int dataSize) int Socket::receive(void *data, int dataSize) {
{ const int MAX_RECV_WAIT_SECONDS = 3;
ssize_t bytesReceived = 0; ssize_t bytesReceived = 0;
if(isSocketValid() == true) { if(isSocketValid() == true) {
@ -1141,12 +1158,19 @@ int Socket::receive(void *data, int dataSize)
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && while((bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= 5)) { (difftime(time(NULL),tStartTimer) <= MAX_RECV_WAIT_SECONDS)) {
if(Socket::isReadable() == true) { if(isConnected() == false) {
int iErr = getLastSocketError();
disconnectSocket();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while receiving socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText(&iErr).c_str());
break;
}
else if(Socket::isReadable() == true) {
MutexSafeWrapper safeMutex(&dataSynchAccessor); MutexSafeWrapper safeMutex(&dataSynchAccessor);
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0); bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #2 EAGAIN during receive, trying again returned: %d\n",__FILE__,__FUNCTION__,bytesReceived); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during receive, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived);
} }
} }
} }
@ -1155,20 +1179,22 @@ int Socket::receive(void *data, int dataSize)
int iErr = getLastSocketError(); int iErr = getLastSocketError();
disconnectSocket(); disconnectSocket();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] DISCONNECTED SOCKET error while receiving socket data, bytesReceived = %d, error = %s\n",__FILE__,__FUNCTION__,bytesReceived,getLastSocketErrorFormattedText(&iErr).c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while receiving socket data, bytesReceived = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText(&iErr).c_str());
//throwException(szBuf); //throwException(szBuf);
} }
return static_cast<int>(bytesReceived); return static_cast<int>(bytesReceived);
} }
int Socket::peek(void *data, int dataSize){ int Socket::peek(void *data, int dataSize) {
const int MAX_PEEK_WAIT_SECONDS = 3;
ssize_t err = 0; ssize_t err = 0;
if(isSocketValid() == true) { if(isSocketValid() == true) {
MutexSafeWrapper safeMutex(&dataSynchAccessor); MutexSafeWrapper safeMutex(&dataSynchAccessor);
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK); err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
} }
if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR PEEKING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR PEEKING SOCKET DATA error while sending socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str());
//throwException(szBuf); //throwException(szBuf);
disconnectSocket(); disconnectSocket();
@ -1178,8 +1204,15 @@ int Socket::peek(void *data, int dataSize){
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && while((err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= 5)) { (difftime(time(NULL),tStartTimer) <= MAX_PEEK_WAIT_SECONDS)) {
if(Socket::isReadable() == true) { if(isConnected() == false) {
int iErr = getLastSocketError();
disconnectSocket();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while peeking socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText(&iErr).c_str());
break;
}
else if(Socket::isReadable() == true) {
MutexSafeWrapper safeMutex(&dataSynchAccessor); MutexSafeWrapper safeMutex(&dataSynchAccessor);
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK); err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
@ -1239,12 +1272,12 @@ bool Socket::isReadable() {
i= select((int)sock + 1, &set, NULL, NULL, &tv); i= select((int)sock + 1, &set, NULL, NULL, &tv);
} }
if(i < 0) { if(i < 0) {
if(difftime(time(NULL),lastDebugEvent) >= 1) { //if(difftime(time(NULL),lastDebugEvent) >= 1) {
lastDebugEvent = time(NULL); // lastDebugEvent = time(NULL);
//throwException("Error selecting socket"); //throwException("Error selecting socket");
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] error while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,i,getLastSocketErrorFormattedText().c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] error while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,i,getLastSocketErrorFormattedText().c_str());
} //}
} }
bool result = (i == 1); bool result = (i == 1);
return result; return result;
@ -1262,7 +1295,7 @@ bool Socket::isWritable(bool waitOnDelayedResponse) {
FD_SET(sock, &set); FD_SET(sock, &set);
time_t maxElapsedCheck = time(NULL); time_t maxElapsedCheck = time(NULL);
const int MAX_CHECK_WAIT_SECONDS = 5; const int MAX_CHECK_WAIT_SECONDS = 2;
bool result = false; bool result = false;
do { do {
@ -1278,9 +1311,9 @@ bool Socket::isWritable(bool waitOnDelayedResponse) {
} }
if(i < 0 ) { if(i < 0 ) {
//if(difftime(time(NULL),lastDebugEvent) >= 1) { //if(difftime(time(NULL),lastDebugEvent) >= 1) {
lastDebugEvent = time(NULL); // lastDebugEvent = time(NULL);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] error while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,i,getLastSocketErrorFormattedText().c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] error while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,i,getLastSocketErrorFormattedText().c_str());
//} //}
waitOnDelayedResponse = false; waitOnDelayedResponse = false;
@ -1288,8 +1321,8 @@ bool Socket::isWritable(bool waitOnDelayedResponse) {
} }
else if(i == 0) { else if(i == 0) {
//if(difftime(time(NULL),lastDebugEvent) >= 1) { //if(difftime(time(NULL),lastDebugEvent) >= 1) {
lastDebugEvent = time(NULL); // lastDebugEvent = time(NULL);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] TIMEOUT while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,i,getLastSocketErrorFormattedText().c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] TIMEOUT while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,i,getLastSocketErrorFormattedText().c_str());
//} //}
if(waitOnDelayedResponse == false) { if(waitOnDelayedResponse == false) {
@ -1301,6 +1334,8 @@ bool Socket::isWritable(bool waitOnDelayedResponse) {
result = true; result = true;
break; break;
} }
if(isSocketValid() == false) return false;
} while(waitOnDelayedResponse == true && result == false); } while(waitOnDelayedResponse == true && result == false);
//return (i == 1 && FD_ISSET(sock, &set)); //return (i == 1 && FD_ISSET(sock, &set));
@ -1837,10 +1872,9 @@ Socket *ServerSocket::accept() {
PLATFORM_SOCKET newSock= ::accept(sock, (struct sockaddr *) &cli_addr, &clilen); PLATFORM_SOCKET newSock= ::accept(sock, (struct sockaddr *) &cli_addr, &clilen);
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
if(isSocketValid(&newSock) == false) if(isSocketValid(&newSock) == false) {
{
char szBuf[1024]=""; char szBuf[1024]="";
sprintf(szBuf, "In [%s::%s] Error accepting socket connection sock = %d, err = %d, error = %s\n",__FILE__,__FUNCTION__,sock,newSock,getLastSocketErrorFormattedText().c_str()); sprintf(szBuf, "In [%s::%s Line: %d] Error accepting socket connection sock = %d, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,sock,newSock,getLastSocketErrorFormattedText().c_str());
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
if(getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) if(getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN)