fix infinite loop while saving empty minimap

master
Eduardo Bart 12 years ago
parent 0c14a8e602
commit 139f389d88

@ -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")

@ -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<std::string>& args)
@ -170,7 +171,6 @@ void Application::run()
{
assert(m_initialized);
m_stopping = false;
m_running = true;
// run the first poll

@ -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;
}

@ -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);
}

Loading…
Cancel
Save