shithub: duke3d

Download patch

ref: 75c1e7929008b37fb05640fa9720e5693b532043
parent: 15af229ba22a403f2c1c4253b9c770bb8cb9dbf4
author: Tanguy Fautre <tanguy@fautre.com>
date: Tue Feb 18 15:29:58 EST 2020

Clean things up a bit

--- a/Engine/src/draw.c
+++ b/Engine/src/draw.c
@@ -859,8 +859,8 @@
 extern int32_t reciptable[2048];
 extern int32_t globalx3, globaly3;
 extern int32_t fpuasm;
-#define low32(a) ((a&0xffffffff))
-#define high32(a) ((int)(((__int64)a&(__int64)0xffffffff00000000)>>32))
+#define low32(a) (((a)&0xffffffff))
+#define high32(a) ((int)(((int64_t)(a)&(int64_t)0xffffffff00000000)>>32))
 
 //FCS: Render RENDER_SLOPPED_CEILING_AND_FLOOR
 void slopevlin(intptr_t i1, uint32_t i2, intptr_t* i3, uint32_t index, int32_t i4, int32_t i5, int32_t i6)
@@ -871,8 +871,8 @@
 //This is so bad to cast asm3 to int then float :( !!!
     float a = (float)(int32_t) asm3 + asm2_f;
     i1 -= slopemach_ecx;
-    esi = i5 + low32((__int64)globalx3 * (__int64)(i2<<3));
-    edi = i6 + low32((__int64)globaly3 * (__int64)(i2<<3));
+    esi = i5 + low32((int64_t)globalx3 * (int64_t)(i2<<3));
+    edi = i6 + low32((int64_t)globaly3 * (int64_t)(i2<<3));
     ebx = i4;
 
 	if (!RENDER_SLOPPED_CEILING_AND_FLOOR)
@@ -895,8 +895,8 @@
 	    edx = i2;
 	    i2 = eax;
 	    eax -= edx;
-	    ecx = low32((__int64)globalx3 * (__int64)eax);
-	    eax = low32((__int64)globaly3 * (__int64)eax);
+	    ecx = low32((int64_t)globalx3 * (int64_t)eax);
+	    eax = low32((int64_t)globaly3 * (int64_t)eax);
 	    a += asm2_f;
 
 	    asm4 = ebx;
--- a/Engine/src/macos_compat.h
+++ b/Engine/src/macos_compat.h
@@ -20,7 +20,6 @@
 #endif
 
 #include <inttypes.h>
-#define __int64 int64_t
 
 #define O_BINARY 0
 
--- a/Engine/src/unix_compat.h
+++ b/Engine/src/unix_compat.h
@@ -22,7 +22,6 @@
 #endif
 
 #include <inttypes.h>
-#define __int64 int64_t
 
 #define O_BINARY 0
 
--- a/Game/src/duke3d.h
+++ b/Game/src/duke3d.h
@@ -26,23 +26,6 @@
 #ifndef _INCL_DUKE3D_H_
 #define _INCL_DUKE3D_H_
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-
-
-#include "platform.h"
-#if !PLATFORM_MACOSX
-#include <malloc.h>
-#endif
-
-#include <inttypes.h>
-
-#include <fcntl.h>
-#include <time.h>
-#include <ctype.h>
-
 #include "build.h"
 
 #if (!defined MAX_PATH)
@@ -67,7 +50,6 @@
 #include "dukewin.h"
 #endif
 
-#include "function.h"
 
 //  FIX_00022: Automatically recognize the shareware grp (v1.3) + full version (1.3d) +
 //             atomic (1.4/1.5 grp) and the con files version (either 1.3 or 1.4) (JonoF's idea)
--- a/Game/src/dukewin.h
+++ b/Game/src/dukewin.h
@@ -1,10 +1,6 @@
 #ifndef _INCL_DUKEWIN_H_
 #define _INCL_DUKEWIN_H_ 1
 
-#ifndef _MSC_VER  /* might need this. */
-typedef int32_t int32_t __int64;
-#endif
-
 #pragma warning(disable:4761)
 
 #ifdef _DEBUG
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -24,6 +24,8 @@
 */
 //-------------------------------------------------------------------------
 
+#include <time.h>
+
 #ifdef _WIN32
   #include <windows.h>
 #elif defined(__APPLE__)
--- a/Game/src/global.c
+++ b/Game/src/global.c
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
+#include <time.h>
 #include <errno.h>
 #include "global.h"
 #include "duke3d.h"
--- a/Game/src/menues.c
+++ b/Game/src/menues.c
@@ -367,15 +367,7 @@
     kdfread(&cloudx[0], sizeof(short) << 7, 1, fil);
     kdfread(&cloudy[0], sizeof(short) << 7, 1, fil);
 
-    //kdfread(&scriptptrs[0], 1, MAXSCRIPTSIZE, fil);
     kdfread(&script[0], 4, MAXSCRIPTSIZE, fil);
-    //for (i = 0; i < MAXSCRIPTSIZE; i++)
-    //    if (scriptptrs[i])
-    //    {
-    //        j = (intptr_t)script[i] + (intptr_t)&script[0];
-    //        script[i] = j;
-    //    }
-
     kdfread(&ptrbuf[0], 4, MAXTILES, fil);
     for (i = 0; i < MAXTILES; i++)
         if (ptrbuf[i])
@@ -383,17 +375,7 @@
             actorscrptr[i] = (int32_t*)((intptr_t)&script[0] + ptrbuf[i]);
         }
 
-    //kdfread(&scriptptrs[0], 1, MAXSPRITES, fil);
     kdfread(&hittype[0], sizeof(struct weaponhit), MAXSPRITES, fil);
-
-    //for (i = 0; i < MAXSPRITES; i++)
-    //{
-    //    j = (intptr_t)(&script[0]);
-    //    if (scriptptrs[i] & 1) T2 += j;
-    //    if (scriptptrs[i] & 2) T5 += j;
-    //    if (scriptptrs[i] & 4) T6 += j;
-    //}
-
     kdfread(&lockclock, sizeof(lockclock), 1, fil);
     kdfread(&pskybits, sizeof(pskybits), 1, fil);
     kdfread(&pskyoff[0], sizeof(pskyoff[0]), MAXPSKYTILES, fil);
@@ -400,8 +382,7 @@
 
     kdfread(&animatecnt, sizeof(animatecnt), 1, fil);
     kdfread(&animatesect[0], 2, MAXANIMATES, fil);
-    //kdfread(&animateptr[0], 4, MAXANIMATES, fil);
-    kdfread(&ptrbuf[0], 4, MAXANIMATES, fil);
+	kdfread(&ptrbuf[0], 4, MAXANIMATES, fil);
     for (i = animatecnt - 1; i >= 0; i--)
     {
         animateptr[i] = (int32_t*)((intptr_t)&sector[0] + ptrbuf[i]);
@@ -659,28 +640,9 @@
     dfwrite(&cloudx[0], sizeof(short) << 7, 1, fil);
     dfwrite(&cloudy[0], sizeof(short) << 7, 1, fil);
 
-    //for (i = 0; i < MAXSCRIPTSIZE; i++)
-    //{
-    //    if (script[i] >= (intptr_t)(&script[0]) && script[i] < (intptr_t)(&script[MAXSCRIPTSIZE]))
-    //    {
-    //        scriptptrs[i] = 1;
-    //        j = script[i] - (intptr_t)&script[0];
-    //        script[i] = j;
-    //    }
-    //    else scriptptrs[i] = 0;
-    //}
-
-    //dfwrite(&scriptptrs[0], 1, MAXSCRIPTSIZE, fil);
     dfwrite(&script[0], 4, MAXSCRIPTSIZE, fil);
 
-    //for (i = 0; i < MAXSCRIPTSIZE; i++)
-    //    if (scriptptrs[i])
-    //    {
-    //        j = script[i] + (intptr_t)&script[0];
-    //        script[i] = j;
-    //    }
-
-    memset(ptrbuf, 0, sizeof(ptrbuf));
+	memset(ptrbuf, 0, sizeof(ptrbuf));
     for (i = 0; i < MAXTILES; i++)
         if (actorscrptr[i])
         {
@@ -688,47 +650,7 @@
         }
     dfwrite(&ptrbuf[0], 4, MAXTILES, fil);
 
-    //for (i = 0; i < MAXSPRITES; i++)
-    //{
-    //    scriptptrs[i] = 0;
-
-    //    if (actorscrptr[PN] == 0) continue;
-
-    //    j = (intptr_t)&script[0];
-
-    //    if (T2 >= j && T2 < (intptr_t)(&script[MAXSCRIPTSIZE]))
-    //    {
-    //        scriptptrs[i] |= 1;
-    //        T2 -= j;
-    //    }
-    //    if (T5 >= j && T5 < (intptr_t)(&script[MAXSCRIPTSIZE]))
-    //    {
-    //        scriptptrs[i] |= 2;
-    //        T5 -= j;
-    //    }
-    //    if (T6 >= j && T6 < (intptr_t)(&script[MAXSCRIPTSIZE]))
-    //    {
-    //        scriptptrs[i] |= 4;
-    //        T6 -= j;
-    //    }
-    //}
-
-    //dfwrite(&scriptptrs[0], 1, MAXSPRITES, fil);
-    dfwrite(&hittype[0], sizeof(struct weaponhit), MAXSPRITES, fil);
-
-    //for (i = 0; i < MAXSPRITES; i++)
-    //{
-    //    if (actorscrptr[PN] == 0) continue;
-    //    j = (intptr_t)&script[0];
-
-    //    if (scriptptrs[i] & 1)
-    //        T2 += j;
-    //    if (scriptptrs[i] & 2)
-    //        T5 += j;
-    //    if (scriptptrs[i] & 4)
-    //        T6 += j;
-    //}
-
+	dfwrite(&hittype[0], sizeof(struct weaponhit), MAXSPRITES, fil);
     dfwrite(&lockclock, sizeof(lockclock), 1, fil);
     dfwrite(&pskybits, sizeof(pskybits), 1, fil);
     dfwrite(&pskyoff[0], sizeof(pskyoff[0]), MAXPSKYTILES, fil);
--- a/Game/src/rts.c
+++ b/Game/src/rts.c
@@ -26,6 +26,7 @@
 
 #include "duke3d.h"
 #include "global.h"
+#include <malloc.h>
 
 //=============
 // STATICS