VCMI dumps something to logcat, then crashes

This commit is contained in:
pelya
2011-06-09 18:01:37 +03:00
parent a12092fb6d
commit ade2c18fbe
6 changed files with 430 additions and 32 deletions

View File

@@ -2,6 +2,7 @@
CHANGE_APP_SETTINGS_VERSION=17
AUTO=
CHANGED=
if [ "X$1" = "X-a" ]; then
AUTO=a
@@ -29,6 +30,7 @@ echo -n "libSDL version to use (1.2 or 1.3) ($LibSdlVersion): "
read var
if [ -n "$var" ] ; then
LibSdlVersion="$var"
CHANGED=1
fi
fi
@@ -38,6 +40,7 @@ echo -n "Specify application name (e.x. My Application) ($AppName): "
read var
if [ -n "$var" ] ; then
AppName="$var"
CHANGED=1
fi
fi
@@ -47,6 +50,7 @@ echo -n "Specify reversed site name of application (e.x. com.mysite.myapp) ($App
read var
if [ -n "$var" ] ; then
AppFullName="$var"
CHANGED=1
fi
fi
@@ -56,6 +60,7 @@ echo -n "Specify screen orientation: (v)ertical or (h)orizontal ($ScreenOrientat
read var
if [ -n "$var" ] ; then
ScreenOrientation="$var"
CHANGED=1
fi
fi
@@ -86,6 +91,7 @@ while true; do
done
if [ -n "$AppDataDownloadUrl1" ] ; then
AppDataDownloadUrl="$AppDataDownloadUrl1"
CHANGED=1
fi
fi
@@ -95,6 +101,7 @@ echo "Application window should be resized to fit into native device screen (480
read var
if [ -n "$var" ] ; then
SdlVideoResize="$var"
CHANGED=1
fi
fi
@@ -104,6 +111,7 @@ echo -n "Application resizing should use 4:3 aspect ratio, creating black bars (
read var
if [ -n "$var" ] ; then
SdlVideoResizeKeepAspect="$var"
CHANGED=1
fi
fi
@@ -113,6 +121,7 @@ echo -n "Enable OpenGL depth buffer (needed only for 3-d applications, small spe
read var
if [ -n "$var" ] ; then
NeedDepthBuffer="$var"
CHANGED=1
fi
fi
@@ -124,6 +133,7 @@ if [ "$LibSdlVersion" = "1.2" ]; then
read var
if [ -n "$var" ] ; then
SwVideoMode="$var"
CHANGED=1
fi
fi
else
@@ -136,6 +146,7 @@ echo -n "Application uses mouse (y) or (n) ($AppUsesMouse): "
read var
if [ -n "$var" ] ; then
AppUsesMouse="$var"
CHANGED=1
fi
fi
@@ -145,6 +156,7 @@ echo -n "Application needs two-button mouse, will also enable advanced point-and
read var
if [ -n "$var" ] ; then
AppNeedsTwoButtonMouse="$var"
CHANGED=1
fi
fi
@@ -155,6 +167,7 @@ echo -n "will be used as arrow keys if phone does not have dpad/trackball ($AppN
read var
if [ -n "$var" ] ; then
AppNeedsArrowKeys="$var"
CHANGED=1
fi
fi
@@ -164,6 +177,7 @@ echo -n "Application needs text input (y) or (n), enables button for text input
read var
if [ -n "$var" ] ; then
AppNeedsTextInput="$var"
CHANGED=1
fi
fi
@@ -175,6 +189,7 @@ echo -n "make sure you can navigate all app menus with joystick or mouse ($AppUs
read var
if [ -n "$var" ] ; then
AppUsesJoystick="$var"
CHANGED=1
fi
fi
@@ -185,6 +200,7 @@ echo -n "SDL will send raw accelerometer data and won't show 'Accelerometer sens
read var
if [ -n "$var" ] ; then
AppHandlesJoystickSensitivity="$var"
CHANGED=1
fi
fi
@@ -195,6 +211,7 @@ echo -n "or additionally as SDL_FINGERDOWN/UP/MOTION events in SDL 1.3, with SDL
read var
if [ -n "$var" ] ; then
AppUsesMultitouch="$var"
CHANGED=1
fi
fi
@@ -206,6 +223,7 @@ echo -n "rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in b
read var
if [ -n "$var" ] ; then
NonBlockingSwapBuffers="$var"
CHANGED=1
fi
fi
@@ -216,6 +234,7 @@ echo -n "applied automatically if you're using accelerometer, but may be useful
read var
if [ -n "$var" ] ; then
InhibitSuspend="$var"
CHANGED=1
fi
fi
@@ -231,6 +250,7 @@ echo -n ": "
read var
if [ -n "$var" ] ; then
RedefinedKeys="$var"
CHANGED=1
fi
fi
@@ -240,6 +260,7 @@ echo -n "Number of virtual keyboard keys (currently 7 is maximum) ($AppTouchscre
read var
if [ -n "$var" ] ; then
AppTouchscreenKeyboardKeysAmount="$var"
CHANGED=1
fi
fi
@@ -249,12 +270,14 @@ echo -n "Number of virtual keyboard keys that support autofire (currently 2 is m
read var
if [ -n "$var" ] ; then
AppTouchscreenKeyboardKeysAmountAutoFire="$var"
CHANGED=1
fi
fi
if [ -z "$RedefinedKeysScreenKb" -o -z "$AUTO" ]; then
if [ -z "$RedefinedKeysScreenKb" ]; then
RedefinedKeysScreenKb="$RedefinedKeys"
CHANGED=1
fi
echo
echo "Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)"
@@ -263,6 +286,7 @@ echo -n ": "
read var
if [ -n "$var" ] ; then
RedefinedKeysScreenKb="$var"
CHANGED=1
fi
fi
@@ -272,6 +296,7 @@ echo -n "How long to show startup menu button, in msec, 0 to disable startup men
read var
if [ -n "$var" ] ; then
StartupMenuButtonTimeout="$var"
CHANGED=1
fi
fi
@@ -284,6 +309,7 @@ echo -n ": "
read var
if [ -n "$var" ] ; then
HiddenMenuOptions="$var"
CHANGED=1
fi
fi
@@ -294,6 +320,7 @@ echo -n "it will also work on old devices, but .apk size is 2x bigger (y) or (n)
read var
if [ -n "$var" ] ; then
MultiABI="$var"
CHANGED=1
fi
fi
@@ -303,6 +330,7 @@ echo -n "Application version code (integer) ($AppVersionCode): "
read var
if [ -n "$var" ] ; then
AppVersionCode="$var"
CHANGED=1
fi
fi
@@ -312,6 +340,7 @@ echo -n "Application user-visible version name (string) ($AppVersionName): "
read var
if [ -n "$var" ] ; then
AppVersionName="$var"
CHANGED=1
fi
fi
@@ -321,6 +350,7 @@ echo -n "Application uses custom build script AndroidBuild.sh instead of Android
read var
if [ -n "$var" ] ; then
CustomBuildScript="$var"
CHANGED=1
fi
fi
@@ -330,6 +360,7 @@ echo -n "Aditional CFLAGS for application ($AppCflags): "
read var
if [ -n "$var" ] ; then
AppCflags="$var"
CHANGED=1
fi
fi
@@ -344,6 +375,7 @@ echo -n ": "
read var
if [ -n "$var" ] ; then
CompiledLibraries="$var"
CHANGED=1
fi
fi
@@ -353,6 +385,7 @@ echo -n "Additional LDFLAGS for application ($AppLdflags): "
read var
if [ -n "$var" ] ; then
AppLdflags="$var"
CHANGED=1
fi
fi
@@ -362,6 +395,7 @@ echo -n "Build only following subdirs (empty will build all dirs, ignored with c
read var
if [ -n "$var" ] ; then
AppSubdirsBuild="$var"
CHANGED=1
fi
fi
@@ -371,6 +405,7 @@ echo -n "Application command line parameters, including app name as 0-th param (
read var
if [ -n "$var" ] ; then
AppCmdline="$var"
CHANGED=1
fi
fi
@@ -395,11 +430,13 @@ while true; do
done
if [ -n "$ReadmeText1" ] ; then
ReadmeText="$ReadmeText1"
CHANGED=1
fi
fi
echo
if [ -n "$CHANGED" ]; then
cat /dev/null > AndroidAppSettings.cfg
echo "# The application settings for Android libSDL port" >> AndroidAppSettings.cfg
echo AppSettingVersion=$CHANGE_APP_SETTINGS_VERSION >> AndroidAppSettings.cfg
@@ -437,6 +474,7 @@ echo AppLdflags=\'$AppLdflags\' >> AndroidAppSettings.cfg
echo AppSubdirsBuild=\'$AppSubdirsBuild\' >> AndroidAppSettings.cfg
echo AppCmdline=\'$AppCmdline\' >> AndroidAppSettings.cfg
echo ReadmeText=\'$ReadmeText\' >> AndroidAppSettings.cfg
fi
AppShortName=`echo $AppName | sed 's/ //g'`
DataPath="$AppFullName"

View File

@@ -33,5 +33,7 @@ cd project && env PATH=$NDKBUILDPATH nice -n19 ndk-build -j4 V=1 && \
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi/libapplication.so \
|| true ; } && \
ant debug && \
test -z "$1" && cd bin && adb install -r DemoActivity-debug.apk 2>&1 | grep 'Failure' && \
adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && adb install DemoActivity-debug.apk
test -z "$1" && cd bin && adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && \
adb push DemoActivity-debug.apk /data/local && \
adb shell pm install -f /data/local/DemoActivity-debug.apk && \
adb shell rm /data/local/DemoActivity-debug.apk

View File

@@ -29,8 +29,8 @@ AppVersionCode=08501
AppVersionName="0.85.01"
CompiledLibraries="sdl_mixer sdl_image sdl_ttf avutil avcore avcodec avformat swscale boost_program_options boost_filesystem boost_iostreams boost_system boost_thread"
CustomBuildScript=n
AppCflags='-DDATA_DIR=\".\" -DBIN_DIR=\"/data/data/eu.vcmi/lib\" -DLIB_DIR=\"/data/data/eu.vcmi/lib\" -DWITH_AVCODEC_DECODE_VIDEO2=1'
AppCflags='-DDATA_DIR=\\\"/sdcard/app-data/eu.vcmi\\\" -DBIN_DIR=\\\"/data/data/eu.vcmi/files\\\" -DLIB_DIR=\\\"/data/data/eu.vcmi/files\\\" -DWITH_AVCODEC_DECODE_VIDEO2=1'
AppLdflags='-lz'
AppSubdirsBuild='vcmi vcmi/lib vcmi/client'
AppSubdirsBuild='vcmi vcmi/client vcmi/lib'
AppCmdline=''
ReadmeText='^You may press "Home" now - the data will be downloaded in background'

View File

@@ -1,8 +1,8 @@
#!/bin/sh
LOCAL_PATH=`dirname $0`
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
make -j4 2>&1 | tee build.log
if false; then
# Uncomment if your configure expects SDL libraries in form "libSDL_name.so"
ln -sf libsdl-1.2.so $LOCAL_PATH/../../../obj/local/armeabi/libSDL.so
ln -sf libsdl-1.2.so $LOCAL_PATH/../../../obj/local/armeabi/libpthread.so
@@ -11,30 +11,25 @@ ln -sf libsdl_image.so $LOCAL_PATH/../../../obj/local/armeabi/libSDL_image.so
ln -sf libsdl_ttf.so $LOCAL_PATH/../../../obj/local/armeabi/libSDL_ttf.so
rm -f libapplication.so
GCC_PREFIX=arm-eabi
if echo $CXX | grep 'arm-linux-androideabi'; then
GCC_PREFIX=arm-linux-androideabi
fi
if [ \! -f vcmi/Makefile -o $0 -nt vcmi/Makefile ] ; then
../setEnvironment.sh sh -c "cd vcmi && \
env LIBS='-lavcodec -lavutil -lavcore -lgcc' \
./configure --host=$GCC_PREFIX --enable-static \
./configure --host=$GCC_PREFIX --enable-shared --disable-static \
--with-boost-system=boost_system \
--with-boost-filesystem=boost_filesystem \
--with-boost-thread=boost_thread \
--with-boost-iostreams=boost_iostreams \
--with-boost-program-options=boost_program_options \
--bindir=/data/data/eu.vcmi/lib" || { rm -f libapplication.so ; exit 1 ; }
--bindir=/data/data/eu.vcmi/lib" || exit 1
fi
../setEnvironment.sh sh -c "cd vcmi && \
../setEnvironment.sh sh -c "cd vcmi/lib && \
make -j4 AM_DEFAULT_VERBOSITY=1 \
pkgdatadir=. pkglibdir=/data/data/eu.vcmi/lib bindir=/data/data/eu.vcmi/lib" && \
cp -f vcmi/client/vcmiclient libapplication.so || exit 1
pkgdatadir=/sdcard/app-data/eu.vcmi pkglibdir=/data/data/eu.vcmi/files bindir=/data/data/eu.vcmi/files" \
|| exit 1
rm -f $LOCAL_PATH/../../../obj/local/armeabi/libSDL.so
rm -f $LOCAL_PATH/../../../obj/local/armeabi/libpthread.so
rm -f $LOCAL_PATH/../../../obj/local/armeabi/libSDL_mixer.so
rm -f $LOCAL_PATH/../../../obj/local/armeabi/libSDL_image.so
rm -f $LOCAL_PATH/../../../obj/local/armeabi/libSDL_ttf.so
exit 0
fi

View File

@@ -0,0 +1,32 @@
$(shell mkdir -p out/vcmi/lib)
LOCAL_PATH=$(shell dirname $0)
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
GCC_PREFIX=$(if $(shell which ndk-build | grep 'android-ndk-r5'),arm-linux-androideabi,arm-eabi)
SOURCES=$(wildcard vcmi/lib/*.cpp)
OBJS=$(patsubst %.cpp, out/%.o, $(SOURCES))
all: libvcmi.so
libvcmi.so: $(OBJS)
../setEnvironment.sh sh -c "$(GCC_PREFIX)-g++ \
\$$LDFLAGS \
$^ -o $@ \
-lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread"
$(OBJS): out/%.o: %.cpp
../setEnvironment.sh sh -c "$(GCC_PREFIX)-g++ \
-c \$$CXXFLAGS -Ivcmi -Ivcmi/lib \
-DDATA_DIR=\\\"/sdcard/app-data/eu.vcmi\\\" \
-DBIN_DIR=\\\"/data/data/eu.vcmi/files\\\" \
-DLIB_DIR=\\\"/data/data/eu.vcmi/files\\\" \
-DWITH_AVCODEC_DECODE_VIDEO2=1 \
$< -o $@"
mkdir -p debug
cp $@ debug/$@
$(GCC_PREFIX)-strip

View File

@@ -1,3 +1,87 @@
Index: server/CGameHandler.cpp
===================================================================
--- server/CGameHandler.cpp (revision 2170)
+++ server/CGameHandler.cpp (working copy)
@@ -24,6 +24,7 @@
#include <boost/random/variate_generator.hpp>
#include <boost/random/poisson_distribution.hpp>
#include "../lib/CCreatureSet.h"
+
/*
* CGameHandler.cpp, part of VCMI engine
@@ -1786,7 +1787,7 @@
iw.player = h1->tempOwner;
iw.components.push_back(Component(Component::SEC_SKILL, 18, ScholarLevel, 0));
- iw.text.addTxt(MetaString::GENERAL_TXT, 139);//"%s, who has studied magic extensively,
+ iw.text.addTxt(MetaString::GENERAL_TXT, 139);//%s, who has studied magic extensively,
iw.text.addReplacement(h1->name);
if (cs2.spells.size())//if found new spell - apply
Index: lib/VCMIDirs.h
===================================================================
--- lib/VCMIDirs.h (revision 2170)
+++ lib/VCMIDirs.h (working copy)
@@ -12,6 +12,7 @@
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
#endif
+#include <android/log.h>
/// Where to find the various VCMI files. This is mostly usefull for linux.
@@ -24,14 +25,23 @@
#ifdef _WIN32
UserPath = DATA_DIR;
#else
- // Find vcmi user directory and create it if necessary
- std::string home_dir = getenv("HOME");
- UserPath = path(home_dir + "/.vcmi").string();
-
- create_directory(UserPath);
- create_directory(UserPath + "/config");
- create_directory(UserPath + "/Games");
+ try {
+ // Find vcmi user directory and create it if necessary
+ std::string home_dir = ".";
+ if( getenv("HOME") != NULL )
+ home_dir = getenv("HOME");
+ UserPath = path(home_dir + "/.vcmi").string();
+#ifdef ANDROID
+ UserPath = DATA_DIR;
#endif
+ create_directory(UserPath);
+ create_directory(UserPath + "/config");
+ create_directory(UserPath + "/Games");
+ }
+ catch(const std::exception & e)
+ {
+ }
+#endif
}
};
extern VCMIDirs GVCMIDirs;
Index: CConsoleHandler.cpp
===================================================================
--- CConsoleHandler.cpp (revision 2170)
+++ CConsoleHandler.cpp (working copy)
@@ -143,6 +143,7 @@
void CConsoleHandler::setColor(int level)
{
+#ifndef ANDROID
TColor color;
switch(level)
{
@@ -179,6 +180,7 @@
#else
std::cout << color;
#endif
+#endif
}
int CConsoleHandler::run()
Index: global.h
===================================================================
--- global.h (revision 2170)
@@ -13,29 +97,276 @@ Index: global.h
//filesystem version 3 causes problems (and it's default as of boost 1.46)
#define BOOST_FILESYSTEM_VERSION 2
typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes)
@@ -622,8 +626,25 @@
@@ -618,20 +622,45 @@
class CLogger //logger, prints log info to console and saves in file
{
const int lvl;
+#ifdef ANDROID
+ std::ostringstream buf;
+ int androidloglevel;
+ void outputAndroid()
+ {
+ int pos = buf.str().find("\n");
+ while( pos >= 0 )
+ {
+ __android_log_print(androidloglevel, "VCMI", "%s", buf.str().substr(0, pos).c_str() );
+ buf.str( buf.str().substr(pos+1) );
+ pos = buf.str().find("\n");
+ }
+ }
+#endif
public:
CLogger& operator<<(std::ostream& (*fun)(std::ostream&))
{
+#ifdef ANDROID
+ std::ostringstream os;
+ os << fun;
+ int loglevel = ANDROID_LOG_INFO;
+ switch(lvl) {
+ case 0: loglevel = ANDROID_LOG_INFO; break;
+ case 1: loglevel = ANDROID_LOG_FATAL; break;
+ case 2: loglevel = ANDROID_LOG_ERROR; break;
+ case 3: loglevel = ANDROID_LOG_WARN; break;
+ case 4: loglevel = ANDROID_LOG_INFO; break;
+ case 5: loglevel = ANDROID_LOG_DEBUG; break;
+ case 6: case -2: loglevel = ANDROID_LOG_VERBOSE; break;
+ };
+ __android_log_print(loglevel, "VCMI", "%s", os.str().c_str());
+#endif
+ buf << fun;
+ outputAndroid();
+#else
if(lvl < CONSOLE_LOGGING_LEVEL)
+ {
std::cout << fun;
+ }
if((lvl < FILE_LOGGING_LEVEL) && logfile)
*logfile << fun;
+#endif
return *this;
}
template<typename T>
CLogger & operator<<(const T & data)
{
+#ifdef ANDROID
+ buf << data;
+ outputAndroid();
+#else
if(lvl < CONSOLE_LOGGING_LEVEL)
{
if(console)
@@ -641,10 +670,25 @@
}
if((lvl < FILE_LOGGING_LEVEL) && logfile)
*logfile << data << std::flush;
+#endif
return *this;
}
- CLogger(const int Lvl) : lvl(Lvl) {}
+ CLogger(const int Lvl) : lvl(Lvl)
+ {
+#ifdef ANDROID
+ androidloglevel = ANDROID_LOG_INFO;
+ switch(lvl) {
+ case 0: androidloglevel = ANDROID_LOG_INFO; break;
+ case 1: androidloglevel = ANDROID_LOG_FATAL; break;
+ case 2: androidloglevel = ANDROID_LOG_ERROR; break;
+ case 3: androidloglevel = ANDROID_LOG_WARN; break;
+ case 4: androidloglevel = ANDROID_LOG_INFO; break;
+ case 5: androidloglevel = ANDROID_LOG_DEBUG; break;
+ case 6: case -2: androidloglevel = ANDROID_LOG_VERBOSE; break;
+ }
+#endif
+ }
};
extern DLL_EXPORT CLogger tlog0; //green - standard progress info
Index: client/CMT.cpp
===================================================================
--- client/CMT.cpp (revision 2170)
+++ client/CMT.cpp (working copy)
@@ -55,6 +55,8 @@
#if __MINGW32__
#undef main
#endif
+
+
namespace po = boost::program_options;
@@ -92,6 +94,7 @@
static void listenForEvents();
void requestChangingResolution();
void startGame(StartInfo * options, CConnection *serv = NULL);
+
#ifndef _WIN32
#ifndef _GNU_SOURCE
@@ -102,6 +105,7 @@
void init()
{
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
timeHandler tmh, pomtime;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int rmask = 0xff000000;int gmask = 0x00ff0000;int bmask = 0x0000ff00;int amask = 0x000000ff;
@@ -157,8 +161,11 @@
tlog0<<"\tMain graphics: "<<tmh.getDif()<<std::endl;
tlog0<<"Initializing game graphics: "<<tmh.getDif()<<std::endl;
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
CMessage::init();
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
tlog0<<"Message handler: "<<tmh.getDif()<<std::endl;
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
//CPG = new CPreGame(); //main menu and submenus
//tlog0<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
}
@@ -184,19 +191,26 @@
}
+#ifdef ANDROID
+int SDL_main(int argc, char** argv)
+#else
#ifdef _WIN32
int _tmain(int argc, _TCHAR* argv[])
#else
int main(int argc, char** argv)
#endif
+#endif
{
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
tlog0 << "Starting... " << std::endl;
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
po::options_description opts("Allowed options");
opts.add_options()
("help,h", "display help and exit")
("version,v", "display version information and exit")
("battle,b", po::value<std::string>(), "runs game in duel mode (battle-only")
("nointro,i", "skips intro movies");
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
po::variables_map vm;
if(argc > 1)
@@ -210,6 +224,7 @@
tlog1 << "Failure during parsing command-line options:\n" << e.what() << std::endl;
}
}
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
po::notify(vm);
if(vm.count("help"))
@@ -222,10 +237,12 @@
prog_version();
return 0;
}
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
//Set environment vars to make window centered. Sometimes work, sometimes not. :/
putenv((char*)"SDL_VIDEO_WINDOW_POS");
putenv((char*)"SDL_VIDEO_CENTERED=1");
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
timeHandler total, pomtime;
std::cout.flags(std::ios::unitbuf);
@@ -235,8 +252,10 @@
console->start();
atexit(dispose);
tlog0 <<"Creating console and logfile: "<<pomtime.getDif() << std::endl;
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
conf.init();
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
tlog0 <<"Loading settings: "<<pomtime.getDif() << std::endl;
tlog0 << NAME << std::endl;
@@ -244,6 +263,7 @@
CCS = new CClientState;
CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler etc.)
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO))
{
@@ -251,6 +271,7 @@
exit(-1);
}
atexit(SDL_Quit);
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
setScreenRes(conf.cc.pregameResx, conf.cc.pregameResy, conf.cc.bpp, conf.cc.fullscreen);
tlog0 <<"\tInitializing screen: "<<pomtime.getDif() << std::endl;
@@ -261,6 +282,7 @@
//we can properly play intro only in the main thread, so we have to move loading to the separate thread
boost::thread loading(init);
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
if(!vm.count("battle") && !vm.count("nointro"))
playIntro();
@@ -269,6 +291,7 @@
CSDL_Ext::update(screen);
loading.join();
tlog0<<"Initialization of VCMI (together): "<<total.getDif()<<std::endl;
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
if(!vm.count("battle"))
{
@@ -284,8 +307,10 @@
si->playerInfos[1].color = 1;
startGame(si);
}
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
mainGUIThread = new boost::thread(&CGuiHandler::run, boost::ref(GH));
listenForEvents();
+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
return 0;
}
@@ -535,10 +560,12 @@
tlog2 << "Warning: SDL says that " << bpp << "bpp is wrong and suggests " << suggestedBpp << std::endl;
}
+#ifndef ANDROID
if(screen) //screen has been already initialized
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
+#endif
if((screen = SDL_SetVideoMode(w, h, suggestedBpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0))) == NULL)
{
@@ -717,3 +744,4 @@
ev.user.code = 1;
SDL_PushEvent(&ev);
}
+
Index: client/CVideoHandler.cpp
===================================================================
--- client/CVideoHandler.cpp (revision 2170)
+++ client/CVideoHandler.cpp (working copy)
@@ -6,6 +6,7 @@
#include "SDL_Extensions.h"
#include "CPlayerInterface.h"
#include "boost/filesystem.hpp"
+
extern SystemOptions GDefaultOptions;
//reads events and returns true on key down
@@ -62,6 +63,7 @@
void DLLHandler::Instantiate(const char *filename)
{
name = filename;
+ tlog1 << "Loading dynamic library " << filename << std::endl;
#ifdef _WIN32
dll = LoadLibraryA(filename);
if(!dll)
@@ -72,6 +74,7 @@
#else
dll = dlopen(filename,RTLD_LOCAL | RTLD_LAZY);
#endif
+ tlog1 << "Loading dynamic library " << filename << dll ? " successful" : " failed" <<std::endl;
}
void *DLLHandler::FindAddress(const char *symbol)
@@ -86,6 +89,10 @@
}
#else
ret = (void *)dlsym(dll, symbol);
+ if(!ret)
+ {
+ tlog1 << "Failed to find " << symbol << " in " << name << std::endl;
+ }
#endif
return ret;
}