diff --git a/setup b/setup index 95166451e..f8c268b5b 100755 --- a/setup +++ b/setup @@ -37,10 +37,11 @@ MAKE=make #------------------------------------------------------------------------------ # DON'T CHANGE ANYTHING FROM HERE DOWN UNLESS YOU KNOW WHAT YOU ARE DOING -VERSION="-DVERSION=\"1.17pre1-build10\"" +VERSION="-DVERSION=\"1.17pre1-build11\"" UNIX=0 BEOS=0 WIN32=0 +DARWIN=0 # Choose optimization level #DEBUG_CFLAGS="-g -O0 \$(PROFILE) -pipe -Wall -Werror \$(IFLAGS) \$(DFLAGS)" @@ -73,7 +74,7 @@ while test $# != 0 ; do case $1 in "-?"|"--help") echo - echo "usage: setup [--static] [--unix] [--beos] [--win32] [--debug] [--profile]" + echo "usage: setup [--static] [--unix] [--beos] [--win32] [--darwin] [--debug] [--profile]" echo echo "Setup will create a Rules.make file that Freecraft needs to compile." echo "Supported command-line arguments (you may use more than one at a time):" @@ -81,6 +82,7 @@ while test $# != 0 ; do echo " unix : Force Unix/Linux compile options (default auto check)" echo " beos : Force BeOS compile options (default auto check)" echo " win32 : Force WIN32 compile options (default auto check)" + echo " darwin : Force Darwin compile options (default auto check)" echo " debug : Compile with debug options (default no)" echo " profile : Compile with profile support (default off)" echo @@ -95,18 +97,28 @@ while test $# != 0 ; do UNIX=1 BEOS=0 WIN32=0 + DARWIN=0 ;; "--beos") UNIX=0 BEOS=1 WIN32=0 + DARWIN=0 ;; "--win32") UNIX=0 BEOS=0 WIN32=1 + DARWIN=0 + ;; + + "--darwin") + UNIX=0 + BEOS=0 + WIN32=0 + DARWIN=1 ;; "--profile") @@ -140,14 +152,16 @@ echo; echo if [ "$UNIX" != "1" ] ; then if [ "$BEOS" != "1" ] ; then if [ "$WIN32" != "1" ] ; then + if [ "$DARWIN" != "1" ] ; then if [ "$WIN32" = "0" ] ; then if [ "`uname | grep -is cygwin` x" != " x" ] ; then UNIX=0 BEOS=0 WIN32=1 + DARWIN=0 echo "It appears that you are in a Cygwin/win32 environment..." - echo "Use --unix or --beos to override" + echo "Use --darwin, --unix or --beos to override" fi fi @@ -156,25 +170,43 @@ if [ "$BEOS" = "0" ] ; then UNIX=0 BEOS=1 WIN32=0 + DARWIN=0 echo "It appears that you are in a BeOS environment..." - echo "Use --unix or --win32 to override" + echo "Use --darwin, --unix or --win32 to override" + fi +fi + +if [ "$DARWIN" = "0" ] ; then + if [ "`uname -a | grep -is darwin` x" != " x" ] ; then + DARWIN=1 + UNIX=0 + BEOS=0 + WIN32=0 + CC=cc + CFLAGS="-O2 -pipe -fomit-frame-pointer -fconserve-space -fexpensive-optimizations -ffast-math \$(IFLAGS) \$(DFLAGS) -traditional-cpp" + echo "It appears that you are in a Darwin environment..." + echo "Use --beos, --win32 or --unix to override" fi fi if [ "$UNIX" = "0" ] ; then if [ "$BEOS" = "0" ] ; then if [ "$WIN32" = "0" ] ; then - UNIX=1 - BEOS=0 - WIN32=0 - echo "It appears that you are in a UNIX environment..." - echo "Use --beos or --win32 to override" + if [ "$DARWIN" = "0" ] ; then + UNIX=1 + BEOS=0 + WIN32=0 + DARWIN=0 + echo "It appears that you are in a UNIX environment..." + echo "Use --beos or --win32 or --darwin to override" + fi fi fi fi - fi - fi +fi +fi +fi fi echo @@ -191,8 +223,13 @@ echo >> $RULESFILE echo "# Use SIOD support" >> $RULESFILE if [ "$BEOS" != "1" ] ; then - echo "CCL = -DUSE_CCL2" >> $RULESFILE - echo "CCLLIB = -lm -ldl" >> $RULESFILE + if [ "$DARWIN" != "1" ] ; then + echo "CCL = -DUSE_CCL2" >> $RULESFILE + echo "CCLLIB = -lm -ldl" >> $RULESFILE + else + echo "CCL = -DUSE_CCL2" >> $RULESFILE + echo "CCLLIB = -dl" >> $RULESFILE + fi else echo "CCL = -DUSE_CCL2 -DUSE_BEOS" >> $RULESFILE echo "CCLLIB =" >> $RULESFILE @@ -215,13 +252,15 @@ fi if [ "$BEOS" != "1" ] ; then -# Check for SVGALIB -LIBCHECK="-lvga -lvgagl" -check_for_libs -if test "$?" = 0 ; then - HAVESVGA=1 -else - echo "...You do not appear to have SVGALIB installed" +if [ "$DARWIN" != "1" ] ; then + # Check for SVGALIB + LIBCHECK="-lvga -lvgagl" + check_for_libs + if test "$?" = 0 ; then + HAVESVGA=1 + else + echo "...You do not appear to have SVGALIB installed" + fi fi echo @@ -452,10 +491,17 @@ echo "" >> $RULESFILE # extra linker flags and include directory # -L/usr/lib -echo "XLDFLAGS = -L/usr/X11R6/lib -L/usr/local/lib \\" >> $RULESFILE -echo " -L\$(TOPDIR)/libpng-1.0.5 -L\$(TOPDIR)/zlib-1.1.3" >> $RULESFILE -echo "XIFLAGS = -I/usr/X11R6/include -I/usr/local/include \\" >> $RULESFILE -echo " -I\$(TOPDIR)/libpng-1.0.5 -I\$(TOPDIR)/zlib-1.1.3" >> $RULESFILE +if [ "$DARWIN" != 1 ] ; then + echo "XLDFLAGS = -L/usr/X11R6/lib -L/usr/local/lib \\" >> $RULESFILE + echo " -L\$(TOPDIR)/libpng-1.0.5 -L\$(TOPDIR)/zlib-1.1.3" >> $RULESFILE + echo "XIFLAGS = -I/usr/X11R6/include -I/usr/local/include \\" >> $RULESFILE + echo " -I\$(TOPDIR)/libpng-1.0.5 -I\$(TOPDIR)/zlib-1.1.3" >> $RULESFILE +else + echo "XLDFLAGS = -L/usr/X11R6/lib -L/usr/local/lib" >> $RULESFILE + echo "XIFLAGS = -I/usr/X11R6/include -I/usr/local/include \\" >> $RULESFILE + echo " -I/usr/include -I/usr/include/machine" >> $RULESFILE +fi + echo >> $RULESFILE # Add the last bits @@ -470,12 +516,21 @@ echo "PROFILE=$PROFILE" >> $RULESFILE echo >> $RULESFILE if [ "$BEOS" != 1 ] ; then - # Libraries needed to build tools - echo "TOOLLIBS=\$(XLDFLAGS) -lpng -lz -lm \$(THREADLIB)" >> $RULESFILE + if [ "$DARWIN" != 1 ] ; then + # Libraries needed to build tools + echo "TOOLLIBS=\$(XLDFLAGS) -lpng -lz -lm \$(THREADLIB)" >> $RULESFILE - # Libraries needed to build freecraft - echo "CLONELIBS=\$(XLDFLAGS) -lpng -lz -lm \\" >> $RULESFILE - echo " \$(THREADLIB) \$(CCLLIB) \$(VIDEOLIB) \$(ZLIBS)" >> $RULESFILE + # Libraries needed to build freecraft + echo "CLONELIBS=\$(XLDFLAGS) -lpng -lz -lm \\" >> $RULESFILE + echo " \$(THREADLIB) \$(CCLLIB) \$(VIDEOLIB) \$(ZLIBS)" >> $RULESFILE + else + # Libraries needed to build tools + echo "TOOLLIBS=\$(XLDFLAGS) -lpng -lz \$(THREADLIB)" >> $RULESFILE + + # Libraries needed to build freecraft + echo "CLONELIBS=\$(XLDFLAGS) -lpng -lz \\" >> $RULESFILE + echo " \$(THREADLIB) \$(CCLLIB) \$(VIDEOLIB) \$(ZLIBS)" >> $RULESFILE + fi else # Libraries needed to build tools echo "TOOLLIBS=\$(XLDFLAGS) -lpng -lz \$(THREADLIB)" >> $RULESFILE @@ -553,6 +608,10 @@ echo "%.o: %.c" >> $RULESFILE echo " \$(CC) -c \$(CFLAGS) \$< -o \$@" >> $RULESFILE echo " @ar cru \$(TOPDIR)/src/libclone.a \$@" >> $RULESFILE +if [ "$DARWIN" = "1" ] ; then + echo " ranlib \$(TOPDIR)/src/libclone.a" >> $RULESFILE +fi + # # Source code documentation diff --git a/src/include/freecraft.h b/src/include/freecraft.h index 12f4e61f3..2e060f161 100644 --- a/src/include/freecraft.h +++ b/src/include/freecraft.h @@ -182,6 +182,19 @@ #define MAGIC_FOR_NEW_UNITS 85 /// magic value, new units start with #define DEMOLISH_DAMAGE 400 /// damage for demolish attack +/*---------------------------------------------------------------------------- +-- MacOS X fixes +----------------------------------------------------------------------------*/ + +#if defined(__APPLE__) + +#define MenuKey FreeCraftMenuKey +#define HideCursor FreeCraftHideCursor +#define InitCursor FreeCraftInitCursor +#define DrawText FreeCraftDrawText + +#endif // defined(__APPLE__) + /*---------------------------------------------------------------------------- -- Screen ----------------------------------------------------------------------------*/ diff --git a/src/include/myendian.h b/src/include/myendian.h index 7f3e2c0c4..780059f4a 100644 --- a/src/include/myendian.h +++ b/src/include/myendian.h @@ -82,6 +82,9 @@ #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN #include <byteswap.h> #endif +#if defined(__APPLE__) +#include <architecture/byte_order.h> +#endif #endif /*---------------------------------------------------------------------------- @@ -102,6 +105,20 @@ #else +#if defined(__APPLE__) + +/** +** Convert a 16 bit value in little endian and return it in native format. +*/ +#define ConvertLE16(v) NXSwapLittleShortToHost(v) + +/** +** Convert a 32 bit value in little endian and return it in native format. +*/ +#define ConvertLE32(v) NXSwapLittleIntToHost(v) + +#else + /** ** Convert a 16 bit value in little endian and return it in native format. */ @@ -112,6 +129,8 @@ */ #define ConvertLE32(v) (v) +#endif // defined(__APPLE__) + #endif // ! defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN /** diff --git a/src/include/siod.h b/src/include/siod.h index 21601a469..24cdac5d6 100644 --- a/src/include/siod.h +++ b/src/include/siod.h @@ -169,7 +169,7 @@ void set_repl_hooks(void (*puts_f)(char *), LISP (*eval_f)(LISP), void (*print_f)(LISP)); long repl(struct repl_hooks *); -LISP err(const char *message, LISP x); +LISP errl(const char *message, LISP x); LISP errswitch(void); char *get_c_string(LISP x); char *get_c_string_dim(LISP x,long *); diff --git a/src/unit/script_unittype.cpp b/src/unit/script_unittype.cpp index 71ce33f8d..3b601e1e0 100644 --- a/src/unit/script_unittype.cpp +++ b/src/unit/script_unittype.cpp @@ -764,7 +764,7 @@ local UnitType* CclGetUnitType(SCM ptr) return UnitTypeByIdent(str); } if( NTYPEP(ptr,SiodUnitTypeTag) ) { - err("not an unit type",ptr); + errl("not an unit type",ptr); } return (UnitType*)CAR(ptr); } diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index a0a82e68b..e68571a4f 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -1028,9 +1028,9 @@ global void RescueUnits(void) // FIXME: could be done faster? #endif n=SelectUnits( - unit->X-1,unit->Y-1, - unit->X+unit->Type->TileWidth+1, - unit->Y+unit->Type->TileHeight+1,near); + unit->X-2,unit->Y-2, + unit->X+unit->Type->TileWidth+2, + unit->Y+unit->Type->TileHeight+2,near); // // Look if human near the unit. //