- 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();
if(ftpClientThread != NULL) {
ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
ftpClientThread = NULL;
@ -434,13 +435,11 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface();
if(mainMessageBox.getEnabled()){
if(mainMessageBox.getEnabled()) {
int button= 1;
if(mainMessageBox.mouseClick(x, y, button))
{
if(mainMessageBox.mouseClick(x, y, button)) {
soundRenderer.playFx(coreData.getClickSoundA());
if(button==1)
{
if(button == 1) {
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__);
soundRenderer.playFx(coreData.getClickSoundA());
if(clientInterface->getSocket() != NULL)
{
if(clientInterface->isConnected() == true)
{
if(clientInterface->getSocket() != NULL) {
if(clientInterface->isConnected() == true) {
string sQuitText = "chose to leave the game!";
clientInterface->sendTextMessage(sQuitText,-1);
sleep(1);
@ -502,19 +499,16 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
return;
}
if (!initialSettingsReceivedFromServer) return;
if (initialSettingsReceivedFromServer == false) return;
// Only allow changes after we get game settings from the server
//if( clientInterface->isConnected() == true &&
// clientInterface->getGameSettingsReceived() == true) {
if( clientInterface->isConnected() == true) {
if(clientInterface->isConnected() == true) {
if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
soundRenderer.playFx(coreData.getClickSoundC());
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
else
{
else {
int myCurrentIndex=-1;
for(int i=0; i<GameConstants::maxPlayers; ++i)
{// 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() {
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) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
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()) {
mainMessageBox.mouseMove(x, y);
}
@ -601,7 +602,7 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){
buttonPlayNow.mouseMove(x, y);
bool editingPlayerName = false;
for(int i=0; i<GameConstants::maxPlayers; ++i){
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
listBoxControls[i].mouseMove(x, y);
listBoxFactions[i].mouseMove(x, y);
listBoxTeams[i].mouseMove(x, y);
@ -1355,6 +1356,16 @@ void MenuStateConnectedGame::update() {
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__);
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) {
scenarioInfo->fogOfWar = scenarioNode->getChild("fog-of-war")->getAttribute("value")->getBoolValue();
//printf("\nFOG OF WAR is set to [%d]\n",scenarioInfo->fogOfWar);
}
else {
scenarioInfo->fogOfWar = true;
@ -338,6 +339,15 @@ void MenuStateScenario::loadGameSettings(const ScenarioInfo *scenarioInfo, GameS
gameSettings->setFactionCount(factionCount);
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())));
}

View File

@ -85,7 +85,9 @@ public:
void addMapToRequests(string mapFilename);
void addTilesetToRequests(string tileSetName);
FTPClientCallbackInterface * getCallBackObject() { return pCBObject; }
FTPClientCallbackInterface * getCallBackObject();
void setCallBackObject(FTPClientCallbackInterface *value);
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 &&
out->ftpServer != NULL &&
out->ftpServer->getCallBackObject() != NULL) {
if(out->ftpServer->getQuitStatus() == true) {
return -1;
}
FTPClientCallbackInterface::FtpProgressStats stats;
stats.download_total = download_total;
stats.download_now = download_now;
@ -279,8 +282,8 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
}
}
MutexSafeWrapper safeMutex(this->getProgressMutex());
if(this->pCBObject != NULL) {
MutexSafeWrapper safeMutex(this->getProgressMutex());
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");
}
MutexSafeWrapper safeMutex(this->getProgressMutex());
if(this->pCBObject != NULL) {
MutexSafeWrapper safeMutex(this->getProgressMutex());
this->pCBObject->FTPClient_CallbackEvent(tileSetName,ftp_cct_Tileset,result,NULL);
}
}
@ -445,6 +448,16 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName,
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() {
{
RunningStatusSafeWrapper runningStatus(this);