Updated OpenTTD

This commit is contained in:
pelya
2012-11-23 20:45:55 +02:00
parent 92626da1a4
commit 6af453d5e1
7 changed files with 186 additions and 178 deletions

View File

@@ -5,8 +5,8 @@ AppName="OpenTTD"
AppFullName=org.openttd.sdl
ScreenOrientation=h
InhibitSuspend=n
AppDataDownloadUrl="!Data files - 20 Mb|http://sourceforge.net/projects/libsdl-android/files/OpenTTD/openttd-data-1.2.3.zip^!MIDI music support (18 Mb)|timidity.zip|http://sourceforge.net/projects/libsdl-android/files/timidity.zip^!Config file|:.openttd/openttd.cfg:openttd-1.2.2.22.cfg"
VideoDepthBpp=24
AppDataDownloadUrl="!Data files - 20 Mb|http://sourceforge.net/projects/libsdl-android/files/OpenTTD/openttd-data-1.2.3.zip^!MIDI music support (18 Mb)|timidity.zip|http://sourceforge.net/projects/libsdl-android/files/timidity.zip^!Config file|:.openttd/openttd.cfg:openttd-1.2.3.24.cfg"
VideoDepthBpp=16
NeedDepthBuffer=n
NeedStencilBuffer=n
NeedGles2=n
@@ -36,16 +36,16 @@ HiddenMenuOptions='OptionalDownloadConfig'
FirstStartMenuOptions=''
MultiABI=n
AppMinimumRAM=0
AppVersionCode=12323
AppVersionName="1.2.3.23"
ResetSdlConfigForThisVersion=n
AppVersionCode=12324
AppVersionName="1.2.3.24"
ResetSdlConfigForThisVersion=y
DeleteFilesOnUpgrade="%"
CompiledLibraries="jpeg png freetype timidity lzma lzo2"
CustomBuildScript=y
AppCflags=''
AppLdflags=''
AppSubdirsBuild=''
AppCmdline='openttd -b 32bpp-anim'
AppCmdline='openttd'
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
MinimumScreenSize=s
AdmobPublisherId=n

View File

@@ -2,20 +2,20 @@
LOCAL_PATH=`dirname $0`
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
VER=1.2.3
# Uncomment if your configure expects SDL libraries in form "libSDL_name.so"
#ln -sf libtremor.a $LOCAL_PATH/../../../obj/local/armeabi/libvorbisidec.a
#ln -sf libflac.a $LOCAL_PATH/../../../obj/local/armeabi/libFLAC.a
# OpenTTD build system is uglier than war.
if [ \! -f openttd/objs/lang/english.lng ] ; then
sh -c "cd openttd && ./configure --without-freetype --without-png --without-zlib --without-lzo2 --without-lzma --endian=LE && make lang && make -C objs/release endian_target.h depend && make -C objs/setting"
rm -f openttd/Makefile
if [ \! -d openttd-$VER ] ; then
wget http://binaries.openttd.org/releases/$VER/openttd-$VER-source.tar.gz -O - | tar xvz && \
patch -p 0 -d openttd-$VER < openttd-trunk-android.patch && patch -p 0 -d openttd-$VER < findversion.sh.patch || exit 1
fi
if [ \! -f openttd/Makefile ] ; then
../setEnvironment.sh sh -c "cd openttd && env ./configure --host=arm-linux-androideabi --with-sdl --with-freetype=sdl-config --with-png --with-zlib --without-icu --with-libtimidity=$LOCAL_PATH/../../../obj/local/armeabi/libtimidity.so --with-lzo2=$LOCAL_PATH/../../../obj/local/armeabi/liblzo2.so --prefix-dir='.' --data-dir='' --without-allegro --without-fontconfig --with-lzma --endian=LE || echo 'Run: sudo apt-get install liblzma-dev - it is needed only for configure script'"
if [ \! -f openttd-$VER/objs/lang/english.lng ] ; then
sh -c "cd openttd-$VER && ./configure --without-freetype --without-png --without-zlib --without-lzo2 --without-lzma --endian=LE && make lang && make -C objs/release endian_target.h depend && make -C objs/setting"
rm -f openttd-$VER/Makefile
fi
../setEnvironment.sh sh -c "cd openttd && make -j4 VERBOSE=1 STRIP='' LIBS='-lsdl-1.2 -llzo2 -lpng -ltimidity -lfreetype -lgcc -lz -lc -lgnustl_static -lsupc++'" && cp -f openttd/objs/release/openttd libapplication.so
if [ \! -f openttd-$VER/Makefile ] ; then
../setEnvironment.sh sh -c "cd openttd-$VER && env ./configure --host=arm-linux-androideabi --with-sdl --with-freetype=sdl-config --with-png --with-zlib --without-icu --with-libtimidity=$LOCAL_PATH/../../../obj/local/armeabi/libtimidity.so --with-lzo2=$LOCAL_PATH/../../../obj/local/armeabi/liblzo2.so --prefix-dir='.' --data-dir='' --without-allegro --without-fontconfig --with-lzma --endian=LE || echo 'Run: sudo apt-get install liblzma-dev - it is needed only for configure script'"
fi
../setEnvironment.sh sh -c "cd openttd-$VER && make -j4 VERBOSE=1 STRIP='' LIBS='-lsdl-1.2 -llzo2 -lpng -ltimidity -lfreetype -lgcc -lz -lc -lgnustl_static -lsupc++'" && cp -f openttd-$VER/objs/release/openttd libapplication.so

View File

@@ -1,10 +1,10 @@
[misc]
resolution = 800,480
small_font = fonts/FreeSans.ttf
medium_font = fonts/FreeSerif.ttf
large_font = fonts/FreeSerif.ttf
mono_font = fonts/FreeMono.ttf
resolution = 640,480
small_font =
medium_font =
large_font =
mono_font =
small_size = 10
medium_size = 12
large_size = 16

View File

@@ -0,0 +1,10 @@
--- findversion.sh (revision 24501)
+++ findversion.sh (working copy)
@@ -134,6 +134,7 @@
REV_NR=""
fi
+MODIFIED="0" # This prevents Andorid build from connecting to a public servers
if [ "$MODIFIED" -eq "2" ]; then
REV="${REV}M"
fi

View File

@@ -1 +0,0 @@
../../../../../openttd-1.2.3

View File

@@ -1,7 +1,114 @@
Index: src/os/unix/unix.cpp
===================================================================
--- src/os/unix/unix.cpp (revision 24562)
+++ src/os/unix/unix.cpp (working copy)
--- src/debug.cpp 2012-10-31 23:39:00.000000000 +0200
+++ src/debug.cpp 2012-11-22 19:01:14.510763002 +0200
@@ -16,6 +16,9 @@
#include "string_func.h"
#include "fileio_func.h"
#include "settings_type.h"
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
#include <time.h>
@@ -82,6 +85,9 @@
*/
static void debug_print(const char *dbg, const char *buf)
{
+#ifdef __ANDROID__
+ __android_log_print(ANDROID_LOG_INFO, "OpenTTD", "[%s] %s", dbg, buf);
+#endif
#if defined(ENABLE_NETWORK)
if (_debug_socket != INVALID_SOCKET) {
char buf2[1024 + 32];
--- src/fontcache.cpp 2012-10-31 23:39:00.000000000 +0200
+++ src/fontcache.cpp 2012-11-23 20:02:36.768406013 +0200
@@ -808,7 +808,15 @@
return ret;
}
-#else /* without WITH_FONTCONFIG */
+#elif defined(__ANDROID__) /* end if defined(WITH_FONTCONFIG) */
+FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) {return FT_Err_Cannot_Open_Resource;}
+bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
+{
+ callback->SetFontNames(settings, "fonts/FreeSans.ttf"); /* We don't really have other fonts on Android, other than our own */
+ callback->FindMissingGlyphs(NULL);
+ return true;
+}
+#else /* end if defined(__ANDROID__) */
FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) {return FT_Err_Cannot_Open_Resource;}
bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { return false; }
#endif /* WITH_FONTCONFIG */
--- src/music/libtimidity.cpp 2012-10-31 23:38:54.000000000 +0200
+++ src/music/libtimidity.cpp 2012-11-22 19:01:14.510763002 +0200
@@ -13,6 +13,7 @@
#include "../openttd.h"
#include "../sound_type.h"
#include "../debug.h"
+#include "../core/math_func.hpp"
#include "libtimidity.h"
#include <fcntl.h>
#include <sys/types.h>
@@ -22,6 +23,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <timidity.h>
+#include <SDL.h>
#if defined(PSP)
#include <pspaudiolib.h>
#endif /* PSP */
@@ -51,6 +53,24 @@
}
}
#endif /* PSP */
+#ifdef __ANDROID__
+/* Android does not have Midi chip, we have to route the libtimidity output through SDL audio output */
+void Android_MidiMixMusic(Sint16 *stream, int len)
+{
+ if (_midi.status == MIDI_PLAYING) {
+ Sint16 buf[16384];
+ while( len > 0 )
+ {
+ int minlen = min(sizeof(buf), len);
+ mid_song_read_wave(_midi.song, stream, min(sizeof(buf), len*2));
+ for( Uint16 i = 0; i < minlen; i++ )
+ stream[i] += buf[i];
+ stream += minlen;
+ len -= minlen;
+ }
+ }
+}
+#endif /* __ANDROID__ */
/** Factory for the libtimidity driver. */
static FMusicDriver_LibTimidity iFMusicDriver_LibTimidity;
--- src/network/core/os_abstraction.h 2012-10-31 23:38:59.000000000 +0200
+++ src/network/core/os_abstraction.h 2012-11-22 19:01:14.506763002 +0200
@@ -161,7 +161,7 @@
# include <net/if.h>
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__INNOTEK_LIBC__) \
- && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
+ && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX) && !defined(__ANDROID__)
/* If for any reason ifaddrs.h does not exist on your system, comment out
* the following two lines and an alternative way will be used to fetch
* the list of IPs from the system. */
--- src/os/unix/crashlog_unix.cpp 2012-10-31 23:38:54.000000000 +0200
+++ src/os/unix/crashlog_unix.cpp 2012-11-22 19:01:14.506763002 +0200
@@ -141,7 +141,11 @@
};
/** The signals we want our crash handler to handle. */
+#ifdef __ANDROID__
+static const int _signals_to_handle[] = { }; // Default Android signal handler will give us stack trace
+#else
static const int _signals_to_handle[] = { SIGSEGV, SIGABRT, SIGFPE, SIGBUS, SIGILL };
+#endif
/**
* Entry point for the crash handler.
--- src/os/unix/unix.cpp 2012-10-31 23:38:54.000000000 +0200
+++ src/os/unix/unix.cpp 2012-11-22 19:01:14.506763002 +0200
@@ -25,7 +25,7 @@
#ifdef __APPLE__
@@ -23,26 +130,8 @@ Index: src/os/unix/unix.cpp
int CDECL main(int argc, char *argv[])
{
int ret;
Index: src/os/unix/crashlog_unix.cpp
===================================================================
--- src/os/unix/crashlog_unix.cpp (revision 24562)
+++ src/os/unix/crashlog_unix.cpp (working copy)
@@ -141,7 +141,11 @@
};
/** The signals we want our crash handler to handle. */
+#ifdef __ANDROID__
+static const int _signals_to_handle[] = { }; // Default Android signal handler will give us stack trace
+#else
static const int _signals_to_handle[] = { SIGSEGV, SIGABRT, SIGFPE, SIGBUS, SIGILL };
+#endif
/**
* Entry point for the crash handler.
Index: src/osk_gui.cpp
===================================================================
--- src/osk_gui.cpp (revision 24562)
+++ src/osk_gui.cpp (working copy)
--- src/osk_gui.cpp 2012-10-31 23:39:00.000000000 +0200
+++ src/osk_gui.cpp 2012-11-22 19:01:14.506763002 +0200
@@ -21,6 +21,9 @@
#include "table/sprites.h"
@@ -68,23 +157,43 @@ Index: src/osk_gui.cpp
}
/**
Index: src/network/core/os_abstraction.h
===================================================================
--- src/network/core/os_abstraction.h (revision 24562)
+++ src/network/core/os_abstraction.h (working copy)
@@ -161,7 +161,7 @@
# include <net/if.h>
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__INNOTEK_LIBC__) \
- && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
+ && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX) && !defined(__ANDROID__)
/* If for any reason ifaddrs.h does not exist on your system, comment out
* the following two lines and an alternative way will be used to fetch
* the list of IPs from the system. */
Index: src/video/sdl_v.cpp
===================================================================
--- src/video/sdl_v.cpp (revision 24562)
+++ src/video/sdl_v.cpp (working copy)
--- src/script/api/script_date.cpp 2012-10-31 23:38:58.000000000 +0200
+++ src/script/api/script_date.cpp 2012-11-22 19:01:14.510763002 +0200
@@ -9,8 +9,8 @@
/** @file script_date.cpp Implementation of ScriptDate. */
+#include "../../stdafx.h" /* Have to be included before time.h, if we want UINT32_MAX macro defined on Android */
#include <time.h>
-#include "../../stdafx.h"
#include "script_date.hpp"
#include "../../date_func.h"
--- src/sound/sdl_s.cpp 2012-10-31 23:38:54.000000000 +0200
+++ src/sound/sdl_s.cpp 2012-11-22 19:01:14.506763002 +0200
@@ -21,6 +21,10 @@
/** Factory for the SDL sound driver. */
static FSoundDriver_SDL iFSoundDriver_SDL;
+#ifdef __ANDROID__
+extern void Android_MidiMixMusic(Sint16 *stream, int len);
+#endif
+
/**
* Callback that fills the sound buffer.
* @param userdata Ignored.
@@ -30,6 +34,9 @@
static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
{
MxMixSamples(stream, len / 4);
+#if defined(__ANDROID__) && defined(LIBTIMIDITY)
+ Android_MidiMixMusic((Sint16 *)stream, len / 2);
+#endif
}
const char *SoundDriver_SDL::Start(const char * const *parm)
--- src/video/sdl_v.cpp 2012-10-31 23:38:49.000000000 +0200
+++ src/video/sdl_v.cpp 2012-11-22 19:01:14.506763002 +0200
@@ -25,6 +25,9 @@
#include "../fileio_func.h"
#include "sdl_v.h"
@@ -134,7 +243,7 @@ Index: src/video/sdl_v.cpp
}
break;
-
+#endif
+#endif /* not __ANDROID__ */
case SDL_QUIT:
HandleExitGameRequest();
break;
@@ -150,7 +259,7 @@ Index: src/video/sdl_v.cpp
CreateMainSurface(w, h);
break;
}
+#endif
+#endif /* not __ANDROID__ */
case SDL_VIDEOEXPOSE: {
/* Force a redraw of the entire screen. Note
* that SDL 1.2 seems to do this automatically
@@ -164,111 +273,3 @@ Index: src/video/sdl_v.cpp
return NULL;
}
Index: src/sound/sdl_s.cpp
===================================================================
--- src/sound/sdl_s.cpp (revision 24562)
+++ src/sound/sdl_s.cpp (working copy)
@@ -21,6 +21,10 @@
/** Factory for the SDL sound driver. */
static FSoundDriver_SDL iFSoundDriver_SDL;
+#ifdef __ANDROID__
+extern void Android_MidiMixMusic(Sint16 *stream, int len);
+#endif
+
/**
* Callback that fills the sound buffer.
* @param userdata Ignored.
@@ -30,6 +34,9 @@
static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
{
MxMixSamples(stream, len / 4);
+#if defined(__ANDROID__) && defined(LIBTIMIDITY)
+ Android_MidiMixMusic((Sint16 *)stream, len / 2);
+#endif
}
const char *SoundDriver_SDL::Start(const char * const *parm)
Index: src/music/libtimidity.cpp
===================================================================
--- src/music/libtimidity.cpp (revision 24562)
+++ src/music/libtimidity.cpp (working copy)
@@ -13,6 +13,7 @@
#include "../openttd.h"
#include "../sound_type.h"
#include "../debug.h"
+#include "../core/math_func.hpp"
#include "libtimidity.h"
#include <fcntl.h>
#include <sys/types.h>
@@ -22,6 +23,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <timidity.h>
+#include <SDL.h>
#if defined(PSP)
#include <pspaudiolib.h>
#endif /* PSP */
@@ -51,6 +53,24 @@
}
}
#endif /* PSP */
+#ifdef __ANDROID__
+/* Android does not have Midi chip, we have to route the libtimidity output through SDL audio output */
+void Android_MidiMixMusic(Sint16 *stream, int len)
+{
+ if (_midi.status == MIDI_PLAYING) {
+ Sint16 buf[16384];
+ while( len > 0 )
+ {
+ int minlen = min(sizeof(buf), len);
+ mid_song_read_wave(_midi.song, stream, min(sizeof(buf), len*2));
+ for( Uint16 i = 0; i < minlen; i++ )
+ stream[i] += buf[i];
+ stream += minlen;
+ len -= minlen;
+ }
+ }
+}
+#endif
/** Factory for the libtimidity driver. */
static FMusicDriver_LibTimidity iFMusicDriver_LibTimidity;
Index: src/script/api/script_date.cpp
===================================================================
--- src/script/api/script_date.cpp (revision 24562)
+++ src/script/api/script_date.cpp (working copy)
@@ -9,8 +9,8 @@
/** @file script_date.cpp Implementation of ScriptDate. */
+#include "../../stdafx.h" /* Have to be included before time.h, if we want UINT32_MAX macro defined on Android */
#include <time.h>
-#include "../../stdafx.h"
#include "script_date.hpp"
#include "../../date_func.h"
Index: src/debug.cpp
===================================================================
--- src/debug.cpp (revision 24562)
+++ src/debug.cpp (working copy)
@@ -16,6 +16,9 @@
#include "string_func.h"
#include "fileio_func.h"
#include "settings_type.h"
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
#include <time.h>
@@ -82,6 +85,9 @@
*/
static void debug_print(const char *dbg, const char *buf)
{
+#ifdef __ANDROID__
+ __android_log_print(ANDROID_LOG_INFO, "OpenTTD", "[%s] %s", dbg, buf);
+#endif
#if defined(ENABLE_NETWORK)
if (_debug_socket != INVALID_SOCKET) {
char buf2[1024 + 32];

View File

@@ -5,6 +5,4 @@ then install Android SDK, Android NDK, and "ant" tool, then launch commands
ln -s openttd project/jni/application/src
./changeAppSettings.sh -a
android update project -p project
then download OpenTTD source release into the dir project/jni/application/openttd/openttd
(or create a symlink to it), then apply patch openttd-trunk-android.patch
and launch build.sh. That should be it.
then launch build.sh. That should be it.