ref: c1414921e4a25ae93629a6430f4edf1f304607ee
parent: 30670c674ee6ae1f468e1ac29b66e0480a113ede
author: fabien sanglard <fabiensanglard@fabiens-Mac-Pro-3.local>
date: Sat Dec 22 19:28:01 EST 2012
Created network module. Removed warnings. Changed draw system signatures.
--- a/Engine/src/cache.c
+++ b/Engine/src/cache.c
@@ -59,8 +59,15 @@
static int32_t cachesize = 0;
int32_t cachecount = 0;
uint8_t zerochar = 0;
-int32_t cachestart = 0, cacnum = 0, agecount = 0;
-typedef struct { int32_t *hand, leng; uint8_t *lock; } cactype;
+uint8_t* cachestart = NULL;
+int32_t cacnum = 0, agecount = 0;
+
+typedef struct {
+ uint8_t** hand;
+ int32_t leng;
+ uint8_t *lock; }
+cactype;
+
cactype cac[MAXCACHEOBJECTS];
int32_t lockrecip[200];
@@ -67,7 +74,7 @@
// TC game directory
char game_dir[512] = { '\0' };
-void initcache(int32_t dacachestart, int32_t dacachesize)
+void initcache(uint8_t* dacachestart, int32_t dacachesize)
{
int32_t i;
@@ -212,7 +219,7 @@
for(i=0;i<cacnum;i++)
{
printf("%d- ",i);
- printf("ptr: 0x%x, ",*cac[i].hand);
+ printf("ptr: 0x%x, ",(int8_t)*cac[i].hand);
printf("leng: %d, ",cac[i].leng);
printf("lock: %d\n",*cac[i].lock);
j += cac[i].leng;
--- a/Engine/src/cache.h
+++ b/Engine/src/cache.h
@@ -17,7 +17,7 @@
#ifndef _INCLUDE_CACHE1D_H_
#define _INCLUDE_CACHE1D_H_
-void initcache(int32_t dacachestart, int32_t dacachesize);
+void initcache(uint8_t* dacachestart, int32_t dacachesize);
void allocache (uint8_t* *newhandle, int32_t newbytes, uint8_t *newlockptr);
void suckcache (int32_t *suckptr);
void agecache(void);
--- a/Engine/src/display.c
+++ b/Engine/src/display.c
@@ -41,11 +41,11 @@
#include "display.h"
#include "fixedPoint_math.h"
#include "engine.h"
-//#include "engine_protos.h"
+#include "network.h"
#include "mmulti_unstable.h"
#include "mmulti_stable.h"
-
+#include "network.h"
#include "icon.h"
// NATIVE TIMER FUNCTION DECLARATION
@@ -64,211 +64,8 @@
-// NETWORK STUFF
-void Setup_UnstableNetworking();
-void Setup_StableNetworking();
-int nNetMode = 0;
-//TODO ( "[Fix this horrible networking mess. Function pointers not happy]" )
-// I do not like this one bit.
-// Figure out what was causing the problems with the function pointers.
-// This mess is a direct result of my lack of time.. bleh
-// This mess shouldn't even be in this file. /slap /slap
-void callcommit(void)
-{
-#ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_callcommit();
- break;
- case 1:
- stable_callcommit();
- break;
- }
-#endif
-}
-void initcrc(void)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_initcrc();
- break;
- case 1:
- stable_initcrc();
- break;
- }
-#endif
-}
-int32_t getcrc(uint8_t *buffer, short bufleng)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- return unstable_getcrc(buffer, bufleng);
- case 1:
- return stable_getcrc(buffer, bufleng);
- }
-#endif
- return 0;
-}
-void initmultiplayers(uint8_t damultioption, uint8_t dacomrateoption, uint8_t dapriority)
-{
-#ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_initmultiplayers(damultioption, dacomrateoption, dapriority);
- break;
- case 1:
- stable_initmultiplayers(damultioption, dacomrateoption, dapriority);
- break;
- }
-#endif
-}
-void sendpacket(int32_t other, uint8_t *bufptr, int32_t messleng)
-{
-#ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_sendpacket(other, bufptr, messleng);
- break;
- case 1:
- stable_sendpacket(other, bufptr, messleng);
- break;
- }
-#endif
-}
-void setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount)
-{
-#ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_setpackettimeout(datimeoutcount, daresendagaincount);
- break;
- case 1:
- stable_setpackettimeout(datimeoutcount, daresendagaincount);
- break;
- }
-#endif
-}
-void uninitmultiplayers(void)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_uninitmultiplayers();
- break;
- case 1:
- stable_uninitmultiplayers();
- break;
- }
-#endif
-}
-void sendlogon(void)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_sendlogon();
- break;
- case 1:
- unstable_sendlogon();
- break;
- }
-#endif
-}
-void sendlogoff(void)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_sendlogoff();
- break;
- case 1:
- stable_sendlogoff();
- break;
- }
-#endif
-}
-int getoutputcirclesize(void)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- return unstable_getoutputcirclesize();
- case 1:
- return stable_getoutputcirclesize();
- }
-#endif
- return 0;
-}
-void setsocket(short newsocket)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_setsocket(newsocket);
- break;
- case 1:
- stable_setsocket(newsocket);
- break;
- }
-#endif
-}
-short getpacket(short *other, uint8_t *bufptr)
-{
-#ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- return unstable_getpacket(other, bufptr); // default
- case 1:
- return stable_getpacket(other, bufptr);
- }
-#endif
- return 0;
-}
-void flushpackets(void)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_flushpackets();
- break;
- case 1:
- stable_flushpackets();
- break;
- }
-#endif
-}
-void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command)
-{
- #ifndef USER_DUMMY_NETWORK
- switch(nNetMode)
- {
- case 0:
- unstable_genericmultifunction(other, bufptr, messleng, command);
- break;
- case 1:
- stable_genericmultifunction(other, bufptr, messleng, command);
- break;
- }
-#endif
-}
-
#if ((defined PLATFORM_WIN32))
#include <windows.h>
#endif
@@ -931,16 +728,7 @@
-//#include "mmulti_stable.h"
-void Setup_UnstableNetworking()
-{
- nNetMode = 0;
-}
-void Setup_StableNetworking()
-{
- nNetMode = 1;
-}
void _platform_init(int argc, char **argv, const char *title, const char *iconName)
--- a/Engine/src/draw.c
+++ b/Engine/src/draw.c
@@ -37,7 +37,7 @@
/* --------------- WALLS RENDERING METHOD (USED TO BE HIGHLY OPTIMIZED ASSEMBLY) ----------------------------*/
extern int32_t asm1;
extern int32_t asm2;
-extern int32_t asm3;
+extern uint8_t *asm3;
extern int32_t asm4;
static uint8_t machxbits_al;
@@ -714,7 +714,7 @@
}
static uint8_t * textureData;
-static int32_t mmach_asm3;
+static uint8_t * mmach_asm3;
static int32_t mmach_asm1;
static int32_t mmach_asm2;
@@ -744,7 +744,7 @@
//Skip transparent color.
if ((colorIndex&0xff) != 0xff){
if (pixelsAllowed-- > 0)
- *dest = (((uint8_t *)mmach_asm3)[colorIndex]);
+ *dest = mmach_asm3[colorIndex];
}
i2 += mmach_asm1;
i5 += mmach_asm2;
@@ -764,12 +764,12 @@
} /* msethlineshift */
-static int32_t tmach_eax;
-static int32_t tmach_asm3;
+static uint8_t * tmach_eax;
+static uint8_t * tmach_asm3;
static int32_t tmach_asm1;
static int32_t tmach_asm2;
-void thline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+void thline(uint8_t * i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, uint8_t * i6)
{
tmach_eax = i1;
tmach_asm3 = asm3;
@@ -780,7 +780,7 @@
static uint8_t tshift_al = 26;
static uint8_t tshift_bl = 6;
-void thlineskipmodify(int32_t i1, uint32_t i2, uint32_t i3, int32_t i4, int32_t i5, int32_t i6)
+void thlineskipmodify(int32_t i1, uint32_t i2, uint32_t i3, int32_t i4, int32_t i5, uint8_t * i6)
{
uint32_t ebx;
int counter = (i3>>16);
@@ -788,17 +788,17 @@
{
ebx = i2 >> tshift_al;
ebx = shld (ebx, (uint32_t)i5, tshift_bl);
- i1 = ((uint8_t *)tmach_eax)[ebx];
+ i1 = tmach_eax[ebx];
if ((i1&0xff) != 0xff)
{
- uint16_t val = (((uint8_t *)tmach_asm3)[i1]);
- val |= (*((uint8_t *)i6)<<8);
+ uint16_t val = tmach_asm3[i1];
+ val |= (*i6)<<8;
if (transrev)
val = ((val>>8)|(val<<8));
if (pixelsAllowed-- > 0)
- *((uint8_t *)i6) = transluc[val];
+ *i6 = transluc[val];
}
i2 += tmach_asm1;
@@ -852,7 +852,8 @@
{
bitwisef2i c;
uint32_t ecx,eax,ebx,edx,esi,edi;
- float a = (float) asm3 + asm2_f;
+#pragma 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));
--- a/Engine/src/draw.h
+++ b/Engine/src/draw.h
@@ -26,7 +26,8 @@
extern uint8_t *globalpalwritten;
extern int16_t globalshiftval;
-extern int32_t vplce[4], vince[4], bufplce[4];
+extern int32_t vplce[4], vince[4];
+extern int32_t bufplce[4];
extern uint8_t* palookupoffse[4];
void sethlinesizes(int32_t,int32_t,uint8_t *);
@@ -61,8 +62,8 @@
void mhline(uint8_t *,int32_t,int32_t,int32_t,int32_t,uint8_t*);
void mhlineskipmodify(uint32_t,int32_t,int32_t,uint8_t*);
void msethlineshift(int32_t,int32_t);
-void thline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void thlineskipmodify(int32_t,uint32_t,uint32_t,int32_t,int32_t,int32_t);
+void thline(uint8_t*,int32_t,int32_t,int32_t,int32_t,uint8_t *);
+void thlineskipmodify(int32_t,uint32_t,uint32_t,int32_t,int32_t,uint8_t *);
void tsethlineshift(int32_t,int32_t);
void setupslopevlin(int32_t,int32_t,int32_t);
void slopevlin(int32_t,uint32_t,int32_t,int32_t,int32_t,int32_t);
--- a/Engine/src/engine.c
+++ b/Engine/src/engine.c
@@ -205,7 +205,8 @@
int32_t asm1, asm2, asm3, asm4;
-int32_t vplce[4], vince[4], bufplce[4];
+int32_t vplce[4], vince[4];
+int32_t bufplce[4];
uint8_t* palookupoffse[4];
@@ -1369,7 +1370,8 @@
if (u4 > y1ve[3])
vplce[3] = prevlineasm1(vince[3],palookupoffse[3],u4-y1ve[3]-1,vplce[3],bufplce[3],ylookup[y1ve[3]]+x+frameoffset+3);
- if (d4 >= u4) vlineasm4(d4-u4+1,ylookup[u4]+x+frameoffset);
+ if (d4 >= u4)
+ vlineasm4(d4-u4+1,ylookup[u4]+x+frameoffset);
i = x+frameoffset+ylookup[d4+1];
@@ -3749,7 +3751,8 @@
int32_t cy1, int32_t cx2, int32_t cy2)
{
int32_t cosang, sinang, v, nextv, dax1, dax2, oy, bx, by, ny1, ny2;
- int32_t i, x, y, x1, y1, x2, y2, gx1, gy1, bufplc;
+ int32_t i, x, y, x1, y1, x2, y2, gx1, gy1;
+ uint8_t* bufplc;
uint8_t* palookupoffs;
uint8_t* p;
int32_t xoff, yoff, npoints, yplc, yinc, lx, rx, xx, xend;
@@ -3966,25 +3969,37 @@
{
if ((bad != 0) || (u4 >= d4))
{
- if (!(bad&1)) prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0);
- if (!(bad&2)) prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1);
- if (!(bad&4)) prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2);
- if (!(bad&8)) prevlineasm1(vince[3],palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3);
+ if (!(bad&1))
+ prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0);
+ if (!(bad&2))
+ prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1);
+ if (!(bad&4))
+ prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2);
+ if (!(bad&8))
+ prevlineasm1(vince[3],palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3);
continue;
}
- if (u4 > y1ve[0]) vplce[0] = prevlineasm1(vince[0],palookupoffse[0],u4-y1ve[0]-1,vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0);
- if (u4 > y1ve[1]) vplce[1] = prevlineasm1(vince[1],palookupoffse[1],u4-y1ve[1]-1,vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1);
- if (u4 > y1ve[2]) vplce[2] = prevlineasm1(vince[2],palookupoffse[2],u4-y1ve[2]-1,vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2);
- if (u4 > y1ve[3]) vplce[3] = prevlineasm1(vince[3],palookupoffse[3],u4-y1ve[3]-1,vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3);
+ if (u4 > y1ve[0])
+ vplce[0] = prevlineasm1(vince[0],palookupoffse[0],u4-y1ve[0]-1,vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0);
+ if (u4 > y1ve[1])
+ vplce[1] = prevlineasm1(vince[1],palookupoffse[1],u4-y1ve[1]-1,vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1);
+ if (u4 > y1ve[2])
+ vplce[2] = prevlineasm1(vince[2],palookupoffse[2],u4-y1ve[2]-1,vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2);
+ if (u4 > y1ve[3])
+ vplce[3] = prevlineasm1(vince[3],palookupoffse[3],u4-y1ve[3]-1,vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3);
if (d4 >= u4) vlineasm4(d4-u4+1,ylookup[u4]+p);
i = p+ylookup[d4+1];
- if (y2ve[0] > d4) prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-d4-1,vplce[0],bufplce[0],i+0);
- if (y2ve[1] > d4) prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-d4-1,vplce[1],bufplce[1],i+1);
- if (y2ve[2] > d4) prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-d4-1,vplce[2],bufplce[2],i+2);
- if (y2ve[3] > d4) prevlineasm1(vince[3],palookupoffse[3],y2ve[3]-d4-1,vplce[3],bufplce[3],i+3);
+ if (y2ve[0] > d4)
+ prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-d4-1,vplce[0],bufplce[0],i+0);
+ if (y2ve[1] > d4)
+ prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-d4-1,vplce[1],bufplce[1],i+1);
+ if (y2ve[2] > d4)
+ prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-d4-1,vplce[2],bufplce[2],i+2);
+ if (y2ve[3] > d4)
+ prevlineasm1(vince[3],palookupoffse[3],y2ve[3]-d4-1,vplce[3],bufplce[3],i+3);
}
else
{
@@ -8942,7 +8957,8 @@
/* MUST USE RESTOREFORDRAWROOMS AFTER DRAWING */
int32_t setviewcnt = 0;
int32_t bakvidoption[4];
-int32_t bakframeplace[4], bakxsiz[4], bakysiz[4];
+uint8_t* bakframeplace[4];
+int32_t bakxsiz[4], bakysiz[4];
int32_t bakwindowx1[4], bakwindowy1[4];
int32_t bakwindowx2[4], bakwindowy2[4];
--- a/Engine/src/engine.h
+++ b/Engine/src/engine.h
@@ -137,12 +137,14 @@
#include "display.h"
#include "fixedPoint_math.h"
#include "tiles.h"
+#include "network.h"
//Exported for tile module
extern int32_t setviewcnt;
extern int32_t bakvidoption[4];
- extern int32_t bakframeplace[4], bakxsiz[4], bakysiz[4];
+ extern uint8_t* bakframeplace[4];
+ extern int32_t bakxsiz[4], bakysiz[4];
extern int32_t bakwindowx1[4], bakwindowy1[4];
extern int32_t bakwindowx2[4], bakwindowy2[4];
extern uint8_t picsiz[MAXTILES], tilefilenum[MAXTILES];
--- a/Engine/src/filesystem.c
+++ b/Engine/src/filesystem.c
@@ -404,6 +404,110 @@
static uint8_t lzwbuflock[5];
static short *lzwbuf2, *lzwbuf3;
+
+
+int32_t compress(uint8_t *lzwinbuf, int32_t uncompleng, uint8_t *lzwoutbuf)
+{
+ int32_t i, addr, newaddr, addrcnt, zx, *longptr;
+ int32_t bytecnt1, bitcnt, numbits, oneupnumbits;
+ short *shortptr;
+
+ for(i=255;i>=0;i--) { lzwbuf1[i] = (uint8_t ) i; lzwbuf3[i] = (short) ((i+1)&255); }
+ clearbuf((void *) FP_OFF(lzwbuf2),256>>1,0xffffffff);
+ clearbuf((void *) FP_OFF(lzwoutbuf),((uncompleng+15)+3)>>2,0L);
+
+ addrcnt = 256; bytecnt1 = 0; bitcnt = (4<<3);
+ numbits = 8; oneupnumbits = (1<<8);
+ do
+ {
+ addr = lzwinbuf[bytecnt1];
+ do
+ {
+ bytecnt1++;
+ if (bytecnt1 == uncompleng) break;
+ if (lzwbuf2[addr] < 0) {lzwbuf2[addr] = (short) addrcnt; break;}
+ newaddr = lzwbuf2[addr];
+ while (lzwbuf1[newaddr] != lzwinbuf[bytecnt1])
+ {
+ zx = lzwbuf3[newaddr];
+ if (zx < 0) {lzwbuf3[newaddr] = (short) addrcnt; break;}
+ newaddr = zx;
+ }
+ if (lzwbuf3[newaddr] == addrcnt) break;
+ addr = newaddr;
+ } while (addr >= 0);
+ lzwbuf1[addrcnt] = lzwinbuf[bytecnt1];
+ lzwbuf2[addrcnt] = -1;
+ lzwbuf3[addrcnt] = -1;
+
+ longptr = (int32_t *)&lzwoutbuf[bitcnt>>3];
+ longptr[0] |= (addr<<(bitcnt&7));
+ bitcnt += numbits;
+ if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1)))
+ bitcnt--;
+
+ addrcnt++;
+ if (addrcnt > oneupnumbits) { numbits++; oneupnumbits <<= 1; }
+ } while ((bytecnt1 < uncompleng) && (bitcnt < (uncompleng<<3)));
+
+ longptr = (int32_t *)&lzwoutbuf[bitcnt>>3];
+ longptr[0] |= (addr<<(bitcnt&7));
+ bitcnt += numbits;
+ if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1)))
+ bitcnt--;
+
+ shortptr = (short *)lzwoutbuf;
+ shortptr[0] = (short)uncompleng;
+ if (((bitcnt+7)>>3) < uncompleng)
+ {
+ shortptr[1] = (short)addrcnt;
+ return((bitcnt+7)>>3);
+ }
+ shortptr[1] = (short)0;
+ for(i=0;i<uncompleng;i++) lzwoutbuf[i+4] = lzwinbuf[i];
+ return(uncompleng+4);
+}
+
+int32_t uncompress(uint8_t *lzwinbuf, int32_t compleng, uint8_t *lzwoutbuf)
+{
+ int32_t strtot, currstr, numbits, oneupnumbits;
+ int32_t i, dat, leng, bitcnt, outbytecnt, *longptr;
+ short *shortptr;
+
+ shortptr = (short *)lzwinbuf;
+ strtot = (int32_t )shortptr[1];
+ if (strtot == 0)
+ {
+ copybuf((void *)(FP_OFF(lzwinbuf)+4),(void *)(FP_OFF(lzwoutbuf)),((compleng-4)+3)>>2);
+ return((int32_t )shortptr[0]); /* uncompleng */
+ }
+ for(i=255;i>=0;i--) { lzwbuf2[i] = (short) i; lzwbuf3[i] = (short) i; }
+ currstr = 256; bitcnt = (4<<3); outbytecnt = 0;
+ numbits = 8; oneupnumbits = (1<<8);
+ do
+ {
+ longptr = (int32_t *)&lzwinbuf[bitcnt>>3];
+ dat = ((longptr[0]>>(bitcnt&7)) & (oneupnumbits-1));
+ bitcnt += numbits;
+ if ((dat&((oneupnumbits>>1)-1)) > ((currstr-1)&((oneupnumbits>>1)-1)))
+ { dat &= ((oneupnumbits>>1)-1); bitcnt--; }
+
+ lzwbuf3[currstr] = (short) dat;
+
+ for(leng=0;dat>=256;leng++,dat=lzwbuf3[dat])
+ lzwbuf1[leng] = (uint8_t ) lzwbuf2[dat];
+
+ lzwoutbuf[outbytecnt++] = (uint8_t ) dat;
+ for(i=leng-1;i>=0;i--) lzwoutbuf[outbytecnt++] = lzwbuf1[i];
+
+ lzwbuf2[currstr-1] = (short) dat; lzwbuf2[currstr] = (short) dat;
+ currstr++;
+ if (currstr > oneupnumbits) { numbits++; oneupnumbits <<= 1; }
+ } while (currstr < strtot);
+ return((int32_t )shortptr[0]); /* uncompleng */
+}
+
+
void kdfread(void *buffer, size_t dasizeof, size_t count, int32_t fil)
{
size_t i, j;
@@ -413,8 +517,8 @@
lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200;
if (lzwbuf1 == NULL) allocache(&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]);
- if (lzwbuf2 == NULL) allocache(&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]);
- if (lzwbuf3 == NULL) allocache(&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]);
+ if (lzwbuf2 == NULL) allocache((uint8_t**)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]);
+ if (lzwbuf3 == NULL) allocache((uint8_t**)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]);
if (lzwbuf4 == NULL) allocache(&lzwbuf4,LZWSIZE,&lzwbuflock[3]);
if (lzwbuf5 == NULL) allocache(&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]);
@@ -450,11 +554,11 @@
uint8_t *ptr;
lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200;
- if (lzwbuf1 == NULL) allocache((int32_t *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]);
- if (lzwbuf2 == NULL) allocache((int32_t *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]);
- if (lzwbuf3 == NULL) allocache((int32_t *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]);
- if (lzwbuf4 == NULL) allocache((int32_t *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]);
- if (lzwbuf5 == NULL) allocache((int32_t *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]);
+ if (lzwbuf1 == NULL) allocache(&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]);
+ if (lzwbuf2 == NULL) allocache((uint8_t**)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]);
+ if (lzwbuf3 == NULL) allocache((uint8_t**)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]);
+ if (lzwbuf4 == NULL) allocache(&lzwbuf4,LZWSIZE,&lzwbuflock[3]);
+ if (lzwbuf5 == NULL) allocache(&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]);
if (dasizeof > LZWSIZE) {
count *= dasizeof;
@@ -494,8 +598,8 @@
lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200;
if (lzwbuf1 == NULL) allocache(&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]);
- if (lzwbuf2 == NULL) allocache(&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]);
- if (lzwbuf3 == NULL) allocache(&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]);
+ if (lzwbuf2 == NULL) allocache((uint8_t**)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]);
+ if (lzwbuf3 == NULL) allocache((uint8_t**)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]);
if (lzwbuf4 == NULL) allocache(&lzwbuf4,LZWSIZE,&lzwbuflock[3]);
if (lzwbuf5 == NULL) allocache(&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]);
@@ -530,106 +634,7 @@
lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 1;
}
-int32_t compress(uint8_t *lzwinbuf, int32_t uncompleng, uint8_t *lzwoutbuf)
-{
- int32_t i, addr, newaddr, addrcnt, zx, *longptr;
- int32_t bytecnt1, bitcnt, numbits, oneupnumbits;
- short *shortptr;
-
- for(i=255;i>=0;i--) { lzwbuf1[i] = (uint8_t ) i; lzwbuf3[i] = (short) ((i+1)&255); }
- clearbuf((void *) FP_OFF(lzwbuf2),256>>1,0xffffffff);
- clearbuf((void *) FP_OFF(lzwoutbuf),((uncompleng+15)+3)>>2,0L);
-
- addrcnt = 256; bytecnt1 = 0; bitcnt = (4<<3);
- numbits = 8; oneupnumbits = (1<<8);
- do
- {
- addr = lzwinbuf[bytecnt1];
- do
- {
- bytecnt1++;
- if (bytecnt1 == uncompleng) break;
- if (lzwbuf2[addr] < 0) {lzwbuf2[addr] = (short) addrcnt; break;}
- newaddr = lzwbuf2[addr];
- while (lzwbuf1[newaddr] != lzwinbuf[bytecnt1])
- {
- zx = lzwbuf3[newaddr];
- if (zx < 0) {lzwbuf3[newaddr] = (short) addrcnt; break;}
- newaddr = zx;
- }
- if (lzwbuf3[newaddr] == addrcnt) break;
- addr = newaddr;
- } while (addr >= 0);
- lzwbuf1[addrcnt] = lzwinbuf[bytecnt1];
- lzwbuf2[addrcnt] = -1;
- lzwbuf3[addrcnt] = -1;
-
- longptr = (int32_t *)&lzwoutbuf[bitcnt>>3];
- longptr[0] |= (addr<<(bitcnt&7));
- bitcnt += numbits;
- if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1)))
- bitcnt--;
-
- addrcnt++;
- if (addrcnt > oneupnumbits) { numbits++; oneupnumbits <<= 1; }
- } while ((bytecnt1 < uncompleng) && (bitcnt < (uncompleng<<3)));
-
- longptr = (int32_t *)&lzwoutbuf[bitcnt>>3];
- longptr[0] |= (addr<<(bitcnt&7));
- bitcnt += numbits;
- if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1)))
- bitcnt--;
-
- shortptr = (short *)lzwoutbuf;
- shortptr[0] = (short)uncompleng;
- if (((bitcnt+7)>>3) < uncompleng)
- {
- shortptr[1] = (short)addrcnt;
- return((bitcnt+7)>>3);
- }
- shortptr[1] = (short)0;
- for(i=0;i<uncompleng;i++) lzwoutbuf[i+4] = lzwinbuf[i];
- return(uncompleng+4);
-}
-int32_t uncompress(uint8_t *lzwinbuf, int32_t compleng, uint8_t *lzwoutbuf)
-{
- int32_t strtot, currstr, numbits, oneupnumbits;
- int32_t i, dat, leng, bitcnt, outbytecnt, *longptr;
- short *shortptr;
-
- shortptr = (short *)lzwinbuf;
- strtot = (int32_t )shortptr[1];
- if (strtot == 0)
- {
- copybuf((void *)(FP_OFF(lzwinbuf)+4),(void *)(FP_OFF(lzwoutbuf)),((compleng-4)+3)>>2);
- return((int32_t )shortptr[0]); /* uncompleng */
- }
- for(i=255;i>=0;i--) { lzwbuf2[i] = (short) i; lzwbuf3[i] = (short) i; }
- currstr = 256; bitcnt = (4<<3); outbytecnt = 0;
- numbits = 8; oneupnumbits = (1<<8);
- do
- {
- longptr = (int32_t *)&lzwinbuf[bitcnt>>3];
- dat = ((longptr[0]>>(bitcnt&7)) & (oneupnumbits-1));
- bitcnt += numbits;
- if ((dat&((oneupnumbits>>1)-1)) > ((currstr-1)&((oneupnumbits>>1)-1)))
- { dat &= ((oneupnumbits>>1)-1); bitcnt--; }
-
- lzwbuf3[currstr] = (short) dat;
-
- for(leng=0;dat>=256;leng++,dat=lzwbuf3[dat])
- lzwbuf1[leng] = (uint8_t ) lzwbuf2[dat];
-
- lzwoutbuf[outbytecnt++] = (uint8_t ) dat;
- for(i=leng-1;i>=0;i--) lzwoutbuf[outbytecnt++] = lzwbuf1[i];
-
- lzwbuf2[currstr-1] = (short) dat; lzwbuf2[currstr] = (short) dat;
- currstr++;
- if (currstr > oneupnumbits) { numbits++; oneupnumbits <<= 1; }
- } while (currstr < strtot);
- return((int32_t )shortptr[0]); /* uncompleng */
-}
int SafeFileExists ( const char * _filename );
int32_t TCkopen4load(const char *filename, int readfromGRP)
--- /dev/null
+++ b/Engine/src/network.c
@@ -1,0 +1,222 @@
+//
+// network.c
+// Duke3D
+//
+// Created by fabien sanglard on 12-12-22.
+// Copyright (c) 2012 fabien sanglard. All rights reserved.
+//
+
+#include "network.h"
+
+int nNetMode = 0;
+
+//#include "mmulti_stable.h"
+void Setup_UnstableNetworking()
+{
+ nNetMode = 0;
+}
+
+void Setup_StableNetworking()
+{
+ nNetMode = 1;
+}
+
+
+//TODO ( "[Fix this horrible networking mess. Function pointers not happy]" )
+// I do not like this one bit.
+// Figure out what was causing the problems with the function pointers.
+// This mess is a direct result of my lack of time.. bleh
+// This mess shouldn't even be in this file. /slap /slap
+void callcommit(void)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_callcommit();
+ break;
+ case 1:
+ stable_callcommit();
+ break;
+ }
+#endif
+}
+void initcrc(void)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_initcrc();
+ break;
+ case 1:
+ stable_initcrc();
+ break;
+ }
+#endif
+}
+int32_t getcrc(uint8_t *buffer, short bufleng)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ return unstable_getcrc(buffer, bufleng);
+ case 1:
+ return stable_getcrc(buffer, bufleng);
+ }
+#endif
+ return 0;
+}
+void initmultiplayers(uint8_t damultioption, uint8_t dacomrateoption, uint8_t dapriority)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_initmultiplayers(damultioption, dacomrateoption, dapriority);
+ break;
+ case 1:
+ stable_initmultiplayers(damultioption, dacomrateoption, dapriority);
+ break;
+ }
+#endif
+}
+void sendpacket(int32_t other, uint8_t *bufptr, int32_t messleng)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_sendpacket(other, bufptr, messleng);
+ break;
+ case 1:
+ stable_sendpacket(other, bufptr, messleng);
+ break;
+ }
+#endif
+}
+void setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_setpackettimeout(datimeoutcount, daresendagaincount);
+ break;
+ case 1:
+ stable_setpackettimeout(datimeoutcount, daresendagaincount);
+ break;
+ }
+#endif
+}
+void uninitmultiplayers(void)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_uninitmultiplayers();
+ break;
+ case 1:
+ stable_uninitmultiplayers();
+ break;
+ }
+#endif
+}
+void sendlogon(void)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_sendlogon();
+ break;
+ case 1:
+ unstable_sendlogon();
+ break;
+ }
+#endif
+}
+void sendlogoff(void)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_sendlogoff();
+ break;
+ case 1:
+ stable_sendlogoff();
+ break;
+ }
+#endif
+}
+int getoutputcirclesize(void)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ return unstable_getoutputcirclesize();
+ case 1:
+ return stable_getoutputcirclesize();
+ }
+#endif
+ return 0;
+}
+void setsocket(short newsocket)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_setsocket(newsocket);
+ break;
+ case 1:
+ stable_setsocket(newsocket);
+ break;
+ }
+#endif
+}
+short getpacket(short *other, uint8_t *bufptr)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ return unstable_getpacket(other, bufptr); // default
+ case 1:
+ return stable_getpacket(other, bufptr);
+ }
+#endif
+ return 0;
+}
+void flushpackets(void)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_flushpackets();
+ break;
+ case 1:
+ stable_flushpackets();
+ break;
+ }
+#endif
+}
+void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command)
+{
+#ifndef USER_DUMMY_NETWORK
+ switch(nNetMode)
+ {
+ case 0:
+ unstable_genericmultifunction(other, bufptr, messleng, command);
+ break;
+ case 1:
+ stable_genericmultifunction(other, bufptr, messleng, command);
+ break;
+ }
+#endif
+}
\ No newline at end of file
--- /dev/null
+++ b/Engine/src/network.h
@@ -1,0 +1,33 @@
+//
+// network.h
+// Duke3D
+//
+// Created by fabien sanglard on 12-12-22.
+// Copyright (c) 2012 fabien sanglard. All rights reserved.
+//
+
+#ifndef Duke3D_network_h
+#define Duke3D_network_h
+
+#include "platform.h"
+
+void Setup_UnstableNetworking();
+void Setup_StableNetworking();
+
+void callcommit(void);
+void initcrc(void);
+int32_t getcrc(uint8_t *buffer, short bufleng);
+void initmultiplayers(uint8_t damultioption, uint8_t dacomrateoption, uint8_t dapriority);
+void sendpacket(int32_t other, uint8_t *bufptr, int32_t messleng);
+void setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount);
+void uninitmultiplayers(void);
+void sendlogon(void);
+void sendlogoff(void);
+int getoutputcirclesize(void);
+void setsocket(short newsocket);
+short getpacket(short *other, uint8_t *bufptr);
+void flushpackets(void);
+void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command);
+
+
+#endif
--- a/Engine/src/tiles.c
+++ b/Engine/src/tiles.c
@@ -273,7 +273,7 @@
cachesize -= 65536L;
if (cachesize < 65536) return(-1);
}
- initcache(((int32_t)FP_OFF(pic)+15)&0xfffffff0,(cachesize-((-(int32_t)FP_OFF(pic))&15))&0xfffffff0);
+ initcache(pic,cachesize);
for(i=0; i<MAXTILES; i++)
{
--- a/Game/src/actors.c
+++ b/Game/src/actors.c
@@ -1293,7 +1293,7 @@
s->xvel = 128;
s->ang = p->ang;
s->extra++;
- IFMOVING;
+
}
else
{
@@ -1569,7 +1569,7 @@
s->picnum = CRANE+1;
s->xvel += 8;
}
- IFMOVING;
+
if(sect == t[1])
t[0]++;
}
@@ -1664,7 +1664,7 @@
if( s->xvel < 192 )
s->xvel += 8;
s->ang = getangle(msx[t[4]]-s->x,msy[t[4]]-s->y);
- IFMOVING;
+
if( ((s->x-msx[t[4]])*(s->x-msx[t[4]])+(s->y-msy[t[4]])*(s->y-msy[t[4]]) ) < (128*128) )
t[0]++;
}
--- a/Game/src/audiolib/fx_man.c
+++ b/Game/src/audiolib/fx_man.c
@@ -654,7 +654,7 @@
int FX_PlayLoopedVOC
(
- char *ptr,
+ uint8_t *ptr,
int32_t loopstart,
int32_t loopend,
int32_t pitchoffset,
@@ -720,7 +720,7 @@
int FX_PlayLoopedWAV
(
- char *ptr,
+ uint8_t *ptr,
int32_t loopstart,
int32_t loopend,
int32_t pitchoffset,
@@ -755,7 +755,7 @@
int FX_PlayVOC3D
(
- char *ptr,
+ uint8_t *ptr,
int32_t pitchoffset,
int32_t angle,
int32_t distance,
@@ -787,7 +787,7 @@
int FX_PlayWAV3D
(
- char *ptr,
+ uint8_t *ptr,
int32_t pitchoffset,
int32_t angle,
int32_t distance,
@@ -818,7 +818,7 @@
int FX_PlayRaw
(
- char *ptr,
+ uint8_t *ptr,
uint32_t length,
uint32_t rate,
int32_t pitchoffset,
@@ -852,7 +852,7 @@
int FX_PlayLoopedRaw
(
- char *ptr,
+ uint8_t *ptr,
uint32_t length,
char *loopstart,
char *loopend,
--- a/Game/src/audiolib/fx_man.h
+++ b/Game/src/audiolib/fx_man.h
@@ -108,22 +108,22 @@
int FX_PlayVOC( char *ptr, int pitchoffset, int vol, int left, int right,
int priority, uint32_t callbackval );
-int FX_PlayLoopedVOC( char *ptr, int32_t loopstart, int32_t loopend,
+int FX_PlayLoopedVOC( uint8_t *ptr, int32_t loopstart, int32_t loopend,
int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority,
uint32_t callbackval );
int FX_PlayWAV( char *ptr, int pitchoffset, int vol, int left, int right,
int priority, uint32_t callbackval );
-int FX_PlayLoopedWAV( char *ptr, int32_t loopstart, int32_t loopend,
+int FX_PlayLoopedWAV( uint8_t *ptr, int32_t loopstart, int32_t loopend,
int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority,
uint32_t callbackval );
-int FX_PlayVOC3D( char *ptr, int32_t pitchoffset, int32_t angle, int32_t distance,
+int FX_PlayVOC3D( uint8_t *ptr, int32_t pitchoffset, int32_t angle, int32_t distance,
int32_t priority, uint32_t callbackval );
-int FX_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance,
+int FX_PlayWAV3D( uint8_t *ptr, int pitchoffset, int angle, int distance,
int priority, uint32_t callbackval );
-int FX_PlayRaw( char *ptr, uint32_t length, uint32_t rate,
+int FX_PlayRaw( uint8_t *ptr, uint32_t length, uint32_t rate,
int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority,
uint32_t callbackval );
-int FX_PlayLoopedRaw( char *ptr, uint32_t length, char *loopstart,
+int FX_PlayLoopedRaw( uint8_t *ptr, uint32_t length, char *loopstart,
char *loopend, uint32_t rate, int32_t pitchoffset, int32_t vol, int32_t left,
int32_t right, int32_t priority, uint32_t callbackval );
int32_t FX_Pan3D( int handle, int angle, int distance );
--- a/Game/src/audiolib/multivoc.c
+++ b/Game/src/audiolib/multivoc.c
@@ -2131,7 +2131,7 @@
int MV_PlayRaw
(
- char *ptr,
+ uint8_t *ptr,
unsigned long length,
unsigned rate,
int pitchoffset,
@@ -2161,7 +2161,7 @@
int MV_PlayLoopedRaw
(
- char *ptr,
+ uint8_t *ptr,
unsigned long length,
char *loopstart,
char *loopend,
@@ -2258,7 +2258,7 @@
int MV_PlayWAV3D
(
- char *ptr,
+ uint8_t *ptr,
int pitchoffset,
int angle,
int distance,
@@ -2310,7 +2310,7 @@
int MV_PlayLoopedWAV
(
- char *ptr,
+ uint8_t *ptr,
long loopstart,
long loopend,
int pitchoffset,
@@ -2447,7 +2447,7 @@
int MV_PlayVOC3D
(
- char *ptr,
+ uint8_t *ptr,
int pitchoffset,
int angle,
int distance,
@@ -2527,7 +2527,7 @@
int MV_PlayLoopedVOC
(
- char *ptr,
+ uint8_t *ptr,
long loopstart,
long loopend,
int pitchoffset,
@@ -2760,7 +2760,7 @@
void MV_SetCallBack
(
- void ( *function )( unsigned long )
+ void ( *function )( int32_t )
)
{
--- a/Game/src/audiolib/multivoc.h
+++ b/Game/src/audiolib/multivoc.h
@@ -91,31 +91,31 @@
int MV_StartDemandFeedPlayback( void ( *function )( char **ptr, uint32_t *length ),
int rate, int pitchoffset, int vol, int left, int right,
int priority, unsigned long callbackval );
-int MV_PlayRaw( char *ptr, unsigned long length,
+int MV_PlayRaw( uint8_t *ptr, unsigned long length,
unsigned rate, int pitchoffset, int vol, int left,
int right, int priority, unsigned long callbackval );
-int MV_PlayLoopedRaw( char *ptr, unsigned long length,
+int MV_PlayLoopedRaw( uint8_t *ptr, unsigned long length,
char *loopstart, char *loopend, unsigned rate, int pitchoffset,
int vol, int left, int right, int priority,
unsigned long callbackval );
int MV_PlayWAV( char *ptr, int pitchoffset, int vol, int left,
int right, int priority, unsigned long callbackval );
-int MV_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance,
+int MV_PlayWAV3D( uint8_t *ptr, int pitchoffset, int angle, int distance,
int priority, unsigned long callbackval );
-int MV_PlayLoopedWAV( char *ptr, long loopstart, long loopend,
+int MV_PlayLoopedWAV( uint8_t *ptr, long loopstart, long loopend,
int pitchoffset, int vol, int left, int right, int priority,
unsigned long callbackval );
-int MV_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance,
+int MV_PlayVOC3D( uint8_t *ptr, int pitchoffset, int angle, int distance,
int priority, unsigned long callbackval );
int MV_PlayVOC( char *ptr, int pitchoffset, int vol, int left, int right,
int priority, unsigned long callbackval );
-int MV_PlayLoopedVOC( char *ptr, long loopstart, long loopend,
+int MV_PlayLoopedVOC( uint8_t *ptr, long loopstart, long loopend,
int pitchoffset, int vol, int left, int right, int priority,
uint32_t callbackval );
void MV_CreateVolumeTable( int index, int volume, int MaxVolume );
void MV_SetVolume( int volume );
int MV_GetVolume( void );
-void MV_SetCallBack( void ( *function )( unsigned long ) );
+void MV_SetCallBack( void ( *function )( int32_t ) );
void MV_SetReverseStereo( int setting );
int MV_GetReverseStereo( void );
int MV_Init( int soundcard, int MixRate, int Voices, int numchannels,
--- a/Game/src/cvar_defs.c
+++ b/Game/src/cvar_defs.c
@@ -12,6 +12,7 @@
//We need a way to access duke to change the level
#include "duke3d.h"
+
//We need to access debug soundinfo
#include "sounddebugdefs.h"
--- a/Game/src/duke3d.h
+++ b/Game/src/duke3d.h
@@ -356,7 +356,7 @@
typedef struct
{
- char *ptr;
+ uint8_t *ptr;
uint8_t lock;
int length, num;
} SAMPLE;
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -104,7 +104,7 @@
int recfilep,totalreccnt;
uint8_t debug_on = 0,actor_tog = 0,memorycheckoveride=0;
-char *rtsptr;
+uint8_t *rtsptr;
extern uint8_t syncstate;
@@ -657,7 +657,7 @@
if (SoundToggle == 0 || ud.lockout == 1 || FXDevice == NumSoundCards)
break;
- rtsptr = (char *)RTS_GetSound(packbuf[1]-1);
+ rtsptr = RTS_GetSound(packbuf[1]-1);
if (*rtsptr == 'C')
FX_PlayVOC3D(rtsptr,0,0,0,255,-packbuf[1]);
else
@@ -781,6 +781,8 @@
}
}
+//From player.c
+void computergetinput(int32_t snum, input *syn);
void faketimerhandler()
{
int32_t i, j, k;
@@ -1101,7 +1103,12 @@
}
extern int32_t cacnum;
-typedef struct { int32_t *hand, leng; uint8_t *lock; } cactype;
+
+typedef struct {
+ uint8_t *hand;
+ int32_t leng;
+ uint8_t *lock; }
+cactype;
extern cactype cac[];
void caches(void)
@@ -2553,14 +2560,15 @@
void typemode(void)
{
- short ch, hitstate, i, j;
-
+ short ch, hitstate, i, j;
+ char text[512];
+
if( ps[myconnectindex].gm&MODE_SENDTOWHOM )
{
if(sendmessagecommand != -1 || ud.multimode < 3 || movesperpacket == 4)
{
- tempbuf[0] = 4; // message command
- tempbuf[1] = 0;
+ text[0] = 4; // message command
+ text[1] = 0;
recbuf[0] = 0;
if(ud.multimode < 3)
@@ -2571,7 +2579,7 @@
strcat(recbuf,typebuf);
j = strlen(recbuf);
recbuf[j] = 0;
- strcat(tempbuf+1,recbuf);
+ strcat(text+1,recbuf);
if(sendmessagecommand >= ud.multimode || movesperpacket == 4)
{
@@ -4412,7 +4420,7 @@
break;
case WATERDRIP:
- if(j >= 0 && sprite[j].statnum == 10 || sprite[j].statnum == 1)
+ if((j >= 0 && sprite[j].statnum == 10) || sprite[j].statnum == 1)
{
sp->shade = 32;
if(sprite[j].pal != 1)
@@ -6598,6 +6606,7 @@
{
short i,ch;
int32_t j;
+ char text[512];
if(ud.recstat == 2)
{
@@ -6734,11 +6743,11 @@
if(music_select == 44) music_select = 0;
}
- strcpy(&tempbuf[0],"PLAYING ");
- strcat(&tempbuf[0],&music_fn[0][music_select][0]);
+ strcpy(text,"PLAYING ");
+ strcat(text,&music_fn[0][music_select][0]);
MUSIC_StopSong(); // FIX_00074: Shift f5 doesn't change hi-res tunes, but only midi tunes.
playmusic(&music_fn[0][music_select][0]);
- strcpy(&fta_quotes[26][0],&tempbuf[0]);
+ strcpy(&fta_quotes[26][0],text);
FTA(26,&ps[myconnectindex],1);
return;
}
@@ -6749,7 +6758,7 @@
tempbuf[ch] = 4;
tempbuf[ch+1] = 0;
- strcat(tempbuf+1,ud.ridecule[i-1]);
+ strcat((char*)tempbuf+1,ud.ridecule[i-1]);
i = 1+strlen(ud.ridecule[i-1]);
@@ -6756,7 +6765,7 @@
if(ud.multimode > 1)
for(ch=connecthead;ch>=0;ch=connectpoint2[ch])
if (ch != myconnectindex)
- sendpacket(ch,(uint8_t*)tempbuf,i);
+ sendpacket(ch,tempbuf,i);
pus = NUMPAGES;
pub = NUMPAGES;
@@ -6768,7 +6777,7 @@
if(ud.lockout == 0)
if(SoundToggle && ALT_IS_PRESSED && ( RTS_NumSounds() > 0 ) && rtsplaying == 0 && VoiceToggle )
{
- rtsptr = (char *)RTS_GetSound (i-1);
+ rtsptr = RTS_GetSound (i-1);
if(*rtsptr == 'C')
FX_PlayVOC3D( rtsptr,0,0,0,255,-i);
else FX_PlayWAV3D( rtsptr,0,0,0,255,-i);
@@ -6957,9 +6966,9 @@
if( KB_KeyPressed( sc_F5 ) && MusicDevice != NumSoundCards )
{
KB_ClearKeyDown( sc_F5 );
- strcpy(&tempbuf[0],&music_fn[0][music_select][0]);
- strcat(&tempbuf[0],". USE SHIFT-F5 TO CHANGE.");
- strcpy(&fta_quotes[26][0],&tempbuf[0]);
+ strcpy(text,&music_fn[0][music_select][0]);
+ strcat(text,". USE SHIFT-F5 TO CHANGE.");
+ strcpy(fta_quotes[26],text);
FTA(26,&ps[myconnectindex],1);
}
@@ -10576,7 +10585,7 @@
time(&time4file);
tmHMS = localtime(&time4file);
- sprintf(tempbuf, "xDuke(v%d.%d) %.4d.%.2d.%.2d %.2dh%.2dm%.2ds",
+ sprintf(text, "xDuke(v%d.%d) %.4d.%.2d.%.2d %.2dh%.2dm%.2ds",
XDUKE_REV_X,
XDUKE_REV_DOT_Y,
tmHMS->tm_year+1900,
--- a/Game/src/player.c
+++ b/Game/src/player.c
@@ -2697,11 +2697,11 @@
p->look_ang -= (p->look_ang>>2);
// 1<<6: toggle ud.auto_aim
- if( (ud.playing_demo_rev == BYTEVERSION_27 ||
+ if( ((ud.playing_demo_rev == BYTEVERSION_27 ||
ud.playing_demo_rev == BYTEVERSION_28 ||
ud.playing_demo_rev == BYTEVERSION_116 ||
ud.playing_demo_rev == BYTEVERSION_117) &&
- sb_snum&(1<<6) ||
+ sb_snum&(1<<6)) ||
(ACTION(gamefunc_Look_Left) && (p->gm&MODE_GAME) &&
!(p->gm&MODE_MENU) && !(p->gm&MODE_TYPE) && !(ud.pause_on) && (ud.recstat != 2)))
{
--- a/Game/src/premap.c
+++ b/Game/src/premap.c
@@ -250,7 +250,7 @@
( l < 12288 ) )
{
Sound[num].lock = 2;
- allocache((int32_t *)&Sound[num].ptr,l,&Sound[num].lock);
+ allocache(&Sound[num].ptr,l,&Sound[num].lock);
if(Sound[num].ptr != NULL)
kread( fp, Sound[num].ptr , l);
}
@@ -300,7 +300,7 @@
if( tiles[sector[i].ceilingpicnum].data == NULL )
{
tloadtile( sector[i].ceilingpicnum );
- if( tiles[sector[i].ceilingpicnum].data == LA)
+ if( tiles[sector[i].ceilingpicnum].data == (uint8_t*)LA)
{
tloadtile(LA+1);
tloadtile(LA+2);
--- a/Game/src/rts.c
+++ b/Game/src/rts.c
@@ -32,7 +32,7 @@
//=============
int32 numlumps;
-static void **lumpcache;
+static uint8_t **lumpcache;
static lumpinfo_t *lumpinfo; // location of each lump on disk
static boolean RTS_Started = false;
@@ -225,7 +225,7 @@
if (lumpcache[lump] == NULL)
{
lumplockbyte[lump] = 200;
- allocache((int32_t *)&lumpcache[lump],(int32_t)RTS_SoundLength(lump-1),&lumplockbyte[lump]);
+ allocache(&lumpcache[lump],(int32_t)RTS_SoundLength(lump-1),&lumplockbyte[lump]);
RTS_ReadLump(lump, lumpcache[lump]);
}
else
--- a/Game/src/sector.c
+++ b/Game/src/sector.c
@@ -2454,8 +2454,8 @@
if( playing_old_demo && !(sb_snum&((15<<8)|(1<<12)|(1<<15)|(1<<16)|(1<<22)|(1<<19)|(1<<20)|(1<<21)|(1<<24)|(1<<25)|(1<<27)|(1<<28)|(1<<29)|(1<<30)|(1<<31))) )
p->interface_toggle_flag = 0;
- else if((p->interface_toggle_flag == 0 && ( sb_snum&(1<<17) ) == 0) && playing_old_demo ||
- (sb_snum && ( sync[snum].bits&(1<<17) ) == 0) && !playing_old_demo)
+ else if(((p->interface_toggle_flag == 0 && ( sb_snum&(1<<17) ) == 0) && playing_old_demo) ||
+ ((sb_snum && ( sync[snum].bits&(1<<17) ) == 0) && !playing_old_demo))
{
if(playing_old_demo)
p->interface_toggle_flag = 1;
--- a/Game/src/sounds.c
+++ b/Game/src/sounds.c
@@ -284,7 +284,7 @@
Sound[num].lock = 200;
- allocache((int32_t *)&Sound[num].ptr,l,(uint8_t *)&Sound[num].lock);
+ allocache(&Sound[num].ptr,l,(uint8_t *)&Sound[num].lock);
kread( fp, Sound[num].ptr , l);
kclose( fp );
return 1;
--- a/xcode/Duke3D.xcodeproj/project.pbxproj
+++ b/xcode/Duke3D.xcodeproj/project.pbxproj
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
2D058BD01686520B00E283DC /* tiles.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D058BCF1686520B00E283DC /* tiles.c */; };
+ 2D058BE4168689B200E283DC /* network.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D058BE3168689B200E283DC /* network.c */; };
2D2A07CA168286D500064107 /* filesystem.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D2A07C9168286D400064107 /* filesystem.c */; };
2D4FB6FF167D430F00915887 /* sdl_midi.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D4FB6FE167D430F00915887 /* sdl_midi.c */; };
2D7B621D1678885A00E35E54 /* draw.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D7B61F11678885A00E35E54 /* draw.c */; };
@@ -74,6 +75,8 @@
/* Begin PBXFileReference section */
2D058BCD168651F700E283DC /* tiles.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = tiles.h; path = ../../Engine/src/tiles.h; sourceTree = "<group>"; };
2D058BCF1686520B00E283DC /* tiles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tiles.c; path = ../../Engine/src/tiles.c; sourceTree = "<group>"; };
+ 2D058BE2168689A500E283DC /* network.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = network.h; path = ../../Engine/src/network.h; sourceTree = "<group>"; };
+ 2D058BE3168689B200E283DC /* network.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = network.c; path = ../../Engine/src/network.c; sourceTree = "<group>"; };
2D2A07B8167EFA4900064107 /* music.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = music.h; path = ../../Game/src/audiolib/music.h; sourceTree = "<group>"; };
2D2A07BA167EFB5500064107 /* premap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = premap.h; path = ../../Game/src/premap.h; sourceTree = "<group>"; };
2D2A07BB167F1ABA00064107 /* global.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = global.h; path = ../../Game/src/global.h; sourceTree = "<group>"; };
@@ -210,6 +213,7 @@
2D7B62191678885A00E35E54 /* platform.h */,
2D7B621B1678885A00E35E54 /* fixedPoint_math.h */,
2D058BCD168651F700E283DC /* tiles.h */,
+ 2D058BE2168689A500E283DC /* network.h */,
);
name = headers;
sourceTree = "<group>";
@@ -226,6 +230,7 @@
2D2A07C9168286D400064107 /* filesystem.c */,
2D7B621A1678885A00E35E54 /* fixedPoint_math.c */,
2D058BCF1686520B00E283DC /* tiles.c */,
+ 2D058BE3168689B200E283DC /* network.c */,
);
name = implementations;
sourceTree = "<group>";
@@ -511,6 +516,7 @@
2D4FB6FF167D430F00915887 /* sdl_midi.c in Sources */,
2D2A07CA168286D500064107 /* filesystem.c in Sources */,
2D058BD01686520B00E283DC /* tiles.c in Sources */,
+ 2D058BE4168689B200E283DC /* network.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -535,6 +541,9 @@
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = NO;
+ GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = NO;
+ GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
@@ -561,6 +570,9 @@
FRAMEWORK_SEARCH_PATHS = "/Library/Frameworks/**";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = NO;
+ GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = NO;
+ GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;