- lua bugfix for fog of war toggling

- ftp client bugfix for reported segfault
This commit is contained in:
Mark Vejvoda
2011-01-10 00:05:31 +00:00
parent 38da21ae18
commit 7bc6b603b9
4 changed files with 57 additions and 21 deletions

View File

@@ -420,6 +420,7 @@ MenuStateConnectedGame::~MenuStateConnectedGame() {
cleanupFactionTexture(); cleanupFactionTexture();
if(ftpClientThread != NULL) { if(ftpClientThread != NULL) {
ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) { if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread; delete ftpClientThread;
ftpClientThread = NULL; ftpClientThread = NULL;
@@ -434,13 +435,11 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
NetworkManager &networkManager= NetworkManager::getInstance(); NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface(); ClientInterface* clientInterface= networkManager.getClientInterface();
if(mainMessageBox.getEnabled()){ if(mainMessageBox.getEnabled()) {
int button= 1; int button= 1;
if(mainMessageBox.mouseClick(x, y, button)) if(mainMessageBox.mouseClick(x, y, button)) {
{
soundRenderer.playFx(coreData.getClickSoundA()); soundRenderer.playFx(coreData.getClickSoundA());
if(button==1) if(button == 1) {
{
mainMessageBox.setEnabled(false); mainMessageBox.setEnabled(false);
} }
} }
@@ -484,10 +483,8 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
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__);
soundRenderer.playFx(coreData.getClickSoundA()); soundRenderer.playFx(coreData.getClickSoundA());
if(clientInterface->getSocket() != NULL) if(clientInterface->getSocket() != NULL) {
{ if(clientInterface->isConnected() == true) {
if(clientInterface->isConnected() == true)
{
string sQuitText = "chose to leave the game!"; string sQuitText = "chose to leave the game!";
clientInterface->sendTextMessage(sQuitText,-1); clientInterface->sendTextMessage(sQuitText,-1);
sleep(1); sleep(1);
@@ -502,19 +499,16 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
return; return;
} }
if (!initialSettingsReceivedFromServer) return; if (initialSettingsReceivedFromServer == false) return;
// Only allow changes after we get game settings from the server // Only allow changes after we get game settings from the server
//if( clientInterface->isConnected() == true && if(clientInterface->isConnected() == true) {
// clientInterface->getGameSettingsReceived() == true) {
if( clientInterface->isConnected() == true) {
if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) { if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
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__);
soundRenderer.playFx(coreData.getClickSoundC()); soundRenderer.playFx(coreData.getClickSoundC());
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__);
} }
else else {
{
int myCurrentIndex=-1; int myCurrentIndex=-1;
for(int i=0; i<GameConstants::maxPlayers; ++i) for(int i=0; i<GameConstants::maxPlayers; ++i)
{// find my current index by looking at editable listBoxes {// find my current index by looking at editable listBoxes
@@ -577,6 +571,14 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
void MenuStateConnectedGame::returnToJoinMenu() { void MenuStateConnectedGame::returnToJoinMenu() {
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__);
if(ftpClientThread != NULL) {
ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
ftpClientThread = NULL;
}
}
if(returnMenuInfo == jmSimple) { if(returnMenuInfo == jmSimple) {
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__);
mainMenu->setState(new MenuStateJoinGame(program, mainMenu)); mainMenu->setState(new MenuStateJoinGame(program, mainMenu));
@@ -587,8 +589,7 @@ void MenuStateConnectedGame::returnToJoinMenu() {
} }
} }
void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms) {
if (mainMessageBox.getEnabled()) { if (mainMessageBox.getEnabled()) {
mainMessageBox.mouseMove(x, y); mainMessageBox.mouseMove(x, y);
} }
@@ -601,7 +602,7 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){
buttonPlayNow.mouseMove(x, y); buttonPlayNow.mouseMove(x, y);
bool editingPlayerName = false; bool editingPlayerName = false;
for(int i=0; i<GameConstants::maxPlayers; ++i){ for(int i = 0; i < GameConstants::maxPlayers; ++i) {
listBoxControls[i].mouseMove(x, y); listBoxControls[i].mouseMove(x, y);
listBoxFactions[i].mouseMove(x, y); listBoxFactions[i].mouseMove(x, y);
listBoxTeams[i].mouseMove(x, y); listBoxTeams[i].mouseMove(x, y);
@@ -1355,6 +1356,16 @@ void MenuStateConnectedGame::update() {
assert(clientInterface != NULL); assert(clientInterface != NULL);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(ftpClientThread != NULL) {
ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
ftpClientThread = NULL;
}
}
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__);
program->setState(new Game(program, clientInterface->getGameSettings())); program->setState(new Game(program, clientInterface->getGameSettings()));

View File

@@ -301,6 +301,7 @@ void MenuStateScenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo
if(scenarioNode->hasChild("fog-of-war") == true) { if(scenarioNode->hasChild("fog-of-war") == true) {
scenarioInfo->fogOfWar = scenarioNode->getChild("fog-of-war")->getAttribute("value")->getBoolValue(); scenarioInfo->fogOfWar = scenarioNode->getChild("fog-of-war")->getAttribute("value")->getBoolValue();
//printf("\nFOG OF WAR is set to [%d]\n",scenarioInfo->fogOfWar);
} }
else { else {
scenarioInfo->fogOfWar = true; scenarioInfo->fogOfWar = true;
@@ -338,6 +339,15 @@ void MenuStateScenario::loadGameSettings(const ScenarioInfo *scenarioInfo, GameS
gameSettings->setFactionCount(factionCount); gameSettings->setFactionCount(factionCount);
gameSettings->setFogOfWar(scenarioInfo->fogOfWar); gameSettings->setFogOfWar(scenarioInfo->fogOfWar);
uint32 valueFlags1 = gameSettings->getFlagTypes1();
if(scenarioInfo->fogOfWar == false) {
valueFlags1 |= ft1_show_map_resources;
gameSettings->setFlagTypes1(valueFlags1);
}
else {
valueFlags1 &= ~ft1_show_map_resources;
gameSettings->setFlagTypes1(valueFlags1);
}
gameSettings->setPathFinderType(static_cast<PathFinderType>(Config::getInstance().getInt("ScenarioPathFinderType",intToStr(pfBasic).c_str()))); gameSettings->setPathFinderType(static_cast<PathFinderType>(Config::getInstance().getInt("ScenarioPathFinderType",intToStr(pfBasic).c_str())));
} }

View File

@@ -85,7 +85,9 @@ public:
void addMapToRequests(string mapFilename); void addMapToRequests(string mapFilename);
void addTilesetToRequests(string tileSetName); void addTilesetToRequests(string tileSetName);
FTPClientCallbackInterface * getCallBackObject() { return pCBObject; } FTPClientCallbackInterface * getCallBackObject();
void setCallBackObject(FTPClientCallbackInterface *value);
Mutex * getProgressMutex() { return &mutexProgressMutex; } Mutex * getProgressMutex() { return &mutexProgressMutex; }
}; };

View File

@@ -159,6 +159,9 @@ int file_progress(struct FtpFile *out,double download_total, double download_now
if(out != NULL && if(out != NULL &&
out->ftpServer != NULL && out->ftpServer != NULL &&
out->ftpServer->getCallBackObject() != NULL) { out->ftpServer->getCallBackObject() != NULL) {
if(out->ftpServer->getQuitStatus() == true) {
return -1;
}
FTPClientCallbackInterface::FtpProgressStats stats; FTPClientCallbackInterface::FtpProgressStats stats;
stats.download_total = download_total; stats.download_total = download_total;
stats.download_now = download_now; stats.download_now = download_now;
@@ -279,8 +282,8 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
} }
} }
MutexSafeWrapper safeMutex(this->getProgressMutex());
if(this->pCBObject != NULL) { if(this->pCBObject != NULL) {
MutexSafeWrapper safeMutex(this->getProgressMutex());
this->pCBObject->FTPClient_CallbackEvent(mapFileName,ftp_cct_Map,result,NULL); this->pCBObject->FTPClient_CallbackEvent(mapFileName,ftp_cct_Map,result,NULL);
} }
} }
@@ -305,8 +308,8 @@ void FTPClientThread::getTilesetFromServer(string tileSetName) {
result = getTilesetFromServer(tileSetName, "tilesets", "", "mg_ftp_server"); result = getTilesetFromServer(tileSetName, "tilesets", "", "mg_ftp_server");
} }
MutexSafeWrapper safeMutex(this->getProgressMutex());
if(this->pCBObject != NULL) { if(this->pCBObject != NULL) {
MutexSafeWrapper safeMutex(this->getProgressMutex());
this->pCBObject->FTPClient_CallbackEvent(tileSetName,ftp_cct_Tileset,result,NULL); this->pCBObject->FTPClient_CallbackEvent(tileSetName,ftp_cct_Tileset,result,NULL);
} }
} }
@@ -445,6 +448,16 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName,
return result; return result;
} }
FTPClientCallbackInterface * FTPClientThread::getCallBackObject() {
MutexSafeWrapper safeMutex(this->getProgressMutex());
return pCBObject;
}
void FTPClientThread::setCallBackObject(FTPClientCallbackInterface *value) {
MutexSafeWrapper safeMutex(this->getProgressMutex());
pCBObject = value;
}
void FTPClientThread::execute() { void FTPClientThread::execute() {
{ {
RunningStatusSafeWrapper runningStatus(this); RunningStatusSafeWrapper runningStatus(this);