Version 1.2.0 with new build/configure system
authorThomas Perl <m@thp.io>
Sun, 28 Jul 2013 00:16:53 +0000 (28 02:16 +0200)
committerThomas Perl <m@thp.io>
Sun, 28 Jul 2013 00:16:53 +0000 (28 02:16 +0200)
45 files changed:
README.MacOSX [deleted file]
README.Maemo [deleted file]
README.win32 [deleted file]
SDLMain.h [deleted file]
SDLMain.m [deleted file]
configure [new file with mode: 0755]
data/Tennix.icns [deleted file]
data/defaultbot.py [moved from defaultbot.py with 100% similarity]
data/icon.ico [deleted file]
data/icon.svg [deleted file]
data/tennix.6 [moved from tennix.6 with 100% similarity]
data/tennix.desktop [moved from tennix.desktop with 100% similarity]
data/tennix.png [moved from data/icon.png with 100% similarity]
doc/court.xcf [moved from data/court.xcf with 100% similarity]
doc/data2csrc.c [moved from data/data2csrc.c with 100% similarity]
doc/stadium.xcf [moved from data/stadium.xcf with 100% similarity]
makefile
osxapp.plist [deleted file]
src/SDL_rotozoom.cc [moved from SDL_rotozoom.c with 95% similarity]
src/SDL_rotozoom.h [moved from SDL_rotozoom.h with 100% similarity]
src/animation.cc [moved from animation.c with 100% similarity]
src/animation.h [moved from animation.h with 100% similarity]
src/archive.cc [moved from archive.cc with 81% similarity]
src/archive.h [moved from archive.hh with 94% similarity]
src/archivetool.cc [moved from archivetool.cc with 85% similarity]
src/credits.h [moved from credits.h with 97% similarity]
src/game.cc [moved from game.c with 97% similarity]
src/game.h [moved from game.h with 100% similarity]
src/graphics.cc [moved from graphics.cc with 97% similarity]
src/graphics.h [moved from graphics.h with 99% similarity]
src/input.cc [moved from input.c with 82% similarity]
src/input.h [moved from input.h with 90% similarity]
src/locations.h [moved from locations.h with 100% similarity]
src/network.cc [moved from network.c with 99% similarity]
src/network.h [moved from network.h with 98% similarity]
src/sound.cc [moved from sound.cc with 99% similarity]
src/sound.h [moved from sound.h with 99% similarity]
src/tennix.cc [moved from tennix.cc with 94% similarity]
src/tennix.h [moved from tennix.h with 85% similarity]
src/tennixpy.cc [moved from tennixpy.cc with 79% similarity]
src/tennixpy.h [moved from tennixpy.h with 56% similarity]
src/util.cc [moved from util.c with 100% similarity]
src/util.h [moved from util.h with 75% similarity]
tennix-installer.iss.in [deleted file]
tennix.res [deleted file]

diff --git a/README.MacOSX b/README.MacOSX
deleted file mode 100644 (file)
index be7c324..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-Build instructions for Tennix on Mac OS X
-=========================================
-
-Install Xcode tools (so you get gcc et al.) and then compile SDL, SDL_mixer,
-SDL_image and SDL_ttf from source. You should install the additional libraries
-in the same $PREFIX as SDL itself, so that "sdl-config --prefix" returns the
-correct prefix for all libraries. After this you should be able to compile
-Tennix with the following commands:
-
-  make
-  make release-osx
-
-This should result in a Tennix.app bundle in the build directory that should
-not depend on anything that is not included with a default Mac OS X install.
-
diff --git a/README.Maemo b/README.Maemo
deleted file mode 100644 (file)
index da72db6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-To enable some code tweaks for the Maemo Platform (Nokia Internet Tablets),
-compile with "make MAEMO=1". This will enable (and disable) some features
-that are needed or unnecessary on Nokia Internet Tablets (i.e. Multiplayer).
-
-For audio to work, you have to convert the .ogg files in the "data/" folder
-to .wav files (Maemo's SDL seems to not have Ogg support compiled in). For
-the background.ogg file, you can create a dummy file with the following
-command: "arecord -twav -d1 background.wav". This makes the binary smaller.
-
-For all other .ogg files in the "data/" folder, you can use "oggdec *.ogg".
-
-Don't forget to update both "makefile" and "data/makefile" to ".wav" instead
-of ".ogg" for it to work correctly.
diff --git a/README.win32 b/README.win32
deleted file mode 100644 (file)
index 2aea90a..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-Tennix can now be built on win32! :)
-
-Guide on installing SDL + MSYS + MinGW on Win32:
-http://www.netadelica.com/coding/sdl/install.html
-
-Cross-compiling on a Debian System (untested!)
-http://wiki.njh.eu/MinGW-Cross-Compiling_mit_SDL
-
-You also need the win32 development packages of
-SDL_mixer, SDL_image and SDL_ttf, these can be found here:
-
-http://www.libsdl.org/projects/SDL_mixer/
-http://www.libsdl.org/projects/SDL_image/
-http://www.libsdl.org/projects/SDL_ttf/
-
-For these libraries, copy the *.h files
-to c:\mingw\include\SDL\ and the *.lib files to 
-c:\mingw\lib\. The .dll files have to be copied 
-to the tennix source folder, so they can be 
-found and copied to the binary release archive.
-
-
-You should also consider installing UPX and ZIP 
-into your $PATH, so the .exe file can be compressed
-and the "zip" utility (from InfoZIP) is needed for
-the "release-win32" makefile target, which will create
-a zipfile with the binary release, ready to be distributed :)
-
-=====================
-Additional notes on Git + Win32 resources + InnoSetup
-=====================
-** GIT **
-You can download and bootstrap Git ported to Windows from
-http://code.google.com/p/msysgit/. Simply download the 
-"GitMe-0.4.2.exe" (or newer) and run it to install Git and
-a local version of msys to c:\msysgit\.
-
-You will be able to use Git on tennix's public repository,
-see the Tennix website for more information.
-
-** Win32 resources **
-We are now using Win32 resource files to have an icon in the
-Windows executable an to store the layout of the startup 
-dialog (that is only displayed in Windows atm).
-
-I've edited the "tennix.res" file (which contains the icon and
-the dialog layout) with "XN Resource Editor", which is a freeware
-resource editor for Windows, but you might want to use another
-resource editor of you choice.
-
-URL: http://www.wilsonc.demon.co.uk/d10resourceeditor.htm
-
-** InnoSetup **
-Make sure you have installed InnoSetup 5 if you
-want to generate a setup installer. You also have to set
-the $PATH variable to point to the Inno Setup install dir
-on your hard drive (eg c:\program files\inno setup 5\). 
-To check if you have set it up correctly, open your msys
-shell and type "iscc". It should respond with "Inno Setup
-5 Command-Line Compiler" and some generic information.
-
-When you have set up iscc correctly, simply do a "make 
-release-win32-setup" to compile a single setup executable
-with innosetup and tennix.
-
-Thomas Perl <thp@perli.net>, 2007-11-21
-=====================
-
-
-#######======------ --- -- -  -
-Additional notes on libraries on Win32
-#######======------ --- -- -  -
-
-You might have to add some libraries for Tennix 1.0 (and later) to compile
-correctly under mingw32:
-
-  -lws2_32 -lkernel32
-
-This can be set as LDFLAGS and/or LIBS variable in the makefile. For some
-specific makefile targets (e.g. the "archive" utility), you might have to
-specify "-lws2_32" directly in the target to get the build going.
-
-#######======------ --- -- -  -
-
diff --git a/SDLMain.h b/SDLMain.h
deleted file mode 100644 (file)
index 4683df5..0000000
--- a/SDLMain.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*   SDLMain.m - main entry point for our Cocoa-ized SDL app
-       Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
-       Non-NIB-Code & other changes: Max Horn <max@quendi.de>
-
-    Feel free to customize this file to suit your needs
-*/
-
-#import <Cocoa/Cocoa.h>
-
-@interface SDLMain : NSObject
-@end
diff --git a/SDLMain.m b/SDLMain.m
deleted file mode 100644 (file)
index 2eaa1c1..0000000
--- a/SDLMain.m
+++ /dev/null
@@ -1,384 +0,0 @@
-/*   SDLMain.m - main entry point for our Cocoa-ized SDL app
-       Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
-       Non-NIB-Code & other changes: Max Horn <max@quendi.de>
-
-    Feel free to customize this file to suit your needs
-*/
-
-#import "SDL.h"
-#import "SDLMain.h"
-#import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
-
-/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
- but the method still is there and works. To avoid warnings, we declare
- it ourselves here. */
-@interface NSApplication(SDL_Missing_Methods)
-- (void)setAppleMenu:(NSMenu *)menu;
-@end
-
-/* Use this flag to determine whether we use SDLMain.nib or not */
-#define                SDL_USE_NIB_FILE        0
-
-/* Use this flag to determine whether we use CPS (docking) or not */
-#define                SDL_USE_CPS             1
-#ifdef SDL_USE_CPS
-/* Portions of CPS.h */
-typedef struct CPSProcessSerNum
-{
-       UInt32          lo;
-       UInt32          hi;
-} CPSProcessSerNum;
-
-extern OSErr   CPSGetCurrentProcess( CPSProcessSerNum *psn);
-extern OSErr   CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
-extern OSErr   CPSSetFrontProcess( CPSProcessSerNum *psn);
-
-#endif /* SDL_USE_CPS */
-
-static int    gArgc;
-static char  **gArgv;
-static BOOL   gFinderLaunch;
-static BOOL   gCalledAppMainline = FALSE;
-
-static NSString *getApplicationName(void)
-{
-    NSDictionary *dict;
-    NSString *appName = 0;
-
-    /* Determine the application name */
-    dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
-    if (dict)
-        appName = [dict objectForKey: @"CFBundleName"];
-    
-    if (![appName length])
-        appName = [[NSProcessInfo processInfo] processName];
-
-    return appName;
-}
-
-#if SDL_USE_NIB_FILE
-/* A helper category for NSString */
-@interface NSString (ReplaceSubString)
-- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
-@end
-#endif
-
-@interface SDLApplication : NSApplication
-@end
-
-@implementation SDLApplication
-/* Invoked from the Quit menu item */
-- (void)terminate:(id)sender
-{
-    /* Post a SDL_QUIT event */
-    SDL_Event event;
-    event.type = SDL_QUIT;
-    SDL_PushEvent(&event);
-}
-@end
-
-/* The main class of the application, the application's delegate */
-@implementation SDLMain
-
-/* Set the working directory to the .app's parent directory */
-- (void) setupWorkingDirectory:(BOOL)shouldChdir
-{
-    if (shouldChdir)
-    {
-        char parentdir[MAXPATHLEN];
-               CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
-               CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
-               if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
-               assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
-               }
-               CFRelease(url);
-               CFRelease(url2);
-       }
-
-}
-
-#if SDL_USE_NIB_FILE
-
-/* Fix menu to contain the real app name instead of "SDL App" */
-- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
-{
-    NSRange aRange;
-    NSEnumerator *enumerator;
-    NSMenuItem *menuItem;
-
-    aRange = [[aMenu title] rangeOfString:@"SDL App"];
-    if (aRange.length != 0)
-        [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
-
-    enumerator = [[aMenu itemArray] objectEnumerator];
-    while ((menuItem = [enumerator nextObject]))
-    {
-        aRange = [[menuItem title] rangeOfString:@"SDL App"];
-        if (aRange.length != 0)
-            [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
-        if ([menuItem hasSubmenu])
-            [self fixMenu:[menuItem submenu] withAppName:appName];
-    }
-    [ aMenu sizeToFit ];
-}
-
-#else
-
-static void setApplicationMenu(void)
-{
-    /* warning: this code is very odd */
-    NSMenu *appleMenu;
-    NSMenuItem *menuItem;
-    NSString *title;
-    NSString *appName;
-    
-    appName = getApplicationName();
-    appleMenu = [[NSMenu alloc] initWithTitle:@""];
-    
-    /* Add menu items */
-    title = [@"About " stringByAppendingString:appName];
-    [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
-
-    [appleMenu addItem:[NSMenuItem separatorItem]];
-
-    title = [@"Hide " stringByAppendingString:appName];
-    [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
-
-    menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
-    [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
-
-    [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
-
-    [appleMenu addItem:[NSMenuItem separatorItem]];
-
-    title = [@"Quit " stringByAppendingString:appName];
-    [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
-
-    
-    /* Put menu into the menubar */
-    menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
-    [menuItem setSubmenu:appleMenu];
-    [[NSApp mainMenu] addItem:menuItem];
-
-    /* Tell the application object that this is now the application menu */
-    [NSApp setAppleMenu:appleMenu];
-
-    /* Finally give up our references to the objects */
-    [appleMenu release];
-    [menuItem release];
-}
-
-/* Create a window menu */
-static void setupWindowMenu(void)
-{
-    NSMenu      *windowMenu;
-    NSMenuItem  *windowMenuItem;
-    NSMenuItem  *menuItem;
-
-    windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
-    
-    /* "Minimize" item */
-    menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
-    [windowMenu addItem:menuItem];
-    [menuItem release];
-    
-    /* Put menu into the menubar */
-    windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
-    [windowMenuItem setSubmenu:windowMenu];
-    [[NSApp mainMenu] addItem:windowMenuItem];
-    
-    /* Tell the application object that this is now the window menu */
-    [NSApp setWindowsMenu:windowMenu];
-
-    /* Finally give up our references to the objects */
-    [windowMenu release];
-    [windowMenuItem release];
-}
-
-/* Replacement for NSApplicationMain */
-static void CustomApplicationMain (int argc, char **argv)
-{
-    NSAutoreleasePool  *pool = [[NSAutoreleasePool alloc] init];
-    SDLMain                            *sdlMain;
-
-    /* Ensure the application object is initialised */
-    [SDLApplication sharedApplication];
-    
-#ifdef SDL_USE_CPS
-    {
-        CPSProcessSerNum PSN;
-        /* Tell the dock about us */
-        if (!CPSGetCurrentProcess(&PSN))
-            if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
-                if (!CPSSetFrontProcess(&PSN))
-                    [SDLApplication sharedApplication];
-    }
-#endif /* SDL_USE_CPS */
-
-    /* Set up the menubar */
-    [NSApp setMainMenu:[[NSMenu alloc] init]];
-    setApplicationMenu();
-    setupWindowMenu();
-
-    /* Create SDLMain and make it the app delegate */
-    sdlMain = [[SDLMain alloc] init];
-    [NSApp setDelegate:sdlMain];
-    
-    /* Start the main event loop */
-    [NSApp run];
-    
-    [sdlMain release];
-    [pool release];
-}
-
-#endif
-
-
-/*
- * Catch document open requests...this lets us notice files when the app
- *  was launched by double-clicking a document, or when a document was
- *  dragged/dropped on the app's icon. You need to have a
- *  CFBundleDocumentsType section in your Info.plist to get this message,
- *  apparently.
- *
- * Files are added to gArgv, so to the app, they'll look like command line
- *  arguments. Previously, apps launched from the finder had nothing but
- *  an argv[0].
- *
- * This message may be received multiple times to open several docs on launch.
- *
- * This message is ignored once the app's mainline has been called.
- */
-- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
-{
-    const char *temparg;
-    size_t arglen;
-    char *arg;
-    char **newargv;
-
-    if (!gFinderLaunch)  /* MacOS is passing command line args. */
-        return FALSE;
-
-    if (gCalledAppMainline)  /* app has started, ignore this document. */
-        return FALSE;
-
-    temparg = [filename UTF8String];
-    arglen = SDL_strlen(temparg) + 1;
-    arg = (char *) SDL_malloc(arglen);
-    if (arg == NULL)
-        return FALSE;
-
-    newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
-    if (newargv == NULL)
-    {
-        SDL_free(arg);
-        return FALSE;
-    }
-    gArgv = newargv;
-
-    SDL_strlcpy(arg, temparg, arglen);
-    gArgv[gArgc++] = arg;
-    gArgv[gArgc] = NULL;
-    return TRUE;
-}
-
-
-/* Called when the internal event loop has just started running */
-- (void) applicationDidFinishLaunching: (NSNotification *) note
-{
-    int status;
-
-    /* Set the working directory to the .app's parent directory */
-    [self setupWorkingDirectory:gFinderLaunch];
-
-#if SDL_USE_NIB_FILE
-    /* Set the main menu to contain the real app name instead of "SDL App" */
-    [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
-#endif
-
-    /* Hand off to main application code */
-    gCalledAppMainline = TRUE;
-    status = SDL_main (gArgc, gArgv);
-
-    /* We're done, thank you for playing */
-    exit(status);
-}
-@end
-
-
-@implementation NSString (ReplaceSubString)
-
-- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
-{
-    unsigned int bufferSize;
-    unsigned int selfLen = [self length];
-    unsigned int aStringLen = [aString length];
-    unichar *buffer;
-    NSRange localRange;
-    NSString *result;
-
-    bufferSize = selfLen + aStringLen - aRange.length;
-    buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
-    
-    /* Get first part into buffer */
-    localRange.location = 0;
-    localRange.length = aRange.location;
-    [self getCharacters:buffer range:localRange];
-    
-    /* Get middle part into buffer */
-    localRange.location = 0;
-    localRange.length = aStringLen;
-    [aString getCharacters:(buffer+aRange.location) range:localRange];
-     
-    /* Get last part into buffer */
-    localRange.location = aRange.location + aRange.length;
-    localRange.length = selfLen - localRange.location;
-    [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
-    
-    /* Build output string */
-    result = [NSString stringWithCharacters:buffer length:bufferSize];
-    
-    NSDeallocateMemoryPages(buffer, bufferSize);
-    
-    return result;
-}
-
-@end
-
-
-
-#ifdef main
-#  undef main
-#endif
-
-
-/* Main entry point to executable - should *not* be SDL_main! */
-int main (int argc, char **argv)
-{
-    /* Copy the arguments into a global variable */
-    /* This is passed if we are launched by double-clicking */
-    if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
-        gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
-        gArgv[0] = argv[0];
-        gArgv[1] = NULL;
-        gArgc = 1;
-        gFinderLaunch = YES;
-    } else {
-        int i;
-        gArgc = argc;
-        gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
-        for (i = 0; i <= argc; i++)
-            gArgv[i] = argv[i];
-        gFinderLaunch = NO;
-    }
-
-#if SDL_USE_NIB_FILE
-    [SDLApplication poseAsClass:[NSApplication class]];
-    NSApplicationMain (argc, argv);
-#else
-    CustomApplicationMain (argc, argv);
-#endif
-    return 0;
-}
-
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..4c19a64
--- /dev/null
+++ b/configure
@@ -0,0 +1,334 @@
+#!/bin/sh
+# Configuration script for Tennix
+# 2013-07-27 Thomas Perl <m@thp.io>
+
+V="1.2.0"
+SILENT="1"
+PREFIX="/usr/local"
+DEFAULT_CFLAGS="-I. -Wno-char-subscripts -Wno-maybe-uninitialized"
+
+if [ -z "$CC" ]; then
+    CC="gcc"
+fi
+
+if [ -z "$CXX" ]; then
+    CXX="g++"
+fi
+
+if [ -z "$CFLAGS" ]; then
+    CFLAGS=""
+fi
+
+if [ -z "$LDFLAGS" ]; then
+    LDFLAGS=""
+fi
+
+CFLAGS="$DEFAULT_CFLAGS $CFLAGS"
+
+PLATFORM=""
+
+GENERATED_HEADER="Generated: $(date)"
+CONFIG_H="/* $GENERATED_HEADER */"
+CONFIG_MK="# $GENERATED_HEADER"
+
+NL='
+'
+
+fail() {
+    echo "ERROR: $1"
+    exit 1
+}
+
+set_make_variable() {
+    CONFIG_MK="$CONFIG_MK$NL$1 := $2"
+}
+
+define_macro() {
+    CONFIG_H="$CONFIG_H$NL#define $1"
+}
+
+undefine_macro() {
+    CONFIG_H="$CONFIG_H$NL#undef $1"
+}
+
+add_definition() {
+    define_macro $1
+    set_make_variable $1 1
+}
+
+no_definition() {
+    undefine_macro $1
+    set_make_variable $1 0
+}
+
+cond_definition() {
+    if [ $1 -eq 0 ]; then
+        add_definition $2
+    else
+        no_definition $2
+    fi
+}
+
+check_cc() {
+    echo "int main() { return 0; }" | $CC $CFLAGS -x c -c -o /dev/null - 2>/dev/null
+}
+
+check_cxx() {
+    echo "class A { public: A() {} }; int main() { A a; }" | $CXX $CFLAGS -x c++ -c -o /dev/null -
+}
+
+check_linker_cc() {
+    echo "int main() { return 0; }" | $CC $CFLAGS $LDFLAGS -l$1 -x c -o /dev/null - 2>/dev/null
+}
+
+check_header_cc() {
+    echo "#include <$1>" | $CC $CFLAGS -c -x c -o /dev/null -c - 2>/dev/null
+}
+
+message_wrapper() {
+    echo -n "$1 ... "
+    shift
+    $*
+    if [ $? -eq 0 ]; then
+        echo "yes"
+        return 0
+    else
+        echo "no"
+        return 1
+    fi
+}
+
+check_sdl_lib() {
+    if ! which sdl-config >/dev/null 2>&1; then
+        return 1
+    fi
+
+    CFLAGS="$(sdl-config --cflags) $CFLAGS"
+    LDFLAGS="$(sdl-config --libs) $LDFLAGS"
+    return 0
+}
+
+check_os() {
+    echo -n "Detecting operating system ... "
+    UNAME=$(uname -s)
+    case $UNAME in
+        Linux)
+            echo "Linux"
+            PLATFORM="linux"
+            ;;
+        Darwin)
+            echo "Mac OS X"
+            PLATFORM="osx"
+            ;;
+        *)
+            echo "???"
+            fail "Unknown platform: $UNAME"
+            ;;
+    esac
+}
+
+check_compiler() {
+    message_wrapper "Testing working C compiler ($CC)" check_cc || fail "C compiler ($CC) not working"
+    message_wrapper "Testing working C++ compiler ($CXX)" check_cxx || fail "C++ compiler ($CXX) not working"
+}
+
+check_sdl() {
+    message_wrapper "Checking for SDL 1.2" check_sdl_lib
+    cond_definition $? HAVE_SDL
+}
+
+require_sdl() {
+    check_sdl || fail "SDL not found"
+}
+
+check_voice_files() {
+    message_wrapper "Checking for voice files" [ -f voice/deuce.ogg ]
+    cond_definition $? HAVE_VOICE_FILES
+}
+
+check_python_lib() {
+    if ! which python-config >/dev/null 2>&1; then
+        return 1
+    fi
+
+    CFLAGS="$(python-config --cflags) $CFLAGS"
+    LDFLAGS="$(python-config --libs) $LDFLAGS"
+    return 0
+}
+
+check_tool_path() {
+    COMMAND=$1
+    VARIABLE=$2
+
+    if ! which $COMMAND >/dev/null 2>&1; then
+        return 1
+    fi
+
+    if [ "$VARIABLE" != "" ]; then
+        set_make_variable $VARIABLE $(which $COMMAND 2>/dev/null)
+    fi
+}
+
+check_tool() {
+    message_wrapper "Checking for $1" check_tool_path $*
+}
+
+require_tool() {
+    check_tool $* || fail "Required command '$1' not found"
+}
+
+check_python() {
+    message_wrapper "Checking for libpython" check_python_lib
+    cond_definition $? HAVE_PYTHON
+}
+
+check_header() {
+    message_wrapper "Checking for $1" check_header_cc $1
+}
+
+check_linker() {
+    message_wrapper "Checking for -l$1" check_linker_cc $1
+}
+
+check_library() {
+    LIBRARY=$1
+    HEADER=$2
+    DEFINE=$3
+    check_linker $LIBRARY
+    HAVE_LINKER=$?
+    check_header $HEADER
+    HAVE_HEADER=$?
+    if [ $HAVE_LINKER -eq 0 -a $HAVE_HEADER -eq 0 ]; then
+        add_definition $DEFINE
+        LDFLAGS="-l$LIBRARY $LDFLAGS"
+    else
+        no_definition $DEFINE
+        return 1
+    fi
+    return 0
+}
+
+require_library() {
+    check_library $* || fail "Library $1 ($2) not found"
+}
+
+generate_dependencies() {
+    echo "Generating dependencies.mk"
+    rm -f dependencies.mk
+    (
+    echo "# $GENERATED_HEADER"
+    for filename in src/*.cc; do $CXX -MM $filename $CFLAGS -o -; done
+    )>dependencies.mk
+}
+
+write_config() {
+    echo "Writing config.h"
+    rm -f config.h
+    (
+    echo "$CONFIG_H"
+    echo "#define VERSION \"$V\""
+    echo "#define PREFIX \"$PREFIX\""
+    )>config.h
+
+    echo "Writing config.mk"
+    rm -f config.mk
+    (
+    echo "$CONFIG_MK"
+    echo "V = $V"
+    echo "SILENT = $SILENT"
+    echo "PREFIX = $PREFIX"
+    echo "PLATFORM = $PLATFORM"
+    echo "CC = $CC"
+    echo "CXX = $CXX"
+    echo "CFLAGS = $CFLAGS"
+    echo "CXXFLAGS = $CFLAGS"
+    echo "LDFLAGS = $LDFLAGS"
+    )>config.mk
+}
+
+usage() {
+    cat <<EOF
+
+    Usage: $0 [options]
+    
+    Supported options:
+    --prefix PREFIX             Install into PREFIX (default: $PREFIX)
+    --help | -h                 Show this help message
+    --with-debug                Enable additional debugging output
+    --enable-update-rect        Visualize screen updates
+    --enable-nonfree-locations  Additional tennis courts on world map
+    --enable-fps-limit          Limit frame rate
+    --disable-silent            Disable silent make output
+
+EOF
+}
+
+parse_arguments() {
+    while [ $# -gt 0 ]; do
+        case $1 in
+            --prefix)
+                [ $# -gt 1 ] || fail "Not enough arguments."
+                PREFIX="$2"
+                shift
+                ;;
+            --with-debug)
+                define_macro DEBUG
+                CFLAGS="-g $CFLAGS"
+                ;;
+            --enable-update-rect)
+                define_macro DRAW_UPDATE_RECTANGLE
+                ;;
+            --enable-nonfree-locations)
+                define_macro NONFREE_LOCATIONS
+                ;;
+            --enable-fps-limit)
+                define_macro ENABLE_FPS_LIMIT
+                ;;
+            --disable-silent)
+                SILENT="0"
+                ;;
+            -h|--help)
+                usage
+                exit 0
+                ;;
+            *)
+                usage
+                fail "Unknown argument: $1"
+                ;;
+        esac
+        shift
+    done
+}
+
+# Parse command-line arguments
+parse_arguments $*
+
+# Check for compatible OS and working compiler
+check_os
+check_compiler
+
+# Check for command-line tools needed for build
+require_tool make
+
+# Check for command-line tools required in makefile
+require_tool ln LN
+require_tool install INSTALL
+require_tool rm RM
+
+# Check for SDL 1.2 and libpython
+require_sdl
+check_python
+
+# Check for mandatory and optional libraries
+require_library SDL_image SDL_image.h HAVE_SDL_IMAGE
+require_library SDL_ttf SDL_ttf.h HAVE_SDL_TTF
+check_library SDL_net SDL_net.h HAVE_SDL_NET
+require_library SDL_mixer SDL_mixer.h HAVE_SDL_MIXER
+
+# Check for optional game content
+check_voice_files
+
+# Save configuration results and generate dependency file
+write_config
+generate_dependencies
+
diff --git a/data/Tennix.icns b/data/Tennix.icns
deleted file mode 100644 (file)
index 5cbc1b8..0000000
Binary files a/data/Tennix.icns and /dev/null differ
similarity index 100%
rename from defaultbot.py
rename to data/defaultbot.py
diff --git a/data/icon.ico b/data/icon.ico
deleted file mode 100644 (file)
index 31494a7..0000000
Binary files a/data/icon.ico and /dev/null differ
diff --git a/data/icon.svg b/data/icon.svg
deleted file mode 100644 (file)
index efd874e..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:xlink="http://www.w3.org/1999/xlink"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   version="1.0"
-   width="192"
-   height="192"
-   id="svg2670">
-  <defs
-     id="defs2672">
-    <linearGradient
-       id="linearGradient3251">
-      <stop
-         id="stop3253"
-         style="stop-color:#c4a000;stop-opacity:1"
-         offset="0" />
-      <stop
-         id="stop3255"
-         style="stop-color:#c4a000;stop-opacity:0"
-         offset="1" />
-    </linearGradient>
-    <radialGradient
-       cx="325.09344"
-       cy="571.14868"
-       r="14.484375"
-       fx="325.09344"
-       fy="571.14868"
-       id="radialGradient3257"
-       xlink:href="#linearGradient3251"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(-3.9244563,5.569333,-3.7924285,-2.8791725,3790.1943,438.67101)" />
-    <linearGradient
-       id="linearGradient3238">
-      <stop
-         id="stop3240"
-         style="stop-color:#eeeeec;stop-opacity:1"
-         offset="0" />
-      <stop
-         id="stop3242"
-         style="stop-color:#eeeeec;stop-opacity:0"
-         offset="1" />
-    </linearGradient>
-    <radialGradient
-       cx="318.72839"
-       cy="498.87436"
-       r="13.081475"
-       fx="318.72839"
-       fy="498.87436"
-       id="radialGradient3244"
-       xlink:href="#linearGradient3238"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(1.0472545,0.1070136,-0.3757488,1.0270592,172.3901,-47.607388)" />
-    <filter
-       id="filter3331"
-       height="1.2446054"
-       y="-0.1223027"
-       width="1.2103326"
-       x="-0.10516628">
-      <feGaussianBlur
-         id="feGaussianBlur3333"
-         stdDeviation="1.4858337"
-         inkscape:collect="always" />
-    </filter>
-    <inkscape:perspective
-       id="perspective2678" />
-    <radialGradient
-       cx="325.09344"
-       cy="571.14868"
-       r="14.484375"
-       fx="325.09344"
-       fy="571.14868"
-       id="radialGradient2714"
-       xlink:href="#linearGradient3251"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(-3.9244563,5.569333,-3.7924285,-2.8791725,3790.1943,438.67101)" />
-    <radialGradient
-       cx="318.72839"
-       cy="498.87436"
-       r="13.081475"
-       fx="318.72839"
-       fy="498.87436"
-       id="radialGradient2716"
-       xlink:href="#linearGradient3238"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(1.0472545,0.1070136,-0.3757488,1.0270592,172.3901,-47.607388)" />
-  </defs>
-  <g
-     transform="translate(-334.55369,-546.93655)"
-     id="layer1">
-    <g
-       transform="translate(9.8043428,9.8785768)"
-       id="g2701">
-      <path
-         d="M 355.06861,515.33984 A 23.359777,23.359777 0 1 1 308.34905,515.33984 A 23.359777,23.359777 0 1 1 355.06861,515.33984 z"
-         transform="matrix(3.6099242,0,0,3.6099242,-776.62018,-1227.2798)"
-         id="path3210"
-         style="opacity:1;fill:#edd400;fill-opacity:1;fill-rule:evenodd;stroke:#2e3436;stroke-width:0.99415743;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-      <path
-         d="M 358.60884,688.05144 C 404.94326,683.4226 438.93823,640.62117 434.47868,592.52711 C 432.98809,576.45194 427.30894,561.85432 418.78571,549.65466 C 416.12032,549.65807 413.52319,549.71258 410.81664,549.983 C 364.48222,554.61184 330.48732,597.41345 334.94681,645.50733 C 336.43976,661.60798 342.09375,676.16849 350.63977,688.37974 C 353.26852,688.37274 355.94015,688.31801 358.60884,688.05144 z"
-         id="path3246"
-         style="opacity:1;fill:url(#radialGradient2714);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-      <path
-         d="M 331.80987,498.87436 A 13.081475,12.020815 0 1 1 305.64692,498.87436 A 13.081475,12.020815 0 1 1 331.80987,498.87436 z"
-         transform="matrix(3.480607,-1.5084662,1.7629288,6.2370256,-1533.3975,-2000.808)"
-         id="path3236"
-         style="opacity:0.83769633;fill:url(#radialGradient2716);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-      <path
-         d="M 424.9519,558.98875 C 424.95345,559.32079 424.78746,560.30438 424.5033,562.57758 C 424.35375,563.77388 424.80236,560.18505 424.9519,558.98875 C 426.65035,545.40107 421.6697,573.03745 428.09213,566.61502 C 434.94504,559.76214 428.2935,583.25924 435.7184,568.40944 C 437.22363,565.39898 435.63855,584.71889 440.65305,574.68989 C 448.71823,558.55952 443.04691,574.0944 447.83071,583.66198 C 449.20775,586.41601 450.8214,589.04522 452.31675,591.73685 C 454.09707,594.94143 451.71318,584.24922 450.07373,580.97035 C 449.23269,579.2883 450.16941,596.90678 458.59721,591.28825 C 464.06168,587.64529 471.62263,601.4852 472.05534,604.29776 C 472.56631,607.61909 473.97694,597.79469 475.64417,594.87708 C 476.32605,593.68383 481.02742,623.64929 481.02742,606.54079 C 481.02742,585.04228 486.00276,598.87418 483.71904,613.71845 C 483.25529,616.73293 484.91531,619.69985 485.51346,622.69053 C 488.30144,636.63053 453.44799,600.07841 456.35419,590.39104 C 468.08849,551.27671 482.53125,633.40614 481.47602,639.73749 C 481.04669,642.31348 480.27976,644.82168 479.68161,647.36376 C 479.30485,648.96492 480.00421,644.04204 479.68161,642.42912 C 478.85269,638.28462 472.20366,678.62142 475.19556,666.65374 C 476.5955,661.05397 477.16049,655.00492 480.13021,650.05539 C 481.14212,648.36885 479.53206,653.94331 479.233,655.88724 C 477.80156,665.19161 478.41672,640.98037 484.16765,649.60678 C 484.72406,650.44144 485.06486,651.4012 485.51346,652.29841 C 486.47013,654.21172 487.82481,646.5735 489.10229,640.18609 C 485.50793,641.8863 486.41067,664.47219 486.41067,650.05539 C 486.41067,648.56006 486.41067,647.0647 486.41067,645.56934 C 486.41067,643.23355 483.11662,649.01078 481.02742,650.05539 C 467.12446,657.00688 448.50466,602.28418 451.86815,619.1017 C 456.95091,644.51541 446.60793,628.72491 456.8028,608.3352 C 462.61911,596.70257 450.94008,649.76114 454.55978,631.66262 C 456.78661,620.52841 456.22758,614.18633 462.63465,605.64358 C 465.05665,602.41424 459.38884,640.45009 465.77488,624.48495 C 476.35777,598.02775 468.03545,649.53662 471.15813,637.04587 C 473.66572,627.01554 473.69195,613.44717 470.26092,604.29776 C 468.21525,598.84267 457.25779,574.22209 452.76536,587.69941 C 448.36096,600.9126 450.2428,607.93842 451.41955,602.05474 C 452.27355,597.78479 448.77533,610.36483 447.83071,614.61566 C 445.46571,625.25816 439.18866,638.45879 437.06421,623.58774 C 435.3222,611.39371 440.74546,595.00107 433.47538,599.36312 C 429.61796,601.67759 434.36513,589.95241 437.06421,586.3536 C 444.43772,576.52228 434.37259,598.06525 434.37259,606.98939 C 433.04917,597.40785 431.68097,587.94105 431.68097,578.27873 C 431.68097,571.71963 426.98071,590.59851 423.60609,596.22289 C 422.78827,597.58593 421.51262,598.61546 420.46586,599.81172 C 415.54209,605.43891 427.31253,565.4826 414.63401,590.83964 C 412.83959,594.42847 411.04518,598.01731 409.25076,601.60614 C 409.12583,601.85599 406.55913,586.05006 406.55913,584.11058 C 406.55913,567.71801 408.22819,573.97744 402.07309,590.39104 C 401.25125,592.58259 399.97962,594.57802 398.93286,596.67149 C 398.58281,597.37157 397.1706,583.5013 399.38147,572.44687 C 401.95969,559.55575 395.35548,584.08772 392.65241,589.49383 C 384.64271,605.51327 391.40536,565.3721 392.2038,562.57758 C 394.06616,556.05929 376.83671,607.67665 380.5401,585.45639 C 385.18552,557.58383 376.3586,596.27091 363.04453,600.70893 C 361.96394,601.06914 371.52688,568.65624 368.42778,587.25081 C 364.84656,608.73812 372.91383,590.27741 372.91383,604.29776 C 372.91383,608.79378 373.51198,613.26985 373.81103,617.75589 C 373.81103,601.44001 373.81103,611.47543 373.81103,614.16706 C 373.81103,640.95314 371.56801,638.43916 371.56801,615.06426 C 371.56801,612.51314 368.53681,620.45308 367.53058,622.24193 C 366.14977,624.69673 369.2408,603.97545 363.94174,611.92403 C 362.38146,614.26446 358.55849,636.02186 358.55849,620.89612 C 358.55849,604.15443 354.96966,636.62866 354.96966,620.44751 C 354.96966,617.03762 353.17524,613.868 352.27804,610.57822 C 351.25202,606.81612 340.04726,647.15209 347.34339,632.55982 C 349.98204,627.28252 380.81432,572.5587 372.46522,610.12962 C 371.684,613.64513 371.86707,617.30728 371.56801,620.89612 C 371.54214,621.2068 383.37628,606.61346 383.68032,606.09218 C 384.39956,604.85924 381.95664,631.89901 385.02614,622.69053 C 393.54018,597.14845 392.91834,578.94488 395.34403,617.75589 C 395.64542,622.5781 399.39995,608.94347 400.72728,604.29776 C 405.15124,588.81389 415.97982,588.8089 415.97982,603.40056 C 415.97982,609.94914 412.57474,623.49587 422.26028,618.6531 C 424.33983,617.61334 424.4013,588.7799 428.54074,617.75589 C 431.46413,638.21963 450.23803,585.91835 432.12957,589.94243 C 430.17674,590.37639 411.68643,568.61856 410.59657,566.16641 C 408.64127,561.76697 411.49378,566.14144 411.49378,561.23177 C 411.49378,560.07724 431.04793,562.2875 433.02678,563.47479 C 439.34398,567.2651 444.24188,553.61792 444.24188,575.5871 C 444.24188,585.80085 433.45589,594.45575 444.69048,578.72733 C 451.97883,568.52367 435.24468,616.46032 442.89607,601.15754 C 444.94454,597.0606 451.41955,561.35594 451.41955,594.87708 C 451.41955,620.49334 459.04582,602.08629 459.04582,610.12962 C 459.04582,646.96124 459.49442,596.00476 459.49442,622.69053 C 459.49442,631.22112 458.5479,647.46242 454.11117,656.33584 C 449.92182,664.71451 435.19651,679.79594 427.19492,669.79397 C 414.94534,654.48196 404.35911,648.91066 417.77424,631.66262 C 433.1081,611.94765 413.3693,650.99437 410.59657,657.23305 C 401.20029,678.37469 408.81145,640.11163 409.69936,633.00843 C 410.05128,630.19313 411.49378,627.62518 412.39099,624.93355 C 417.27683,610.27601 397.54198,657.9285 412.39099,650.50399 C 412.8289,650.28503 394.02115,647.81236 392.65241,647.81236 C 380.82587,647.81236 369.7736,625.1837 369.7736,643.77493 C 369.7736,656.98402 364.22745,656.8671 362.14733,646.46655 C 354.53954,608.42758 354.07245,673.0583 354.07245,643.77493 C 354.07245,640.92984 355.30267,649.56278 354.52106,652.29841 C 349.73301,669.05653 355.65821,629.10658 370.2222,650.95259 C 372.9795,655.08851 385.70084,661.05153 384.12893,656.33584 C 381.02491,647.02379 380.39464,662.4403 380.09149,664.41072 C 379.46258,668.49854 381.78,656.31086 382.78312,652.29841 C 383.89052,647.86878 390.07408,628.59639 396.24124,624.48495 C 403.03329,619.95692 394.80025,640.8342 392.65241,648.70957 C 391.33918,653.52467 391.15705,658.57886 390.40939,663.51351 C 389.12527,671.98872 388.69787,648.83023 394.89543,641.0833 C 407.70853,625.06692 398.52532,658.21237 402.07309,665.30793 C 407.32424,675.81021 399.18161,651.15246 408.35355,641.98051 C 416.45753,633.87657 399.80926,666.65894 412.39099,663.51351 C 416.3373,662.52694 414.78356,655.73773 415.97982,651.8498 C 417.1631,648.00415 421.96122,646.46655 424.9519,643.77493 C 427.81884,641.1947 422.14113,658.54208 428.98934,667.10234 C 432.3065,671.24881 426.52945,652.68909 431.68097,651.4012 C 432.05646,651.30735 440.18639,620.57388 436.61561,645.56934 C 436.15035,648.82607 436.61561,652.14889 436.61561,655.43863 C 436.61561,659.98655 438.85863,646.52842 438.85863,641.98051 C 438.85863,639.03501 444.13917,644.6379 446.93351,645.56934 C 458.43869,649.40441 457.2514,604.17165 457.2514,636.59726 C 457.2514,637.86613 459.04582,634.80285 459.94302,633.90564 C 464.46011,629.38855 462.7318,646.46088 465.32627,652.29841 C 468.63608,659.74541 462.69824,659.15552 472.95254,661.71909 C 482.73455,664.16459 476.53614,674.51217 484.16765,663.0649 C 494.14109,648.10475 488.32843,657.43496 486.85927,660.37328 C 485.94968,662.19246 488.1604,656.5146 488.65369,654.54143 C 489.69416,650.37956 490.2734,645.37092 491.34531,641.0833 C 492.31846,637.19068 489.17202,649.44234 485.96206,651.8498 C 473.09542,661.49978 435.2698,630.46858 435.2698,654.09282 C 435.2698,665.87632 438.85863,678.25155 438.85863,690.42976 C 438.85863,697.01609 472.50394,696.56749 472.50394,689.98115 C 472.50394,685.95872 465.00981,666.60159 467.12069,672.9342 C 468.2722,676.38873 464.72812,679.8128 463.53186,683.25209 C 463.32069,683.85918 463.98046,657.915 463.98046,669.79397 C 463.98046,687.90207 453.21396,702.8899 453.21396,675.17722 C 453.21396,672.03304 449.78591,686.42605 446.93351,677.86884 C 441.7199,662.22799 448.08868,638.1954 436.16701,667.99955 C 419.01127,710.88887 426.29772,678.01537 426.29772,655.43863 C 426.29772,650.98292 420.46586,706.21908 420.46586,680.56047 C 420.46586,649.32814 422.4395,719.38701 393.99822,698.05603 C 387.83045,693.4302 390.55186,662.35765 385.02614,654.99003 C 384.03835,653.673 354.80307,665.14133 365.28756,675.62582 C 369.00394,679.3422 365.43577,663.06096 368.87639,673.3828 C 369.44777,675.09693 370.11716,669.95155 371.11941,668.44815 C 375.77671,661.46224 364.77087,661.16752 375.15685,667.10234 C 381.73715,670.86251 385.92334,633.0988 385.92334,631.66262 C 385.92334,622.72793 391.7552,665.48923 391.7552,650.95259 C 391.7552,649.99509 392.95146,649.45727 393.54961,648.70957 C 397.3897,643.90947 394.81888,665.11126 398.03566,682.80349 C 400.91221,698.6245 399.25249,711.26185 402.07309,697.15882 C 405.25043,681.27213 436.03928,629.99596 417.77424,648.26097 C 413.83818,652.19702 417.09437,694.00466 418.67145,697.15882 C 430.40129,720.61848 429.40428,678.72682 430.78376,671.13978 C 433.13401,658.21334 435.05135,628.34689 440.65305,621.34472 C 444.10934,617.02434 440.65305,632.41031 440.65305,637.94307 C 440.65305,651.77989 440.52841,675.30178 445.58769,683.25209 C 451.23569,692.12753 444.69048,674.14449 444.69048,660.82188 C 444.69048,646.25499 447.54102,618.49418 456.35419,609.68101 C 459.27507,606.76017 456.86126,625.51954 455.45698,643.77493 C 454.9904,649.84034 455.63011,679.47434 459.94302,685.94371 C 462.02168,689.06169 457.20955,678.7242 454.55978,676.07442 C 441.69747,663.21212 433.36764,649.68452 417.77424,639.28889 C 408.49308,633.10145 425.48632,622.78287 431.68097,618.6531 C 442.3529,611.53849 427.19338,646.47725 424.5033,665.30793 C 421.3054,687.69331 407.00774,617.3174 407.00774,614.16706 C 407.00774,611.32592 407.00774,608.48475 407.00774,605.64358 C 407.00774,599.79766 404.29121,609.91357 402.07309,617.30728 C 396.16121,637.01364 394.9742,652.64412 392.2038,672.03699 C 391.10885,679.70162 387.71776,685.01453 387.71776,694.9158"
-         id="path3348"
-         style="opacity:0.71204188;fill:none;fill-rule:evenodd;stroke:#8ae234;stroke-width:1.0766499;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-      <path
-         d="M 501.80098,621.4001 C 446.84859,657.81929 439.98161,700.7615 438.38609,714.24059"
-         id="path3214"
-         style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#555753;stroke-width:3.58883286;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-      <path
-         d="M 345.48804,668.92393 C 384.682,661.67287 414.46096,627.32723 414.46092,586.04431 C 414.46092,573.92231 411.89498,562.37058 407.28325,551.9504"
-         id="path3216"
-         style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:3.58883286;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-      <path
-         d="M 348.49244,558.7948 C 354.98342,559.46959 341.4072,561.12718 349.74244,565.2948 C 354.12699,567.48707 345.50067,567.80303 348.99244,571.2948 C 350.99315,573.29551 347.48286,574.32172 345.74244,574.6698 C 344.631,574.89209 347.57577,576.00314 348.49244,576.6698 C 353.71834,580.47045 356.05815,578.82773 350.99244,580.6698 C 347.54297,581.92415 343.65911,581.00314 339.99244,581.1698 C 338.402,581.24209 343.2175,581.21232 344.74244,581.6698 C 348.67271,582.84888 351.99847,582.43924 348.36744,584.4198 C 346.81725,585.26536 351.75383,585.45264 353.36744,586.1698 C 357.89294,588.18113 356.01084,584.23988 360.74244,582.1698 C 361.25874,581.94392 360.13537,582.03587 353.99244,582.4198 C 353.25607,582.46583 337.26173,583.66208 342.24244,581.6698 C 351.3568,578.02406 360.5912,576.40461 370.24244,574.9198 C 371.13056,574.78317 362.08381,574.17633 361.99244,574.1698 C 347.40036,573.12751 354.29641,572.31185 356.99244,566.9198 C 357.79861,565.30747 341.0422,562.4198 346.49244,562.4198 C 349.43458,562.4198 352.40249,561.9198 355.36744,561.9198 C 358.00704,561.9198 340.74974,562.69923 348.36744,560.7948 C 350.77637,560.19257 375.31154,558.47034 357.99244,560.0448 C 355.33154,560.2867 352.65911,560.37814 349.99244,560.5448 C 348.63788,560.62946 352.6073,559.79886 353.86744,559.2948 C 359.36675,557.09508 379.8446,558.2948 370.99244,558.2948 C 369.04879,558.2948 367.65911,560.2948 365.99244,561.2948 C 363.38287,562.86054 355.95264,565.51454 353.49244,568.7948 C 350.95571,572.17711 359.05169,567.60839 362.99244,566.2948 C 364.53405,565.78093 366.24244,566.2948 367.86744,566.2948 C 369.36975,566.2948 365.17974,567.73251 364.11744,568.7948 C 359.5415,573.37075 367.83428,571.57796 360.86744,578.5448 C 360.82577,578.58647 360.95077,578.62814 360.99244,578.6698 C 361.96783,579.64519 358.49244,579.83647 357.24244,580.4198 C 351.51926,583.09062 360.13708,583.45908 360.74244,584.6698"
-         transform="matrix(3.588833,0,0,3.588833,-866.10363,-1415.9274)"
-         id="path3261"
-         style="opacity:0.49214663;fill:none;fill-rule:evenodd;stroke:#ce5c00;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter3331)" />
-      <path
-         d="M 355.06861,515.33984 A 23.359777,23.359777 0 1 1 308.34905,515.33984 A 23.359777,23.359777 0 1 1 355.06861,515.33984 z"
-         transform="matrix(3.6099242,0,0,3.6099242,-776.62018,-1227.2798)"
-         id="path3338"
-         style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#2e3436;stroke-width:0.99415743;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-      <path
-         d="M 498.60384,619.112 C 443.65145,655.53119 436.78447,698.47341 435.18894,711.95249"
-         id="path3344"
-         style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:3.58883286;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-      <path
-         d="M 349.08283,670.65895 C 388.27679,663.40789 418.05575,629.06226 418.05571,587.77934 C 418.05571,575.65733 415.48977,564.1056 410.87804,553.68542"
-         id="path3346"
-         style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#555753;stroke-width:3.58883286;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-      <path
-         d="M 331.71875,493.03125 C 319.40723,493.03125 309.40624,503.03223 309.40625,515.34375 C 309.40625,527.65527 319.40549,537.62498 331.71875,537.625 C 344.03201,537.625 354.00001,527.65701 354,515.34375 C 354,503.03049 344.03027,493.03124 331.71875,493.03125 z"
-         transform="matrix(3.6099242,0,0,3.6099242,-776.62018,-1227.2798)"
-         id="path3342"
-         style="opacity:0.82722515;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#eeeeec;stroke-width:0.99415743;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" />
-    </g>
-  </g>
-</svg>
similarity index 100%
rename from tennix.6
rename to data/tennix.6
similarity index 100%
rename from tennix.desktop
rename to data/tennix.desktop
similarity index 100%
rename from data/icon.png
rename to data/tennix.png
similarity index 100%
rename from data/court.xcf
rename to doc/court.xcf
similarity index 100%
rename from data/data2csrc.c
rename to doc/data2csrc.c
similarity index 100%
rename from data/stadium.xcf
rename to doc/stadium.xcf
dissimilarity index 84%
index 28986ba..7d1891d 100644 (file)
--- a/makefile
+++ b/makefile
-
-#
-# Tennix! SDL Port
-# Copyright (C) 2003, 2007, 2008, 2009 Thomas Perl <thp@thpinfo.com>
-# 
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
-# MA  02110-1301, USA.
-#
-
-CC = g++
-
-
-ifeq ($(MKCALLGRAPH),1)
-  CC        =  nccgen -ncgcc -ncld -ncfabs
-  LD        =  nccld
-endif
-
-RELEASE = 1.1.1
-
-PREFIX ?= /usr/local
-BINDIR ?= $(PREFIX)/bin
-DATAROOTDIR ?= $(PREFIX)/share
-DATADIR ?= $(DATAROOTDIR)/games
-
-CFLAGS += -W -Wall -DVERSION=\"$(RELEASE)\" -O2 -DPREFIX=\"$(PREFIX)\"
-CXXFLAGS += $(CFLAGS)
-
-USE_PYTHON ?= 1
-
-ifeq ($(USE_PYTHON),1)
-  PYTHON_INCLUDES := $(shell python-config --includes)
-  PYTHON_LIBS := $(shell python-config --libs)
-  CFLAGS += $(PYTHON_INCLUDES) -DTENNIX_PYTHON
-  LIBS += $(PYTHON_LIBS)
-endif
-
-ifeq ($(NONFREE_LOCATIONS),1)
-  CFLAGS += -DNONFREE_LOCATIONS
-endif
-
-ifeq ($(UPDRECTANGLE),1)
-  CFLAGS += -DDRAW_UPDATE_RECTANGLE
-endif
-
-ifeq ($(DELUXE),1)
-  CFLAGS += -DDELUXE_EDITION
-endif
-
-ifeq ($(DEBUG),1)
-  CFLAGS += -DDEBUG
-endif
-
-ifeq ($(MAEMO),1)
-  CFLAGS += -DMAEMO
-endif
-
-SDL_LIBS := $(shell sdl-config --libs)
-SDL_CFLAGS := $(shell sdl-config --cflags)
-
-LIBS += $(SDL_LIBS) -lSDL_mixer -lSDL_image -lSDL_ttf -lSDL_net
-CFLAGS += $(SDL_CFLAGS)
-
-OBJ = tennix.o game.o graphics.o input.o util.o sound.o animation.o archive.o SDL_rotozoom.o network.o
-
-ifeq ($(MSYSTEM),MINGW32)
-  OBJ += tennixres.o
-endif
-ifeq ($(USE_PYTHON),1)
-  OBJ += tennixpy.o
-endif
-
-TOARCHIVE=$(wildcard data/*.ogg data/*.ttf wildcard data/*.png voice/*.ogg *.py)
-
-WIN32LIBS = *.dll
-OSXAPP = Tennix.app
-
-DATAFILES = README README.*
-DATAFILES_OSX = $(DATAFILES) data/Tennix.icns
-
-tennix: $(OBJ) tennix.tnx
-       $(CC) $(CFLAGS) $(LDFLAGS)  -o tennix $(OBJ) $(LIBS)
-       test -f tennix.exe && upx tennix.exe || true 
-
-ChangeLog:
-       git log >ChangeLog
-
-install: tennix
-       install -d -m 755 $(DESTDIR)$(BINDIR)
-       install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/pixmaps
-       install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/applications
-       install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/man/man6
-       install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps
-       install -d -m 755 $(DESTDIR)$(DATADIR)/tennix
-       install -m 755 tennix $(DESTDIR)$(BINDIR)/
-       install -m 644 tennix.6 $(DESTDIR)$(DATAROOTDIR)/man/man6/
-       install -m 644 data/icon.png $(DESTDIR)$(DATAROOTDIR)/pixmaps/tennix.png
-       install -m 644 data/icon.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps/tennix.svg
-       install -m 644 tennix.desktop $(DESTDIR)$(DATAROOTDIR)/applications/
-       install -m 644 tennix.tnx $(DESTDIR)$(DATADIR)/tennix/
-
-archive.o: archive.cc archive.cc
-tennix.o: tennix.cc tennix.h game.h graphics.h input.h util.h animation.h sound.h locations.h util.h archive.hh
-graphics.o: graphics.cc graphics.h tennix.h archive.hh sound.h
-game.o: game.c game.h graphics.h tennix.h sound.h input.h util.h network.h
-sound.o: sound.cc sound.h tennix.h archive.hh graphics.h
-input.o: input.c input.h tennix.h graphics.h game.h util.h tennixpy.h archive.hh
-util.o: util.c util.h tennix.h
-animation.o: animation.c animation.h graphics.h tennix.h credits.h
-tennixpy.o: tennixpy.cc tennix.h game.h archive.hh
-network.o: network.c network.h game.h
-SDL_rotozoom.o: SDL_rotozoom.c SDL_rotozoom.h
-
-tennixar: archive dump
-
-archive: archivetool.cc archive.o archive.hh
-
-dump: archive
-       ln -s archive dump
-
-tennix.tnx: archive $(TOARCHIVE)
-       rm -f tennix.tnx
-       ./archive $@ $(TOARCHIVE)
-
-# Mac OS X-specific targets
-release-osx: tennix tennix.tnx ChangeLog
-       mkdir -p $(OSXAPP)/Contents/{MacOS,/Resources}
-       cp -rpv tennix $(OSXAPP)/Contents/MacOS/Tennix
-       cp -rpv tennix.tnx $(DATAFILES_OSX) ChangeLog $(OSXAPP)/Contents/Resources/
-       sed -e 's/TENNIX_VERSION/$(RELEASE)/' osxapp.plist >$(OSXAPP)/Contents/Info.plist
-       echo 'APPL????' >$(OSXAPP)/Contents/PkgInfo
-       zip -r tennix-$(RELEASE)-macosx.zip $(OSXAPP)
-# End Mac OS X-specific targets
-
-# Windows-specific targets
-release-win32: tennix ChangeLog
-       zip tennix-$(RELEASE)-win32.zip tennix.exe $(WIN32LIBS) $(DATAFILES) ChangeLog
-
-tennix-installer.iss: tennix-installer.iss.in
-       sed tennix-installer.iss.in -e 's/{version}/$(RELEASE)/g' >tennix-installer.iss
-
-release-win32-setup: tennix ChangeLog tennix-installer.iss
-       iscc tennix-installer.iss
-
-tennixres.o: tennix.res
-       windres tennix.res tennixres.o
-# End Windows-specific targets
-
-release-bin: tennix ChangeLog
-       tar czvf tennix-$(RELEASE)-bin.tar.gz tennix $(DATAFILES) ChangeLog
-
-release: distclean ChangeLog
-       mkdir -p .release-tmp/tennix-$(RELEASE)/
-       cp -rv * .release-tmp/tennix-$(RELEASE)/
-       rm -rf .release-tmp/tennix-$(RELEASE)/.git
-       tar czvf tennix-$(RELEASE).tar.gz -C .release-tmp tennix-$(RELEASE)
-       rm -rf .release-tmp
-
-clean:
-       rm -f *.o tennix tennix.exe archive archive.exe dump dump.exe
-       rm -rf $(OSXAPP) tennix-*-macosx.zip
-       rm -f tennixres.o tennix-installer.iss tennix-*-win32-setup.exe
-       rm -f tennix.tnx
-
-distclean: clean
-       rm -rf tennix-$(RELEASE).zip tennix-$(RELEASE)-bin.tar.gz .release-tmp tennix-$(RELEASE).tar.gz
-
-.PHONY: distclean clean release-bin release-win32 release-win32-setup release-osx install tennixar
-
+
+#
+# Tennix! SDL Port
+# Copyright (C) 2003, 2007, 2008, 2009 Thomas Perl <thp@thpinfo.com>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+# MA  02110-1301, USA.
+#
+
+-include config.mk
+
+CONFIGURE_OUTPUT := config.mk config.h dependencies.mk
+
+ifeq ($(SILENT),0)
+    SILENTMSG := @true
+    SILENTCMD := 
+else
+    SILENTMSG := @echo
+    SILENTCMD := @
+endif
+
+# Object files for "tennix"
+TENNIX_BIN := tennix
+TENNIX_OBJ += src/tennix.o src/game.o src/graphics.o src/input.o
+TENNIX_OBJ += src/util.o src/sound.o src/animation.o src/archive.o
+TENNIX_OBJ += src/SDL_rotozoom.o src/network.o src/tennixpy.o
+
+# Object files for "archive"
+ARCHIVE_BIN := archive
+ARCHIVE_OBJ += src/archivetool.o src/archive.o
+
+# Target filename for "dump"
+DUMP_BIN := dump
+
+# Data files for tennix.tnx
+TENNIX_TNX := tennix.tnx
+TENNIX_TNX_DATA += $(wildcard data/*.ogg)
+TENNIX_TNX_DATA += $(wildcard data/*.ttf)
+TENNIX_TNX_DATA += $(wildcard data/*.png)
+
+ifeq ($(HAVE_VOICE_FILES),1)
+TENNIX_TNX_DATA += $(wildcard voice/*.ogg)
+endif
+
+ifeq ($(HAVE_PYTHON),1)
+TENNIX_TNX_DATA += $(wildcard data/*.py)
+endif
+
+# Installable files
+TENNIX_PNG := data/tennix.png
+TENNIX_DESKTOP := data/tennix.desktop
+TENNIX_MAN := data/tennix.6
+
+all: $(TENNIX_BIN) $(ARCHIVE_BIN) $(DUMP_BIN) $(TENNIX_TNX)
+
+%.o: %.cc
+       $(SILENTMSG) "  CXX     $@"
+       $(SILENTCMD)$(CXX) -c $(CFLAGS) -o $@ $<
+
+$(TENNIX_BIN): $(TENNIX_OBJ)
+       $(SILENTMSG) "  LD      $@"
+       $(SILENTCMD)$(CXX) $(LDFLAGS) -o $@ $^
+
+$(ARCHIVE_BIN): $(ARCHIVE_OBJ)
+       $(SILENTMSG) "  LD      $@"
+       $(SILENTCMD)$(CXX) -o $@ $^
+
+$(DUMP_BIN): $(ARCHIVE_BIN)
+       $(SILENTMSG) "  SYMLINK $@"
+       $(SILENTCMD)$(LN) -s $< $@
+
+$(TENNIX_TNX): $(ARCHIVE_BIN) $(TENNIX_TNX_DATA)
+       $(SILENTMSG) "  ARCHIVE $@"
+       $(SILENTCMD)./$(ARCHIVE_BIN) $@ $(TENNIX_TNX_DATA)
+
+install: $(TENNIX_BIN) $(TENNIX_TNX) $(TENNIX_PNG) $(TENNIX_DESKTOP) $(TENNIX_MAN)
+       $(SILENTMSG) "  INSTALL $(TENNIX_BIN)"
+       $(SILENTCMD)$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin/
+       $(SILENTCMD)$(INSTALL) -m 755 $(TENNIX_BIN) $(DESTDIR)$(PREFIX)/bin/
+       $(SILENTMSG) "  INSTALL $(TENNIX_TNX)"
+       $(SILENTCMD)$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/tennix/
+       $(SILENTCMD)$(INSTALL) -m 644 $(TENNIX_TNX) $(DESTDIR)$(PREFIX)/share/tennix/
+       $(SILENTMSG) "  INSTALL $(TENNIX_PNG)"
+       $(SILENTCMD)$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/pixmaps/
+       $(SILENTCMD)$(INSTALL) -m 644 $(TENNIX_PNG) $(DESTDIR)$(PREFIX)/share/pixmaps/
+       $(SILENTMSG) "  INSTALL $(TENNIX_DESKTOP)"
+       $(SILENTCMD)$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/applications/
+       $(SILENTCMD)$(INSTALL) -m 644 $(TENNIX_DESKTOP) $(DESTDIR)$(PREFIX)/share/applications/
+       $(SILENTMSG) "  INSTALL $(TENNIX_MAN)"
+       $(SILENTCMD)$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man6/
+       $(SILENTCMD)$(INSTALL) -m 644 $(TENNIX_MAN) $(DESTDIR)$(PREFIX)/share/man/man6/
+
+clean:
+       $(SILENTMSG) "  CLEAN"
+       $(SILENTCMD)$(RM) -f $(TENNIX_BIN) $(TENNIX_OBJ)
+       $(SILENTCMD)$(RM) -f $(ARCHIVE_BIN) $(ARCHIVE_OBJ)
+       $(SILENTCMD)$(RM) -f $(DUMP_BIN)
+       $(SILENTCMD)$(RM) -f $(TENNIX_TNX)
+
+distclean: clean
+       $(SILENTMSG) "  DISTCLEAN"
+       $(SILENTCMD)$(RM) -f $(CONFIGURE_OUTPUT)
+
+$(CONFIGURE_OUTPUT): configure
+       $(SILENTMSG) "  CONFIGURE"
+       $(SILENTCMD)./$<
+
+-include dependencies.mk
+
+.PHONY: install clean distclean
diff --git a/osxapp.plist b/osxapp.plist
deleted file mode 100644 (file)
index 08980be..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>CFBundleDevelopmentRegion</key>
-       <string>English</string>
-       <key>CFBundleExecutable</key>
-       <string>Tennix</string>
-       <key>CFBundleIdentifier</key>
-       <string>com.thpinfo.2007.TennixSDL</string>
-       <key>CFBundleInfoDictionaryVersion</key>
-       <string>6.0</string>
-       <key>CFBundleName</key>
-       <string>Tennix</string>
-       <key>CFBundlePackageType</key>
-       <string>APPL</string>
-       <key>CFBundleSignature</key>
-       <string>????</string>
-       <key>CFBundleVersion</key>
-       <string>TENNIX_VERSION</string>
-        <key>CFBundleIconFile</key>
-        <string>Tennix.icns</string>
-       <key>NSPrincipalClass</key>
-       <string>NSApplication</string>
-</dict>
-</plist>
similarity index 95%
rename from SDL_rotozoom.c
rename to src/SDL_rotozoom.cc
index baff64d..041efb0 100644 (file)
@@ -24,7 +24,7 @@
 \r
 int shrinkSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int factorx, int factory)\r
 {\r
-    int x, y, dx, dy, sgap, dgap, ra, ga, ba, aa;\r
+    int x, y, dx, dy, /*sgap, */dgap, ra, ga, ba, aa;\r
     int n_average;\r
     tColorRGBA *sp, *osp, *oosp;\r
     tColorRGBA *dp;\r
@@ -40,7 +40,7 @@ int shrinkSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int factorx, int fac
      * Scan destination\r
      */\r
     sp = (tColorRGBA *) src->pixels;\r
-    sgap = src->pitch - src->w * 4;\r
+    //sgap = src->pitch - src->w * 4;\r
 \r
     dp = (tColorRGBA *) dst->pixels;\r
     dgap = dst->pitch - dst->w * 4;\r
@@ -102,7 +102,7 @@ int shrinkSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int factorx, int fac
 \r
 int shrinkSurfaceY(SDL_Surface * src, SDL_Surface * dst, int factorx, int factory)\r
 {\r
-    int x, y, dx, dy, sgap, dgap, a;\r
+    int x, y, dx, dy, /*sgap, */dgap, a;\r
     int n_average;\r
     Uint8 *sp, *osp, *oosp;\r
     Uint8 *dp;\r
@@ -118,7 +118,7 @@ int shrinkSurfaceY(SDL_Surface * src, SDL_Surface * dst, int factorx, int factor
      * Scan destination\r
      */\r
     sp = (Uint8 *) src->pixels;\r
-    sgap = src->pitch - src->w;\r
+    //sgap = src->pitch - src->w;\r
 \r
     dp = (Uint8 *) dst->pixels;\r
     dgap = dst->pitch - dst->w;\r
@@ -640,7 +640,7 @@ void transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy,
 \r
 void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos)\r
 {\r
-    int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay, sw, sh;\r
+    int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay/*, sw, sh*/;\r
     tColorY *pc, *sp;\r
     int gap;\r
 \r
@@ -651,8 +651,8 @@ void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int
     yd = ((src->h - dst->h) << 15);\r
     ax = (cx << 16) - (icos * cx);\r
     ay = (cy << 16) - (isin * cx);\r
-    sw = src->w - 1;\r
-    sh = src->h - 1;\r
+    //sw = src->w - 1;\r
+    //sh = src->h - 1;\r
     pc = (tColorY*)dst->pixels;\r
     gap = dst->pitch - dst->w;\r
     /*\r
similarity index 100%
rename from SDL_rotozoom.h
rename to src/SDL_rotozoom.h
similarity index 100%
rename from animation.c
rename to src/animation.cc
similarity index 100%
rename from animation.h
rename to src/animation.h
similarity index 81%
rename from archive.cc
rename to src/archive.cc
index 5546173..962a950 100644 (file)
  *
  **/
 
+#include "tennix.h"
+
 #include <iostream>
 
 #include <libgen.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
 
 #include <arpa/inet.h>
 
-#include "archive.hh"
+#include "archive.h"
+
+TennixArchive::TennixArchive()
+    : fp(NULL)
+    , header()
+    , items(NULL)
+    , blobs(NULL)
+    , offset(0)
+    , current_item(0)
+    , building(1)
+{
+    strcpy(header.header, TENNIX_ARCHIVE_HEADER);
+    header.items = 0;
+}
 
 TennixArchive::TennixArchive(const char* filename, const char* fallback)
+    : fp(NULL)
+    , header()
+    , items(NULL)
+    , blobs(NULL)
+    , offset(0)
+    , current_item(0)
+    , building(0)
 {
     fp = fopen(filename, "rb");
     if (fp == NULL && fallback != NULL) {
         fp = fopen(fallback, "rb");
     }
-    assert(fp != NULL);
+    tnx_assert(fp != NULL);
 
     offset = sizeof(TennixArchiveHeader)*fread(&(header), sizeof(TennixArchiveHeader), 1, fp);
-    assert(offset == sizeof(TennixArchiveHeader));
-    assert(strncmp(header.header, TENNIX_ARCHIVE_HEADER, TENNIX_ARCHIVE_HEADER_LEN) == 0);
-    assert(header.versionmajor == TENNIX_ARCHIVE_VERSIONMAJOR);
-    assert(header.versionminor == TENNIX_ARCHIVE_VERSIONMINOR);
+    tnx_assert(offset == sizeof(TennixArchiveHeader));
+    tnx_assert(strncmp(header.header, TENNIX_ARCHIVE_HEADER, TENNIX_ARCHIVE_HEADER_LEN) == 0);
+    tnx_assert(header.versionmajor == TENNIX_ARCHIVE_VERSIONMAJOR);
+    tnx_assert(header.versionminor == TENNIX_ARCHIVE_VERSIONMINOR);
 
     items = (TennixArchiveItem*)calloc(header.items, sizeof(TennixArchiveItem));
-    assert(items != NULL);
+    tnx_assert(items != NULL);
     offset += sizeof(TennixArchiveItem)*fread(items, sizeof(TennixArchiveItem), header.items, fp);
-    assert(offset == sizeof(TennixArchiveHeader) + header.items*sizeof(TennixArchiveItem));
+    tnx_assert(offset == sizeof(TennixArchiveHeader) + header.items*sizeof(TennixArchiveItem));
 
     xormem((char*)(items), header.items*sizeof(TennixArchiveItem), header.key);
 
@@ -63,10 +84,6 @@ TennixArchive::TennixArchive(const char* filename, const char* fallback)
         items[i].offset = ntohl(items[i].offset);
         items[i].length = ntohl(items[i].length);
     }
-
-    current_item = 0;
-
-    building = 0;
 }
 
 std::ostream&
@@ -116,7 +133,7 @@ TennixArchive::getItemBytes()
     /* the last char is a null character, so this works for strings, too */
     data[size]='\0';
     fseek(fp, items[current_item].offset, SEEK_SET);
-    assert(fread(data, size, 1, fp) == 1);
+    tnx_assert(fread(data, size, 1, fp) == 1);
     xormem(data, size, items[current_item].key);
     return data;
 }
@@ -158,7 +175,7 @@ TennixArchive::buildFile(char* filename)
     memsize = (size_t*)calloc(header.items, sizeof(size_t));
 
     fp = fopen(filename, "wb");
-    assert(fp != NULL);
+    tnx_assert(fp != NULL);
 
     offset += sizeof(TennixArchiveHeader) + header.items*sizeof(TennixArchiveItem);
 
@@ -167,9 +184,7 @@ TennixArchive::buildFile(char* filename)
 
     header.key = (0xaa + 0x77*header.items*3) % 0xff;
 
-    fprintf(stderr, "Packing: ");
     for (int i=0; i<header.items; i++) {
-        fprintf(stderr, "%s", items[i].filename);
         items[i].offset = htonl(offset); /* network byte order */
         items[i].key = 0xaa ^ ((i<<2)%0x100);
         xormem(blobs[i], items[i].length, items[i].key);
@@ -177,24 +192,14 @@ TennixArchive::buildFile(char* filename)
         offset += items[i].length;
         items[i].length = htonl(items[i].length); /* network byte order */
         xormem((char*)(items + i), sizeof(TennixArchiveItem), header.key);
-        if (i != header.items-1) {
-            fprintf(stderr, ", ");
-        }
     }
-    fputc('\n', stderr);
-
-    fprintf(stderr, "Writing: %s", filename);
-    fputc('.', stderr);
-    assert(fwrite(&(header), sizeof(TennixArchiveHeader), 1, fp) == 1);
-    fputc('.', stderr);
-    assert(fwrite(items, sizeof(TennixArchiveItem), header.items, fp) == header.items);
-    fputc('.', stderr);
+
+    tnx_assert(fwrite(&(header), sizeof(TennixArchiveHeader), 1, fp) == 1);
+    tnx_assert(fwrite(items, sizeof(TennixArchiveItem), header.items, fp) == header.items);
     for (int i=0; i<header.items; i++) {
-        assert(fwrite(blobs[i], memsize[i], 1, fp) == 1);
+        tnx_assert(fwrite(blobs[i], memsize[i], 1, fp) == 1);
         free(blobs[i]);
     }
-    fputc('.', stderr);
-    fprintf(stderr, "OK\n");
 
     free(memsize);
     free(blobs);
similarity index 94%
rename from archive.hh
rename to src/archive.h
index 0ec2509..e2b5ab4 100644 (file)
@@ -79,13 +79,7 @@ class TennixArchive {
         static void xormem(char* mem, uint32_t length, char key);
 
     public:
-        TennixArchive() {
-            strcpy(header.header, TENNIX_ARCHIVE_HEADER);
-            header.items = 0;
-            building = 1;
-            fp = NULL;
-        }
-
+        TennixArchive();
         TennixArchive(const char* filename, const char* fallback=NULL);
 
         ~TennixArchive() {
similarity index 85%
rename from archivetool.cc
rename to src/archivetool.cc
index ad61006..893c7b4 100644 (file)
  *
  **/
 
-#include <assert.h>
+#include "tennix.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <libgen.h>
 #include <sys/stat.h>
 
-#include "archive.hh"
+#include "archive.h"
 
 int main(int argc, char* argv[])
 {
@@ -37,7 +38,6 @@ int main(int argc, char* argv[])
     const char* filename;
     char *bn = (char*)basename(argv[0]);
     int len, i;
-    struct stat st;
 
     if(strcmp(bn, "archive") == 0) {
         if (argc < 2) {
@@ -48,26 +48,26 @@ int main(int argc, char* argv[])
             exit(EXIT_FAILURE);
         }
 
-        if (stat(argv[1], &st) != -1) {
-            fprintf(stderr, "File %s already exists. Aborting.\n", argv[1]);
+        if (strcmp(".tnx", argv[1] + strlen(argv[1]) - 4) != 0) {
+            fprintf(stderr, "Wrong file extension: %s\n", argv[1]);
             exit(EXIT_FAILURE);
         }
 
-        tnxar = new TennixArchive();
+        TennixArchive archive;
 
-        fprintf(stderr, "Creating %s with %d files\n", argv[1], argc-2);
+        //fprintf(stderr, "Creating %s with %d files\n", argv[1], argc-2);
         for (i=2; i<argc; i++) {
             fp = fopen(argv[i], "rb");
             fseek(fp, 0, SEEK_END);
             len = ftell(fp);
             fseek(fp, 0, SEEK_SET);
             data = (char*)malloc(len);
-            assert(fread(data, len, 1, fp) == 1);
+            tnx_assert(fread(data, len, 1, fp) == 1);
             fclose(fp);
-            tnxar->appendItem((char*)basename(argv[i]), data, len);
+            char *filename = strdup(basename(argv[i]));
+            archive.appendItem(filename, data, len);
         }
-        tnxar->buildFile(argv[1]);
-        delete tnxar;
+        archive.buildFile(argv[1]);
     } else if(strcmp(bn, "dump") == 0) {
         if (argc < 2) {
             fprintf(stderr, "Usage: %s archive.tnx\n", bn);
@@ -90,7 +90,7 @@ int main(int argc, char* argv[])
                 fprintf(stderr, " (%d bytes)", len);
                 fp = fopen(filename, "wb");
                 fputc('.', stderr);
-                assert(fwrite(data, len, 1, fp) == 1);
+                tnx_assert(fwrite(data, len, 1, fp) == 1);
                 fputc('.', stderr);
                 fclose(fp);
                 fprintf(stderr, ".OK\n");
@@ -106,7 +106,7 @@ int main(int argc, char* argv[])
                 fprintf(stderr, " (%d bytes)", len);
                 fp = fopen(filename, "wb");
                 fputc('.', stderr);
-                assert(fwrite(data, len, 1, fp) == 1);
+                tnx_assert(fwrite(data, len, 1, fp) == 1);
                 fputc('.', stderr);
                 fclose(fp);
                 fprintf(stderr, ".OK\n");
similarity index 97%
rename from credits.h
rename to src/credits.h
index 2c646ed..39557dc 100644 (file)
--- a/credits.h
@@ -29,7 +29,7 @@
 
 const char* credits_text[] = {
     "Tennix Classic Championship Tour 2011",
-    "Version " VERSION " (2011-02-10)",
+    "Version " VERSION " (2013-07-28)",
     CREDITS_EMPTY_TEXT,
     "Code, graphics and idea by",
     "Thomas Perl (thp.io)",
similarity index 97%
rename from game.c
rename to src/game.cc
index 11aa799..9b0e73d 100644 (file)
--- a/game.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <assert.h>
 #include <unistd.h>
 
 #include "tennix.h"
@@ -76,12 +75,6 @@ int gamestate_save(GameState* s, const char* filename)
     InputDevice* input_devices[MAXPLAYERS];
     int i, result = 0;
     FILE* fp = NULL;
-#ifndef WIN32
-    char tmp[MAXPATHLEN];
-
-    assert(getcwd(tmp, MAXPATHLEN) == tmp);
-    assert(chdir(getenv("HOME")) == 0);
-#endif
 
     /**
      * Process-specific data (pointers to data
@@ -116,10 +109,6 @@ int gamestate_save(GameState* s, const char* filename)
 
     fclose(fp);
 
-#ifndef WIN32
-    assert(chdir(tmp) == 0);
-#endif
-
     return result;
 }
 
@@ -128,12 +117,6 @@ GameState* gamestate_load(const char* filename)
 {
     FILE* fp;
     GameState* s = NULL;
-#ifndef WIN32
-    char tmp[MAXPATHLEN];
-
-    assert(getcwd(tmp, MAXPATHLEN) == tmp);
-    assert(chdir(getenv("HOME")) == 0);
-#endif
 
     fp = fopen(filename, "r");
 
@@ -151,10 +134,6 @@ GameState* gamestate_load(const char* filename)
         fclose(fp);
     }
 
-#ifndef WIN32
-    assert(chdir(tmp) == 0);
-#endif
-
     return s;
 }
 
@@ -165,9 +144,11 @@ void gameloop(GameState *s, TennixNet* c) {
     Uint32 dt = GAME_TICKS;
     Uint32 diff;
     Uint32 accumulator = 0;
+#ifdef HAVE_SDL_NET
+    int i = 0;
+#endif /* HAVE_SDL_NET */
     bool quit = false;
     int p;
-    int i=0;
     RenderState r = {
         SOUND_EVENT_NONE,
         REFEREE_COUNT,
@@ -214,12 +195,14 @@ void gameloop(GameState *s, TennixNet* c) {
         while( accumulator >= dt) {
             step(s);
 
+#ifdef HAVE_SDL_NET
             network_receive(c);
             network_get_gamestate(c, s);
 
             if ((i++) % 10 == 0) {
                 network_send_state(c, s);
             }
+#endif /* HAVE_SDL_NET */
 
             quit = handle_input(s, c);
             accumulator -= dt;
@@ -352,7 +335,7 @@ void step(GameState* s) {
                     s->referee = REFEREE_PLAYER2;
                     break;
                 default:
-                    assert(0);
+                    tnx_assert(0);
                     break;
             }
             s->score_time = 0;
@@ -389,7 +372,7 @@ void step(GameState* s) {
                         s->ball.move_z = 1.1*PLAYER(s, p).power/PLAYER_POWER_MAX;
                         break;
                     default:
-                        assert(false);
+                        tnx_assert(false);
                         break;
                 }
                 s->ball.move_y = get_move_y( s, p);
@@ -406,14 +389,16 @@ void step(GameState* s) {
 }
 
 bool handle_input(GameState* s, TennixNet* c) {
-    static NetworkGameState tmp;
-    static NetworkInputData net_input;
     Uint8* keys = NULL;
     int p;
 
     SDL_PumpEvents();
     keys = SDL_GetKeyState(NULL);
 
+#ifdef HAVE_SDL_NET
+    static NetworkGameState tmp;
+    static NetworkInputData net_input;
+
     if (keys['1']) {
         net_serialize_gamestate(s, &tmp);
     } else if (keys['2']) {
@@ -421,17 +406,22 @@ bool handle_input(GameState* s, TennixNet* c) {
     }
 
     network_get_input(c, &net_input);
+#endif /* HAVE_SDL_NET */
     if (s->winner == WINNER_NONE) {
         for (p=1; p<=MAXPLAYERS; p++) {
             if( PLAYER(s, p).type == PLAYER_TYPE_HUMAN) {
+#ifdef HAVE_SDL_NET
                 if (PLAYER(s, p).input->type == INPUT_TYPE_NETWORK) {
                     memcpy(&(PLAYER(s, p).input->net), &net_input,
                             sizeof(NetworkInputData));
                 }
+#endif /* HAVE_SDL_NET */
                 input_human(s, p);
+#ifdef HAVE_SDL_NET
                 if (PLAYER(s, p).input->type != INPUT_TYPE_NETWORK) {
                     network_send_input(c, &(PLAYER(s, p).input->net));
                 }
+#endif /* HAVE_SDL_NET */
             } else {
                 input_ai(s, p);
             }
@@ -450,7 +440,7 @@ bool handle_input(GameState* s, TennixNet* c) {
 }
 
 void render(const GameState* s, RenderState* r) {
-    int x, y, b;
+    int x, y;
     unsigned int i;
     float zoom;
     float rotate;
@@ -571,14 +561,6 @@ void render(const GameState* s, RenderState* r) {
     rectangle(10, HEIGHT-30, (int)(PLAYER(s, 1).power), 10, 200, 200, 200);
     rectangle(WIDTH-PLAYER_POWER_MAX-10, HEIGHT-30, (int)(PLAYER(s, 2).power), 10, 200, 200, 200);
     
-    if( s->ball.move_x > 0) {
-        b = (time/100)%BALL_STATES;
-    } else if( s->ball.move_x < 0) {
-        b = BALL_STATES-1-(time/100)%BALL_STATES;
-    } else {
-        b = 0;
-    }
-
     rotate = 0.0;
     zoom = fmaxf(0.5, fminf(1.0, (float)(30.-(s->ball.z))/10.));
     show_image_rotozoom(GR_SHADOW, s->ball.x, s->ball.y+3, rotate, zoom);
@@ -805,7 +787,7 @@ int score_game(GameState* s) {
     }
 
     /* we cannot be in an "impossibly high" set */
-    assert(s->current_set < SETS_TO_WIN*2-1);
+    tnx_assert(s->current_set < SETS_TO_WIN*2-1);
 
     winner->game++;
     s->ec_game++;
similarity index 100%
rename from game.h
rename to src/game.h
similarity index 97%
rename from graphics.cc
rename to src/graphics.cc
index 49937a8..9789600 100644 (file)
 #include <stdlib.h>
 #include <math.h>
 #include <unistd.h>
-#include <assert.h>
 #include <ctype.h>
 #include <string.h>
-#include <assert.h>
 
 #include "tennix.h"
 #include "graphics.h"
-#include "archive.hh"
+#include "archive.h"
 #include "sound.h"
 
 #include "SDL_rotozoom.h"
@@ -151,16 +149,16 @@ void init_graphics(TennixArchive& tnxar) {
     /* Load fonts from resource file */
     for (i=0; i<FONT_COUNT; i++) {
         if (font_desc[i].filename != NULL) {
-            assert(tnxar.setItemFilename(font_desc[i].filename) != 0);
+            tnx_assert(tnxar.setItemFilename(font_desc[i].filename) != 0);
             font_data = tnxar.getItemBytes();
             freelist_append(font_freelist, font_data);
         }
-        assert(font_data != NULL);
+        tnx_assert(font_data != NULL);
         rw = SDL_RWFromMem((void*)font_data, tnxar.getItemSize());
         fonts[i].data = TTF_OpenFontRW(rw, 1, font_desc[i].size);
         if (fonts[i].data == NULL) {
             fprintf(stderr, "TTF error: %s\n", TTF_GetError());
-            assert(fonts[i].data != NULL);
+            tnx_assert(fonts[i].data != NULL);
         }
         TTF_SetFontStyle(fonts[i].data, font_desc[i].style);
     }
@@ -233,7 +231,7 @@ void uninit_graphics() {
 FreeList* freelist_create()
 {
     FreeList* list = (FreeList*)malloc(sizeof(FreeList));
-    assert(list != NULL);
+    tnx_assert(list != NULL);
 
     list->head = NULL;
 
@@ -244,8 +242,8 @@ void freelist_append(FreeList* list, const char* data)
 {
     FreeListItem* new_item = (FreeListItem*)malloc(sizeof(FreeListItem));
 
-    assert(list != NULL);
-    assert(data != NULL);
+    tnx_assert(list != NULL);
+    tnx_assert(data != NULL);
 
     new_item->data = data;
 
@@ -258,7 +256,7 @@ void freelist_free_all(FreeList* list)
 {
     FreeListItem* next;
 
-    assert(list != NULL);
+    tnx_assert(list != NULL);
 
     while (list->head != NULL) {
         /* Remove one item from the head of the list */
@@ -287,7 +285,7 @@ int get_sprite_width( image_id id, int items) {
 void show_sprite( image_id id, int pos, int items, int x_offset,
         int y_offset, int opacity)
 {
-    assert(id < GR_COUNT);
+    tnx_assert(id < GR_COUNT);
     SDL_SetAlpha(images[id].data, SDL_SRCALPHA | SDL_RLEACCEL, opacity);
     blit_surface(images[id].data, x_offset, y_offset, pos, items);
 }
@@ -297,7 +295,7 @@ void show_image_rotozoom(image_id id, int x, int y, float rotate, float zoom)
     SDL_Surface* tmp;
     SDL_Rect src, dst;
 
-    assert(id < GR_COUNT);
+    tnx_assert(id < GR_COUNT);
 
     tmp = rotozoomSurface(images[id].data, rotate, zoom, SMOOTHING_OFF);
 
@@ -591,11 +589,11 @@ SDL_Surface* font_render_surface(font_id id, const char* text, Uint8 r,
     color.g = g;
     color.b = b;
 
-    assert(id < FONT_COUNT);
+    tnx_assert(id < FONT_COUNT);
 
     result = TTF_RenderText_Blended(fonts[id].data, text, color);
 
-    assert(result != NULL);
+    tnx_assert(result != NULL);
 
     return result;
 }
@@ -617,7 +615,7 @@ void blit_surface(SDL_Surface* surface, int x, int y, int pos, int count)
 
 SDL_Surface* get_surface(image_id id)
 {
-    assert(id < GR_COUNT);
+    tnx_assert(id < GR_COUNT);
     return images[id].data;
 }
 
@@ -632,7 +630,7 @@ void font_draw_string_color(font_id id, const char* s, int x_offset, int y_offse
 int font_get_string_width(font_id id, const char* s) {
     int w, h;
 
-    assert(id < FONT_COUNT);
+    tnx_assert(id < FONT_COUNT);
 
     if (TTF_SizeText(fonts[id].data, s, &w, &h) != 0) {
         return 0;
@@ -642,7 +640,7 @@ int font_get_string_width(font_id id, const char* s) {
 }
 
 int font_get_height(font_id id) {
-    assert(id < FONT_COUNT);
+    tnx_assert(id < FONT_COUNT);
     return TTF_FontHeight(fonts[id].data);
 }
 
similarity index 99%
rename from graphics.h
rename to src/graphics.h
index c95f85f..25f4c77 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef __GRAPHICS_H
 #define __GRAPHICS_H
 
-#include "archive.hh"
+#include "archive.h"
 #include "tennix.h"
 
 #include "SDL_image.h"
similarity index 82%
rename from input.c
rename to src/input.cc
index ef2c175..3eb9d02 100644 (file)
--- a/input.c
 #include "game.h"
 #include "input.h"
 #include "util.h"
-#include "archive.hh"
+#include "archive.h"
+
 
 static InputDevice devices[MAX_INPUT_DEVICES];
 static int devices_count;
 
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
 #include "tennixpy.h"
 #endif
 
@@ -43,7 +44,6 @@ void init_input(TennixArchive& tnxar)
 
     SDL_JoystickEventState(SDL_ENABLE);
 
-#ifndef MAEMO
     /* keyboard presets */
     devices[devices_count].type = INPUT_TYPE_KEYBOARD;
     devices[devices_count].up_key = 'w';
@@ -67,7 +67,6 @@ void init_input(TennixArchive& tnxar)
     devices[devices_count].exclusive_to_player = 2;
     strcpy(devices[devices_count].name, "Keyboard (OL/KIJ)");
     devices_count++;
-#endif
 
     /* keyboard presets */
     devices[devices_count].type = INPUT_TYPE_KEYBOARD;
@@ -76,15 +75,8 @@ void init_input(TennixArchive& tnxar)
     devices[devices_count].input_keys[INPUT_KEY_HIT]= SDLK_SPACE;
     devices[devices_count].input_keys[INPUT_KEY_TOPSPIN] = SDLK_LCTRL;
     devices[devices_count].input_keys[INPUT_KEY_SMASH] = SDLK_LALT;
-#ifdef MAEMO
-    devices[devices_count].icon = GR_INPUT_MAEMO_DPAD;
-    strcpy(devices[devices_count].name, "D-Pad");
-    devices[devices_count].input_keys[INPUT_KEY_HIT]= SDLK_RETURN;
-    /* FIXME: No TOPSPIN and SMASH keys on Maemo yet with d-pad */
-#else
     devices[devices_count].icon = GR_INPUT_KEYBOARD_ARROWS;
     strcpy(devices[devices_count].name, "Keyboard (arrows)");
-#endif
     devices_count++;
 
     /* mouse */
@@ -92,13 +84,8 @@ void init_input(TennixArchive& tnxar)
     devices[devices_count].input_keys[INPUT_KEY_HIT]= SDL_BUTTON(1);
     devices[devices_count].input_keys[INPUT_KEY_TOPSPIN] = SDL_BUTTON(2);
     devices[devices_count].input_keys[INPUT_KEY_SMASH] = SDL_BUTTON(3);
-#ifdef MAEMO
-    devices[devices_count].icon = GR_INPUT_TOUCHSCREEN;
-    strcpy(devices[devices_count].name, "Touchscreen");
-#else
     devices[devices_count].icon = GR_INPUT_MOUSE;
     strcpy(devices[devices_count].name, "Mouse");
-#endif
     devices_count++;
 
     /* network peer */
@@ -122,7 +109,7 @@ void init_input(TennixArchive& tnxar)
         devices_count++;
     }
 
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
     /* This will init Python and load all available bots */
     tennixpy_init(tnxar);
 #endif
@@ -137,14 +124,14 @@ void uninit_input()
     for (i=0; i<devices_count; i++) {
         if (devices[i].type == INPUT_TYPE_JOYSTICK) {
             SDL_JoystickClose(devices[i].joystick);
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
         } else if (devices[i].type == INPUT_TYPE_AI_PYTHON) {
-            tennixpy_unregister_bot(devices[i].py_bot_class);
+            tennixpy_unregister_bot(&(devices[i]));
 #endif
         }
     }
 
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
     tennixpy_uninit();
 #endif
 
@@ -156,7 +143,7 @@ input_pack_axis(float v)
 {
     static const float min = -1.2;
     static const float max = 1.2;
-    assert(v >= min && v < max);
+    tnx_assert(v >= min && v < max);
     return (Uint8)((1U<<7) * (v-min) / (max-min));
 }
 
@@ -165,7 +152,7 @@ input_unpack_axis(Uint8 v)
 {
     static const float min = -1.2;
     static const float max = 1.2;
-    assert(v < (1U<<7));
+    tnx_assert(v < (1U<<7));
     return v * (max-min) / (1U<<7) + min;
 }
 
@@ -183,9 +170,9 @@ void input_device_join_game(InputDevice* device, void* gamestate, int player_id)
         return;
     }
     fprintf(stderr, "Input Device %s joins the game\n", device->name);
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
     if (device->type == INPUT_TYPE_AI_PYTHON) {
-        device->py_bot = tennixpy_create_bot(device->py_bot_class, (GameState*)gamestate, player_id);
+        tennixpy_create_bot(device, (GameState*)gamestate, player_id);
     }
 #endif
 }
@@ -196,10 +183,9 @@ void input_device_part_game(InputDevice* device)
         /* player is a c-style bot with no device attached */
         return;
     }
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
     if (device->type == INPUT_TYPE_AI_PYTHON) {
-        tennixpy_destroy_bot(device->py_bot);
-        device->py_bot = NULL;
+        tennixpy_destroy_bot(device);
     }
 #endif
     fprintf(stderr, "Input Device %s leaves the game\n", device->name);
@@ -212,7 +198,7 @@ const char* input_device_get_name(InputDevice* d)
 
 float input_device_get_axis(InputDevice* d, unsigned const char axis) {
     Uint8 *keystate;
-    Uint8 mb;
+    //Uint8 mb;
     Uint8 net_value;
     float result = 0.0;
 
@@ -232,7 +218,7 @@ float input_device_get_axis(InputDevice* d, unsigned const char axis) {
             result = JOYSTICK_PERCENTIZE(SDL_JoystickGetAxis(d->joystick, 1+d->y_axis*2));
         }
     } else if (d->type == INPUT_TYPE_MOUSE) {
-        mb = SDL_GetMouseState(&d->mx, &d->my);
+        //mb = SDL_GetMouseState(&d->mx, &d->my);
         if (axis == INPUT_AXIS_X) {
             /* Not x-movement yet (PLAYER_MOVE_X is not defined!) */
             /*if (fabsf(d->mx - d->player_x) > PLAYER_MOVE_X) {
@@ -251,9 +237,9 @@ float input_device_get_axis(InputDevice* d, unsigned const char axis) {
                 }
             }
         }
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
     } else if (d->type == INPUT_TYPE_AI_PYTHON) {
-        result = tennixpy_bot_get_axis(d->py_bot, axis);
+        result = tennixpy_bot_get_axis(d, axis);
 #endif
     } else if (d->type == INPUT_TYPE_NETWORK) {
         if (axis == INPUT_AXIS_X) {
@@ -262,7 +248,7 @@ float input_device_get_axis(InputDevice* d, unsigned const char axis) {
             result = input_unpack_axis(d->net.y);
         }
     } else {
-        assert(0/*unimplemented*/);
+        tnx_assert(0/*unimplemented*/);
     }
 
     net_value = input_pack_axis(result);
@@ -287,14 +273,14 @@ char input_device_get_key(InputDevice* d, unsigned const char key) {
     } else if (d->type == INPUT_TYPE_MOUSE) {
         mb = SDL_GetMouseState(NULL, NULL);
         result = (mb & d->input_keys[key]) != 0;
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
     } else if (d->type == INPUT_TYPE_AI_PYTHON) {
-        result = tennixpy_bot_get_key(d->py_bot, key);
+        result = tennixpy_bot_get_key(d, key);
 #endif
     } else if (d->type == INPUT_TYPE_NETWORK) {
         result = (d->net.keys & (1<<key));
     } else {
-        assert(0/*unimplemented*/);
+        tnx_assert(0/*unimplemented*/);
     }
 
     /* Update the input device's NetworkInputData struct */
@@ -308,23 +294,10 @@ char input_device_get_key(InputDevice* d, unsigned const char key) {
 }
 
 
-#ifdef TENNIX_PYTHON
-
-void input_add_python_bot(PyObject* bot_class)
+InputDevice *
+input_add_device()
 {
-    if (devices_count < MAX_INPUT_DEVICES) {
-        devices[devices_count].type = INPUT_TYPE_AI_PYTHON;
-        devices[devices_count].icon = GR_INPUT_AI;
-        devices[devices_count].py_bot_class = bot_class;
-        tennixpy_get_bot_name(bot_class, devices[devices_count].name, INPUT_DEVICE_NAME_MAX);
-        fprintf(stderr, " %s", devices[devices_count].name);
-        devices_count++;
-    } else {
-        fprintf(stderr, "Warning: Cannot add any more Python bots.\n");
-        /* We carry a ref of bot_class, so give it up here */
-        tennixpy_unregister_bot(bot_class);
-    }
+    tnx_assert(devices_count < MAX_INPUT_DEVICES);
+    return &(devices[devices_count++]);
 }
 
-#endif
-
similarity index 90%
rename from input.h
rename to src/input.h
index f3f8213..9f5ff7d 100644 (file)
--- a/input.h
 #ifndef __INPUT_H
 #define __INPUT_H
 
-#include "archive.hh"
+#include "archive.h"
 #include "graphics.h"
 
-#ifdef TENNIX_PYTHON
-#include <Python.h>
-#endif
-
 #define JOYSTICK_PERCENTIZE(x) ((float)(x)/(float)(32768))
 
 #define MAX_INPUT_DEVICES 16
@@ -45,7 +41,7 @@ enum {
     INPUT_TYPE_JOYSTICK,
     INPUT_TYPE_MOUSE,
     INPUT_TYPE_NETWORK,
-#ifdef TENNIX_PYTHON
+#ifdef HAVE_PYTHON
     INPUT_TYPE_AI_PYTHON,
 #endif
     INPUT_TYPE_MAX
@@ -98,11 +94,8 @@ typedef struct {
     /* Network-specific items */
     NetworkInputData net;
 
-#ifdef TENNIX_PYTHON
-    /* Python-specific items */
-    PyObject* py_bot_class;
-    PyObject* py_bot;
-#endif
+    /* Plugin-specific data */
+    void *user_data;
 
     /* The picture for this input device */
     image_id icon;
@@ -114,9 +107,7 @@ typedef struct {
 void init_input(TennixArchive& tnxar);
 void uninit_input();
 
-#ifdef TENNIX_PYTHON
-void input_add_python_bot(PyObject* pyclass);
-#endif
+InputDevice *input_add_device();
 
 InputDevice* find_input_devices(unsigned int*);
 
similarity index 100%
rename from locations.h
rename to src/locations.h
similarity index 99%
rename from network.c
rename to src/network.cc
index e860230..5538593 100644 (file)
--- a/network.c
  *
  **/
 
+#include "config.h"
+
+#ifdef HAVE_SDL_NET
+
 #include "game.h"
 #include "network.h"
 
@@ -271,3 +275,4 @@ net_unserialize_gamestate(NetworkGameState* src, GameState* dest)
     dest->status_message = src->status_message;
 }
 
+#endif /* HAVE_SDL_NET */
similarity index 98%
rename from network.h
rename to src/network.h
index 6110faf..7e3331b 100644 (file)
--- a/network.h
 #ifndef __NETWORK_H
 #define __NETWORK_H
 
+#include "config.h"
+
 #include "game.h"
 #include "input.h"
 
+#ifdef HAVE_SDL_NET
 #include <SDL/SDL_net.h>
+#endif
 
 /* Vanity ports "STNX" and "MTNX" */
 #define TENNIXNET_PORT_SLAVE 7869
similarity index 99%
rename from sound.cc
rename to src/sound.cc
index f36c620..96f64bc 100644 (file)
--- a/sound.cc
@@ -23,7 +23,7 @@
 
 #include "tennix.h"
 #include "sound.h"
-#include "archive.hh"
+#include "archive.h"
 #include "graphics.h"
 
 #include <stdarg.h>
similarity index 99%
rename from sound.h
rename to src/sound.h
index 87b765a..6ea3cf6 100644 (file)
--- a/sound.h
@@ -24,7 +24,7 @@
 #ifndef __SOUND_H
 #define __SOUND_H
 
-#include "archive.hh"
+#include "archive.h"
 
 #include "SDL_mixer.h"
 
similarity index 94%
rename from tennix.cc
rename to src/tennix.cc
index 8f5f730..9090d43 100644 (file)
--- a/tennix.cc
 #include <string.h>
 #include <stdlib.h>
 
-#ifdef WIN32
-#include <windows.h>
-#endif
-
 #include "tennix.h"
-#include "archive.hh"
+#include "archive.h"
 #include "game.h"
 #include "graphics.h"
 #include "sound.h"
 
 SDL_Surface *screen;
 
-#ifdef WIN32
-
-/* IDs from the resource file */
-#define START_BUTTON 1
-#define CHECKBOX_FULLSCREEN 2
-#define QUIT_BUTTON 3
-
-BOOL CALLBACK ConfigDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-    static int checkbox_is_checked;
-
-    switch (uMsg) {
-        case WM_CLOSE:
-            EndDialog(hwndDlg, IDCANCEL);
-            break;
-        case WM_COMMAND:
-            switch (wParam) {
-                case START_BUTTON:
-                    EndDialog(hwndDlg, (checkbox_is_checked)?(IDYES):(IDNO));
-                    break;
-                case QUIT_BUTTON:
-                    EndDialog(hwndDlg, IDCANCEL);
-                    break;
-                case CHECKBOX_FULLSCREEN:
-                    checkbox_is_checked ^= 1;
-                    break;
-            }
-            break;
-        default:
-            return FALSE;
-    }
-    return TRUE;
-}
-#endif
-
-#ifdef WIN32
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
-    LPSTR lpCmdLine, int nCmdShow) {
-#else
 int main( int argc, char** argv) {
-#endif
     int i, slide, slide_direction;
     unsigned int x;
     Uint32 ticks;
@@ -108,8 +64,10 @@ int main( int argc, char** argv) {
     AnimationState *intro_playback;
     float wiggle;
     TennixNet* connection = NULL;
+#ifdef HAVE_SDL_NET
     char* net_host = NULL;
     bool net_master = false;
+#endif /* HAVE_SDL_NET */
     TennixArchive* tnxar = NULL;
 
     MenuButton btn_back = {
@@ -161,25 +119,6 @@ int main( int argc, char** argv) {
     Uint32 ft, frames; /* frame timer and frames */
 #endif
 
-#if defined(MAEMO) || defined(MACOSX)
-    sdl_flags |= SDL_FULLSCREEN;
-#endif
-
-#ifdef WIN32
-    int mb_result;
-    mb_result = DialogBox(hInstance, "CONFIG", 0, (DLGPROC)ConfigDialogProc);
-
-    switch (mb_result) {
-        case IDYES:
-            sdl_flags |= SDL_FULLSCREEN;
-            break;
-        case IDCANCEL:
-            return 0;
-            break;
-        default:
-            break;
-    }
-#else
     fprintf(stderr, "Tennix Classic Championship Tour 2011 (v" VERSION ")\n" COPYRIGHT "\n" URL "\n\n");
 
     i = 1;
@@ -200,6 +139,7 @@ int main( int argc, char** argv) {
         else if (OPTION_SET("--benchmark", "-b")) {
             benchmark = true;
         }
+#ifdef HAVE_SDL_NET
         else if (OPTION_SET("--slave", "-s")) {
             net_host = OPTION_VALUE;
             if (OPTION_VALUE != NULL) {
@@ -222,6 +162,7 @@ int main( int argc, char** argv) {
                 break;
             }
         }
+#endif /* HAVE_SDL_NET */
         else {
             fprintf(stderr, "Unknown option: %s\n", argv[i]);
             do_help = true;
@@ -234,13 +175,14 @@ int main( int argc, char** argv) {
         " Where [OPTIONS] are zero or more of the following:\n\n"
         "    [--fullscreen|-f]           Fullscreen mode\n"
         "    [--benchmark|-b]            Run in benchmark/attract mode\n"
+#ifdef HAVE_SDL_NET
         "    [--master|-m <IP-of-slave>] Network play as master\n"
         "    [--slave|-s <IP-of-master>] Network play as slave\n"
+#endif /* HAVE_SDL_NET */
         "    [--help|-h]                 Show help information\n\n"
         " See tennix(6) for details.\n", argv[0]);
         return 0;
     }
-#endif
 
     if (benchmark) {
         srand(100);
@@ -267,12 +209,16 @@ int main( int argc, char** argv) {
     init_graphics(*tnxar);
     init_sound(*tnxar);
     init_input(*tnxar);
+#ifdef HAVE_SDL_NET
     init_network();
+#endif /* HAVE_SDL_NET */
     delete tnxar;
 
+#ifdef HAVE_SDL_NET
     if (net_host != NULL) {
         connection = network_connect(net_host, net_master);
     }
+#endif /* HAVE_SDL_NET */
 
     menu_button_init(&btn_back);
     menu_button_init(&btn_start);
@@ -409,11 +355,7 @@ int main( int argc, char** argv) {
                     /* FIXME - this should not be written here, but taken from the input devices */
                     btn_player1.text = "Keyboard (arrows)";
                     btn_player2.text = "Carl Van Court";
-#ifdef MAEMO
-                    PLAYER(prepared_game, 1).input_device_index = 0;
-#else
                     PLAYER(prepared_game, 1).input_device_index = 2;
-#endif
                     PLAYER(prepared_game, 1).type = PLAYER_TYPE_HUMAN;
                     PLAYER(prepared_game, 1).input = &(input_devices[PLAYER(prepared_game, 1).input_device_index]);
                     location_info_visible = false;
@@ -619,7 +561,6 @@ int main( int argc, char** argv) {
             /* No menu screen - no hovering. */
             btn_hovering = 0;
         }
-#ifndef MAEMO /* On Maemo, we cannot really "hover" (touchscreen!) */
         if (btn_hovering_old != btn_hovering && btn_hovering != 0) {
 #ifdef HAVE_VOICE_FILES
             if (btn_hovering == MENU_QUIT) {
@@ -630,10 +571,9 @@ int main( int argc, char** argv) {
                 play_sample(SOUND_MOUSEOVER);
             }
 #else
-            /*play_sample(SOUND_MOUSEOVER);*/
+            play_sample(SOUND_MOUSEOVER);
 #endif
         }
-#endif
    
         if( keys[SDLK_ESCAPE] || keys['q']) {
             /* FIXME: do the state thingie! */
@@ -644,11 +584,9 @@ int main( int argc, char** argv) {
             SDL_WM_ToggleFullScreen( screen);
         }
    
-#ifndef MAEMO /* No mouse cursor on Maemo (we have a touchscreen) */
         if (state == MENU_STATE_MAINMENU || state == MENU_STATE_OPTIONS || state == MENU_STATE_LOCATION) {
             show_image(GR_CURSOR, mx-2, my-1, 255);
         }
-#endif
 
         /* Draw the "real" mouse coordinates */
         /*rectangle(mx-1, my-1, 2, 2, 255, 255, 255);*/
@@ -800,7 +738,9 @@ int main( int argc, char** argv) {
 
     uninit_graphics();
     uninit_input();
+#ifdef HAVE_SDL_NET
     uninit_network();
+#endif /* HAVE_SDL_NET */
 
     SDL_Quit();
     return 0;
similarity index 85%
rename from tennix.h
rename to src/tennix.h
index 0fb30f4..a547aee 100644 (file)
--- a/tennix.h
 #ifndef __TENNIX_H
 #define __TENNIX_H
 
+#include "config.h"
+
+#define tnx_assert(x) do { \
+    if (!(x)) { \
+        fprintf(stderr, "Assertion fail: %s\n", #x); \
+        exit(1); \
+    } \
+} while(0)
+
 #include <sys/param.h>
 
 #include <SDL/SDL.h>
+
+#ifdef HAVE_SDL_NET
 #include <SDL/SDL_net.h>
+#endif
 
 typedef struct {
     unsigned char x;
@@ -35,7 +47,7 @@ typedef struct {
     unsigned char keys; /* bitfield (0 = key pressed, 1 = not pressed) */
 } NetworkInputData;
 
-
+#ifdef HAVE_SDL_NET
 typedef struct {
     UDPsocket send_socket;
     UDPsocket recv_input_socket;
@@ -56,30 +68,16 @@ typedef struct {
 
     bool master;
 } TennixNet;
-
-#ifdef DELUXE_EDITION
-#  define HAVE_VOICE_FILES
-#  define NONFREE_LOCATIONS
-#endif
-
-#if defined(__MACH__) && defined(__APPLE__)
-#  define MACOSX
-#endif
+#else
+typedef void TennixNet;
+#endif /* HAVE_SDL_NET */
 
 #define ARCHIVE_FILE "tennix.tnx"
-#ifdef MACOSX
-#  define ARCHIVE_FILE_INSTALLED "Tennix.app/Contents/Resources/" ARCHIVE_FILE
-#else
-#  define ARCHIVE_FILE_INSTALLED "/" PREFIX "/share/games/tennix/" ARCHIVE_FILE
-#endif
+#define ARCHIVE_FILE_INSTALLED "/" PREFIX "/share/tennix/" ARCHIVE_FILE
 
-#ifdef WIN32
-#  define GAMESTATE_FILE "current_match-" VERSION ".tennix"
-#else
-#  define GAMESTATE_FILE ".tennix-current_match-" VERSION
-#endif
+#define GAMESTATE_FILE ".tennix-current_match-" VERSION
 
-#define COPYRIGHT "Copyright 2003, 2007-2011 Thomas Perl"
+#define COPYRIGHT "Copyright 2003, 2007-2011, 2013 Thomas Perl"
 #define URL "http://icculus.org/tennix/"
 
 #define WIDTH 640
@@ -137,8 +135,6 @@ enum {
     MENU_STATE_QUIT
 };
 
-/* Comment the following #define to disable FPS limiting */
-/*#define ENABLE_FPS_LIMIT*/
 #define DEFAULT_FPS 33
 
 
similarity index 79%
rename from tennixpy.cc
rename to src/tennixpy.cc
index 7f2c87e..8aea008 100644 (file)
  *
  **/
 
-#ifdef TENNIX_PYTHON
+#include "config.h"
+
+#ifdef HAVE_PYTHON
 
 #include <Python.h>
 
 #include "game.h"
-#include "archive.hh"
+#include "archive.h"
 #include "tennixpy.h"
 
+PyObject* tennixpy_register_bot(PyObject* self, PyObject* bot_class);
+PyObject* tennixpy_get_ball_pos(PyObject* self, PyObject* gamestate);
+PyObject* tennixpy_get_power(PyObject* self, PyObject* args);
+PyObject* tennixpy_get_position(PyObject* self, PyObject* args);
+PyObject* tennixpy_create_module(void);
+
+
+struct InputDevicePython {
+    PyObject* py_bot_class;
+    PyObject* py_bot;
+};
+
+
 /* This saves our current Python thread state */
 PyThreadState* _py_save;
 
@@ -53,8 +68,12 @@ PyObject* tennixpy_create_module(void)
     return module;
 }
 
-PyObject* tennixpy_create_bot(PyObject* bot_class, GameState* s, int player_id)
+void
+tennixpy_create_bot(InputDevice *device, GameState *s, int player_id)
 {
+    InputDevicePython *pydevice = (InputDevicePython*)device->user_data;
+    PyObject *bot_class = pydevice->py_bot_class;
+
     PyObject* o = NULL;
     PyObject* args;
     PyObject* gamestate;
@@ -77,11 +96,14 @@ PyObject* tennixpy_create_bot(PyObject* bot_class, GameState* s, int player_id)
     }
     _py_save = PyEval_SaveThread();
 
-    return o;
+    pydevice->py_bot = o;
 }
 
-void tennixpy_destroy_bot(PyObject* bot)
+void tennixpy_destroy_bot(InputDevice *device)
 {
+    InputDevicePython *pydevice = (InputDevicePython*)device->user_data;
+    PyObject *bot = pydevice->py_bot;
+
     PyObject* finish_func;
     PyEval_RestoreThread(_py_save);
     finish_func = PyObject_GetAttrString(bot, "finish");
@@ -92,8 +114,11 @@ void tennixpy_destroy_bot(PyObject* bot)
     _py_save = PyEval_SaveThread();
 }
 
-float tennixpy_bot_get_axis(PyObject* bot, int axis)
+float tennixpy_bot_get_axis(InputDevice *device, int axis)
 {
+    InputDevicePython *pydevice = (InputDevicePython*)device->user_data;
+    PyObject *bot = pydevice->py_bot;
+
     PyObject* args;
     PyObject* get_axis_func;
     PyObject* r;
@@ -124,8 +149,11 @@ float tennixpy_bot_get_axis(PyObject* bot, int axis)
     return result;
 }
 
-char tennixpy_bot_get_key(PyObject* bot, int key)
+char tennixpy_bot_get_key(InputDevice *device, int key)
 {
+    InputDevicePython *pydevice = (InputDevicePython*)device->user_data;
+    PyObject *bot = pydevice->py_bot;
+
     PyObject* args;
     PyObject* get_key_func;
     PyObject* r;
@@ -158,6 +186,29 @@ char tennixpy_bot_get_key(PyObject* bot, int key)
     return result;
 }
 
+static void
+input_add_python_bot(PyObject* bot_class)
+{
+    InputDevice *device = input_add_device();
+
+    if (device == NULL) {
+        fprintf(stderr, "Warning: Cannot add any more Python bots.\n");
+        // We carry a ref of bot_class, so give it up here
+        Py_DECREF(bot_class);
+        return;
+    }
+
+    device->type = INPUT_TYPE_AI_PYTHON;
+    device->icon = GR_INPUT_AI;
+
+    InputDevicePython *pydevice = new InputDevicePython;
+    pydevice->py_bot_class = bot_class;
+    pydevice->py_bot = NULL;
+    device->user_data = (void*)pydevice;
+    tennixpy_get_bot_name(device, device->name, INPUT_DEVICE_NAME_MAX);
+    fprintf(stderr, " %s", device->name);
+}
+
 PyObject* tennixpy_register_bot(PyObject* self, PyObject* bot_class)
 {
     assert(self == NULL);
@@ -172,8 +223,10 @@ PyObject* tennixpy_register_bot(PyObject* self, PyObject* bot_class)
     Py_RETURN_NONE;
 }
 
-void tennixpy_get_bot_name(PyObject* bot_class, char* dest, int maxlen)
+void tennixpy_get_bot_name(InputDevice *device, char* dest, int maxlen)
 {
+    InputDevicePython *pydevice = (InputDevicePython*)device->user_data;
+    PyObject *bot_class = pydevice->py_bot_class;
     PyObject *name;
 
     name = PyObject_GetAttrString(bot_class, "name");
@@ -305,11 +358,13 @@ void tennixpy_init(TennixArchive& tnxar)
     _py_save = PyEval_SaveThread();
 }
 
-void tennixpy_unregister_bot(PyObject* bot)
+void tennixpy_unregister_bot(InputDevice *device)
 {
+    InputDevicePython *pydevice = (InputDevicePython*)device->user_data;
     PyEval_RestoreThread(_py_save);
-    Py_DECREF(bot);
+    Py_XDECREF(pydevice->py_bot);
     _py_save = PyEval_SaveThread();
+    delete pydevice;
 }
 
 void tennixpy_uninit()
@@ -322,4 +377,4 @@ void tennixpy_uninit()
     /*Py_Finalize();*/
 }
 
-#endif
+#endif /* HAVE_PYTHON */
similarity index 56%
rename from tennixpy.h
rename to src/tennixpy.h
index a3ab98d..2a5e463 100644 (file)
 #ifndef __TENNIXPY_H
 #define __TENNIXPY_H
 
-#ifdef TENNIX_PYTHON
+#include "config.h"
 
-#include "archive.hh"
+#ifdef HAVE_PYTHON
 
-extern PyThreadState* _py_save;
+#include "archive.h"
+#include "input.h"
 
-PyObject* tennixpy_register_bot(PyObject* self, PyObject* bot_class);
-void tennixpy_unregister_bot(PyObject* bot);
-void tennixpy_get_bot_name(PyObject* bot_class, char* dest, int maxlen);
+void tennixpy_unregister_bot(InputDevice *device);
+void tennixpy_get_bot_name(InputDevice *device, char *dest, int maxlen);
 
-PyObject* tennixpy_create_bot(PyObject* bot_class, GameState* s, int player_id);
-void tennixpy_destroy_bot(PyObject* bot);
+void tennixpy_create_bot(InputDevice *device, GameState *s, int player_id);
+void tennixpy_destroy_bot(InputDevice *device);
 
-float tennixpy_bot_get_axis(PyObject* bot, int axis);
-char tennixpy_bot_get_key(PyObject* bot, int key);
-
-PyObject* tennixpy_get_ball_pos(PyObject* self, PyObject* gamestate);
-PyObject* tennixpy_get_power(PyObject* self, PyObject* args);
-PyObject* tennixpy_get_position(PyObject* self, PyObject* args);
-
-PyObject* tennixpy_create_module(void);
+//float tennixpy_bot_get_axis(PyObject* bot, int axis);
+float tennixpy_bot_get_axis(InputDevice *device, int axis);
+//char tennixpy_bot_get_key(PyObject* bot, int key);
+char tennixpy_bot_get_key(InputDevice *device, int key);
 
 void tennixpy_init(TennixArchive& tnxar);
 void tennixpy_uninit();
 
-#endif
+#endif /* HAVE_PYTHON */
 
-#endif
+#endif /* __TENNIXPY_H */
similarity index 100%
rename from util.c
rename to src/util.cc
similarity index 75%
rename from util.h
rename to src/util.h
index 048708c..2a3e21f 100644 (file)
--- a/util.h
 
 void day_night(unsigned int width, unsigned int* start, unsigned int* end);
 
-/**
- * On Maemo, we somehow don't get these defined in any of the header files,
- * so we define the prototypes here - if we don't do that, bad things will
- * happen.
- **/
-#ifdef MAEMO
-float fminf(float, float);
-float fmaxf(float, float);
-float fabsf(float);
-float sinf(float);
-float cosf(float);
-#endif
-
-
 #endif
-
diff --git a/tennix-installer.iss.in b/tennix-installer.iss.in
deleted file mode 100644 (file)
index 9adbc2c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-; Inno Setup Script Template for Tennix (on Windows)\r
-; Copyright (c) 2007 Thomas Perl <thpinfo.com/about>\r
-; Licensed under the same terms as Tennix iself\r
-\r
-[Setup]\r
-AppName=Tennix\r
-AppVerName=Tennix {version}\r
-AppPublisher=Thomas Perl\r
-AppPublisherURL=http://icculus.org/tennix/\r
-AppSupportURL=http://icculus.org/tennix/\r
-AppUpdatesURL=http://icculus.org/tennix/\r
-DefaultDirName={pf}\Tennix\r
-DefaultGroupName=Tennix\r
-LicenseFile=COPYING\r
-OutputDir=.\r
-OutputBaseFilename=tennix-{version}-win32-setup\r
-Compression=lzma\r
-SolidCompression=yes\r
-\r
-[Languages]\r
-Name: "english"; MessagesFile: "compiler:Default.isl"\r
-\r
-[Tasks]\r
-Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked\r
-\r
-[Files]\r
-Source: "tennix.exe"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "SDL.dll"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "SDL_image.dll"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "SDL_mixer.dll"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "libpng12.dll"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "COPYING"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "ChangeLog"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "README.win32"; DestDir: "{app}"; Flags: ignoreversion\r
-Source: "README"; DestDir: "{app}"; Flags: ignoreversion\r
-; NOTE: Don't use "Flags: ignoreversion" on any shared system files\r
-\r
-[Icons]\r
-Name: "{group}\Tennix"; Filename: "{app}\tennix.exe"\r
-Name: "{group}\{cm:ProgramOnTheWeb,Tennix}"; Filename: "http://icculus.org/tennix/"\r
-Name: "{group}\{cm:UninstallProgram,Tennix}"; Filename: "{uninstallexe}"\r
-Name: "{commondesktop}\Tennix"; Filename: "{app}\tennix.exe"; Tasks: desktopicon\r
-\r
-[Run]\r
-Filename: "{app}\tennix.exe"; Description: "{cm:LaunchProgram,Tennix}"; Flags: nowait postinstall skipifsilent\r
-\r
diff --git a/tennix.res b/tennix.res
deleted file mode 100644 (file)
index 919e42d..0000000
Binary files a/tennix.res and /dev/null differ