VCMI: messing with code at random, it loads start menu but then crashes
This commit is contained in:
@@ -1,19 +1,28 @@
|
||||
Index: client/battle/CBattleInterface.cpp
|
||||
Index: client/CPreGame.cpp
|
||||
===================================================================
|
||||
--- client/battle/CBattleInterface.cpp (revision 3490)
|
||||
+++ client/battle/CBattleInterface.cpp (working copy)
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../CMT.h"
|
||||
--- client/CPreGame.cpp (revision 3494)
|
||||
+++ client/CPreGame.cpp (working copy)
|
||||
@@ -1141,7 +1141,7 @@
|
||||
|
||||
-#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
+#if (defined(_MSC_VER) && _MSC_VER >= 1800) || defined(ANDROID)
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#else
|
||||
// Create the map info object
|
||||
CMapInfo mapInfo;
|
||||
- mapInfo.mapHeader = make_unique<CMapHeader>();
|
||||
+ mapInfo.mapHeader = std::make_shared<CMapHeader>(CMapHeader());
|
||||
mapInfo.scenarioOpts = new StartInfo;
|
||||
lf >> *(mapInfo.mapHeader.get()) >> mapInfo.scenarioOpts;
|
||||
mapInfo.fileURI = file.getName();
|
||||
@@ -1836,7 +1836,7 @@
|
||||
// Generate header info
|
||||
mapInfo = make_unique<CMapInfo>();
|
||||
mapInfo->isRandomMap = true;
|
||||
- mapInfo->mapHeader = make_unique<CMapHeader>();
|
||||
+ mapInfo->mapHeader = std::make_shared<CMapHeader>(CMapHeader());
|
||||
mapInfo->mapHeader->version = EMapFormat::SOD;
|
||||
mapInfo->mapHeader->name = CGI->generaltexth->allTexts[740];
|
||||
mapInfo->mapHeader->description = CGI->generaltexth->allTexts[741];
|
||||
Index: client/CMT.cpp
|
||||
===================================================================
|
||||
--- client/CMT.cpp (revision 3490)
|
||||
--- client/CMT.cpp (revision 3494)
|
||||
+++ client/CMT.cpp (working copy)
|
||||
@@ -194,7 +194,7 @@
|
||||
|
||||
@@ -24,23 +33,263 @@ Index: client/CMT.cpp
|
||||
int SDL_main(int argc, char *argv[])
|
||||
#else
|
||||
int main(int argc, char** argv)
|
||||
Index: CMakeLists.txt
|
||||
===================================================================
|
||||
--- CMakeLists.txt (revision 3490)
|
||||
+++ CMakeLists.txt (working copy)
|
||||
@@ -117,6 +117,9 @@
|
||||
add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/${BIN_DIR}")
|
||||
add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
|
||||
|
||||
+#add_definitions(-DDLL_EXPORT=)
|
||||
+add_definitions(-DIOAPI_NO_64)
|
||||
@@ -217,6 +217,13 @@
|
||||
}
|
||||
fclose(check);
|
||||
#endif
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "%s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
+
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/vcmi")
|
||||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
+ // Fix crashing locale shit in Boost
|
||||
+ setenv( "LANG", "C", 1 );
|
||||
+ setenv( "LANGUAGE", "C", 1 );
|
||||
+ setenv( "LC_ALL", "C", 1 );
|
||||
+
|
||||
std::cout << "Starting... " << std::endl;
|
||||
po::options_description opts("Allowed options");
|
||||
opts.add_options()
|
||||
@@ -289,6 +296,7 @@
|
||||
|
||||
// Initialize logging based on settings
|
||||
logConfig.configure();
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Trace: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
|
||||
// Some basic data validation to produce better error messages in cases of incorrect install
|
||||
auto testFile = [](std::string filename, std::string message) -> bool
|
||||
@@ -300,22 +308,31 @@
|
||||
return false;
|
||||
};
|
||||
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Trace: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
if (!testFile("DATA/HELP.TXT", "Heroes III data") ||
|
||||
!testFile("MODS/VCMI/MOD.JSON", "VCMI mod") ||
|
||||
- !testFile("DATA/StackQueueBgBig.PCX", "VCMI data"))
|
||||
+ !testFile("DATA/StackQueueBgBig.PCX", "VCMI data"))
|
||||
+ {
|
||||
+ __android_log_print(ANDROID_LOG_ERROR, "VCMI", "Cannot find data files!");
|
||||
exit(1); // These are unrecoverable errors
|
||||
+ }
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Trace: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
|
||||
// these two are optional + some installs have them on CD and not in data directory
|
||||
testFile("VIDEO/GOOD1A.SMK", "campaign movies");
|
||||
testFile("SOUNDS/G1A.WAV", "campaign music"); //technically not a music but voiced intro sounds
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Trace: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Trace: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
conf.init();
|
||||
logGlobal->infoStream() <<"Loading settings: "<<pomtime.getDiff();
|
||||
logGlobal->infoStream() << NAME;
|
||||
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Trace: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
srand ( time(nullptr) );
|
||||
|
||||
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Trace: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
const JsonNode& video = settings["video"];
|
||||
const JsonNode& res = video["screenRes"];
|
||||
|
||||
@@ -330,6 +347,7 @@
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Trace: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
if(!gNoGUI)
|
||||
{
|
||||
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO))
|
||||
@@ -360,7 +378,8 @@
|
||||
|
||||
|
||||
//we can properly play intro only in the main thread, so we have to move loading to the separate thread
|
||||
- boost::thread loading(init);
|
||||
+ //boost::thread loading(init);
|
||||
+ init(); // boost::thread crashes when destroyed
|
||||
|
||||
if(!gNoGUI )
|
||||
{
|
||||
@@ -370,8 +389,8 @@
|
||||
}
|
||||
|
||||
CSDL_Ext::update(screen);
|
||||
- loading.join();
|
||||
- logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff();
|
||||
+ //loading.join();
|
||||
+ logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff();
|
||||
|
||||
if(!vm.count("battle"))
|
||||
{
|
||||
Index: Global.h
|
||||
===================================================================
|
||||
--- Global.h (revision 3494)
|
||||
+++ Global.h (working copy)
|
||||
@@ -62,7 +62,35 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <stdio.h>
|
||||
-
|
||||
+#ifdef ANDROID
|
||||
+/*
|
||||
+#define move disable_move // It crashes with NDK r9 and GCC 4.8
|
||||
+#include <algorithm>
|
||||
+#undef move
|
||||
+namespace std
|
||||
+{
|
||||
+ template<typename _Tp>
|
||||
+ _Tp move(_Tp __t)
|
||||
+ {
|
||||
+ return __t; // Unoptimized version that does not crash
|
||||
+ }
|
||||
+
|
||||
+ template<class InputIt, class OutputIt>
|
||||
+ OutputIt move(InputIt first, InputIt last, OutputIt d_first)
|
||||
+ {
|
||||
+ while (first != last)
|
||||
+ {
|
||||
+ *d_first++ = *first++;
|
||||
+ }
|
||||
+ return d_first;
|
||||
+ }
|
||||
+}
|
||||
+*/
|
||||
+/*
|
||||
+#include <memory>
|
||||
+#define unique_ptr shared_ptr
|
||||
+*/
|
||||
+#endif
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
Index: lib/filesystem/Filesystem.cpp
|
||||
===================================================================
|
||||
--- lib/filesystem/Filesystem.cpp (revision 3494)
|
||||
+++ lib/filesystem/Filesystem.cpp (working copy)
|
||||
@@ -24,14 +24,14 @@
|
||||
|
||||
ResourceID::ResourceID(std::string name)
|
||||
{
|
||||
- CFileInfo info(std::move(name));
|
||||
+ CFileInfo info(/*std::move*/(name));
|
||||
setName(info.getStem());
|
||||
setType(info.getType());
|
||||
}
|
||||
|
||||
ResourceID::ResourceID(std::string name, EResType::Type type)
|
||||
{
|
||||
- setName(std::move(name));
|
||||
+ setName(/*std::move*/(name));
|
||||
setType(type);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
void ResourceID::setName(std::string name)
|
||||
{
|
||||
- this->name = std::move(name);
|
||||
+ this->name = /*std::move*/(name);
|
||||
|
||||
size_t dotPos = this->name.find_last_of("/.");
|
||||
|
||||
Index: lib/filesystem/CFileInfo.cpp
|
||||
===================================================================
|
||||
--- lib/filesystem/CFileInfo.cpp (revision 3494)
|
||||
+++ lib/filesystem/CFileInfo.cpp (working copy)
|
||||
@@ -7,7 +7,7 @@
|
||||
}
|
||||
|
||||
CFileInfo::CFileInfo(std::string name)
|
||||
- : name(std::move(name))
|
||||
+ : name(/*std::move*/(name))
|
||||
{
|
||||
|
||||
}
|
||||
Index: lib/mapping/CMapInfo.cpp
|
||||
===================================================================
|
||||
--- lib/mapping/CMapInfo.cpp (revision 3494)
|
||||
+++ lib/mapping/CMapInfo.cpp (working copy)
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
}
|
||||
|
||||
-#define STEAL(x) x = std::move(tmp.x)
|
||||
+#define STEAL(x) x = /*std::move*/(tmp.x)
|
||||
|
||||
CMapInfo::CMapInfo(CMapInfo && tmp)
|
||||
{
|
||||
@@ -54,13 +54,13 @@
|
||||
void CMapInfo::mapInit(const std::string & fname)
|
||||
{
|
||||
fileURI = fname;
|
||||
- mapHeader = CMapService::loadMapHeader(fname);
|
||||
+ mapHeader = std::make_shared<CMapHeader>(*CMapService::loadMapHeader(fname));
|
||||
countPlayers();
|
||||
}
|
||||
|
||||
void CMapInfo::campaignInit()
|
||||
{
|
||||
- campaignHeader = std::unique_ptr<CCampaignHeader>(new CCampaignHeader(CCampaignHandler::getHeader(fileURI)));
|
||||
+ campaignHeader = std::make_shared<CCampaignHeader>(CCampaignHandler::getHeader(fileURI));
|
||||
}
|
||||
|
||||
CMapInfo & CMapInfo::operator=(CMapInfo &&tmp)
|
||||
Index: lib/mapping/CMapInfo.h
|
||||
===================================================================
|
||||
--- lib/mapping/CMapInfo.h (revision 3494)
|
||||
+++ lib/mapping/CMapInfo.h (working copy)
|
||||
@@ -20,8 +20,8 @@
|
||||
class DLL_LINKAGE CMapInfo
|
||||
{
|
||||
public:
|
||||
- unique_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
|
||||
- unique_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
|
||||
+ shared_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
|
||||
+ shared_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
|
||||
StartInfo * scenarioOpts; //options with which scenario has been started (used only with saved games)
|
||||
std::string fileURI;
|
||||
std::string date;
|
||||
Index: lib/logging/CLogger.cpp
|
||||
===================================================================
|
||||
--- lib/logging/CLogger.cpp (revision 3494)
|
||||
+++ lib/logging/CLogger.cpp (working copy)
|
||||
@@ -387,6 +387,9 @@
|
||||
if(threshold > record.level) return;
|
||||
|
||||
std::string message = formatter.format(record);
|
||||
+#ifdef ANDROID
|
||||
+ __android_log_print(ANDROID_LOG_INFO, "VCMI", "%s", message.c_str());
|
||||
+#endif
|
||||
bool printToStdErr = record.level >= ELogLevel::WARN;
|
||||
if(console)
|
||||
{
|
||||
Index: lib/logging/CLogger.h
|
||||
===================================================================
|
||||
--- lib/logging/CLogger.h (revision 3494)
|
||||
+++ lib/logging/CLogger.h (working copy)
|
||||
@@ -289,3 +289,11 @@
|
||||
CLogFormatter formatter;
|
||||
mutable boost::mutex mx;
|
||||
};
|
||||
+
|
||||
+#ifdef ANDROID
|
||||
+static bool AndroidStaticInitLog()
|
||||
+{
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Static init: %s", __SOURCE_FILE__);
|
||||
+}
|
||||
+static bool AndroidStaticInitLogFlag = AndroidStaticInitLog();
|
||||
+#endif
|
||||
Index: lib/JsonNode.cpp
|
||||
===================================================================
|
||||
--- lib/JsonNode.cpp (revision 3494)
|
||||
+++ lib/JsonNode.cpp (working copy)
|
||||
@@ -1574,7 +1574,7 @@
|
||||
//reserve place and *move* remaining data from source to dest
|
||||
source.Vector().reserve(source.Vector().size() + dest.Vector().size());
|
||||
|
||||
- std::move(source.Vector().begin() + total, source.Vector().end(),
|
||||
+ std::copy(source.Vector().begin() + total, source.Vector().end(),
|
||||
std::back_inserter(dest.Vector()));
|
||||
}
|
||||
break;
|
||||
Index: lib/vcmi_endian.h
|
||||
--- lib/vcmi_endian.h (revision 3490)
|
||||
===================================================================
|
||||
--- lib/vcmi_endian.h (revision 3494)
|
||||
+++ lib/vcmi_endian.h (working copy)
|
||||
@@ -19,7 +19,7 @@
|
||||
@@ -51,37 +300,35 @@ Index: lib/vcmi_endian.h
|
||||
+#if defined(ANDROID) || defined(linux) && (defined(sparc) || defined(__arm__))
|
||||
/* SPARC does not support unaligned memory access. Let gcc know when
|
||||
* to emit the right code. */
|
||||
Index: lib/logging/CLogger.cpp
|
||||
struct unaligned_Uint16 { ui16 val __attribute__(( packed )); };
|
||||
Index: lib/VCMIDirs.cpp
|
||||
--- lib/logging/CLogger.cpp (revision 3490)
|
||||
+++ lib/logging/CLogger.cpp (working copy)
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "StdInc.h"
|
||||
#include "CLogger.h"
|
||||
+#ifdef ANDROID
|
||||
+#include <android/log.h>
|
||||
+#endif
|
||||
===================================================================
|
||||
--- lib/VCMIDirs.cpp (revision 3494)
|
||||
+++ lib/VCMIDirs.cpp (working copy)
|
||||
@@ -15,11 +15,16 @@
|
||||
+
|
||||
const std::string CLoggerDomain::DOMAIN_GLOBAL = "global";
|
||||
|
||||
CLoggerDomain::CLoggerDomain(const std::string & name) : name(name)
|
||||
@@ -379,6 +383,8 @@
|
||||
|
||||
CLogConsoleTarget::CLogConsoleTarget(CConsoleHandler * console) : console(console), threshold(ELogLevel::INFO), coloredOutputEnabled(true)
|
||||
|
||||
VCMIDirs::VCMIDirs()
|
||||
+ __android_log_print(ANDROID_LOG_INFO, "VCMI", "CLogConsoleTarget::CLogConsoleTarget()");
|
||||
+
|
||||
formatter.setPattern("%m");
|
||||
{
|
||||
+ char buf[1024] = "";
|
||||
+ getcwd(buf, sizeof(buf));
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "%s:%s:%d: mkdir '%s' '%s' '%s' '%s' curdir '%s'", __FUNCTION__, __FILE__, __LINE__,
|
||||
+ userDataPath().c_str(), userCachePath().c_str(), userConfigPath().c_str(), userSavePath().c_str(), buf);
|
||||
// initialize local directory and create folders to which VCMI needs write access
|
||||
boost::filesystem::create_directory(userDataPath());
|
||||
boost::filesystem::create_directory(userCachePath());
|
||||
boost::filesystem::create_directory(userConfigPath());
|
||||
boost::filesystem::create_directory(userSavePath());
|
||||
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "%s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
|
||||
}
|
||||
@@ -387,6 +393,9 @@
|
||||
if(threshold > record.level) return;
|
||||
|
||||
VCMIDirs & VCMIDirs::get()
|
||||
@@ -115,8 +120,10 @@
|
||||
std::string message = formatter.format(record);
|
||||
+#ifdef ANDROID
|
||||
+ __android_log_print(ANDROID_LOG_INFO, "VCMI", "%s", message.c_str());
|
||||
|
||||
std::string VCMIDirs::userDataPath() const
|
||||
{
|
||||
+#ifndef ANDROID
|
||||
if (getenv("HOME") != nullptr )
|
||||
return std::string(getenv("HOME")) + "/.vcmi";
|
||||
bool printToStdErr = record.level >= ELogLevel::WARN;
|
||||
if(console)
|
||||
{
|
||||
+#endif
|
||||
return ".";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user