diff --git a/project/jni/application/vcmi-r2387/.gitignore b/project/jni/application/vcmi-r2387/.gitignore deleted file mode 100644 index 11ed32df9..000000000 --- a/project/jni/application/vcmi-r2387/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -libvcmi.so -libvcmi.a -AI -Scripting -debug -out -vcmiserver -vcmiserver.zip -build.log -AndroidData/binaries.zip diff --git a/project/jni/application/vcmi-r2387/AndroidAppSettings.cfg b/project/jni/application/vcmi-r2387/AndroidAppSettings.cfg deleted file mode 100644 index 9cf7afcec..000000000 --- a/project/jni/application/vcmi-r2387/AndroidAppSettings.cfg +++ /dev/null @@ -1,215 +0,0 @@ -# The application settings for Android libSDL port - -AppSettingVersion=19 - -# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2) -LibSdlVersion=1.2 - -# Specify application name (e.x. My Application) -AppName="VCMI" - -# Specify reversed site name of application (e.x. com.mysite.myapp) -AppFullName=eu.vcmi - -# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape -ScreenOrientation=h - -# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer -InhibitSuspend=y - -# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...' -# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu -# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped -# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir - -# these files are put inside .apk package by build system -# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS -AppDataDownloadUrl="!Data files|data1.zip^!Data files|data2.zip^!Data files|data3.zip^" - -# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only -# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32) -VideoDepthBpp=16 - -# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n) -NeedDepthBuffer=n - -# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n) -NeedStencilBuffer=n - -# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device -# you need this option only if you're developing 3-d app (y) or (n) -NeedGles2=n - -# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL, -# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n) -SwVideoMode=y - -# Application video output will be resized to fit into native device screen (y)/(n) -SdlVideoResize=y - -# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n) -SdlVideoResizeKeepAspect=n - -# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread - -# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n) -CompatibilityHacks=y - -# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n) -CompatibilityHacksStaticInit=n - -# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n) -CompatibilityHacksTextInputEmulatesHwKeyboard=n - -# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n) -CompatibilityHacksPreventAudioChopping=n - -# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n) -CompatibilityHacksAppIgnoresAudioBufferSize=n - -# Hack for VCMI: preload additional shared libraries before aplication start -CompatibilityHacksAdditionalPreloadedSharedLibraries="vcmi" - -# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue - -# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n) -CompatibilityHacksSlowCompatibleEventQueue=n - -# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL -CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState= - -# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user -AppUsesMouse=y - -# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n) -AppNeedsTwoButtonMouse=y - -# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n) -ShowMouseCursor=n - -# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n) -ForceRelativeMouseMode=n - -# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n) -AppNeedsArrowKeys=n - -# Application needs text input (y) or (n), enables button for text input on screen -AppNeedsTextInput=y - -# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1 -AppUsesJoystick=n - -# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n) -AppUsesSecondJoystick=n - -# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7 -AppUsesAccelerometer=n - -# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4 -AppUsesGyroscope=n - -# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0 -AppUsesMultitouch=n - -# Application records audio (it will use any available source, such a s microphone) -# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void); -# This option will add additional permission to Android manifest (y)/(n) -AppRecordsAudio=n - -# Application implements Android-specific routines to put to background, and will not draw anything to screen -# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them -# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n) -# This option is reported to be buggy, sometimes failing to restore video state -NonBlockingSwapBuffers=n - -# Redefine common hardware keys to SDL keysyms -# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent -# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices -# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th) -# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA -RedefinedKeys="LALT RETURN NO_REMAP NO_REMAP E" - -# Number of virtual keyboard keys (currently 6 is maximum) -AppTouchscreenKeyboardKeysAmount=0 - -# Number of virtual keyboard keys that support autofire (currently 2 is maximum) -AppTouchscreenKeyboardKeysAmountAutoFire=0 - -# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right) -RedefinedKeysScreenKb="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2" - -# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu -RedefinedKeysScreenKbNames="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2" - -# How long to show startup menu button, in msec, 0 to disable startup menu -StartupMenuButtonTimeout=3000 - -# Menu items to hide from startup menu, available menu items: -# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout -HiddenMenuOptions='SettingsMenuMisc.OptionalDownloadConfig' - -# Menu items to show at startup - this is Java code snippet, leave empty for default -# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration() -# Available menu items: -# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout -FirstStartMenuOptions='' - -# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices, -# but .apk size is 2x bigger (y) / (n) / (x86) / (all) -MultiABI=armeabi-v7a - -# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower -AppMinimumRAM=128 - -# Application version code (integer) -AppVersionCode=08606 - -# Application user-visible version name (string) -AppVersionName="0.86.06" - -# Reset SDL config when updating application to the new version (y) / (n) -ResetSdlConfigForThisVersion=y - -# Delete application data files when upgrading (specify file/dir paths separated by spaces) -DeleteFilesOnUpgrade="libsdl-DownloadFinished-0.flag libsdl-DownloadFinished-1.flag libsdl-DownloadFinished-2.flag libsdl-DownloadFinished-3.flag libsdl-DownloadFinished-4.flag libsdl-DownloadFinished-5.flag" - -# Optional shared libraries to compile - removing some of them will save space -# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed -# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2 -CompiledLibraries="mad sdl_mixer sdl_image sdl_ttf avutil avcore avcodec avformat swscale boost_program_options boost_filesystem boost_iostreams boost_system boost_thread android" - -# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n) -CustomBuildScript=y - -# Aditional CFLAGS for application -AppCflags='' - -# Additional LDFLAGS for application -AppLdflags='' - -# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable -AppOverlapsSystemHeaders= - -# Build only following subdirs (empty will build all dirs, ignored with custom script) -AppSubdirsBuild='' - -# Exclude these files from build -AppBuildExclude='' - -# Application command line parameters, including app name as 0-th param -AppCmdline='' - -# Here you may type readme text, which will be shown during startup. Format is: -# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?) -ReadmeText='^You may press "Home" now - the data will be downloaded in background' - -# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens -# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge -MinimumScreenSize=s - -# Your AdMob Publisher ID, (n) if you don't want advertisements -AdmobPublisherId=n - -# Your AdMob test device ID, to receive a test ad -AdmobTestDeviceId= - -# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER) -AdmobBannerSize= - diff --git a/project/jni/application/vcmi-r2387/AndroidBuild.sh b/project/jni/application/vcmi-r2387/AndroidBuild.sh deleted file mode 100755 index d42619359..000000000 --- a/project/jni/application/vcmi-r2387/AndroidBuild.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# For some reason I'm getting errors with "make -j4" -make -k ARCH=$1 || exit 1 -[ -f libapplication-$1.so ] || exit 1 -[ -e libapplication.so ] || ln -s libapplication-armeabi.so libapplication.so -exit 0 diff --git a/project/jni/application/vcmi-r2387/AndroidData/data1.zip b/project/jni/application/vcmi-r2387/AndroidData/data1.zip deleted file mode 100644 index be8147f11..000000000 Binary files a/project/jni/application/vcmi-r2387/AndroidData/data1.zip and /dev/null differ diff --git a/project/jni/application/vcmi-r2387/AndroidData/data2.zip b/project/jni/application/vcmi-r2387/AndroidData/data2.zip deleted file mode 100644 index 54bfa22a4..000000000 Binary files a/project/jni/application/vcmi-r2387/AndroidData/data2.zip and /dev/null differ diff --git a/project/jni/application/vcmi-r2387/AndroidData/data3.zip b/project/jni/application/vcmi-r2387/AndroidData/data3.zip deleted file mode 100644 index 2f275aeb7..000000000 Binary files a/project/jni/application/vcmi-r2387/AndroidData/data3.zip and /dev/null differ diff --git a/project/jni/application/vcmi-r2387/Makefile b/project/jni/application/vcmi-r2387/Makefile deleted file mode 100644 index 8bb83a906..000000000 --- a/project/jni/application/vcmi-r2387/Makefile +++ /dev/null @@ -1,98 +0,0 @@ -$(shell mkdir -p $(ARCH)/AI debug/$(ARCH)/AI $(ARCH)/Scripting debug/$(ARCH)/Scripting \ - $(ARCH)/out/vcmi/lib $(ARCH)/out/vcmi/server $(ARCH)/out/vcmi/AI/StupidAI \ - $(ARCH)/out/vcmi/AI/GeniusAI $(ARCH)/out/vcmi/client $(ARCH)/out/vcmi/Scripting/ERM) - -GCC_VERSION:=4.8 -ARCH:=armeabi-v7a - -SOURCES_LIB:=$(wildcard vcmi/lib/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp) -OBJS_LIB:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_LIB)) - -SOURCES_SERVER:=$(wildcard vcmi/server/*.cpp) -OBJS_SERVER:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_SERVER)) - -SOURCES_STUPIDAI:=$(wildcard vcmi/AI/StupidAI/*.cpp) -OBJS_STUPIDAI:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_STUPIDAI)) - -SOURCES_GENIUSAI:=$(filter-out %/ExpertSystem.cpp, $(wildcard vcmi/AI/GeniusAI/*.cpp)) -OBJS_GENIUSAI:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_GENIUSAI)) - -SOURCES_ERM:=$(wildcard vcmi/Scripting/ERM/*.cpp) -OBJS_ERM:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_ERM)) - -SOURCES_CLIENT:=$(wildcard vcmi/client/*.cpp vcmi/CCallback.cpp) -OBJS_CLIENT:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_CLIENT)) - -all: AndroidData/binaries-$(ARCH).zip libapplication-$(ARCH).so - -AndroidData/binaries-$(ARCH).zip: $(ARCH)/vcmiserver $(ARCH)/AI/libGeniusAI.so $(ARCH)/AI/libStupidAI.so $(ARCH)/Scripting/libvcmiERM.so $(ARCH)/libvcmi.so - rm -f $@ - cd $(ARCH) && zip -r ../$@ $(foreach F, $^, $(patsubst $(ARCH)/%,%,$(F))) - -$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_GENIUSAI) $(OBJS_STUPIDAI) $(OBJS_CLIENT) $(OBJS_ERM): $(ARCH)/out/%.o: %.cpp - env GCCVER=$(GCC_VERSION) ../setEnvironment-$(ARCH).sh sh -c \ - "\$$CXX \ - -c \$$CXXFLAGS -Ivcmi -Ivcmi/lib \ - -DDATA_DIR=\\\"/sdcard/Android/data/eu.vcmi/files\\\" \ - -DBIN_DIR=\\\"/data/data/eu.vcmi/files\\\" \ - -DLIB_DIR=\\\"/data/data/eu.vcmi/files\\\" \ - -DWITH_AVCODEC_DECODE_VIDEO2=1 \ - -Wstrict-aliasing -Wcast-align -Wpointer-arith -Waddress \ - $< -o $@" -# -Werror=strict-aliasing -Werror=cast-align -Werror=pointer-arith -Werror=address - -#ALLOW_UNRESOLVED_SYMBOLS=1 -LINK_LIB= \ - env GCCVER=$(GCC_VERSION) NO_SHARED_LIBS=1 SHARED_LIBRARY_NAME=`basename $@` \ - ../setEnvironment-$(ARCH).sh sh -c \ - "\$$CXX \ - -Wl,--whole-archive $^ -Wl,--no-whole-archive -o $@ \ - \$$LDFLAGS -L$(ARCH) \ - -Wl,--undefined=__gnu_thumb1_case_uqi -Wl,--undefined=__gnu_thumb1_case_uhi \ - -Wl,--undefined=__clzsi2 -lgcc \ - -lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread && \ - cp $@ debug/$@ && \ - \$$STRIP --strip-unneeded $@" - -#$(ARCH)/libvcmi.a: $(OBJS_LIB) -# ar rcs $@ $^ - -$(ARCH)/libvcmi.so: $(OBJS_LIB) - $(LINK_LIB) - --lvcmi: $(ARCH)/libvcmi.so -# cp -f $^ ../../../libs/$^ - -.PHONY: -lvcmi - -$(ARCH)/AI/libGeniusAI.so: $(OBJS_GENIUSAI) -lvcmi - $(LINK_LIB) - -$(ARCH)/AI/libStupidAI.so: $(OBJS_STUPIDAI) -lvcmi - $(LINK_LIB) - -$(ARCH)/Scripting/libvcmiERM.so: $(OBJS_ERM) -lvcmi - $(LINK_LIB) - -$(ARCH)/vcmiserver: $(OBJS_SERVER) -lvcmi - env GCCVER=$(GCC_VERSION) BUILD_EXECUTABLE=1 NO_SHARED_LIBS=1 ../setEnvironment-$(ARCH).sh sh -c \ - "\$$CXX \ - -Wl,--whole-archive $^ -Wl,--no-whole-archive -o $@ \ - \$$LDFLAGS -L$(ARCH) -Wl,-rpath,/data/data/eu.vcmi/lib \ - -lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread && \ - cp $@ debug/$@ && \ - \$$STRIP --strip-unneeded $@" - -libapplication-$(ARCH).so: $(OBJS_CLIENT) -lvcmi - env GCCVER=$(GCC_VERSION) ../setEnvironment-$(ARCH).sh sh -c \ - "\$$CXX \ - -Wl,--whole-archive $^ -Wl,--no-whole-archive -o $@ \ - \$$LDFLAGS -L$(ARCH) \ - -lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread -lboost_program_options && \ - cp $@ debug/$@" -# No need to strip, it's done inside build.sh script - -clean: - rm -rf armeabi* debug AndroidData/binaries-*.zip libapplication*.so - -.PHONY: clean diff --git a/project/jni/application/vcmi-r2387/icon.png b/project/jni/application/vcmi-r2387/icon.png deleted file mode 100644 index 970b73138..000000000 Binary files a/project/jni/application/vcmi-r2387/icon.png and /dev/null differ diff --git a/project/jni/application/vcmi-r2387/readme.txt b/project/jni/application/vcmi-r2387/readme.txt deleted file mode 100644 index 4de332a52..000000000 --- a/project/jni/application/vcmi-r2387/readme.txt +++ /dev/null @@ -1,14 +0,0 @@ -Quick compilation guide: -Download my GIT repo from https://github.com/pelya/commandergenius, -then install Android SDK from http://developer.android.com, -NDK r8d from http://crystax.net/ and "ant" tool, then launch commands - android update project -p project - rm project/jni/application/src - ln -s vcmi project/jni/application/src - echo > project/jni/application/vcmi/libvcmi.so -then download VCMI revision 2387 into the dir project/jni/application/vcmi/vcmi -(or create a symlink to it if you already have downloaded it), then apply patch vcmi-android.diff, -then launch build.sh. - -To run it you should have complete installation of Heroes 3: Wake of Gods on your SD card on your device, -in the directory Android/data/eu.vcmi/files diff --git a/project/jni/application/vcmi-r2387/vcmi-android.diff b/project/jni/application/vcmi-r2387/vcmi-android.diff deleted file mode 100644 index 31da08814..000000000 --- a/project/jni/application/vcmi-r2387/vcmi-android.diff +++ /dev/null @@ -1,1599 +0,0 @@ -Index: server/CGameHandler.cpp -=================================================================== ---- server/CGameHandler.cpp (revision 2387) -+++ server/CGameHandler.cpp (working copy) -@@ -638,6 +638,7 @@ - (packType != typeList.getTypeID() || !isAllowedArrangePack((ArrangeStacks*)pack)) && // for dialogs like garrison - states[getCurrentPlayer()].queries.size()) - { -+ tlog0<<__FUNCTION__ << " at " << __FILE__ << ":" << __LINE__ << std::endl; - complain("Answer the query before attempting any further actions!"); - PackageApplied applied; - applied.result = false; -@@ -650,6 +651,7 @@ - else if(apply) - { - bool result = apply->applyOnGH(this,&c,pack); -+ tlog0<<__FUNCTION__ << " at " << __FILE__ << ":" << __LINE__ << std::endl; - tlog5 << "Message successfully applied (result=" << result << ")!\n"; - - //send confirmation that we've applied the package -@@ -1833,7 +1835,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: server/CVCMIServer.cpp -=================================================================== ---- server/CVCMIServer.cpp (revision 2387) -+++ server/CVCMIServer.cpp (working copy) -@@ -29,7 +29,7 @@ - using namespace boost; - using namespace boost::asio; - using namespace boost::asio::ip; --namespace intpr = boost::interprocess; -+//namespace intpr = boost::interprocess; - bool end2 = false; - int port = 3030; - VCMIDirs GVCMIDirs; -@@ -379,6 +379,7 @@ - - void CVCMIServer::start() - { -+ /* - ServerReady *sr = NULL; - intpr::mapped_region *mr; - try -@@ -395,13 +396,17 @@ - mr = new intpr::mapped_region(smo,intpr::read_write); - sr = new(mr->get_address())ServerReady(); - } -+ */ -+ notifyServerReady(); - - boost::system::error_code error; - tlog0<<"Listening for connections at port " << acceptor->local_endpoint().port() << std::endl; - tcp::socket * s = new tcp::socket(acceptor->get_io_service()); - boost::thread acc(boost::bind(vaccept,acceptor,s,&error)); -+ /* - sr->setToTrueAndNotify(); - delete mr; -+ */ - - acc.join(); - if (error) -Index: server/stdafx.h -=================================================================== ---- server/stdafx.h (revision 2387) -+++ server/stdafx.h (working copy) -@@ -15,8 +15,8 @@ - #include "../global.h" - - #include --#include --#include -+//#include -+//#include - #include - #include - #include -Index: global.h -=================================================================== ---- global.h (revision 2387) -+++ global.h (working copy) -@@ -4,6 +4,7 @@ - #include - #include - #include //std::find -+#include //memcpy - #include //std::find - #include - #include -@@ -15,7 +16,7 @@ - #include - #endif - //filesystem version 3 causes problems (and it's default as of boost 1.46) --#define BOOST_FILESYSTEM_VERSION 2 -+//#define BOOST_FILESYSTEM_VERSION 2 - typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) - typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes) - typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) -@@ -725,29 +726,21 @@ - } - - --#if defined(linux) && defined(sparc) --/* SPARC does not support unaligned memory access. Let gcc know when -- * to emit the right code. */ --struct unaligned_Uint16 { ui16 val __attribute__(( packed )); }; --struct unaligned_Uint32 { ui32 val __attribute__(( packed )); }; - - static inline ui16 read_unaligned_u16(const void *p) - { -- const struct unaligned_Uint16 *v = (const struct unaligned_Uint16 *)p; -- return v->val; -+ ui16 out; -+ memcpy(&out, p, sizeof(out)); -+ return out; - } - - static inline ui32 read_unaligned_u32(const void *p) - { -- const struct unaligned_Uint32 *v = (const struct unaligned_Uint32 *)p; -- return v->val; -+ ui32 out; -+ memcpy(&out, p, sizeof(out)); -+ return out; - } - --#else --#define read_unaligned_u16(p) (* reinterpret_cast(p)) --#define read_unaligned_u32(p) (* reinterpret_cast(p)) --#endif -- - //for explicit overrides - #ifdef _MSC_VER - #define OVERRIDE override -Index: Scripting/ERM/ERMParser.cpp -=================================================================== ---- Scripting/ERM/ERMParser.cpp (revision 2387) -+++ Scripting/ERM/ERMParser.cpp (working copy) -@@ -2,7 +2,7 @@ - #include - //To make compilation with older boost versions possible - //Don't know exact version - 1.46 works while 1.42 not --#if BOOST_VERSION >= 104600 -+#if BOOST_VERSION >= 104500 - - #include - #include -Index: AI/GeniusAI/neuralNetwork.cpp -=================================================================== ---- AI/GeniusAI/neuralNetwork.cpp (revision 2387) -+++ AI/GeniusAI/neuralNetwork.cpp (working copy) -@@ -14,9 +14,9 @@ - static bool in = 0; - if(!in) - { -- float x = (rand()+1)/float(RAND_MAX+1); -+ float x = (rand())/float(RAND_MAX); - float f = sqrtf( - 2.0f * log(x) ); -- x = (rand()+1)/float(RAND_MAX+1); -+ x = (rand())/float(RAND_MAX); - kept = f * cosf( 2.0f * M_PI * x ); - in = true; - return f * sinf( 2.0f * M_PI * x ); -Index: AI/GeniusAI/CGeniusAI.cpp -=================================================================== ---- AI/GeniusAI/CGeniusAI.cpp (revision 2387) -+++ AI/GeniusAI/CGeniusAI.cpp (working copy) -@@ -1393,6 +1393,7 @@ - } - - -+#ifndef ANDROID - //WTF?!? why is this needed?!?!?! - BattleAction CGlobalAI::activeStack( const CStack * stack ) - { -@@ -1400,4 +1401,5 @@ - ba.stackNumber = stack->ID; - return ba; - } -+#endif - -Index: lib/Interprocess.h -=================================================================== ---- lib/Interprocess.h (revision 2387) -+++ lib/Interprocess.h (working copy) -@@ -1,3 +1,4 @@ -+/* - #include - #include - #include -@@ -2,2 +3,3 @@ - #include -+*/ - -@@ -13,6 +15,7 @@ - * - */ - -+/* - struct ServerReady - { - bool ready; -@@ -51,4 +54,48 @@ - delete mr; - boost::interprocess::shared_memory_object::remove("vcmi_memory"); - } --}; -\ No newline at end of file -+}; -+*/ -+ -+#include -+#ifdef WIN32 -+#include -+#else -+#include -+#endif -+#include "VCMIDirs.h" -+ -+#define SERVER_READY_FILENAME "/VcmiServerReadyFlag.lock" -+ -+void clearServerReady() -+{ -+ unlink((GVCMIDirs.UserPath + SERVER_READY_FILENAME).c_str()); -+} -+ -+void waitServerReady() -+{ -+ while(true) -+ { -+ FILE * ff = fopen((GVCMIDirs.UserPath + SERVER_READY_FILENAME).c_str(), "r"); -+ if(ff) -+ { -+ fclose(ff); -+ clearServerReady(); -+ break; -+ } -+#ifdef WIN32 -+ Sleep(200); -+#else -+ usleep(200000); -+#endif -+ } -+} -+ -+void notifyServerReady() -+{ -+ FILE * ff = fopen((GVCMIDirs.UserPath + SERVER_READY_FILENAME).c_str(), "w"); -+ if(!ff) -+ return; -+ fwrite("1", 1, 1, ff); -+ fclose(ff); -+} -Index: lib/CLodHandler.cpp -=================================================================== ---- lib/CLodHandler.cpp (revision 2387) -+++ lib/CLodHandler.cpp (working copy) -@@ -87,13 +87,15 @@ - Entry ourEntry = *en_it; - - if(length) *length = ourEntry.realSize; -+ enum { SAFETY_MARGIN = 4096 }; // VCMI functions tend to read past the array end, crashing at random - mutex->lock(); - - unsigned char * outp; - if (ourEntry.offset<0) //file is in the sprites/ folder; no compression - { - int result; -- outp = new unsigned char[ourEntry.realSize]; -+ outp = new unsigned char[ourEntry.realSize+SAFETY_MARGIN]; -+ memset(outp+ourEntry.realSize, 0, SAFETY_MARGIN); - FILE * f = fopen((myDir + "/" + ourEntry.realName).c_str(), "rb"); - if (f) - { -@@ -109,16 +111,21 @@ - delete[] outp; - return NULL; - } -- else -+ else -+ { -+ //tlog0 << "Loaded file: " << fname << " size " << ourEntry.realSize << " ptr " << (void *)outp << " safety " << (int)SAFETY_MARGIN << std::endl; - return outp; -+ } - } - else if (ourEntry.size==0) //file is not compressed - { -- outp = new unsigned char[ourEntry.realSize]; -+ outp = new unsigned char[ourEntry.realSize+SAFETY_MARGIN]; -+ memset(outp+ourEntry.realSize, 0, SAFETY_MARGIN); - - LOD.seekg(ourEntry.offset, std::ios::beg); - LOD.read((char*)outp, ourEntry.realSize); - mutex->unlock(); -+ //tlog0 << "Loaded file: " << fname << " size " << ourEntry.realSize << " ptr " << (void *)outp << " safety " << (int)SAFETY_MARGIN << std::endl; - return outp; - } - else //we will decompress file -@@ -131,7 +138,12 @@ - infs2(outp, ourEntry.size, ourEntry.realSize, decomp); - mutex->unlock(); - delete[] outp; -- return decomp; -+ outp = new unsigned char[ourEntry.realSize+SAFETY_MARGIN]; -+ memset(outp+ourEntry.realSize, 0, SAFETY_MARGIN); -+ memcpy(outp, decomp, ourEntry.realSize); -+ delete [] decomp; -+ //tlog0 << "Loaded file: " << fname << " size " << ourEntry.realSize << " ptr " << (void *)outp << " safety " << (int)SAFETY_MARGIN << std::endl; -+ return outp; - } - return NULL; - } -Index: lib/Connection.h -=================================================================== ---- lib/Connection.h (revision 2387) -+++ lib/Connection.h (working copy) -@@ -82,7 +82,9 @@ - { - bool operator()(const std::type_info *a, const std::type_info *b) const - { -- return a->before(*b); -+ // Comparing pointers is bad bad practice, because type_info pointers to the same types -+ // are different inside shared library and the executable that links to that library -+ return strcmp(a->name(), b->name()) > 0; - } - }; - -Index: lib/CGameInterface.cpp -=================================================================== ---- lib/CGameInterface.cpp (revision 2387) -+++ lib/CGameInterface.cpp (working copy) -@@ -26,6 +26,7 @@ - rett * ret=NULL; - rett*(*getAI)(); - void(*getName)(char*); -+ const char * errorMsg = NULL; - - #ifdef _WIN32 - HINSTANCE dll = LoadLibraryA(dllname.c_str()); -@@ -36,6 +37,7 @@ - } - #else - void *dll = dlopen(dllname.c_str(), RTLD_LOCAL | RTLD_LAZY); -+ errorMsg = dlerror(); - if (dll) - { - getName = (void(*)(char*))dlsym(dll,"GetAiName"); -@@ -44,13 +46,14 @@ - #endif - if (!dll) - { -- tlog1 << "Cannot open dynamic library ("<ourImages.size(); ++y) - { -@@ -508,13 +515,20 @@ - pr[3].first = &Graphics::flags4; - pr[3].second+=("AF00.DEF"),("AF01.DEF"),("AF02.DEF"),("AF03.DEF"),("AF04.DEF"), - ("AF05.DEF"),("AF06.DEF"),("AF07.DEF"); -+#ifdef ANDROID -+ // We ain't no need any filthy multithreading -+ for(int g=0; g<4; g++) -+ { -+ loadHeroFlags(pr[g],true); -+ } -+#else - boost::thread_group grupa; - for(int g=3; g>=0; --g) - { - grupa.create_thread(boost::bind(&Graphics::loadHeroFlags,this,boost::ref(pr[g]),true)); - } - grupa.join_all(); -- tlog0 << "Loading and transforming heroes' flags: "<musich->setVolume(GDefaultOptions.musicVolume); - tlog0<<"\tInitializing sound: "<(CGI)->setFromLib(); -@@ -154,7 +158,9 @@ - CCS->curh->show(); - tlog0<<"Screen handler: "<loadHeroAnims(); - tlog0<<"\tMain graphics: "<start(); - atexit(dispose); - tlog0 <<"Creating console and logfile: "<playerInfos[1].color = 1; - startGame(si); - } -+ // Drawing and running event loop from non-main thread does not work at all on Andorid and crashes often on Linux -+#if defined(ANDROID) || defined(LINUX) -+ GH.loopInitFromMainThread(); -+ while( GH.loopFromMainThread() ) -+ { -+ while( loopListenForEvents(false) ); -+ } -+#else - mainGUIThread = new boost::thread(&CGuiHandler::run, boost::ref(GH)); - listenForEvents(); -+#endif - - return 0; - } -@@ -561,10 +585,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) - { -@@ -609,14 +635,27 @@ - setResolution = true; - } - -+ - static void listenForEvents() - { -- while(1) //main SDL events loop -- { -+ while(loopListenForEvents(true)); //main SDL events loop -+} -+ -+static bool loopListenForEvents(bool block) -+{ - SDL_Event *ev = new SDL_Event(); - - //tlog0 << "Waiting... "; -- int ret = SDL_WaitEvent(ev); -+ int ret = 1; -+ if( block ) -+ ret = SDL_WaitEvent(ev); -+ else -+ { -+ if(!SDL_PollEvent(ev)) { -+ delete ev; -+ return false; -+ } -+ } - //tlog0 << "got " << (int)ev->type; - if (ret == 0 || (ev->type==SDL_QUIT) || - (ev->type == SDL_KEYDOWN && ev->key.keysym.sym==SDLK_F4 && (ev->key.keysym.mod & KMOD_ALT))) -@@ -635,7 +674,7 @@ - SDL_Delay(750); - SDL_Quit(); - tlog0 << "Ending...\n"; -- break; -+ return false; - } - else if(LOCPLINT && ev->type == SDL_KEYDOWN && ev->key.keysym.sym==SDLK_F4) - { -@@ -644,7 +683,7 @@ - setScreenRes(conf.cc.screenx, conf.cc.screeny, conf.cc.bpp, full); - GH.totalRedraw(); - delete ev; -- continue; -+ return true; - } - else if(ev->type == SDL_USEREVENT) - { -@@ -674,7 +713,7 @@ - } - - delete ev; -- continue; -+ return true; - } - - //tlog0 << " pushing "; -@@ -682,7 +721,7 @@ - events.push(ev); - eventsM.unlock(); - //tlog0 << " done\n"; -- } -+ return true; - } - - void startGame(StartInfo * options, CConnection *serv/* = NULL*/) -@@ -742,3 +781,4 @@ - ev.user.code = 1; - SDL_PushEvent(&ev); - } -+ -Index: client/CDefHandler.cpp -=================================================================== ---- client/CDefHandler.cpp (revision 2387) -+++ client/CDefHandler.cpp (working copy) -@@ -50,10 +50,19 @@ - SDL_FreeSurface(ourImages[i].bitmap); - } - --void CDefHandler::openFromMemory(unsigned char *table, const std::string & name) -+#define CHECK_LOD_MEM_BLOCK_SIZE1(S, FF, F, L) { \ -+ if( lodLength < (S) ) \ -+ tlog1<<"ERROR in " << FF << " " << F << ":" << L << ": reading past the end of LOD mem block by " << \ -+ (S) - lodLength << " bytes, fname " << name << " size " << lodLength << std::endl; } -+#define CHECK_LOD_MEM_BLOCK_SIZE(S) CHECK_LOD_MEM_BLOCK_SIZE1(S, __FUNCTION__, __FILE__, __LINE__) -+ -+void CDefHandler::openFromMemory(unsigned char *table, const std::string & name, int lodLength) - { -+ //tlog0<<"openFromMemory ptr " << (void *)table <(table); -+ SDefEntry de; -+ memcpy(&de, table, sizeof(de)); - unsigned char *p; - - defName = name; -@@ -61,6 +70,8 @@ - width = SDL_SwapLE32(de.width); - height = SDL_SwapLE32(de.height); - unsigned int totalBlocks = SDL_SwapLE32(de.totalBlocks); -+ -+ //tlog0<<"openFromMemory w " << width << " h " << height << " totalBlocks " << totalBlocks <(&de); -+ p = table; - p += sizeof(de); -- -+ - int totalEntries=0; - for (unsigned int z=0; z(p); -+ //tlog0<<"Megadebug 443 - read size " << p - table <(FDef + BaseOffset); -+ SSpriteDef sd; -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + sizeof(sd)); -+ -+ memcpy(&sd, FDef + BaseOffset, sizeof(sd)); - - prSize = SDL_SwapLE32(sd.prSize); //TODO use me - defType2 = SDL_SwapLE32(sd.defType2); -@@ -170,12 +206,14 @@ - if (add==4) - add=0; - -+ //tlog0<<"getSprite: 11: SDL_CreateRGBSurface " << FullWidth << ":" << FullHeight << std::endl; - ret = SDL_CreateRGBSurface(SDL_SWSURFACE, FullWidth, FullHeight, 8, 0, 0, 0, 0); - //int tempee2 = readNormalNr(0,4,((unsigned char *)tempee.c_str())); - - BaseOffset += sizeof(SSpriteDef); - int BaseOffsetor = BaseOffset; - -+ //tlog0<<"getSprite: 12: set palette" << std::endl; - for(int i=0; i<256; ++i) - { - SDL_Color pr; -@@ -188,6 +226,7 @@ - - int ftcp=0; - -+ //tlog0<<"getSprite: 13" << std::endl; - // If there's a margin anywhere, just blank out the whole surface. - if (TopMargin > 0 || BottomMargin > 0 || LeftMargin > 0 || RightMargin > 0) { - memset( reinterpret_cast(ret->pixels), 0, FullHeight*FullWidth); -@@ -197,6 +236,7 @@ - if (TopMargin > 0) - ftcp += TopMargin*(FullWidth+add); - -+ //tlog0<<"getSprite: 14: defType2 " << defType2 << std::endl; - switch(defType2) - { - case 0: -@@ -206,7 +246,10 @@ - if (LeftMargin>0) - ftcp += LeftMargin; - -- memcpy(reinterpret_cast(ret->pixels)+ftcp, &FDef[BaseOffset], SpriteWidth); -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + SpriteWidth); -+ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + SpriteWidth) -+ else -+ memcpy(reinterpret_cast(ret->pixels)+ftcp, &FDef[BaseOffset], SpriteWidth); - ftcp += SpriteWidth; - BaseOffset += SpriteWidth; - -@@ -218,11 +261,12 @@ - - case 1: - { -- const unsigned int * RWEntriesLoc = reinterpret_cast(FDef+BaseOffset); -+ unsigned int RWEntriesLoc = BaseOffset; - BaseOffset += sizeof(int) * SpriteHeight; - for (unsigned int i=0;i0) - ftcp += LeftMargin; - -@@ -230,18 +274,25 @@ - do - { - unsigned int SegmentLength; -+ -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + 4); - - SegmentType=FDef[BaseOffset++]; - SegmentLength=FDef[BaseOffset++] + 1; -- -+ - if (SegmentType==0xFF) - { -- memcpy(reinterpret_cast(ret->pixels)+ftcp, FDef + BaseOffset, SegmentLength); -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + SegmentLength); -+ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + SegmentLength) -+ else -+ memcpy(reinterpret_cast(ret->pixels)+ftcp, FDef + BaseOffset, SegmentLength); - BaseOffset+=SegmentLength; - } - else - { -- memset(reinterpret_cast(ret->pixels)+ftcp, SegmentType, SegmentLength); -+ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + SegmentLength) -+ else -+ memset(reinterpret_cast(ret->pixels)+ftcp, SegmentType, SegmentLength); - } - ftcp += SegmentLength; - TotalRowLength += SegmentLength; -@@ -260,6 +311,7 @@ - - case 2: - { -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffsetor+2); - BaseOffset = BaseOffsetor + SDL_SwapLE16(read_unaligned_u16(FDef + BaseOffsetor)); - - for (unsigned int i=0;i(ret->pixels)+ftcp, &FDef[BaseOffset], value); -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + value); -+ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + value) -+ else -+ memcpy(reinterpret_cast(ret->pixels)+ftcp, &FDef[BaseOffset], value); - ftcp += value; - BaseOffset += value; - } - else - { -- memset(reinterpret_cast(ret->pixels)+ftcp, code, value); -+ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + value) -+ else -+ memset(reinterpret_cast(ret->pixels)+ftcp, code, value); - ftcp += value; - } - TotalRowLength+=value; -@@ -304,6 +362,7 @@ - { - for (unsigned int i=0;i0) - ftcp += LeftMargin; -@@ -312,6 +371,7 @@ - - do - { -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset+1); - SegmentType=FDef[BaseOffset++]; - unsigned char code = SegmentType / 32; - unsigned char value = (SegmentType & 31) + 1; -@@ -321,13 +381,18 @@ - - if(code==7) - { -- memcpy((ui8*)ret->pixels + ftcp, FDef + BaseOffset, len); -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + len); -+ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + len) -+ else -+ memcpy((ui8*)ret->pixels + ftcp, FDef + BaseOffset, len); - ftcp += len; - BaseOffset += len; - } - else - { -- memset((ui8*)ret->pixels + ftcp, code, len); -+ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + len) -+ else -+ memset((ui8*)ret->pixels + ftcp, code, len); - ftcp += len; - } - TotalRowLength+=( LeftMargin>=0 ? value : value+LeftMargin ); -@@ -345,6 +410,7 @@ - break; - - default: -+ tlog1<<"getSprite: Unknown sprite format."<< std::endl; - throw std::string("Unknown sprite format."); - break; - } -@@ -365,11 +431,15 @@ - - CDefHandler * CDefHandler::giveDef(const std::string & defName) - { -- unsigned char * data = spriteh->giveFile(defName, FILE_ANIMATION); -- if(!data) -- throw "bad def name!"; -+ //tlog0<<"giveDef " << defName <giveFile(defName, FILE_ANIMATION, &lodLength); -+ if(!data) { -+ tlog0<<"Bad def name: " << defName <openFromMemory(data, defName); -+ nh->openFromMemory(data, defName, lodLength); - delete [] data; - return nh; - } -Index: client/Client.h -=================================================================== ---- client/Client.h (revision 2387) -+++ client/Client.h (working copy) -@@ -43,7 +43,7 @@ - public: - timeHandler th; - boost::thread *serverThread; //thread that called system to run server -- SharedMem *shared; //interprocess memory (for waiting for server) -+ //SharedMem *shared; //interprocess memory (for waiting for server) - bool verbose; //whether to print log msgs - std::string port; //port number in text form - -Index: client/Client.cpp -=================================================================== ---- client/Client.cpp (revision 2387) -+++ client/Client.cpp (working copy) -@@ -41,7 +41,7 @@ - #include "../lib/RegisterTypes.cpp" - - extern std::string NAME; --namespace intpr = boost::interprocess; -+//namespace intpr = boost::interprocess; - - /* - * Client.cpp, part of VCMI engine -@@ -476,9 +476,9 @@ - - void CClient::handlePack( CPack * pack ) - { -- CBaseForCLApply *apply = applier->apps[typeList.getTypeID(pack)]; //find the applier -- if(apply) -+ if(applier->apps.find(typeList.getTypeID(pack)) != applier->apps.end()) - { -+ CBaseForCLApply *apply = applier->apps[typeList.getTypeID(pack)]; //find the applier - apply->applyOnClBefore(this,pack); - tlog5 << "\tMade first apply on cl\n"; - gs->apply(pack); -@@ -639,18 +639,22 @@ - startServer(); - - th.update(); -+ /* - intpr::scoped_lock slock(shared->sr->mutex); - while(!shared->sr->ready) - { - shared->sr->cond.wait(slock); - } -+ */ -+ tlog0 << "Waiting for server..." << std::endl; -+ waitServerReady(); - if(verbose) - tlog0 << "Waiting for server: " << th.getDif() << std::endl; - } - - CConnection * CServerHandler::connectToServer() - { -- if(!shared->sr->ready) -+ if(!serverThread) - waitForServer(); - - th.update(); -@@ -665,27 +669,31 @@ - CServerHandler::CServerHandler(bool runServer /*= false*/) - { - serverThread = NULL; -- shared = NULL; -+ //shared = NULL; - port = boost::lexical_cast(conf.cc.port); - verbose = false; - -+ /* - boost::interprocess::shared_memory_object::remove("vcmi_memory"); //if the application has previously crashed, the memory may not have been removed. to avoid problems - try to destroy it - try - { - shared = new SharedMem(); - } HANDLE_EXCEPTIONC(tlog1 << "Cannot open interprocess memory: ";) -+ */ - } - - CServerHandler::~CServerHandler() - { -- delete shared; -+ //delete shared; - delete serverThread; //detaches, not kills thread - } - - void CServerHandler::callServer() - { -+ clearServerReady(); - setThreadName(-1, "CServerHandler::callServer"); -- std::string comm = std::string(BIN_DIR PATH_SEPARATOR SERVER_NAME " ") + port + " > server_log.txt"; -+ std::string comm = std::string("LD_LIBRARY_PATH=" LIB_DIR "/../lib " BIN_DIR PATH_SEPARATOR SERVER_NAME " ") + port + " > server_log.txt"; -+ tlog0 << "Invoking VCMI server : " << comm << std::endl; - std::system(comm.c_str()); - tlog0 << "Server finished\n"; - } -Index: client/CSndHandler.cpp -=================================================================== ---- client/CSndHandler.cpp (revision 2387) -+++ client/CSndHandler.cpp (working copy) -@@ -151,16 +151,17 @@ - } - - const char *data = mfile->data(); -- unsigned int numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]); -- struct soundEntry *se = (struct soundEntry *)&data[4]; -+ unsigned int numFiles = SDL_SwapLE32(read_unaligned_u32(&data[0])); -+ struct soundEntry se; - -- for (unsigned int i=0; ifilename; -- entry.offset = SDL_SwapLE32(se->offset); -- entry.size = SDL_SwapLE32(se->size); -+ entry.name = se.filename; -+ entry.offset = SDL_SwapLE32(se.offset); -+ entry.size = SDL_SwapLE32(se.size); - entry.data = mfile->data() + entry.offset; - - entries.push_back(entry); -@@ -186,24 +187,26 @@ - return; - } - const unsigned char *data = (const unsigned char *)mfile->data(); -- unsigned int numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]); -- struct videoEntry *ve = (struct videoEntry *)&data[4]; -+ unsigned int numFiles = SDL_SwapLE32(read_unaligned_u32(&data[0])); -+ struct videoEntry ve; - -- for (unsigned int i=0; ifilename; -- entry.offset = SDL_SwapLE32(ve->offset); -+ entry.name = ve.filename; -+ entry.offset = SDL_SwapLE32(ve.offset); - entry.name.erase(entry.name.find_last_of('.')); - - // There is no size, so check where the next file is - if (i == numFiles - 1) { - entry.size = mfile->size() - entry.offset; - } else { -- struct videoEntry *ve_next = ve+1; -+ struct videoEntry ve_next; -+ memcpy(&ve_next, &data[4+(i+1)*sizeof(ve)], sizeof(ve)); - -- entry.size = SDL_SwapLE32(ve_next->offset) - entry.offset; -+ entry.size = SDL_SwapLE32(ve_next.offset) - entry.offset; - } - entry.data = mfile->data() + entry.offset; - -Index: client/CCreatureAnimation.cpp -=================================================================== ---- client/CCreatureAnimation.cpp (revision 2387) -+++ client/CCreatureAnimation.cpp (working copy) -@@ -37,15 +37,23 @@ - } - } - -+#define CHECK_LOD_MEM_BLOCK_SIZE1(S, FF, F, L) { \ -+ if( lodLength < (S) ) \ -+ tlog1<<"ERROR in " << FF << " " << F << ":" << L << ": reading past the end of LOD mem block by " << \ -+ (S) - lodLength << " bytes, fname " << fname << " size " << lodLength << std::endl; } -+#define CHECK_LOD_MEM_BLOCK_SIZE(S) CHECK_LOD_MEM_BLOCK_SIZE1(S, __FUNCTION__, __FILE__, __LINE__) -+ - CCreatureAnimation::CCreatureAnimation(std::string name) : internalFrame(0), once(false) - { -- FDef = spriteh->giveFile(name, FILE_ANIMATION); //load main file -+ FDef = spriteh->giveFile(name, FILE_ANIMATION, &lodLength); //load main file -+ fname = name; - - //init anim data - int i,j, totalInBlock; - - defName=name; - i = 0; -+ CHECK_LOD_MEM_BLOCK_SIZE(i+0x310); - DEFType = readNormalNr<4>(i,FDef); i+=4; - fullWidth = readNormalNr<4>(i,FDef); i+=4; - fullHeight = readNormalNr<4>(i,FDef); i+=4; -@@ -64,6 +72,7 @@ - totalEntries=0; - for (int z=0; z frameIDs; - int group = readNormalNr<4>(i,FDef); i+=4; //block ID - totalInBlock = readNormalNr<4>(i,FDef); i+=4; -@@ -76,6 +85,7 @@ - /*int unknown2 = readNormalNr<4>(i,FDef);*/ i+=4; //TODO use me - /*int unknown3 = readNormalNr<4>(i,FDef);*/ i+=4; //TODO use me - i+=13*totalInBlock; //ommiting names -+ CHECK_LOD_MEM_BLOCK_SIZE(i+totalInBlock*4); - for (j=0; j(i,FDef); i+=4; -@@ -173,6 +183,7 @@ - unsigned char SegmentType, SegmentLength; - - i = BaseOffset = SEntries[SIndex].offset; -+ CHECK_LOD_MEM_BLOCK_SIZE(i+32); - /*int prSize = readNormalNr<4>(i, FDef);*/ i += 4; //TODO use me - int defType2 = readNormalNr<4>(i, FDef); i += 4; - FullWidth = readNormalNr<4>(i, FDef); i += 4; -@@ -194,11 +205,12 @@ - { - ftcp += FullWidth * TopMargin; - } -- int *RLEntries = (int*)(FDef + BaseOffset); -+ unsigned char *RLEntries = (FDef + BaseOffset); - BaseOffset += sizeof(int) * SpriteHeight; - for (int i = 0; i < SpriteHeight; i++) - { -- BaseOffset = BaseOffsetor + RLEntries[i]; -+ CHECK_LOD_MEM_BLOCK_SIZE(RLEntries+i*4-FDef); -+ BaseOffset = BaseOffsetor + read_unaligned_u32(RLEntries+i*4); - if (LeftMargin > 0) - { - ftcp += LeftMargin; -@@ -213,6 +225,7 @@ - - do - { -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset+2); - SegmentType = FDef[BaseOffset++]; - SegmentLength = FDef[BaseOffset++]; - -@@ -227,6 +240,8 @@ - { - if(!destRect || (destRect->x <= xB && destRect->x + destRect->w > xB && destRect->y <= yB && destRect->y + destRect->h > yB)) - { -+ if(SegmentType == 0xff) -+ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset+k+1); - const ui8 colorNr = SegmentType == 0xff ? FDef[BaseOffset+k] : SegmentType; - putPixel(dest, xB, yB, palette[colorNr], colorNr, yellowBorder, blueBorder, aCountMod); - } -Index: client/GUIBase.h -=================================================================== ---- client/GUIBase.h (revision 2387) -+++ client/GUIBase.h (working copy) -@@ -558,6 +558,8 @@ - CGuiHandler(); - ~CGuiHandler(); - void run(); // holds the main loop for the whole program after initialization and manages the update/rendering system -+ void loopInitFromMainThread(); -+ bool loopFromMainThread(); - - void totalRedraw(); //forces total redraw (using showAll), sets a flag, method gets called at the end of the rendering - void simpleRedraw(); //update only top interface and draw background from buffer, sets a flag, method gets called at the end of the rendering -Index: client/CAnimation.h -=================================================================== ---- client/CAnimation.h (revision 2387) -+++ client/CAnimation.h (working copy) -@@ -47,6 +47,8 @@ - std::map > offset; - - unsigned char * data; -+ int lodLength; -+ std::string fname; - SDL_Color * palette; - - public: -@@ -125,6 +127,8 @@ - * 2nd byte = size of segment - * raw data (if any) - */ -+// Buggy, disabled for Android -+/* - class CompImage : public IImage - { - //x,y - margins, w,h - sprite size -@@ -158,8 +162,8 @@ - - friend class CompImageLoader; - }; -+*/ - -- - /// Class for handling animation - class CAnimation - { -Index: client/CCreatureAnimation.h -=================================================================== ---- client/CCreatureAnimation.h (revision 2387) -+++ client/CCreatureAnimation.h (working copy) -@@ -66,6 +66,8 @@ - int curFrame, internalFrame; //number of currently displayed frame - unsigned int frames; //number of frames - CCreatureAnim::EAnimType type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1]) -+ int lodLength; -+ std::string fname; - - template - int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next -Index: client/CAnimation.cpp -=================================================================== ---- client/CAnimation.cpp (revision 2387) -+++ client/CAnimation.cpp (working copy) -@@ -46,6 +46,8 @@ - ~SDLImageLoader(); - }; - -+// It's buggy, disabled for Android build -+/* - class CompImageLoader - { - CompImage * image; -@@ -69,11 +71,18 @@ - CompImageLoader(CompImage * Img); - ~CompImageLoader(); - }; -- -+*/ - /************************************************************************* - * DefFile, class used for def loading * - *************************************************************************/ - -+ -+#define CHECK_LOD_MEM_BLOCK_SIZE1(S, FF, F, L) { \ -+ if( lodLength < (S) ) \ -+ tlog1<<"ERROR in " << FF << " " << F << ":" << L << ": reading past the end of LOD mem block by " << \ -+ (S) - lodLength << " bytes, fname " << fname << " size " << lodLength << std::endl; } -+#define CHECK_LOD_MEM_BLOCK_SIZE(S) CHECK_LOD_MEM_BLOCK_SIZE1(S, __FUNCTION__, __FILE__, __LINE__) -+ - CDefFile::CDefFile(std::string Name): - data(NULL), - palette(NULL) -@@ -91,15 +100,18 @@ - { 0, 0, 0, 192} // 75% - shadow border below selection - }; - -- data = spriteh->giveFile(Name, FILE_ANIMATION); -+ fname = Name; -+ data = spriteh->giveFile(Name, FILE_ANIMATION, &lodLength); - palette = new SDL_Color[256]; - int it = 0; - -+ CHECK_LOD_MEM_BLOCK_SIZE(it+4); - unsigned int type = readNormalNr(data, it); - it+=4; - //int width = readNormalNr(data, it); it+=4;//not used - //int height = readNormalNr(data, it); it+=4; - it+=8; -+ CHECK_LOD_MEM_BLOCK_SIZE(it+4); - unsigned int totalBlocks = readNormalNr(data, it); - it+=4; - -@@ -117,6 +129,7 @@ - - for (unsigned int i=0; isecond[frame]; - -- const SSpriteDef sd = * reinterpret_cast(FDef); -+ SSpriteDef sd; -+ CHECK_LOD_MEM_BLOCK_SIZE((FDef-data)+sizeof(sd)); -+ memcpy(&sd, FDef, sizeof(sd)); - SSpriteDef sprite; - - //sprite.size = SDL_SwapLE32(sd.size);//unused -@@ -170,6 +186,7 @@ - //pixel data is not compressed, copy data to surface - for (unsigned int i=0; i(FDef+currentOffset); -+ const unsigned char * RWEntriesLoc = FDef+currentOffset; - currentOffset += sizeof(ui32) * sprite.height; - - for (unsigned int i=0; isurf->pixels + image->surf->h*image->surf->pitch >= position + size ) - { - memcpy((void *)position, data, size); - position += size; -@@ -323,7 +357,7 @@ - - inline void SDLImageLoader::Load(size_t size, ui8 color) - { -- if (size) -+ if (size && (ui8 *)image->surf->pixels + image->surf->h*image->surf->pitch >= position + size) - { - memset((void *)position, color, size); - position += size; -@@ -345,6 +379,7 @@ - - //////////////////////////////////////////////////////////////////////////////// - -+/* - CompImageLoader::CompImageLoader(CompImage * Img): - image(Img), - position(NULL), -@@ -518,6 +553,7 @@ - image->surf = newPtr; - } - -+*/ - /************************************************************************* - * Classes for images, support loading from file and drawing on surface * - *************************************************************************/ -@@ -625,6 +661,8 @@ - SDL_FreeSurface(surf); - } - -+// Buggy, disabled for Android -+/* - CompImage::CompImage(const CDefFile *data, size_t frame, size_t group): - surf(NULL), - line(NULL), -@@ -845,6 +883,7 @@ - delete [] line; - delete [] palette; - } -+*/ - - /************************************************************************* - * CAnimation for animations handling, can load part of file if needed * -@@ -889,9 +928,11 @@ - //try to get image from def - if (source[group][frame].getType() == JsonNode::DATA_NULL) - { -+ /* - if (compressed) - images[group][frame] = new CompImage(file, frame, group); - else -+ */ - images[group][frame] = new SDLImage(file, frame, group); - } - else //load from separate file -Index: client/SDL_Extensions.cpp -=================================================================== ---- client/SDL_Extensions.cpp (revision 2387) -+++ client/SDL_Extensions.cpp (working copy) -@@ -119,8 +119,8 @@ - if(incrementPtr == -1) - ptr -= 2; - -- Uint16 * const px = (Uint16*)ptr; -- *px = (B>>3) + ((G>>2) << 5) + ((R>>3) << 11); //drop least significant bits of 24 bpp encoded color -+ Uint16 px = (B>>3) + ((G>>2) << 5) + ((R>>3) << 11); //drop least significant bits of 24 bpp encoded color -+ memcpy(ptr, &px, sizeof(px)); - - if(incrementPtr == 1) - ptr += 2; //bpp -@@ -150,9 +150,9 @@ - const int rmask = 0xF800, gmask = 0x7E0, bmask = 0x1F; - const int rshift = 11, gshift = 5, bshift = 0; - -- const Uint8 r5 = (*((Uint16 *)ptr) & rmask) >> rshift, -- b5 = (*((Uint16 *)ptr) & bmask) >> bshift, -- g5 = (*((Uint16 *)ptr) & gmask) >> gshift; -+ const Uint8 r5 = (read_unaligned_u16(ptr) & rmask) >> rshift, -+ b5 = (read_unaligned_u16(ptr) & bmask) >> bshift, -+ g5 = (read_unaligned_u16(ptr) & gmask) >> gshift; - - const Uint32 r8 = (r5 << (8 - rbit)) | (r5 >> (2*rbit - 8)), - g8 = (g5 << (8 - gbit)) | (g5 >> (2*gbit - 8)), -@@ -649,7 +649,7 @@ - return *p; - - case 2: -- return *(Uint16 *)p; -+ return read_unaligned_u16(p); - - case 3: - /* -@@ -661,7 +661,7 @@ - //#endif - - case 4: -- return *(Uint32 *)p; -+ return read_unaligned_u32(p); - - default: - return 0; // shouldn't happen, but avoids warnings -Index: client/CDefHandler.h -=================================================================== ---- client/CDefHandler.h (revision 2387) -+++ client/CDefHandler.h (working copy) -@@ -30,7 +30,6 @@ - ui32 totalInBlock; - ui32 unknown2; - ui32 unknown3; -- unsigned char data[0]; - }; - - // Def entry in file. Integer fields are all little endian and will -@@ -94,9 +93,9 @@ - - CDefHandler(); //c-tor - ~CDefHandler(); //d-tor -- SDL_Surface * getSprite (int SIndex, const unsigned char * FDef, const BMPPalette * palette) const; //saves picture with given number to "testtt.bmp" -+ SDL_Surface * getSprite (int SIndex, const unsigned char * FDef, const BMPPalette * palette, const std::string & name, int lodLength) const; //saves picture with given number to "testtt.bmp" - static void expand(unsigned char N,unsigned char & BL, unsigned char & BR); -- void openFromMemory(unsigned char * table, const std::string & name); -+ void openFromMemory(unsigned char * table, const std::string & name, int lodLength); - CDefEssential * essentialize(); - - static CDefHandler * giveDef(const std::string & defName); -Index: client/GUIBase.cpp -=================================================================== ---- client/GUIBase.cpp (revision 2387) -+++ client/GUIBase.cpp (working copy) -@@ -11,6 +11,7 @@ - #include "../CThreadHelper.h" - #include "CConfigHandler.h" - #include -+ - - /* - * GUIBase.cpp, part of VCMI engine -@@ -365,6 +366,26 @@ - } - } HANDLE_EXCEPTION - } -+ -+void CGuiHandler::loopInitFromMainThread() -+{ -+ setThreadName(-1, "CGuiHandler::run"); -+ CCS->curh->centerCursor(); -+ mainFPSmng->init(); // resets internal clock, needed for FPS manager -+} -+ -+bool CGuiHandler::loopFromMainThread() -+{ -+ if(terminate) -+ return false; -+ if(curInt) -+ curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment -+ -+ mainFPSmng->framerateDelay(); // holds a constant FPS -+ return true; -+} -+ -+ - - CGuiHandler::CGuiHandler() - :lastClick(-500, -500) -Index: CConsoleHandler.cpp -=================================================================== ---- CConsoleHandler.cpp (revision 2387) -+++ 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() diff --git a/project/jni/application/vcmi/.gitignore b/project/jni/application/vcmi/.gitignore deleted file mode 100644 index 0311e198b..000000000 --- a/project/jni/application/vcmi/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -libvcmi.so -AI -Scripting -debug -out -vcmiserver -vcmiserver.zip -build.log -AndroidData/binaries.zip diff --git a/project/jni/application/vcmi/AndroidAppSettings.cfg b/project/jni/application/vcmi/AndroidAppSettings.cfg deleted file mode 100644 index 41c3b7d6c..000000000 --- a/project/jni/application/vcmi/AndroidAppSettings.cfg +++ /dev/null @@ -1,232 +0,0 @@ -# The application settings for Android libSDL port - -AppSettingVersion=19 - -# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2) -LibSdlVersion=1.2 - -# Specify application name (e.x. My Application) -AppName="VCMI" - -# Specify reversed site name of application (e.x. com.mysite.myapp) -AppFullName=eu.vcmi - -# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape -ScreenOrientation=h - -# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer -InhibitSuspend=n - -# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...' -# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu -# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped -# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir - -# these files are put inside .apk package by build system -# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS -AppDataDownloadUrl="!Data files|vcmi_094.zip" - -# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only -# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32) -VideoDepthBpp=16 - -# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n) -NeedDepthBuffer=n - -# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n) -NeedStencilBuffer=n - -# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device -# you need this option only if you're developing 3-d app (y) or (n) -NeedGles2=n - -# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL, -# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n) -SwVideoMode=y - -# Application video output will be resized to fit into native device screen (y)/(n) -SdlVideoResize=y - -# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n) -SdlVideoResizeKeepAspect=n - -# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread - -# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n) -CompatibilityHacks=y - -# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n) -CompatibilityHacksStaticInit=n - -CompatibilityHacksTextInputEmulatesHwKeyboard=n - -# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n) -CompatibilityHacksPreventAudioChopping=n - -# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n) -CompatibilityHacksAppIgnoresAudioBufferSize=n - -# Hack for VCMI: preload additional shared libraries before aplication start -CompatibilityHacksAdditionalPreloadedSharedLibraries="vcmi" - -# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue - -# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n) -CompatibilityHacksSlowCompatibleEventQueue=n - -# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL -CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState= - -# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects. -# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n) -CompatibilityHacksProperUsageOfSDL_UpdateRects= - -# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user -AppUsesMouse=y - -# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n) -AppNeedsTwoButtonMouse=y - -# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n) -ShowMouseCursor=n - -# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n) -GenerateSubframeTouchEvents= - -# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n) -ForceRelativeMouseMode=n - -# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n) -AppNeedsArrowKeys=n - -# Application needs text input (y) or (n), enables button for text input on screen -AppNeedsTextInput=y - -# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1 -AppUsesJoystick=n - -# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n) -AppUsesSecondJoystick=n - -# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7 -AppUsesAccelerometer=n - -# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4 -AppUsesGyroscope=n - -# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0 -AppUsesMultitouch=n - -# Application records audio (it will use any available source, such a s microphone) -# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void); -# This option will add additional permission to Android manifest (y)/(n) -AppRecordsAudio=n - -# Application implements Android-specific routines to put to background, and will not draw anything to screen -# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them -# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n) -# This option is reported to be buggy, sometimes failing to restore video state -NonBlockingSwapBuffers=n - -# Redefine common hardware keys to SDL keysyms -# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent -# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices -# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th) -# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA -RedefinedKeys="LALT RETURN NO_REMAP NO_REMAP E" - -# Number of virtual keyboard keys (currently 6 is maximum) -AppTouchscreenKeyboardKeysAmount=0 - -# Number of virtual keyboard keys that support autofire (currently 2 is maximum) -AppTouchscreenKeyboardKeysAmountAutoFire=0 - -# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right) -RedefinedKeysScreenKb="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2" - -# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu -RedefinedKeysScreenKbNames="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2" - -# On-screen keys theme -# 0 = Ultimate Droid by Sean Stieber (green, with gamepad joystick) -# 1 = Simple Theme by Beholder (white, with gamepad joystick) -# 2 = Sun by Sirea (yellow, with round joystick) -# 3 = Keen by Gerstrong (multicolor, with round joystick) -TouchscreenKeysTheme=1 - -# Redefine gamepad keys to SDL keysyms, button order is: -# A B X Y L1 R1 L2 R2 LThumb RThumb -RedefinedKeysGamepad="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2" - -# How long to show startup menu button, in msec, 0 to disable startup menu -StartupMenuButtonTimeout=3000 - -# Menu items to hide from startup menu, available menu items: -# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout -HiddenMenuOptions='SettingsMenuMisc.OptionalDownloadConfig' - -# Menu items to show at startup - this is Java code snippet, leave empty for default -# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration() -# Available menu items: -# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout -FirstStartMenuOptions='' - -# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices, -# but .apk size is 2x bigger (y) / (n) / (x86) / (all) -MultiABI=armeabi-v7a - -# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower -AppMinimumRAM=128 - -# Application version code (integer) -AppVersionCode=09301 - -# Application user-visible version name (string) -AppVersionName="0.93.01" - -# Reset SDL config when updating application to the new version (y) / (n) -ResetSdlConfigForThisVersion=n - -# Delete application data files when upgrading (specify file/dir paths separated by spaces) -DeleteFilesOnUpgrade="%" - -# Optional shared libraries to compile - removing some of them will save space -# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed -# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2 -CompiledLibraries="mad sdl_mixer sdl_image sdl_ttf avutil avcodec avformat swscale shmem boost_program_options boost_filesystem boost_iostreams boost_system boost_thread android" - -# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n) -CustomBuildScript=y - -# Aditional CFLAGS for application -AppCflags='' - -# Additional LDFLAGS for application -AppLdflags='' - -# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable -AppOverlapsSystemHeaders= - -# Build only following subdirs (empty will build all dirs, ignored with custom script) -AppSubdirsBuild='' - -# Exclude these files from build -AppBuildExclude='' - -# Application command line parameters, including app name as 0-th param -AppCmdline='' - -# Here you may type readme text, which will be shown during startup. Format is: -# Text in English, use \\\\\\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?) -ReadmeText='^You may press "Home" now - the data will be downloaded in background' - -# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens -# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge -MinimumScreenSize=m - -# Your AdMob Publisher ID, (n) if you don't want advertisements -AdmobPublisherId=n - -# Your AdMob test device ID, to receive a test ad -AdmobTestDeviceId= - -# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER) -AdmobBannerSize= - diff --git a/project/jni/application/vcmi/AndroidBuild.sh b/project/jni/application/vcmi/AndroidBuild.sh deleted file mode 100755 index ec927301a..000000000 --- a/project/jni/application/vcmi/AndroidBuild.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# With default -O3 optimization each G++ process eats 2Gb RAM, so tone optimization down to -O2, and limit make to two jobs -{ make -j4 2>&1 || exit 1 ; } | tee build.log -[ -f libapplication.so ] || exit 1 -mv -f libapplication.so libapplication-armeabi-v7a.so -exit 0 diff --git a/project/jni/application/vcmi/AndroidPreBuild.sh b/project/jni/application/vcmi/AndroidPreBuild.sh deleted file mode 100755 index cce70fac8..000000000 --- a/project/jni/application/vcmi/AndroidPreBuild.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# Download and patch sources -if [ -e vcmi ]; then - exit 0 -else - svn co http://svn.code.sf.net/p/vcmi/code/trunk/ vcmi && patch -p0 -d vcmi < vcmi-android.diff || exit 1 -fi diff --git a/project/jni/application/vcmi/Makefile b/project/jni/application/vcmi/Makefile deleted file mode 100644 index f87499a2d..000000000 --- a/project/jni/application/vcmi/Makefile +++ /dev/null @@ -1,136 +0,0 @@ - -$(shell mkdir -p AI debug/AI \ - out/vcmi/lib out/vcmi/lib/logging out/vcmi/lib/filesystem \ - out/vcmi/lib/mapping out/vcmi/lib/rmg out/vcmi/lib/minizip \ - out/vcmi/server out/vcmi/AI/StupidAI out/vcmi/AI/BattleAI \ - out/vcmi/AI/VCAI out/vcmi/AI/FuzzyLite \ - out/vcmi/scripting/erm out/vcmi/client \ - out/vcmi/client/gui out/vcmi/client/battle) - -LOCAL_PATH=$(shell dirname $0) -LOCAL_PATH=`cd $LOCAL_PATH && pwd` - -GCC_PREFIX=arm-linux-androideabi -GCC_VERSION=4.8 - -SOURCES_LIB=$(wildcard vcmi/lib/*.cpp) -OBJS_LIB=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB)) - -SOURCES_MINIZIP=vcmi/lib/minizip/zip.c vcmi/lib/minizip/unzip.c vcmi/lib/minizip/ioapi.c -OBJS_MINIZIP=$(patsubst %.c, out/%.o, $(SOURCES_MINIZIP)) - -SOURCES_LIB_FILESYSTEM:=$(wildcard vcmi/lib/filesystem/*.cpp) -OBJS_LIB_FILESYSTEM:=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB_FILESYSTEM)) - -SOURCES_LIB_LOGGING:=$(wildcard vcmi/lib/logging/*.cpp) -OBJS_LIB_LOGGING:=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB_LOGGING)) - -SOURCES_LIB_MAPPING:=$(wildcard vcmi/lib/mapping/*.cpp) -OBJS_LIB_MAPPING:=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB_MAPPING)) - -SOURCES_LIB_RMG:=$(wildcard vcmi/lib/rmg/*.cpp) -OBJS_LIB_RMG:=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB_RMG)) - -OBJS_LIB_ALL:= $(OBJS_MINIZIP) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_LOGGING) $(OBJS_LIB_MAPPING) $(OBJS_LIB_RMG) $(OBJS_LIB) - -SOURCES_SERVER:=$(wildcard vcmi/server/*.cpp) -OBJS_SERVER:=$(patsubst %.cpp, out/%.o, $(SOURCES_SERVER)) - -SOURCES_CLIENT:=$(wildcard vcmi/client/*.cpp vcmi/client/gui/*.cpp vcmi/client/battle/*.cpp vcmi/*.cpp) -OBJS_CLIENT:=$(patsubst %.cpp, out/%.o, $(SOURCES_CLIENT)) - -SOURCES_BATTLEAI:=$(wildcard vcmi/AI/BattleAI/*.cpp) -OBJS_BATTLEAI:=$(patsubst %.cpp, out/%.o, $(SOURCES_BATTLEAI)) - -SOURCES_STUPIDAI:=$(wildcard vcmi/AI/StupidAI/*.cpp) -OBJS_STUPIDAI:=$(patsubst %.cpp, out/%.o, $(SOURCES_STUPIDAI)) - -SOURCES_VCAI:=$(wildcard vcmi/AI/VCAI/*.cpp) -OBJS_VCAI:=$(patsubst %.cpp, out/%.o, $(SOURCES_VCAI)) - -SOURCES_FUZZYLITE:=$(wildcard vcmi/AI/FuzzyLite/*.cpp) -OBJS_FUZZYLITE:=$(patsubst %.cpp, out/%.o, $(SOURCES_FUZZYLITE)) - -SOURCES_ERM:=$(wildcard vcmi/scripting/erm/*.cpp) -OBJS_ERM:=$(patsubst %.cpp, out/%.o, $(SOURCES_ERM)) - -all: AndroidData/binaries.zip libapplication.so - -AndroidData/binaries.zip: libvcmi.so vcmiserver AI/libBattleAI.so AI/libStupidAI.so AI/libVCAI.so libicuuc.a libicudata.a # Scripting/libvcmiERM.so AI/libEmptyAI.so - rm -f $@ - zip -r $@ $^ - -# With default -O3 optimization each G++ process eats 2Gb RAM, so tone optimization down to -O2, and limit make to two jobs -$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_LOGGING) $(OBJS_LIB_MAPPING) $(OBJS_LIB_RMG) \ - $(OBJS_BATTLEAI) $(OBJS_STUPIDAI) $(OBJS_FUZZYLITE) $(OBJS_VCAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp - env GCCVER=$(GCC_VERSION) ../setEnvironment-armeabi-v7a.sh sh -c \ - "$(GCC_PREFIX)-g++ \ - -c \$$CXXFLAGS -O1 -Ivcmi -I../../shmem -std=c++0x -Ivcmi/lib \ - -DM_DATA_DIR=\\\".\\\" \ - -DM_BIN_DIR=\\\"/data/data/eu.vcmi/files\\\" \ - -DM_LIB_DIR=\\\"/data/data/eu.vcmi/files\\\" \ - -Wstrict-aliasing -Wcast-align -Wpointer-arith -Waddress \ - -D__SOURCE_FILE__=\\\"$<\\\" \ - $< -o $@" -# -Werror=strict-aliasing -Werror=cast-align -Werror=pointer-arith -Werror=address - -$(OBJS_MINIZIP): out/%.o: %.c - env GCCVER=$(GCC_VERSION) ../setEnvironment-armeabi-v7a.sh sh -c \ - "$(GCC_PREFIX)-gcc \ - -c \$$CFLAGS -O2 -DDLL_EXPORT= -DIOAPI_NO_64 \ - -Wstrict-aliasing -Wcast-align -Wpointer-arith -Waddress \ - $< -o $@" - -LINK_BOOST_LIBS:=-L../../boost/lib/arm-linux-androideabi-4.6 \ - -lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread -lboost_program_options -lboost_locale -lgnustl_static -lshmem - -LINK_ICU:=-L../../libiconv-libicu/armeabi-v7a \ - -licuuc -licudata - -LINK_LIB= \ - env BUILD_EXECUTABLE=1 NO_SHARED_LIBS=1 GCCVER=$(GCC_VERSION) ../setEnvironment-armeabi-v7a.sh sh -c \ - "$(GCC_PREFIX)-g++ \ - $^ -o $@ \ - -shared \$$LDFLAGS -L. $(LINK_BOOST_LIBS) $(LINK_ICU) " && \ - cp $@ debug/$@ && \ - $(GCC_PREFIX)-strip $@ - -.PHONY: -lvcmi --lvcmi: libvcmi.so - -AI/libBattleAI.so: $(OBJS_BATTLEAI) -lvcmi - $(LINK_LIB) - -AI/libEmptyAI.so: $(OBJS_EMPTYAI) -lvcmi - $(LINK_LIB) - -AI/libStupidAI.so: $(OBJS_STUPIDAI) -lvcmi - $(LINK_LIB) - -AI/libVCAI.so: $(OBJS_VCAI) $(OBJS_FUZZYLITE) -lvcmi - $(LINK_LIB) - -Scripting/libvcmiERM.so: $(OBJS_ERM) -lvcmi - $(LINK_LIB) - -libvcmi.so: $(OBJS_LIB_ALL) - $(LINK_LIB) - -libapplication.so: $(OBJS_CLIENT) -lvcmi - env GCCVER=$(GCC_VERSION) ../setEnvironment-armeabi-v7a.sh sh -c \ - "$(GCC_PREFIX)-g++ $^ -o $@ \ - \$$LDFLAGS -L. $(LINK_BOOST_LIBS)" - -vcmiserver: $(OBJS_SERVER) -lvcmi - env BUILD_EXECUTABLE=1 NO_SHARED_LIBS=1 GCCVER=$(GCC_VERSION) ../setEnvironment-armeabi-v7a.sh sh -c \ - "$(GCC_PREFIX)-g++ \ - $^ -o $@ \ - \$$LDFLAGS -L. $(LINK_BOOST_LIBS)" && \ - cp $@ debug/$@ && \ - $(GCC_PREFIX)-strip $@ - -clean: - rm -rf out debug *.so vcmiserver* AndroidData/vcmiserver* libapplication.so AI Scripting - -.PHONY: clean - diff --git a/project/jni/application/vcmi/icon.png b/project/jni/application/vcmi/icon.png deleted file mode 100644 index 4f236d1ae..000000000 Binary files a/project/jni/application/vcmi/icon.png and /dev/null differ diff --git a/project/jni/application/vcmi/readme.txt b/project/jni/application/vcmi/readme.txt index 373bfcc84..d76daa92f 100644 --- a/project/jni/application/vcmi/readme.txt +++ b/project/jni/application/vcmi/readme.txt @@ -1,13 +1,5 @@ -Quick compilation guide: -Download my GIT repo from https://github.com/pelya/commandergenius, -then install Android SDK and NDK r9 from http://developer.android.com, -ANT, patch and Subversion tools, then launch commands - android update project -p project - rm project/jni/application/src - ln -s vcmi project/jni/application/src - mkdir -p project/obj/local/armeabi-v7a/ - cp -f project/jni/boost/lib/arm-linux-androideabi-4.6/* project/obj/local/armeabi-v7a/ -then launch build.sh. +VCMI sources are moved here: -To run it you should have complete installation of Heroes 3: Wake of Gods -on your SD card, in the directory Android/data/eu.vcmi/files +https://github.com/xyzz/vcmi + +https://github.com/xyzz/vcmi-build diff --git a/project/jni/application/vcmi/vcmi-android-WIP-crap-shit.diff b/project/jni/application/vcmi/vcmi-android-WIP-crap-shit.diff deleted file mode 100644 index 59ed7978e..000000000 --- a/project/jni/application/vcmi/vcmi-android-WIP-crap-shit.diff +++ /dev/null @@ -1,1051 +0,0 @@ -Index: lib/CGeneralTextHandler.h -=================================================================== ---- lib/CGeneralTextHandler.h (revision 3494) -+++ lib/CGeneralTextHandler.h (working copy) -@@ -15,7 +15,7 @@ - /// Parser for any text files from H3 - class CLegacyConfigParser - { -- std::unique_ptr data; -+ std::vector data; - char * curr; - char * end; - -Index: lib/IGameCallback.cpp -=================================================================== ---- lib/IGameCallback.cpp (revision 3494) -+++ lib/IGameCallback.cpp (working copy) -@@ -661,7 +661,7 @@ - - const CMapHeader * CGameInfoCallback::getMapHeader() const - { -- return gs->map; -+ return gs->map.get(); - } - - bool CGameInfoCallback::hasAccess(boost::optional playerId) const -Index: lib/Connection.cpp -=================================================================== ---- lib/Connection.cpp (revision 3494) -+++ lib/Connection.cpp (working copy) -@@ -526,10 +526,10 @@ - return ret; - } - --unique_ptr CLoadIntegrityValidator::decay() -+std::unique_ptr CLoadIntegrityValidator::decay() - { - primaryFile->loadedPointers = this->loadedPointers; -- return std::move(primaryFile); -+ return /*std::move*/(primaryFile); - } - - void CLoadIntegrityValidator::checkMagicBytes( const std::string &text ) -Index: lib/CDefObjInfoHandler.cpp -=================================================================== ---- lib/CDefObjInfoHandler.cpp (revision 3494) -+++ lib/CDefObjInfoHandler.cpp (working copy) -@@ -37,12 +37,12 @@ - - auto msk = CResourceHandler::get()->load(ResourceID(std::string("SPRITES/") + name, EResType::MASK))->readAll(); - -- width = msk.first.get()[0]; -- height = msk.first.get()[1]; -+ width = msk[0]; -+ height = msk[1]; - for(int i=0; i<6; ++i) - { -- coverageMap[i] = msk.first.get()[i+2]; -- shadowCoverage[i] = msk.first.get()[i+8]; -+ coverageMap[i] = msk[i+2]; -+ shadowCoverage[i] = msk[i+8]; - } - } - -@@ -51,7 +51,7 @@ - VLC->dobjinfo = this; - - auto textFile = CResourceHandler::get()->load(ResourceID("DATA/OBJECTS.TXT"))->readAll(); -- std::istringstream inp(std::string((char*)textFile.first.get(), textFile.second)); -+ std::istringstream inp(std::string((char*)textFile.data(), textFile.size())); - int objNumber; - inp>>objNumber; - std::string mapStr; -Index: lib/JsonNode.cpp -=================================================================== ---- lib/JsonNode.cpp (revision 3494) -+++ lib/JsonNode.cpp (working copy) -@@ -43,7 +43,7 @@ - { - auto file = CResourceHandler::get()->load(fileURI)->readAll(); - -- JsonParser parser(reinterpret_cast(file.first.get()), file.second); -+ JsonParser parser((const char *)file.data(), file.size()); - *this = parser.parse(fileURI.getName()); - } - -@@ -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; -@@ -1615,10 +1615,10 @@ - { - // FIXME: some way to make this code more readable - auto stream = loader->load(resID); -- std::unique_ptr textData(new ui8[stream->getSize()]); -- stream->read(textData.get(), stream->getSize()); -+ std::vector textData(stream->getSize()); -+ stream->read(textData.data(), stream->getSize()); - -- JsonNode section((char*)textData.get(), stream->getSize()); -+ JsonNode section((char*)textData.data(), stream->getSize()); - merge(result, section); - } - return result; -Index: lib/CGameState.h -=================================================================== ---- lib/CGameState.h (revision 3494) -+++ lib/CGameState.h (working copy) -@@ -363,7 +363,7 @@ - PlayerColor currentPlayer; //ID of player currently having turn - ConstTransitivePtr curB; //current battle - ui32 day; //total number of days in game -- ConstTransitivePtr map; -+ shared_ptr map; - bmap players; - bmap teams; - CBonusSystemNode globalEffects; -Index: lib/mapping/CMapInfo.cpp -=================================================================== ---- lib/mapping/CMapInfo.cpp (revision 3494) -+++ lib/mapping/CMapInfo.cpp (working copy) -@@ -35,9 +35,9 @@ - - } - --#define STEAL(x) x = std::move(tmp.x) -+#define STEAL(x) x = /*std::move*/(tmp.x) - --CMapInfo::CMapInfo(CMapInfo && tmp) -+CMapInfo::CMapInfo(const CMapInfo & tmp) - { - STEAL(mapHeader); - STEAL(campaignHeader); -@@ -54,16 +54,16 @@ - void CMapInfo::mapInit(const std::string & fname) - { - fileURI = fname; -- mapHeader = CMapService::loadMapHeader(fname); -+ mapHeader = std::make_shared(*CMapService::loadMapHeader(fname)); - countPlayers(); - } - - void CMapInfo::campaignInit() - { -- campaignHeader = std::unique_ptr(new CCampaignHeader(CCampaignHandler::getHeader(fileURI))); -+ campaignHeader = std::make_shared(CCampaignHandler::getHeader(fileURI)); - } - --CMapInfo & CMapInfo::operator=(CMapInfo &&tmp) -+CMapInfo & CMapInfo::operator=(const CMapInfo &tmp) - { - STEAL(mapHeader); - STEAL(campaignHeader); -Index: lib/mapping/MapFormatH3M.cpp -=================================================================== ---- lib/mapping/MapFormatH3M.cpp (revision 3494) -+++ lib/mapping/MapFormatH3M.cpp (working copy) -@@ -44,7 +44,7 @@ - mapHeader = std::unique_ptr(dynamic_cast(map)); - init(); - -- return std::unique_ptr(dynamic_cast(mapHeader.release()));; -+ return std::unique_ptr(dynamic_cast(mapHeader.get())); - } - - std::unique_ptr CMapLoaderH3M::loadMapHeader() -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 mapHeader; //may be nullptr if campaign -- unique_ptr campaignHeader; //may be nullptr if scenario -+ shared_ptr mapHeader; //may be nullptr if campaign -+ shared_ptr 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; -@@ -31,9 +31,9 @@ - bool isRandomMap; // true if the map will be created randomly, false if not - - CMapInfo(); -- CMapInfo(CMapInfo && tmp); -+ CMapInfo(const CMapInfo & tmp); - -- CMapInfo &operator=(CMapInfo &&other); -+ CMapInfo &operator=(const CMapInfo &other); - - void mapInit(const std::string & fname); - void campaignInit(); -Index: lib/CGameState.cpp -=================================================================== ---- lib/CGameState.cpp (revision 3494) -+++ lib/CGameState.cpp (working copy) -@@ -757,7 +757,7 @@ - CGameState::~CGameState() - { - //delete mx;//TODO: crash on Linux (mutex must be unlocked before destruction) -- map.dellNull(); -+ map.reset(); - curB.dellNull(); - //delete scenarioOps; //TODO: fix for loading ind delete - //delete initialOpts; -@@ -868,7 +868,7 @@ - - // Gen map - CMapGenerator mapGen(*(scenarioOps->mapGenOptions), scenarioOps->seedToBeUsed); -- map = mapGen.generate().release(); -+ map = mapGen.generate(); - - // Update starting options - for(int i = 0; i < map->players.size(); ++i) -@@ -897,7 +897,7 @@ - else - { - logGlobal->infoStream() << "Open map file: " << scenarioOps->mapname; -- map = CMapService::loadMap(scenarioOps->mapname).release(); -+ map = CMapService::loadMap(scenarioOps->mapname); - } - } - break; -@@ -909,7 +909,7 @@ - - std::string & mapContent = campaign->camp->mapPieces[scenarioOps->campState->currentMap]; - auto buffer = reinterpret_cast(mapContent.data()); -- map = CMapService::loadMap(buffer, mapContent.size()).release(); -+ map = CMapService::loadMap(buffer, mapContent.size()); - } - break; - case StartInfo::DUEL: -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/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/Connection.h -=================================================================== ---- lib/Connection.h (revision 3494) -+++ lib/Connection.h (working copy) -@@ -709,12 +709,14 @@ - T *internalPtr = data.get(); - *this << internalPtr; - } -+ /* - template - void saveSerializable(const unique_ptr &data) - { - T *internalPtr = data.get(); - *this << internalPtr; - } -+ */ - template - void saveSerializable(const std::vector &data) - { -@@ -1098,6 +1100,7 @@ - else - data.reset(); - } -+ /* - template - void loadSerializable(unique_ptr &data) - { -@@ -1105,6 +1108,7 @@ - *this >> internalPtr; - data.reset(internalPtr); - } -+ */ - template - void loadSerializable(std::vector &data) - { -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 )); }; -Index: lib/CGeneralTextHandler.cpp -=================================================================== ---- lib/CGeneralTextHandler.cpp (revision 3494) -+++ lib/CGeneralTextHandler.cpp (working copy) -@@ -40,10 +40,10 @@ - - void CLegacyConfigParser::init(const std::unique_ptr & input) - { -- data.reset(new char[input->getSize()]); -- input->read((ui8*)data.get(), input->getSize()); -+ data.resize(input->getSize()); -+ input->read((ui8*)data.data(), input->getSize()); - -- curr = data.get(); -+ curr = data.data(); - end = curr + input->getSize(); - } - -Index: lib/filesystem/CInputStream.h -=================================================================== ---- lib/filesystem/CInputStream.h (revision 3494) -+++ lib/filesystem/CInputStream.h (working copy) -@@ -65,13 +65,13 @@ - * - * @return pair, first = raw data, second = size of data - */ -- std::pair, size_t> readAll() -+ std::vector readAll() - { -- std::unique_ptr data(new ui8[getSize()]); -+ std::vector data(getSize()); - -- size_t readSize = read(data.get(), getSize()); -+ size_t readSize = read(data.data(), getSize()); - assert(readSize == getSize()); - -- return std::make_pair(std::move(data), getSize()); -+ return data; - } - }; -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("/."); - -@@ -227,7 +227,7 @@ - if (filename) - { - auto configData = initialLoader->load(ResourceID(URI, EResType::TEXT))->readAll(); -- const JsonNode config((char*)configData.first.get(), configData.second); -+ const JsonNode config((char*)configData.data(), configData.size()); - resourceLoader->addLoader(new CMappedFileLoader(mountPoint, config), false); - } - } -@@ -236,7 +236,7 @@ - { - auto fsConfigData = initialLoader->load(ResourceID(fsConfigURI, EResType::TEXT))->readAll(); - -- const JsonNode fsConfig((char*)fsConfigData.first.get(), fsConfigData.second); -+ const JsonNode fsConfig((char*)fsConfigData.data(), fsConfigData.size()); - - loadModFileSystem("", fsConfig["filesystem"]); - -@@ -320,7 +320,7 @@ - { - ResourceID modConfFile("mods/" + modName + "/mod", EResType::TEXT); - auto fsConfigData = initialLoader->load(modConfFile)->readAll(); -- const JsonNode fsConfig((char*)fsConfigData.first.get(), fsConfigData.second); -+ const JsonNode fsConfig((char*)fsConfigData.data(), fsConfigData.size()); - - if (!fsConfig["filesystem"].isNull()) - loadModFileSystem("mods/" + modName, fsConfig["filesystem"]); -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: client/CAnimation.cpp -=================================================================== ---- client/CAnimation.cpp (revision 3494) -+++ client/CAnimation.cpp (working copy) -@@ -109,8 +109,9 @@ - - auto data = CResourceHandler::get()->load(rid)->readAll(); - cache.back().name = ResourceID(rid); -- cache.back().size = data.second; -- cache.back().data = data.first.release(); -+ cache.back().size = data.size(); -+ cache.back().data = new ui8[data.size()]; -+ memcpy(cache.back().data, data.data(), data.size()); - - return cache.back().getCopy(); - } -@@ -1037,7 +1038,7 @@ - for(auto & loader : configList) - { - auto stream = loader->load(resID); -- std::unique_ptr textData(new ui8[stream->getSize()]); -+ std::unique_ptr textData(new ui8[stream->getSize()]); - stream->read(textData.get(), stream->getSize()); - - const JsonNode config((char*)textData.get(), stream->getSize()); -Index: client/CPreGame.h -=================================================================== ---- client/CPreGame.h (revision 3494) -+++ client/CPreGame.h (working copy) -@@ -307,7 +307,7 @@ - * compOnlyTeamsCntGroup, * waterContentGroup, * monsterStrengthGroup; - CAdventureMapButton * showRandMaps; - CMapGenOptions mapGenOptions; -- unique_ptr mapInfo; -+ shared_ptr mapInfo; - CFunctionList mapInfoChanged; - }; - -@@ -495,7 +495,7 @@ - - void loadPositionsOfGraphics(); - shared_ptr ourCampaign; -- CMapHeader *ourHeader; -+ std::shared_ptr ourHeader; - CDefHandler *sizes; //icons of map sizes - SDL_Surface* diffPics[5]; //pictures of difficulties, user-selectable (or not if campaign locks this) - CAdventureMapButton * diffLb, * diffRb; //buttons for changing difficulty -Index: client/Graphics.cpp -=================================================================== ---- client/Graphics.cpp (revision 3494) -+++ client/Graphics.cpp (working copy) -@@ -48,7 +48,7 @@ - void Graphics::loadPaletteAndColors() - { - auto textFile = CResourceHandler::get()->load(ResourceID("DATA/PLAYERS.PAL"))->readAll(); -- std::string pals((char*)textFile.first.get(), textFile.second); -+ std::string pals((char*)textFile.data(), textFile.size()); - - playerColorPalette = new SDL_Color[256]; - neutralColor = new SDL_Color; -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: "<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): "<infoStream()<<"Initialization of VCMI (together): "<load(filename)->readAll(); - -- file.write((char*)text.first.get(), text.second); -+ file.write((char*)text.data(), text.size()); - } - - std::cout << "\rExtracting done :)\n"; -@@ -689,7 +708,7 @@ - - boost::filesystem::create_directories(fullPath.substr(0, fullPath.find_last_of("/"))); - std::ofstream outFile(outPath + outName); -- outFile.write((char*)data.first.get(), data.second); -+ outFile.write((char*)data.data(), data.size()); - } - else - logGlobal->errorStream() << "File not found!"; -Index: client/CDefHandler.cpp -=================================================================== ---- client/CDefHandler.cpp (revision 3494) -+++ client/CDefHandler.cpp (working copy) -@@ -364,11 +364,11 @@ - { - ResourceID resID(std::string("SPRITES/") + defName, EResType::ANIMATION); - -- auto data = CResourceHandler::get()->load(resID)->readAll().first; -- if(!data) -+ auto data = CResourceHandler::get()->load(resID)->readAll(); -+ if(!data.size()) - throw std::runtime_error("bad def name!"); - auto nh = new CDefHandler(); -- nh->openFromMemory(data.get(), defName); -+ nh->openFromMemory(data.data(), defName); - return nh; - } - CDefEssential * CDefHandler::giveDefEss(const std::string & defName) -Index: client/CBitmapHandler.cpp -=================================================================== ---- client/CBitmapHandler.cpp (revision 3494) -+++ client/CBitmapHandler.cpp (working copy) -@@ -114,9 +114,9 @@ - - auto readFile = CResourceHandler::get()->load(ResourceID(path + fname, EResType::IMAGE))->readAll(); - -- if (isPCX(readFile.first.get())) -+ if (isPCX(readFile.data())) - {//H3-style PCX -- ret = loadH3PCX(readFile.first.get(), readFile.second); -+ ret = loadH3PCX(readFile.data(), readFile.size()); - if (ret) - { - if(ret->format->BytesPerPixel == 1 && setKey) -@@ -132,7 +132,7 @@ - { //loading via SDL_Image - ret = IMG_Load_RW( - //create SDL_RW with our data (will be deleted by SDL) -- SDL_RWFromConstMem((void*)readFile.first.get(), readFile.second), -+ SDL_RWFromConstMem((void*)readFile.data(), readFile.size()), - 1); // mark it for auto-deleting - if (ret) - { -Index: client/CPreGame.cpp -=================================================================== ---- client/CPreGame.cpp (revision 3494) -+++ client/CPreGame.cpp (working copy) -@@ -404,7 +404,7 @@ - pos.w = CGP->menu->pos.w; - pos.h = CGP->menu->pos.h; - auto textFile = CResourceHandler::get()->load(ResourceID("DATA/CREDITS.TXT"))->readAll(); -- std::string text((char*)textFile.first.get(), textFile.second); -+ std::string text((char*)textFile.data(), textFile.size()); - size_t firstQuote = text.find('\"')+1; - text = text.substr(firstQuote, text.find('\"', firstQuote) - firstQuote ); - credits = new CTextBox(text, Rect(pos.w - 350, 600, 350, 32000), 0, FONT_CREDITS, CENTER, Colors::WHITE); -@@ -1105,9 +1105,11 @@ - - void SelectionTab::parseMaps(const std::unordered_set &files) - { -+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "%s:%s:%d", __FUNCTION__, __FILE__, __LINE__); - allItems.clear(); - for(auto & file : files) - { -+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "checking file %s", file.getName().c_str()); - try - { - CMapInfo mapInfo; -@@ -1115,13 +1117,15 @@ - - // ignore unsupported map versions (e.g. WoG maps without WoG - if (mapInfo.mapHeader->version <= CGI->modh->settings.data["textData"]["mapVersion"].Float()) -- allItems.push_back(std::move(mapInfo)); -+ allItems.push_back(/*std::move*/(mapInfo)); - } - catch(std::exception & e) - { -+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Error loading file %s", file.getName().c_str()); - logGlobal->errorStream() << "Map " << file.getName() << " is invalid. Message: " << e.what(); - } - } -+ __android_log_print(ANDROID_LOG_DEBUG, "VCMI", "%s:%s:%d", __FUNCTION__, __FILE__, __LINE__); - } - - void SelectionTab::parseGames(const std::unordered_set &files, bool multi) -@@ -1141,7 +1145,7 @@ - - // Create the map info object - CMapInfo mapInfo; -- mapInfo.mapHeader = make_unique(); -+ mapInfo.mapHeader = std::make_shared(CMapHeader()); - mapInfo.scenarioOpts = new StartInfo; - lf >> *(mapInfo.mapHeader.get()) >> mapInfo.scenarioOpts; - mapInfo.fileURI = file.getName(); -@@ -1834,9 +1838,9 @@ - void CRandomMapTab::updateMapInfo() - { - // Generate header info -- mapInfo = make_unique(); -+ mapInfo = make_shared(); - mapInfo->isRandomMap = true; -- mapInfo->mapHeader = make_unique(); -+ mapInfo->mapHeader = std::make_shared(CMapHeader()); - mapInfo->mapHeader->version = EMapFormat::SOD; - mapInfo->mapHeader->name = CGI->generaltexth->allTexts[740]; - mapInfo->mapHeader->description = CGI->generaltexth->allTexts[741]; -@@ -3256,7 +3260,7 @@ - { - SDL_FreeSurface(background); - delete sizes; -- delete ourHeader; -+ ourHeader.reset(); - delete sFlags; - for (auto & elem : diffPics) - { -@@ -3320,14 +3324,14 @@ - ourCampaign->currentMap = whichOne; - - //get header -- delete ourHeader; -+ //delete ourHeader; - std::string & headerStr = ourCampaign->camp->mapPieces.find(whichOne)->second; - auto buffer = reinterpret_cast(headerStr.data()); -- ourHeader = CMapService::loadMapHeader(buffer, headerStr.size()).release(); -+ ourHeader = CMapService::loadMapHeader(buffer, headerStr.size()); - - std::map names; - names[1] = settings["general"]["playerName"].String(); -- updateStartInfo(ourCampaign->camp->header.filename, sInfo, ourHeader, names); -+ updateStartInfo(ourCampaign->camp->header.filename, sInfo, ourHeader.get(), names); - sInfo.turnTime = 0; - sInfo.difficulty = ourCampaign->camp->scenarios[whichOne].difficulty; - -Index: client/Client.cpp -=================================================================== ---- client/Client.cpp (revision 3494) -+++ client/Client.cpp (working copy) -@@ -252,7 +252,7 @@ - } - logNetwork->infoStream() << "Loaded common part of save " << tmh.getDiff(); - const_cast(CGI)->mh = new CMapHandler(); -- const_cast(CGI)->mh->map = gs->map; -+ const_cast(CGI)->mh->map = gs->map.get(); - pathInfo = make_unique(getMapSize()); - CGI->mh->init(); - logNetwork->infoStream() <<"Initing maphandler: "<map) - { - const_cast(CGI)->mh = new CMapHandler(); -- CGI->mh->map = gs->map; -+ CGI->mh->map = gs->map.get(); - logNetwork->infoStream() <<"Creating mapHandler: "<mh->init(); - pathInfo = make_unique(getMapSize()); -Index: client/CVideoHandler.cpp -=================================================================== ---- client/CVideoHandler.cpp (revision 3494) -+++ client/CVideoHandler.cpp (working copy) -@@ -415,7 +415,7 @@ - auto data = CResourceHandler::get()->load(videoID)->readAll(); - - // try to determine video format using magic number from header (3 bytes, SMK or BIK) -- std::string magic(reinterpret_cast(data.first.get()), 3); -+ std::string magic(reinterpret_cast(data.data()), 3); - if (magic == "BIK") - current = &bikPlayer; - else if (magic == "SMK") -Index: client/CMusicHandler.cpp -=================================================================== ---- client/CMusicHandler.cpp (revision 3494) -+++ client/CMusicHandler.cpp (working copy) -@@ -141,7 +141,9 @@ - { - auto data = CResourceHandler::get()->load(ResourceID(std::string("SOUNDS/") + fname, EResType::SOUND))->readAll(); - -- SDL_RWops *ops = SDL_RWFromMem(data.first.release(), data.second); -+ char *buf = new char[data.size()]; // Never release it -+ memcpy(buf, data.data(), data.size()); -+ SDL_RWops *ops = SDL_RWFromMem(buf, data.size()); - Mix_Chunk *chunk; - chunk = Mix_LoadWAV_RW(ops, 1); // will free ops - soundChunks.insert(std::pair(soundID, chunk)); -@@ -164,7 +166,9 @@ - { - auto data = CResourceHandler::get()->load(ResourceID(std::string("SOUNDS/") + sound, EResType::SOUND))->readAll(); - -- SDL_RWops *ops = SDL_RWFromMem(data.first.release(), data.second); -+ char *buf = new char[data.size()]; // Never release it -+ memcpy(buf, data.data(), data.size()); -+ SDL_RWops *ops = SDL_RWFromMem(buf, data.size()); - Mix_Chunk *chunk; - chunk = Mix_LoadWAV_RW(ops, 1); // will free ops - return chunk; -@@ -400,11 +404,11 @@ - - boost::mutex::scoped_lock guard(musicMutex); - -- next = std::move(queued); -+ next = /*std::move*/(queued); - - if (current.get() == nullptr || !current->stop(1000)) - { -- current.reset(next.release()); -+ current = next; - current->play(); - } - } -@@ -457,7 +461,7 @@ - - if (current.get() == nullptr && next.get() != nullptr) - { -- current.reset(next.release()); -+ current = next; - current->play(); - } - } -@@ -496,7 +500,9 @@ - logGlobal->traceStream()<<"Loading music file "<load(ResourceID(musicURI, EResType::MUSIC))->readAll(); -- musicFile = SDL_RWFromConstMem(data.first.release(), data.second); -+ char *buf = new char[data.size()]; // Never release it -+ memcpy(buf, data.data(), data.size()); -+ musicFile = SDL_RWFromConstMem(buf, data.size()); - music = Mix_LoadMUS_RW(musicFile); - - if(!music) -Index: client/battle/CCreatureAnimation.h -=================================================================== ---- client/battle/CCreatureAnimation.h (revision 3494) -+++ client/battle/CCreatureAnimation.h (working copy) -@@ -66,8 +66,7 @@ - - //animation raw data - //TODO: use vector instead? -- unique_ptr pixelData; -- size_t pixelDataSize; -+ std::vector pixelData; - - // speed of animation, measure in frames per second - float speed; -Index: client/battle/CCreatureAnimation.cpp -=================================================================== ---- client/battle/CCreatureAnimation.cpp (revision 3494) -+++ client/battle/CCreatureAnimation.cpp (working copy) -@@ -159,11 +159,10 @@ - - auto data = CResourceHandler::get()->load(resID)->readAll(); - -- pixelData = std::move(data.first); -- pixelDataSize = data.second; -+ pixelData = data; - } - -- CBinaryReader reader(new CMemoryStream(pixelData.get(), pixelDataSize)); -+ CBinaryReader reader(new CMemoryStream(pixelData.data(), pixelData.size())); - - reader.readInt32(); // def type, unused - -@@ -307,7 +306,7 @@ - - ui32 offset = dataOffsets.at(type).at(floor(currentFrame)); - -- CBinaryReader reader(new CMemoryStream(pixelData.get(), pixelDataSize)); -+ CBinaryReader reader(new CMemoryStream(pixelData.data(), pixelData.size())); - - reader.getStream()->seek(offset); - -@@ -332,7 +331,7 @@ - for (ui32 i=0; iload(ResourceID("data/" + filename, EResType::BMP_FONT))->readAll()), - chars(loadChars()), -- height(data.first.get()[5]) -+ height(data.data()[5]) - {} - - size_t CBitmapFont::getLineHeight() const -@@ -195,7 +195,7 @@ - SDL_UnlockSurface(surface); - } - --std::pair, ui64> CTrueTypeFont::loadData(const JsonNode & config) -+std::vector CTrueTypeFont::loadData(const JsonNode & config) - { - std::string filename = "Data/" + config["file"].String(); - return CResourceHandler::get()->load(ResourceID(filename, EResType::TTF_FONT))->readAll(); -@@ -208,7 +208,7 @@ - if(!TTF_WasInit() && TTF_Init()==-1) - throw std::runtime_error(std::string("Failed to initialize true type support: ") + TTF_GetError() + "\n"); - -- return TTF_OpenFontRW(SDL_RWFromConstMem(data.first.get(), data.second), 1, pointSize); -+ return TTF_OpenFontRW(SDL_RWFromConstMem(data.data(), data.size()), 1, pointSize); - } - - int CTrueTypeFont::getFontStyle(const JsonNode &config) -@@ -227,7 +227,7 @@ - - CTrueTypeFont::CTrueTypeFont(const JsonNode & fontConfig): - data(loadData(fontConfig)), -- font(loadFont(fontConfig), TTF_CloseFont), -+ font(loadFont(fontConfig), &TTF_CloseFont), - blended(fontConfig["blend"].Bool()) - { - assert(font); -Index: client/gui/Fonts.h -=================================================================== ---- client/gui/Fonts.h (revision 3494) -+++ client/gui/Fonts.h (working copy) -@@ -68,7 +68,7 @@ - ui8 *pixels; // pixels of this character, part of BitmapFont::data - }; - -- const std::pair, ui64> data; -+ std::vector data; - - const std::array chars; - const ui8 height; -@@ -88,12 +88,12 @@ - - class CTrueTypeFont : public IFont - { -- const std::pair, ui64> data; -+ std::vector data; - -- const std::unique_ptr font; -+ const std::unique_ptr font; - const bool blended; - -- std::pair, ui64> loadData(const JsonNode & config); -+ std::vector loadData(const JsonNode & config); - TTF_Font * loadFont(const JsonNode & config); - int getFontStyle(const JsonNode & config); - -Index: Global.h -=================================================================== ---- Global.h (revision 3494) -+++ Global.h (working copy) -@@ -62,7 +62,35 @@ - - #include - #include -- -+#ifdef ANDROID -+/* -+#define move disable_move // It crashes with NDK r9 and GCC 4.8 -+#include -+#undef move -+namespace std -+{ -+ template -+ _Tp move(_Tp __t) -+ { -+ return __t; // Unoptimized version that does not crash -+ } -+ -+ template -+ OutputIt move(InputIt first, InputIt last, OutputIt d_first) -+ { -+ while (first != last) -+ { -+ *d_first++ = *first++; -+ } -+ return d_first; -+ } -+} -+*/ -+/* -+#include -+#define unique_ptr shared_ptr -+*/ -+#endif - #include - #include - #include -@@ -129,6 +157,8 @@ - using std::make_shared; - //using namespace std::placeholders; - namespace range = boost::range; -+#define unique_ptr shared_ptr -+#define make_unique make_shared - - /* ---------------------------------------------------------------------------- */ - /* Typedefs */ diff --git a/project/jni/application/vcmi/vcmi-android.diff b/project/jni/application/vcmi/vcmi-android.diff deleted file mode 100644 index 8bb6b64b2..000000000 --- a/project/jni/application/vcmi/vcmi-android.diff +++ /dev/null @@ -1,226 +0,0 @@ -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: "<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): "< 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 )); }; diff --git a/project/jni/application/xserver-debian/xserver b/project/jni/application/xserver-debian/xserver index 1fb188061..5eecca50c 160000 --- a/project/jni/application/xserver-debian/xserver +++ b/project/jni/application/xserver-debian/xserver @@ -1 +1 @@ -Subproject commit 1fb188061d89bc997d88c9e21ab2e677166c2cf4 +Subproject commit 5eecca50cbd8bad6eb9d2804094b0a603413ff8f diff --git a/project/jni/application/xserver-gimp/xserver b/project/jni/application/xserver-gimp/xserver index 1fb188061..5eecca50c 160000 --- a/project/jni/application/xserver-gimp/xserver +++ b/project/jni/application/xserver-gimp/xserver @@ -1 +1 @@ -Subproject commit 1fb188061d89bc997d88c9e21ab2e677166c2cf4 +Subproject commit 5eecca50cbd8bad6eb9d2804094b0a603413ff8f diff --git a/project/jni/application/xserver/xserver b/project/jni/application/xserver/xserver index 1fb188061..5eecca50c 160000 --- a/project/jni/application/xserver/xserver +++ b/project/jni/application/xserver/xserver @@ -1 +1 @@ -Subproject commit 1fb188061d89bc997d88c9e21ab2e677166c2cf4 +Subproject commit 5eecca50cbd8bad6eb9d2804094b0a603413ff8f