shithub: duke3d

Download patch

ref: cb7e5f5651fe9a9b414aebe0554b8d7d0b14eb25
parent: 8a328bb03cd65d602d3ae98a5eff07a9c0c61d24
parent: 3f18b383142fa983fcdfd5eb48f2a1ec9eb4746c
author: Fabien <fabien.sanglard@gmail.com>
date: Thu Apr 3 10:17:27 EDT 2014

Merge pull request #10 from juanmabc/master

Really minimal modification for Linux integration

--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,9 @@
 */ReleaseVC7
 *vcxproj.user
 DUKE3D.GRP
+
+# Linux
+*.o
+*.a
+chocolate-duke3d
+duke3d.grp
--- /dev/null
+++ b/Engine/src/Makefile
@@ -1,0 +1,10 @@
+SOURCES=cache.c display.c draw.c dummy_multi.c engine.c filesystem.c fixedPoint_math.c mmulti.c network.c tiles.c
+OBJECTS=cache.o display.o draw.o dummy_multi.o engine.o filesystem.o fixedPoint_math.o mmulti.o network.o tiles.o
+
+../../libEngine.a: $(SOURCES)
+	gcc -DPLATFORM_UNIX -DBYTE_ORDER=LITTLE_ENDIAN -D_XOPEN_SOURCE=500 -I /usr/include/SDL -I enet/include -c $(SOURCES)
+	ar cru ../../libEngine.a $(OBJECTS)
+	ranlib ../../libEngine.a
+
+clean:
+	rm $(OBJECTS) ../../libEngine.a
--- a/Engine/src/filesystem.c
+++ b/Engine/src/filesystem.c
@@ -404,7 +404,7 @@
 	
 }
 
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__linux__)
 int32_t filelength(int32_t fd){
     struct stat stats;
     fstat(fd, &stats);
--- a/Engine/src/filesystem.h
+++ b/Engine/src/filesystem.h
@@ -42,7 +42,7 @@
 
 int32_t  TCkopen4load(const char  *filename, int32_t readfromGRP);
 
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__linux__)
 int32_t  filelength(int32_t fd);
 #endif
 
--- /dev/null
+++ b/Engine/src/unix_compat.h
@@ -1,0 +1,67 @@
+//
+//  unix_compat.h
+//  Duke3D
+//
+//  Based on macos_compat.h
+//  Copyright Wed, Jul 31, 2013, Juan Manuel Borges Caño (GPLv3+)
+//
+
+#ifndef Duke3D_unix_compat_h
+#define Duke3D_unix_compat_h
+
+//#define BYTE_ORDER LITTLE_ENDIAN
+#define PLATFORM_SUPPORTS_SDL
+
+#include <stdlib.h>
+
+#define kmalloc(x) malloc(x)
+#define kkmalloc(x) malloc(x)
+#define kfree(x) free(x)
+#define kkfree(x) free(x)
+
+#ifdef FP_OFF
+#undef FP_OFF
+#endif
+
+// Horrible horrible macro: Watcom allowed memory pointer to be cast
+// to a 32bits integer. The code is unfortunately stuffed with this :( !
+#define FP_OFF(x) ((int32_t) (x))
+
+#ifndef max
+#define max(x, y)  (((x) > (y)) ? (x) : (y))
+#endif
+
+#ifndef min
+#define min(x, y)  (((x) < (y)) ? (x) : (y))
+#endif
+
+#include <inttypes.h>
+#define __int64 int64_t
+
+#define O_BINARY 0
+
+#define UDP_NETWORKING 1
+
+#define PLATFORM_UNIX 1
+
+/*
+#define SOL_IP SOL_SOCKET
+#define IP_RECVERR  SO_BROADCAST
+*/
+
+#define stricmp strcasecmp
+#define strcmpi strcasecmp
+
+#define S_IREAD S_IRUSR
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <string.h>
+
+#define USER_DUMMY_NETWORK 1
+
+#endif
--- /dev/null
+++ b/Game/src/Makefile
@@ -1,0 +1,17 @@
+SOURCES=actors.c animlib.c config.c console.c control.c cvar_defs.c cvars.c dummy_audiolib.c game.c gamedef.c global.c keyboard.c menues.c player.c premap.c rts.c scriplib.c sector.c sounds.c
+OBJECTS=actors.o animlib.o config.o console.o control.o cvar_defs.o cvars.o dummy_audiolib.o game.o gamedef.o global.o keyboard.o menues.o player.o premap.o rts.o scriplib.o sector.o sounds.o
+
+../../libGame.a: audiolib.a libmidi.a $(SOURCES)
+	gcc -DPLATFORM_UNIX -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -I /usr/include/SDL/ -I ../../Engine/src/ -c $(SOURCES)
+	ar cru ../../libGame.a $(OBJECTS) audiolib/*.o midi/*.o
+	ranlib ../../libGame.a
+
+audiolib.a:
+	cd audiolib && make
+libmidi.a:
+	cd midi && make
+
+clean:
+	rm $(OBJECTS) ../../libGame.a
+	cd midi && make clean
+	cd audiolib && make clean
--- a/Game/src/audiolib/Makefile
+++ b/Game/src/audiolib/Makefile
@@ -4,19 +4,19 @@
 CFLAGS=-g -O2
 LDLIBS=
 
-CFLAGS += $(shell sdl-config --cflags)
+CFLAGS += $(shell sdl-config --cflags) -DPLATFORM_UNIX -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -DBYTE_ORDER=LITTLE_ENDIAN -I /usr/include/SDL -I ../../../Engine/src/
 LDLIBS += $(shell sdl-config --libs)
 
 OBJ=fx_man.o dsl.o ll_man.o multivoc.o mv_mix.o mvreverb.o nodpmi.o \
 	pitch.o user.o usrhooks.o
 
-audiolib.a: $(OBJ)
+../audiolib.a: $(OBJ)
 	rm -rf $@
 	$(AR) rc $@ $^
 	$(RANLIB) $@
 
 clean:
-	rm -rf audiolib.a *.o
+	rm -rf ../audiolib.a *.o
 
 distclean: clean
 	rm -rf *~
--- a/Game/src/audiolib/usrhooks.c
+++ b/Game/src/audiolib/usrhooks.c
@@ -43,7 +43,7 @@
 int USRHOOKS_GetMem
    (
    void **ptr,
-   unsigned long size
+   uint32_t size
    )
 
    {
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -8079,7 +8079,8 @@
     {
         
         
-        if (dukeGRP_Match(dirEntry->d_name,dirEntry->d_namlen))
+        //if (dukeGRP_Match(dirEntry->d_name,dirEntry->d_namlen))
+        if (dukeGRP_Match(dirEntry->d_name, _D_EXACT_NAMLEN(dirEntry)))
         {
             sprintf(groupfilefullpath,"%s",dirEntry->d_name);
             return;
--- a/Game/src/global.c
+++ b/Game/src/global.c
@@ -839,7 +839,7 @@
 	return string;
 }
 
-uint8_t  *ultoa(unsigned int32_t value, uint8_t  *string, int radix)
+uint8_t  *ultoa(uint32_t value, uint8_t  *string, int radix)
 {
 	switch (radix) {
 		case 10:
@@ -866,7 +866,8 @@
 
 	snprintf (ApogeePath, sizeof (ApogeePath), "%s/.duke3d/", getenv ("HOME"));
 
-	err = mkdir (ApogeePath, S_IRWXU);
+	//err = mkdir (ApogeePath, S_IRWXU);
+	err = mkdir (ApogeePath);
 	if (err == -1 && errno != EEXIST)
 	{
 		fprintf (stderr, "Couldn't create preferences directory: %s\n", 
--- /dev/null
+++ b/Game/src/midi/Makefile
@@ -1,0 +1,10 @@
+SOURCES=sdl_midi.c
+OBJECTS=sdl_midi.o
+
+../libmidi.a: $(SOURCES)
+	gcc -DPLATFORM_UNIX -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -DBYTE_ORDER=LITTLE_ENDIAN -I /usr/include/SDL/ -I ../../../Engine/src/ -c $(SOURCES)
+	ar cru ../libmidi.a $(OBJECTS)
+	ranlib ../libmidi.a
+
+clean:
+	rm ../libmidi.a $(OBJECTS)
--- a/Game/src/midi/sdl_midi.c
+++ b/Game/src/midi/sdl_midi.c
@@ -9,7 +9,7 @@
 #include <stdio.h>
 #include "../audiolib/music.h"
 #include "SDL.h"
-#include "SDL_Mixer.h"
+#include "SDL_mixer.h"
 #include "build.h"
 
 /*
@@ -185,4 +185,4 @@
 // This is the method called from the Game Module.
 void PlayMusic(char  *fileName){
     MUSIC_PlaySong(fileName,1);
-}
\ No newline at end of file
+}
--- /dev/null
+++ b/Makefile
@@ -1,0 +1,9 @@
+all:
+	cd Engine/src && make
+	cd Game/src && make
+	gcc libGame.a libEngine.a `pkg-config --cflags --libs sdl SDL_mixer` -o chocolate-duke3d
+
+clean:
+	cd Game/src && make clean
+	cd Engine/src && make clean
+	rm chocolate-duke3d
--- a/README.md
+++ b/README.md
@@ -21,16 +21,26 @@
 Build
 =====
 
+Linux: Use 'make' (.grp in binary working directory and with rw permissions)
 Windows: Use Visual Studio 2005 or Visual Studio 2012  
 OS X: Use Xcode 4.0  
-Linux: Not yet tested 
 
 
-Background
-==========
+Contributors
+============
 
-**Project initiator:** Fabien Sanglard 
+**Project Initiator:** Fabien Sanglard 
+**Linux Tweaks:** Juan Manuel Borges Caño 
 
-**More information:** [Review of the Duke 3D source code](http://fabiensanglard.net/duke3d/)
-
+More Information
+================
 
+[Linux Integration](http://juanmabcblog.blogspot.com/2013/07/chocolate-duke3d.html)
+[Review of the Duke 3D source code](http://fabiensanglard.net/duke3d/)
+
+chocolate-duke3d (Chocolate Duke Nukem 3D) Linux integration licensed GPLv3 by Juan Manuel Borges Caño
+* homepage: < http://juanmabcblog.blogspot.com/2013/07/chocolate-duke3d.html >
+* blog < http://juanmabcblog.blogspot.com >
+* mail < mailto:juanmabcmail@gmail.com >
+
+Copyright (C) 2013 - 2014 Juan Manuel Borges Caño :-) Thanks through email (suggested subject chocolate-duke3d) or/and Payments through blog with BitCoin, Flattr, Western Union and PayPal Welcome :-)