diff --git a/project/jni/application/fheroes2/fheroes2-r2050.diff b/project/jni/application/fheroes2/fheroes2-r2050.diff deleted file mode 100644 index e7198fe1f..000000000 --- a/project/jni/application/fheroes2/fheroes2-r2050.diff +++ /dev/null @@ -1,165 +0,0 @@ -diff -u -r -b -x .svn -x '*.o' -x '*.d' /home/pelya/src/endless_space/fheroes2/src/fheroes2/army/army.cpp src/fheroes2/army/army.cpp ---- /home/pelya/src/endless_space/fheroes2/src/fheroes2/army/army.cpp 2010-11-15 19:17:40.859414020 +0200 -+++ src/fheroes2/army/army.cpp 2010-11-12 16:15:26.000000000 +0200 -@@ -728,12 +728,16 @@ - - void Army::army_t::BattleSetModes(u32 f) - { -- std::for_each(army.begin(), army.end(), std::bind2nd(std::mem_fun_ref(&Troop::BattleSetModes), f)); -+ //std::for_each(army.begin(), army.end(), std::bind2nd(std::mem_fun_ref(&Troop::BattleSetModes), f)); // Cannot call non-const function here -+ for( std::vector ::iterator it = army.begin(); it != army.end(); it++ ) -+ it->BattleSetModes(f); - } - - void Army::army_t::BattleResetModes(u32 f) - { -- std::for_each(army.begin(), army.end(), std::bind2nd(std::mem_fun_ref(&Troop::BattleResetModes), f)); -+ //std::for_each(army.begin(), army.end(), std::bind2nd(std::mem_fun_ref(&Troop::BattleResetModes), f)); // Cannot call non-const function here -+ for( std::vector ::iterator it = army.begin(); it != army.end(); it++ ) -+ it->BattleResetModes(f); - } - - Army::Troop* Army::army_t::BattleFindModes(u32 f) -diff -u -r -b -x .svn -x '*.o' -x '*.d' /home/pelya/src/endless_space/fheroes2/src/fheroes2/game/fheroes2.cpp src/fheroes2/game/fheroes2.cpp ---- /home/pelya/src/endless_space/fheroes2/src/fheroes2/game/fheroes2.cpp 2010-11-15 19:17:40.859414020 +0200 -+++ src/fheroes2/game/fheroes2.cpp 2010-11-22 15:16:37.000000000 +0200 -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - #include "gamedefs.h" - #include "engine.h" -@@ -69,13 +70,18 @@ - - int main(int argc, char **argv) - { -+ VERBOSE("000 - entered SDL_main()"); - Settings & conf = Settings::Get(); - int test = 0; - - std::cout << "Free Heroes II, " + conf.BuildVersion() << std::endl; -+ VERBOSE("Free Heroes II, " + conf.BuildVersion()); - - LoadConfigFiles(conf, GetDirname(argv[0])); - -+ VERBOSE("001"); -+ -+#ifndef ANDROID // Crashes for some reason - // getopt - { - int opt; -@@ -109,13 +115,20 @@ - default: break; - } - } -+#endif -+ -+ VERBOSE("002"); - - if(conf.SelectVideoDriver().size()) SetVideoDriver(conf.SelectVideoDriver()); - -+ VERBOSE("003"); -+ - // random init - Rand::Init(); - if(conf.Music()) SetTimidityEnvPath(conf); - -+ VERBOSE("004"); -+ - u32 subsystem = INIT_VIDEO | INIT_TIMER; - - if(conf.Sound() || conf.Music()) -@@ -128,9 +141,12 @@ - Network::SetProtocolVersion(static_cast((conf.MajorVersion() << 8)) | conf.MinorVersion()); - #endif - -+ VERBOSE("005"); -+ - if(SDL::Init(subsystem)) - try - { -+ VERBOSE("006"); - std::atexit(SDL::Quit); - - if(conf.Unicode()) SetLangEnvPath(conf); -@@ -163,17 +179,23 @@ - //Ensure the mouse position is updated to prevent bad initial values. - LocalEvent::Get().GetMouseCursor(); - -+ VERBOSE("007"); -+ - #ifdef WITH_ZLIB - ZSurface zicons; - if(zicons.Load(FH2_ICONS_WIDTH, FH2_ICONS_HEIGHT, FH2_ICONS_BPP, fh2_icons_pack, FH2_ICONS_SIZE, true)) Display::SetIcons(zicons); - #endif - AGG::Cache & cache = AGG::Cache::Get(); - -+ VERBOSE("008"); -+ - // read data dir - if(! cache.ReadDataDir()) Error::Except("FHeroes2: ", "AGG data files not found."); - - if(IS_DEBUG(DBG_GAME, DBG_INFO)) conf.Dump(); - -+ VERBOSE("009"); -+ - // load palette - cache.LoadPAL(); - -diff -u -r -b -x .svn -x '*.o' -x '*.d' /home/pelya/src/endless_space/fheroes2/src/fheroes2/system/settings.cpp src/fheroes2/system/settings.cpp ---- /home/pelya/src/endless_space/fheroes2/src/fheroes2/system/settings.cpp 2010-11-15 19:17:34.879413999 +0200 -+++ src/fheroes2/system/settings.cpp 2010-11-12 17:31:10.000000000 +0200 -@@ -1424,6 +1419,9 @@ - { - u32 flags = opt_global.Modes(GLOBAL_USESWSURFACE) ? SDL_SWSURFACE : SDL_SWSURFACE | SDL_HWSURFACE; - if(opt_global.Modes(GLOBAL_FULLSCREEN)) flags |= SDL_FULLSCREEN; -+ #ifdef ANDROID -+ flags = SDL_SWSURFACE; -+ #endif - - return flags; - } -diff -u -r -b -x .svn -x '*.o' -x '*.d' /home/pelya/src/endless_space/fheroes2/src/fheroes2/system/settings.h src/fheroes2/system/settings.h ---- /home/pelya/src/endless_space/fheroes2/src/fheroes2/system/settings.h 2010-11-15 19:17:34.869414019 +0200 -+++ src/fheroes2/system/settings.h 2010-11-12 16:09:03.000000000 +0200 -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - #include "gamedefs.h" - #include "difficulty.h" - #include "race.h" -@@ -35,6 +36,9 @@ - #include "game.h" - #include "game_io.h" - #include "bitmodes.h" -+#ifdef ANDROID -+#include -+#endif - - #define FORMAT_VERSION_2031 0x07EF - #define FORMAT_VERSION_1978 0x07BA -@@ -71,6 +75,9 @@ - #ifdef __SYMBIAN32__ - #define VERBOSE(x) - #define DEBUG(x, y, z) -+#elif defined(ANDROID) -+#define VERBOSE(x) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); } -+#define DEBUG(x, y, z) if(IS_DEBUG((x), (y))) VERBOSE(z) - #else - #define VERBOSE(x) std::cout << x << std::endl - #define DEBUG(x, y, z) if(IS_DEBUG((x), (y))) VERBOSE(z) -diff -u -r -b -x .svn -x '*.o' -x '*.d' /home/pelya/src/endless_space/fheroes2/src/xmlccwrap/gzstream.h src/xmlccwrap/gzstream.h ---- /home/pelya/src/endless_space/fheroes2/src/xmlccwrap/gzstream.h 2010-11-15 19:17:31.869414019 +0200 -+++ src/xmlccwrap/gzstream.h 2010-11-12 16:06:58.000000000 +0200 -@@ -33,6 +33,7 @@ - #include - #include - #include -+#include - - #ifdef GZSTREAM_NAMESPACE - namespace GZSTREAM_NAMESPACE { diff --git a/project/jni/application/fheroes2/fheroes2-r2082.diff b/project/jni/application/fheroes2/fheroes2-r2082.diff new file mode 100644 index 000000000..27664e0dd --- /dev/null +++ b/project/jni/application/fheroes2/fheroes2-r2082.diff @@ -0,0 +1,336 @@ +Index: files/lang/fheroes2.pot +=================================================================== +Index: src/xmlccwrap/gzstream.h +=================================================================== +--- src/xmlccwrap/gzstream.h (revision 2082) ++++ src/xmlccwrap/gzstream.h (working copy) +@@ -33,6 +33,7 @@ + #include + #include + #include ++#include + + #ifdef GZSTREAM_NAMESPACE + namespace GZSTREAM_NAMESPACE { +Index: src/engine/tools.cpp +=================================================================== +--- src/engine/tools.cpp (revision 2082) ++++ src/engine/tools.cpp (working copy) +@@ -25,7 +25,9 @@ + #include + #include + #include ++#include + #include ++#include + #include "error.h" + #include "types.h" + #include "tools.h" +Index: src/engine/midi_mtrk.cpp +=================================================================== +--- src/engine/midi_mtrk.cpp (revision 2082) ++++ src/engine/midi_mtrk.cpp (working copy) +@@ -258,7 +258,9 @@ + if(delta2) delta -= delta2; + + // decrease duration +- std::for_each(notesoff.begin(), notesoff.end(), std::bind2nd(std::mem_fun_ref(&meta_t::decrease_duration), delta)); ++ //std::for_each(notesoff.begin(), notesoff.end(), std::bind2nd(std::mem_fun_ref(&meta_t::decrease_duration), delta)); ++ for( std::list :: iterator it = notesoff.begin(); it != notesoff.end(); it++ ) ++ it->decrease_duration(delta); + } + + // interval +Index: src/engine/error.cpp +=================================================================== +--- src/engine/error.cpp (revision 2082) ++++ src/engine/error.cpp (working copy) +@@ -23,10 +23,19 @@ + #include + #include + #include "error.h" ++#ifdef ANDROID ++#include ++#endif + + /* exception */ + void Error::Except(const char* message, const char* cstr) + { ++#ifndef ANDROID + std::cerr << "Error::Except: " << message << cstr << std::endl; + throw Exception(); ++#else ++ __android_log_print(ANDROID_LOG_FATAL, "fheroes2", "======"); ++ __android_log_print(ANDROID_LOG_FATAL, "fheroes2", "Error: %s: %s", message, cstr); ++ __android_log_print(ANDROID_LOG_FATAL, "fheroes2", "======"); ++#endif + } +Index: src/fheroes2/gui/text.cpp +=================================================================== +--- src/fheroes2/gui/text.cpp (revision 2082) ++++ src/fheroes2/gui/text.cpp (working copy) +@@ -21,6 +21,7 @@ + ***************************************************************************/ + + #include ++#include + #include "agg.h" + #include "settings.h" + #include "text.h" +Index: src/fheroes2/system/settings.cpp +=================================================================== +--- src/fheroes2/system/settings.cpp (revision 2082) ++++ src/fheroes2/system/settings.cpp (working copy) +@@ -1427,6 +1427,9 @@ + { + u32 flags = opt_global.Modes(GLOBAL_USESWSURFACE) ? SDL_SWSURFACE : SDL_SWSURFACE | SDL_HWSURFACE; + if(opt_global.Modes(GLOBAL_FULLSCREEN)) flags |= SDL_FULLSCREEN; ++ #ifdef ANDROID ++ flags = SDL_SWSURFACE; ++ #endif + + return flags; + } +Index: src/fheroes2/system/settings.h +=================================================================== +--- src/fheroes2/system/settings.h (revision 2082) ++++ src/fheroes2/system/settings.h (working copy) +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + #include "gamedefs.h" + #include "difficulty.h" + #include "race.h" +@@ -35,6 +36,9 @@ + #include "game.h" + #include "game_io.h" + #include "bitmodes.h" ++#ifdef ANDROID ++#include ++#endif + + #define FORMAT_VERSION_2031 0x07EF + #define FORMAT_VERSION_1978 0x07BA +@@ -71,6 +75,9 @@ + #ifdef __SYMBIAN32__ + #define VERBOSE(x) + #define DEBUG(x, y, z) ++#elif defined(ANDROID) ++#define VERBOSE(x) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); } ++#define DEBUG(x, y, z) if(IS_DEBUG((x), (y))) VERBOSE(z) + #else + #define VERBOSE(x) std::cout << x << std::endl + #define DEBUG(x, y, z) if(IS_DEBUG((x), (y))) VERBOSE(z) +Index: src/fheroes2/heroes/portrait.cpp +=================================================================== +--- src/fheroes2/heroes/portrait.cpp (revision 2082) ++++ src/fheroes2/heroes/portrait.cpp (working copy) +@@ -31,7 +31,7 @@ + { + if(hero.GetType() == Skill::Primary::CAPTAIN) + return Captain(hero.GetRace(), sz); +- else return Hero(dynamic_cast(hero), sz); ++ else return Hero(reinterpret_cast(hero), sz); + } + + const Surface & Portrait::Captain(const Race::race_t rc, const Portrait::size_t sz) +Index: src/fheroes2/network/server.cpp +=================================================================== +--- src/fheroes2/network/server.cpp (revision 2082) ++++ src/fheroes2/network/server.cpp (working copy) +@@ -307,7 +307,8 @@ + for(Color::color_t color = Color::BLUE; color != Color::GRAY; ++color) if(color & conf.PlayersColors()) + world.GetKingdom(color).SetControl(Game::REMOTE); + +- std::for_each(clients.begin(), clients.end(), std::bind2nd(std::mem_fun_ref(&FH2RemoteClient::SetModes), ST_INGAME)); ++ for( std::vector :: iterator it = clients.begin(); it != clients.end(); it++ ) ++ it->SetModes(ST_INGAME); + + GameOver::Result::Get().Reset(); + std::vector::iterator it; +Index: src/fheroes2/network/network.cpp +=================================================================== +--- src/fheroes2/network/network.cpp (revision 2082) ++++ src/fheroes2/network/network.cpp (working copy) +@@ -154,7 +154,9 @@ + Network::SetProtocolVersion(static_cast((conf.MajorVersion() << 8)) | conf.MinorVersion()); + + if(SDL::Init(INIT_TIMER)) ++#ifndef ANDROID + try ++#endif + { + std::atexit(SDL::Quit); + +@@ -171,6 +173,7 @@ + + return FH2Server::callbackCreateThread(&server); + } ++#ifndef ANDROID + catch(std::bad_alloc) + { + } +@@ -178,6 +181,7 @@ + { + conf.Dump(); + } ++#endif + + return 0; + } +Index: src/fheroes2/dialog/dialog_selectfile.cpp +=================================================================== +--- src/fheroes2/dialog/dialog_selectfile.cpp (revision 2082) ++++ src/fheroes2/dialog/dialog_selectfile.cpp (working copy) +@@ -34,7 +34,7 @@ + #include "pocketpc.h" + #include "dialog.h" + +-#ifdef __SYMBIAN32__ ++#if defined __SYMBIAN32__ || defined(ANDROID) + #include + #endif + +Index: src/fheroes2/maps/pairs.h +=================================================================== +--- src/fheroes2/maps/pairs.h (revision 2082) ++++ src/fheroes2/maps/pairs.h (working copy) +@@ -23,6 +23,7 @@ + #ifndef H2PAIRS_H + #define H2PAIRS_H + ++#include + #include + #include "maps_tiles.h" + +Index: src/fheroes2/game/fheroes2.cpp +=================================================================== +--- src/fheroes2/game/fheroes2.cpp (revision 2082) ++++ src/fheroes2/game/fheroes2.cpp (working copy) +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + #include "gamedefs.h" + #include "engine.h" +@@ -69,13 +70,18 @@ + + int main(int argc, char **argv) + { ++ VERBOSE("000 - entered SDL_main()"); + Settings & conf = Settings::Get(); + int test = 0; + +- std::cout << "Free Heroes II, " + conf.BuildVersion() << std::endl; ++ //std::cout << "Free Heroes II, " + conf.BuildVersion() << std::endl; ++ VERBOSE("Free Heroes II, " + conf.BuildVersion()); + + LoadConfigFiles(conf, GetDirname(argv[0])); + ++ VERBOSE("001"); ++ ++#ifndef ANDROID // Crashes for some reason + // getopt + { + int opt; +@@ -86,7 +92,7 @@ + case 'e': + conf.SetEditor(); + conf.SetDebug(DBG_DEVEL | DBG_GAME | DBG_INFO); +- std::cout << "start: editor mode." << std::endl; ++ //std::cout << "start: editor mode." << std::endl; + break; + #endif + #ifndef BUILD_RELEASE +@@ -109,13 +115,20 @@ + default: break; + } + } ++#endif + ++ VERBOSE("002"); ++ + if(conf.SelectVideoDriver().size()) SetVideoDriver(conf.SelectVideoDriver()); + ++ VERBOSE("003"); ++ + // random init + Rand::Init(); + if(conf.Music()) SetTimidityEnvPath(conf); + ++ VERBOSE("004"); ++ + u32 subsystem = INIT_VIDEO | INIT_TIMER; + + if(conf.Sound() || conf.Music()) +@@ -128,9 +141,14 @@ + Network::SetProtocolVersion(static_cast((conf.MajorVersion() << 8)) | conf.MinorVersion()); + #endif + ++ VERBOSE("005"); ++ + if(SDL::Init(subsystem)) ++#ifndef ANDROID + try ++#endif + { ++ VERBOSE("006"); + std::atexit(SDL::Quit); + + if(conf.Unicode()) SetLangEnvPath(conf); +@@ -163,17 +181,23 @@ + //Ensure the mouse position is updated to prevent bad initial values. + LocalEvent::Get().GetMouseCursor(); + ++ VERBOSE("007"); ++ + #ifdef WITH_ZLIB + ZSurface zicons; + if(zicons.Load(FH2_ICONS_WIDTH, FH2_ICONS_HEIGHT, FH2_ICONS_BPP, fh2_icons_pack, FH2_ICONS_SIZE, true)) Display::SetIcons(zicons); + #endif + AGG::Cache & cache = AGG::Cache::Get(); + ++ VERBOSE("008"); ++ + // read data dir + if(! cache.ReadDataDir()) Error::Except("FHeroes2: ", "AGG data files not found."); + + if(IS_DEBUG(DBG_GAME, DBG_INFO)) conf.Dump(); + ++ VERBOSE("009"); ++ + // load palette + cache.LoadPAL(); + +@@ -233,7 +257,9 @@ + //Display::ShowCursor(); + if(Settings::Get().ExtUseFade()) Display::Fade(); + +- } catch(std::bad_alloc) ++ } ++#ifndef ANDROID ++ catch(std::bad_alloc) + { + DEBUG(DBG_GAME, DBG_WARN, "std::bad_alloc"); + AGG::Cache::Get().Dump(); +@@ -246,6 +272,7 @@ + AGG::Cache::Get().Dump(); + conf.Dump(); + } ++#endif + + return EXIT_SUCCESS; + } +@@ -345,7 +372,7 @@ + std::string strtmp = conf.LocalPrefix() + SEPARATOR + "fheroes2.cfg"; + if(FilePresent(strtmp)) + { +- std::cout << "config: " << strtmp << " load." << std::endl; ++ //std::cout << "config: " << strtmp << " load." << std::endl; + conf.Read(strtmp); + } + } diff --git a/project/jni/application/fheroes2/readme.txt b/project/jni/application/fheroes2/readme.txt index 8527db977..b9aef486a 100644 --- a/project/jni/application/fheroes2/readme.txt +++ b/project/jni/application/fheroes2/readme.txt @@ -1,5 +1,6 @@ Grab Free Heroes 2 sources with SVN from https://fheroes2.svn.sourceforge.net/svnroot/fheroes2/trunk/fheroes2 and put them here, in directory "fheroes2", then apply patch -fheroes2-r2050.diff +fheroes2-r2082.diff and compile with build.sh +You will need Android SDK 2.2, NDK r4b, and "ant" tool. \ No newline at end of file