From 139f389d88a94c24e21f1de9248ad7442a277f8e Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 22 Jun 2012 14:26:12 -0300 Subject: [PATCH] fix infinite loop while saving empty minimap --- src/framework/CMakeLists.txt | 11 ++++++----- src/framework/application.cpp | 4 ++-- src/framework/net/protocol.cpp | 2 +- src/otclient/core/map.cpp | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 4ce6db0e..4394aa73 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -15,11 +15,12 @@ IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "RelWithDebInfo") ENDIF() -IF(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET(ARCH_FLAGS "-m64 -march=x86-64 -mtune=generic") -ELSE() - SET(ARCH_FLAGS "-m32 -march=i686 -mtune=generic") -ENDIF() +##IF(CMAKE_SIZEOF_VOID_P EQUAL 8) +## SET(ARCH_FLAGS "-m64 -march=x86-64 -mtune=generic") +##ELSE() +## SET(ARCH_FLAGS "-m32 -march=i686 -mtune=generic") +##ENDIF() + SET(WARNS_FLAGS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNS_FLAGS} ${ARCH_FLAGS} -std=gnu++0x -pipe") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb") diff --git a/src/framework/application.cpp b/src/framework/application.cpp index 3f94adbd..330f5d8b 100644 --- a/src/framework/application.cpp +++ b/src/framework/application.cpp @@ -47,7 +47,7 @@ void exitSignalHandler(int sig) case SIGINT: if(!signaled) { signaled = true; - g_eventDispatcher.addEvent(std::bind(&Application::close, g_app)); + g_eventDispatcher.addEvent(std::bind(&Application::close, &g_app)); } break; } @@ -59,6 +59,7 @@ Application::Application() m_appCompactName = "app"; m_appVersion = "none"; m_foregroundFrameCounter.setMaxFps(60); + m_stopping = false; } void Application::init(const std::string& compactName, const std::vector& args) @@ -170,7 +171,6 @@ void Application::run() { assert(m_initialized); - m_stopping = false; m_running = true; // run the first poll diff --git a/src/framework/net/protocol.cpp b/src/framework/net/protocol.cpp index 5df1ff1a..223c2cee 100644 --- a/src/framework/net/protocol.cpp +++ b/src/framework/net/protocol.cpp @@ -192,7 +192,7 @@ bool Protocol::xteaDecrypt(const InputMessagePtr& inputMessage) uint16 decryptedSize = inputMessage->getU16() + 2; int sizeDelta = decryptedSize - encryptedSize; if(sizeDelta > 0 || -sizeDelta > encryptedSize) { - g_logger.traceError("invalid decrypted a network message"); + g_logger.traceError("invalid decrypted network message"); return false; } diff --git a/src/otclient/core/map.cpp b/src/otclient/core/map.cpp index 0179e483..77d7394f 100644 --- a/src/otclient/core/map.cpp +++ b/src/otclient/core/map.cpp @@ -317,13 +317,13 @@ void Map::saveOtcm(const std::string& fileName) { std::stringstream out; + uint16 id; for(auto& pair : m_tiles) { Position pos = pair.first; TilePtr tile = pair.second; if(!tile || tile->isEmpty()) continue; out.write((char*)&pos, sizeof(pos)); - uint16 id; for(const ThingPtr& thing : tile->getThings()) { if(ItemPtr item = thing->asItem()) { id = item->getId(); @@ -334,9 +334,9 @@ void Map::saveOtcm(const std::string& fileName) } } } - id = 0xFFFF; - out.write((char*)&id, sizeof(id)); } + id = 0xFFFF; + out.write((char*)&id, sizeof(id)); g_resources.saveFile(fileName, out); }