Files
commandergenius/project/jni/application/vcmi/vcmi-android.diff

227 lines
7.6 KiB
Diff

Index: client/CMT.cpp
===================================================================
--- client/CMT.cpp (revision 3494)
+++ client/CMT.cpp (working copy)
@@ -194,7 +194,7 @@
#ifdef _WIN32
int wmain(int argc, wchar_t* argv[])
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) || defined(ANDROID)
int SDL_main(int argc, char *argv[])
#else
int main(int argc, char** argv)
@@ -217,6 +217,13 @@
}
fclose(check);
#endif
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "%s:%s:%d", __FUNCTION__, __FILE__, __LINE__);
+
+ // 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,7 +389,7 @@
}
CSDL_Ext::update(screen);
- loading.join();
+ //loading.join();
logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff();
if(!vm.count("battle"))
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/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/VCMIDirs.cpp
===================================================================
--- lib/VCMIDirs.cpp (revision 3494)
+++ lib/VCMIDirs.cpp (working copy)
@@ -15,11 +15,16 @@
VCMIDirs::VCMIDirs()
{
+ 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__);
}
VCMIDirs & VCMIDirs::get()
@@ -115,8 +120,10 @@
std::string VCMIDirs::userDataPath() const
{
+#ifndef ANDROID
if (getenv("HOME") != nullptr )
return std::string(getenv("HOME")) + "/.vcmi";
+#endif
return ".";
}
Index: lib/vcmi_endian.h
===================================================================
--- lib/vcmi_endian.h (revision 3494)
+++ lib/vcmi_endian.h (working copy)
@@ -19,7 +19,7 @@
* memory. On big endian machines, the value will be byteswapped.
*/
-#if defined(linux) && (defined(sparc) || defined(__arm__))
+#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. */
struct unaligned_Uint16 { ui16 val __attribute__(( packed )); };