git-svn-id: https://svn.eduke32.com/eduke32@1206 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2009-01-10 07:38:50 +00:00
parent d6914ed108
commit 9095a4911d
46 changed files with 941 additions and 984 deletions

View file

@ -100,11 +100,11 @@ typedef struct BPACK
int16_t ceilingstat, floorstat; int16_t ceilingstat, floorstat;
int16_t ceilingpicnum, ceilingheinum; int16_t ceilingpicnum, ceilingheinum;
int8_t ceilingshade; int8_t ceilingshade;
char ceilingpal, ceilingxpanning, ceilingypanning; uint8_t ceilingpal, ceilingxpanning, ceilingypanning;
int16_t floorpicnum, floorheinum; int16_t floorpicnum, floorheinum;
int8_t floorshade; int8_t floorshade;
char floorpal, floorxpanning, floorypanning; uint8_t floorpal, floorxpanning, floorypanning;
char visibility, filler; uint8_t visibility, filler;
int16_t lotag, hitag, extra; int16_t lotag, hitag, extra;
} sectortype; } sectortype;
@ -128,7 +128,7 @@ typedef struct BPACK
int16_t point2, nextwall, nextsector, cstat; int16_t point2, nextwall, nextsector, cstat;
int16_t picnum, overpicnum; int16_t picnum, overpicnum;
int8_t shade; int8_t shade;
char pal, xrepeat, yrepeat, xpanning, ypanning; uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
int16_t lotag, hitag, extra; int16_t lotag, hitag, extra;
} walltype; } walltype;
@ -153,8 +153,8 @@ typedef struct BPACK
int32_t x, y, z; int32_t x, y, z;
int16_t cstat, picnum; int16_t cstat, picnum;
int8_t shade; int8_t shade;
char pal, clipdist, filler; uint8_t pal, clipdist, filler;
char xrepeat, yrepeat; uint8_t xrepeat, yrepeat;
int8_t xoffset, yoffset; int8_t xoffset, yoffset;
int16_t sectnum, statnum; int16_t sectnum, statnum;
int16_t ang, owner, xvel, yvel, zvel; int16_t ang, owner, xvel, yvel, zvel;
@ -167,18 +167,18 @@ typedef struct BPACK {
int16_t angoff; int16_t angoff;
int16_t pitch, roll; int16_t pitch, roll;
int32_t xoff, yoff, zoff; int32_t xoff, yoff, zoff;
char flags; uint8_t flags;
char xpanning, ypanning; uint8_t xpanning, ypanning;
char filler[1]; uint8_t filler[1];
spritetype *tspr; spritetype *tspr;
} spriteexttype; } spriteext_t;
typedef struct BPACK { typedef struct BPACK {
float smoothduration; float smoothduration;
int16_t mdcurframe, mdoldframe; int16_t mdcurframe, mdoldframe;
int16_t mdsmooth; int16_t mdsmooth;
char filler[2]; uint8_t filler[2];
} spritesmoothtype; } spritesmooth_t;
#define SPREXT_NOTMD 1 #define SPREXT_NOTMD 1
#define SPREXT_NOMDANIM 2 #define SPREXT_NOMDANIM 2
@ -186,8 +186,8 @@ typedef struct BPACK {
#define SPREXT_AWAY2 8 #define SPREXT_AWAY2 8
#define SPREXT_TSPRACCESS 16 #define SPREXT_TSPRACCESS 16
EXTERN spriteexttype *spriteext; EXTERN spriteext_t *spriteext;
EXTERN spritesmoothtype *spritesmooth; EXTERN spritesmooth_t *spritesmooth;
EXTERN int32_t guniqhudid; EXTERN int32_t guniqhudid;
EXTERN sectortype *sector; EXTERN sectortype *sector;
@ -220,7 +220,7 @@ EXTERN char display_mirror;
EXTERN /*volatile*/ int32_t totalclock; EXTERN /*volatile*/ int32_t totalclock;
EXTERN int32_t numframes, randomseed; EXTERN int32_t numframes, randomseed;
EXTERN int16_t sintable[2048]; EXTERN int16_t sintable[2048];
EXTERN char palette[768]; EXTERN uint8_t palette[768];
EXTERN int16_t numpalookups; EXTERN int16_t numpalookups;
EXTERN char *palookup[MAXPALOOKUPS]; EXTERN char *palookup[MAXPALOOKUPS];
EXTERN char parallaxtype, showinvisibility; EXTERN char parallaxtype, showinvisibility;
@ -416,7 +416,7 @@ int32_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz);
void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2); void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
void makepalookup(int32_t palnum, char *remapbuf, int8_t r, int8_t g, int8_t b, char dastat); void makepalookup(int32_t palnum, char *remapbuf, int8_t r, int8_t g, int8_t b, char dastat);
void setvgapalette(void); void setvgapalette(void);
void setbrightness(char dabrightness, char *dapal, char noapply); void setbrightness(char dabrightness, uint8_t *dapal, char noapply);
void setpalettefade(char r, char g, char b, char offset); void setpalettefade(char r, char g, char b, char offset);
void squarerotatetile(int16_t tilenume); void squarerotatetile(int16_t tilenume);
@ -600,20 +600,20 @@ typedef struct _hashitem // size is 12/24 bits.
char *string; char *string;
int32_t key; int32_t key;
struct _hashitem *next; struct _hashitem *next;
} HASH_item; } hashitem_t;
typedef struct typedef struct
{ {
int32_t size; int32_t size;
HASH_item **items; hashitem_t **items;
} HASH_table; } hashtable_t;
void HASH_init(HASH_table *t); void hash_init(hashtable_t *t);
void HASH_free(HASH_table *t); void hash_free(hashtable_t *t);
int32_t HASH_findcase(HASH_table *t, const char *s); int32_t hash_findcase(hashtable_t *t, const char *s);
int32_t HASH_find(HASH_table *t, const char *s); int32_t hash_find(hashtable_t *t, const char *s);
void HASH_replace(HASH_table *t, const char *s, int32_t key); void hash_replace(hashtable_t *t, const char *s, int32_t key);
void HASH_add(HASH_table *t, const char *s, int32_t key); void hash_add(hashtable_t *t, const char *s, int32_t key);
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma pack() #pragma pack()

View file

@ -9,17 +9,17 @@
typedef struct typedef struct
{ {
int mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! int32_t mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure!
int shadeoff; int32_t shadeoff;
float scale, bscale, zadd; float scale, bscale, zadd;
GLuint *texid; // skins GLuint *texid; // skins
int flags; int32_t flags;
} mdmodel; } mdmodel_t;
typedef struct _mdanim_t typedef struct _mdanim_t
{ {
int startframe, endframe; int32_t startframe, endframe;
int fpssc, flags; int32_t fpssc, flags;
struct _mdanim_t *next; struct _mdanim_t *next;
} mdanim_t; } mdanim_t;
#define MDANIM_LOOP 0 #define MDANIM_LOOP 0
@ -28,12 +28,12 @@ typedef struct _mdanim_t
typedef struct _mdskinmap_t typedef struct _mdskinmap_t
{ {
unsigned char palette, filler[3]; // Build palette number unsigned char palette, filler[3]; // Build palette number
int skinnum, surfnum; // Skin identifier, surface number int32_t skinnum, surfnum; // Skin identifier, surface number
char *fn; // Skin filename char *fn; // Skin filename
GLuint texid[HICEFFECTMASK+1]; // OpenGL texture numbers for effect variations GLuint texid[HICEFFECTMASK+1]; // OpenGL texture numbers for effect variations
struct _mdskinmap_t *next; struct _mdskinmap_t *next;
float param; float param;
char *palmap;int size; char *palmap;int32_t size;
} mdskinmap_t; } mdskinmap_t;
@ -46,9 +46,9 @@ typedef struct { float x, y, z; } point3d;
typedef struct typedef struct
{ {
int id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8 int32_t id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8
int numskins, numverts, numuv, numtris, numglcmds, numframes; int32_t numskins, numverts, numuv, numtris, numglcmds, numframes;
int ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each) int32_t ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each)
} md2head_t; } md2head_t;
typedef struct { unsigned char v[3], ni; } md2vert_t; //compressed vertex coords (x,y,z) typedef struct { unsigned char v[3], ni; } md2vert_t; //compressed vertex coords (x,y,z)
@ -59,42 +59,42 @@ typedef struct
md2vert_t verts[1]; //first vertex of this frame md2vert_t verts[1]; //first vertex of this frame
} md2frame_t; } md2frame_t;
typedef struct { short u, v; } md2uv_t; typedef struct { int16_t u, v; } md2uv_t;
typedef struct typedef struct
{ {
unsigned short v[3]; uint16_t v[3];
unsigned short u[3]; uint16_t u[3];
} md2tri_t; } md2tri_t;
typedef struct typedef struct
{ {
//WARNING: This top block is a union between md2model&md3model: Make sure it matches! //WARNING: This top block is a union between md2model&md3model: Make sure it matches!
int mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! int32_t mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure!
int shadeoff; int32_t shadeoff;
float scale, bscale, zadd; float scale, bscale, zadd;
GLuint *texid; // texture ids for base skin if no mappings defined GLuint *texid; // texture ids for base skin if no mappings defined
int flags; int32_t flags;
int numframes, cframe, nframe, fpssc, usesalpha; int32_t numframes, cframe, nframe, fpssc, usesalpha;
float oldtime, curtime, interpol; float oldtime, curtime, interpol;
mdanim_t *animations; mdanim_t *animations;
mdskinmap_t *skinmap; mdskinmap_t *skinmap;
int numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified, int32_t numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified,
//MD2 specific stuff: //MD2 specific stuff:
int numverts, numglcmds, framebytes, *glcmds; int32_t numverts, numglcmds, framebytes, *glcmds;
char *frames; char *frames;
char *basepath; // pointer to string of base path char *basepath; // pointer to string of base path
char *skinfn; // pointer to first of numskins 64-char strings char *skinfn; // pointer to first of numskins 64-char strings
md2uv_t *uv; md2uv_t *uv;
md2tri_t* tris; md2tri_t* tris;
} md2model; } md2model_t;
typedef struct { char nam[64]; int i; } md3shader_t; //ascz path of shader, shader index typedef struct { char nam[64]; int32_t i; } md3shader_t; //ascz path of shader, shader index
typedef struct { int i[3]; } md3tri_t; //indices of tri typedef struct { int32_t i[3]; } md3tri_t; //indices of tri
typedef struct { float u, v; } md3uv_t; typedef struct { float u, v; } md3uv_t;
typedef struct { signed short x, y, z; unsigned char nlat, nlng; } md3xyzn_t; //xyz are [10:6] ints typedef struct { int16_t x, y, z; unsigned char nlat, nlng; } md3xyzn_t; //xyz are [10:6] ints
typedef struct typedef struct
{ {
@ -111,15 +111,15 @@ typedef struct
typedef struct typedef struct
{ {
int id; //IDP3(0x33806873) int32_t id; //IDP3(0x33806873)
char nam[64]; //ascz surface name char nam[64]; //ascz surface name
int flags; //? int32_t flags; //?
int numframes, numshaders, numverts, numtris; //numframes same as md3head,max shade=~256,vert=~4096,tri=~8192 int32_t numframes, numshaders, numverts, numtris; //numframes same as md3head,max shade=~256,vert=~4096,tri=~8192
int ofstris; int32_t ofstris;
int ofsshaders; int32_t ofsshaders;
int ofsuv; int32_t ofsuv;
int ofsxyzn; int32_t ofsxyzn;
int ofsend; int32_t ofsend;
// DO NOT read directly to this structure // DO NOT read directly to this structure
// the following block is NOT in the file format // the following block is NOT in the file format
// be sure to use the SIZEOF_MD3SURF_T macro // be sure to use the SIZEOF_MD3SURF_T macro
@ -133,14 +133,14 @@ typedef struct
typedef struct typedef struct
{ {
int id, vers; //id=IDP3(0x33806873), vers=15 int32_t id, vers; //id=IDP3(0x33806873), vers=15
char nam[64]; //ascz path in PK3 char nam[64]; //ascz path in PK3
int flags; //? int32_t flags; //?
int numframes, numtags, numsurfs, numskins; //max=~1024,~16,~32,numskins=artifact of MD2; use shader field instead int32_t numframes, numtags, numsurfs, numskins; //max=~1024,~16,~32,numskins=artifact of MD2; use shader field instead
int ofsframes; int32_t ofsframes;
int ofstags; int32_t ofstags;
int ofssurfs; int32_t ofssurfs;
int eof; int32_t eof;
// DO NOT read directly to this structure // DO NOT read directly to this structure
// the following block is NOT in the file format // the following block is NOT in the file format
// be sure to use the SIZEOF_MD3HEAD_T macro // be sure to use the SIZEOF_MD3HEAD_T macro
@ -154,90 +154,90 @@ typedef struct
typedef struct typedef struct
{ {
//WARNING: This top block is a union between md2model&md3model: Make sure it matches! //WARNING: This top block is a union between md2model&md3model: Make sure it matches!
int mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! int32_t mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure!
int shadeoff; int32_t shadeoff;
float scale, bscale, zadd; float scale, bscale, zadd;
unsigned int *texid; // texture ids for base skin if no mappings defined uint32_t *texid; // texture ids for base skin if no mappings defined
int flags; int32_t flags;
int numframes, cframe, nframe, fpssc, usesalpha; int32_t numframes, cframe, nframe, fpssc, usesalpha;
float oldtime, curtime, interpol; float oldtime, curtime, interpol;
mdanim_t *animations; mdanim_t *animations;
mdskinmap_t *skinmap; mdskinmap_t *skinmap;
int numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified, int32_t numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified,
//MD3 specific //MD3 specific
md3head_t head; md3head_t head;
point3d *muladdframes; point3d *muladdframes;
unsigned short *indexes; uint16_t *indexes;
unsigned short *vindexes; uint16_t *vindexes;
float *maxdepths; float *maxdepths;
GLuint* vbos; GLuint* vbos;
// polymer VBO names after that, allocated per surface // polymer VBO names after that, allocated per surface
GLuint* indices; GLuint* indices;
GLuint* texcoords; GLuint* texcoords;
GLuint* geometry; GLuint* geometry;
} md3model; } md3model_t;
#define VOXBORDWIDTH 1 //use 0 to save memory, but has texture artifacts; 1 looks better... #define VOXBORDWIDTH 1 //use 0 to save memory, but has texture artifacts; 1 looks better...
#define VOXUSECHAR 0 #define VOXUSECHAR 0
#if (VOXUSECHAR != 0) #if (VOXUSECHAR != 0)
typedef struct { unsigned char x, y, z, u, v; } vert_t; typedef struct { unsigned char x, y, z, u, v; } vert_t;
#else #else
typedef struct { unsigned short x, y, z, u, v; } vert_t; typedef struct { uint16_t x, y, z, u, v; } vert_t;
#endif #endif
typedef struct { vert_t v[4]; } voxrect_t; typedef struct { vert_t v[4]; } voxrect_t;
typedef struct typedef struct
{ {
//WARNING: This top block is a union of md2model,md3model,voxmodel: Make sure it matches! //WARNING: This top block is a union of md2model,md3model,voxmodel: Make sure it matches!
int mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! int32_t mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure!
int shadeoff; int32_t shadeoff;
float scale, bscale, zadd; float scale, bscale, zadd;
unsigned int *texid; // skins for palettes uint32_t *texid; // skins for palettes
int flags; int32_t flags;
//VOX specific stuff: //VOX specific stuff:
voxrect_t *quad; int qcnt, qfacind[7]; voxrect_t *quad; int32_t qcnt, qfacind[7];
int *mytex, mytexx, mytexy; int32_t *mytex, mytexx, mytexy;
int xsiz, ysiz, zsiz; int32_t xsiz, ysiz, zsiz;
float xpiv, ypiv, zpiv; float xpiv, ypiv, zpiv;
int is8bit; int32_t is8bit;
} voxmodel; } voxmodel_t;
typedef struct typedef struct
{ {
// maps build tiles to particular animation frames of a model // maps build tiles to particular animation frames of a model
int modelid; int32_t modelid;
int skinnum; int32_t skinnum;
int framenum; // calculate the number from the name when declaring int32_t framenum; // calculate the number from the name when declaring
float smoothduration; float smoothduration;
int next; int32_t next;
char pal; char pal;
} tile2model_t; } tile2model_t;
#define EXTRATILES MAXTILES #define EXTRATILES MAXTILES
EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES]; EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES];
EXTERN mdmodel **models; EXTERN mdmodel_t **models;
void updateanimation(md2model *m, spritetype *tspr); void updateanimation(md2model_t *m, spritetype *tspr);
int mdloadskin(md2model *m, int number, int pal, int surf); int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf);
void mdinit(void); void mdinit(void);
void freeallmodels(void); void freeallmodels(void);
void clearskins(void); void clearskins(void);
int mddraw(spritetype *tspr); int32_t mddraw(spritetype *tspr);
typedef struct { float xadd, yadd, zadd; short angadd, flags; } hudtyp; typedef struct { float xadd, yadd, zadd; int16_t angadd, flags; } hudtyp;
EXTERN hudtyp hudmem[2][MAXTILES]; //~320KB ... ok for now ... could replace with dynamic alloc EXTERN hudtyp hudmem[2][MAXTILES]; //~320KB ... ok for now ... could replace with dynamic alloc
EXTERN int mdinited; EXTERN int32_t mdinited;
EXTERN int mdpause; EXTERN int32_t mdpause;
EXTERN int nummodelsalloced, nextmodelid; EXTERN int32_t nummodelsalloced, nextmodelid;
EXTERN voxmodel *voxmodels[MAXVOXELS]; EXTERN voxmodel_t *voxmodels[MAXVOXELS];
void voxfree(voxmodel *m); void voxfree(voxmodel_t *m);
voxmodel *voxload(const char *filnam); voxmodel_t *voxload(const char *filnam);
int voxdraw(voxmodel *m, spritetype *tspr); int32_t voxdraw(voxmodel_t *m, spritetype *tspr);
#endif // !_mdsprite_h_ #endif // !_mdsprite_h_

View file

@ -16,14 +16,13 @@ int32_t initmultiplayerscycle(void);
void mmulti_initmultiplayers(int32_t argc, char **argv); void mmulti_initmultiplayers(int32_t argc, char **argv);
void mmulti_setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount); void mmulti_setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount);
void mmulti_uninitmultiplayers(void); void mmulti_uninitmultiplayers(void);
void sendlogon(void); void mmulti_sendlogon(void);
void sendlogoff(void); void mmulti_sendlogoff(void);
int32_t getoutputcirclesize(void); int32_t mmulti_getoutputcirclesize(void);
void setsocket(int16_t newsocket);
void mmulti_sendpacket(int32_t other, char *bufptr, int32_t messleng); void mmulti_sendpacket(int32_t other, char *bufptr, int32_t messleng);
int32_t mmulti_getpacket(int32_t *other, char *bufptr); int32_t mmulti_getpacket(int32_t *other, char *bufptr);
void mmulti_flushpackets(void); void mmulti_flushpackets(void);
void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command); void mmulti_generic(int32_t other, char *bufptr, int32_t messleng, int32_t command);
int32_t isvalidipaddress(char *st); int32_t isvalidipaddress(char *st);
void nfIncCP(void); //Addfaz NatFree void nfIncCP(void); //Addfaz NatFree

View file

@ -10,13 +10,12 @@ void mmulti_initmultiplayers(int32_t argc, char **argv);
void mmulti_sendpacket(int32_t other, char *bufptr, int32_t messleng); void mmulti_sendpacket(int32_t other, char *bufptr, int32_t messleng);
void mmulti_setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount); void mmulti_setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount);
void mmulti_uninitmultiplayers(void); void mmulti_uninitmultiplayers(void);
void sendlogon(void); void mmulti_sendlogon(void);
void sendlogoff(void); void mmulti_sendlogoff(void);
int32_t getoutputcirclesize(void); int32_t mmulti_getoutputcirclesize(void);
void setsocket(int32_t newsocket);
int32_t mmulti_getpacket(int32_t *other, char *bufptr); int32_t mmulti_getpacket(int32_t *other, char *bufptr);
void mmulti_flushpackets(void); void mmulti_flushpackets(void);
void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command); void mmulti_generic(int32_t other, char *bufptr, int32_t messleng, int32_t command);
extern int32_t natfree; extern int32_t natfree;

View file

@ -232,7 +232,7 @@ static void polymer_drawartskyquad(int32_t p1, int32_t p2, GLfloat heigh
static void polymer_drawskybox(int16_t tilenum); static void polymer_drawskybox(int16_t tilenum);
// MDSPRITES // MDSPRITES
static void polymer_drawmdsprite(spritetype *tspr); static void polymer_drawmdsprite(spritetype *tspr);
static void polymer_loadmodelvbos(md3model* m); static void polymer_loadmodelvbos(md3model_t* m);
// MATERIALS // MATERIALS
static void polymer_getscratchmaterial(_prmaterial* material); static void polymer_getscratchmaterial(_prmaterial* material);
static void polymer_getbuildmaterial(_prmaterial* material, int16_t tilenum, char pal, int8_t shade); static void polymer_getbuildmaterial(_prmaterial* material, int16_t tilenum, char pal, int8_t shade);

View file

@ -61,7 +61,7 @@ extern GLuint peelprogram[2];
extern int32_t cachefilehandle; extern int32_t cachefilehandle;
extern FILE *cacheindexptr; extern FILE *cacheindexptr;
extern HASH_table cacheH; extern hashtable_t cacheH;
struct cacheitem_t struct cacheitem_t
{ {

View file

@ -3585,7 +3585,7 @@ static __inline void swapbuf4(void *a, void *b, int32_t c)
add eax, 4 add eax, 4
add ebx, 4 add ebx, 4
dec ecx dec ecx
jnz int16_t begswap jnz short begswap
} }
} }

View file

@ -762,7 +762,7 @@ void editinput(void)
} }
if (keystatus[0x44]) if (keystatus[0x44])
{ {
memset(spriteext, 0, sizeof(spriteexttype) * MAXSPRITES); memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth)); memset(spritesmooth, 0, sizeof(spritesmooth));
mhk=0; mhk=0;
initprintf("Maphacks disabled\n"); initprintf("Maphacks disabled\n");

View file

@ -25,7 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> // #include <sys/stat.h>
#ifdef __APPLE__ #ifdef __APPLE__
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3

View file

@ -229,10 +229,10 @@ static inline int32_t nsqrtasm(int32_t a)
mov eax, a mov eax, a
test eax, 0xff000000 test eax, 0xff000000
mov ebx, eax mov ebx, eax
jnz int16_t over24 jnz short over24
shr ebx, 12 shr ebx, 12
mov cx, word ptr shlookup[ebx*2] mov cx, word ptr shlookup[ebx*2]
jmp int16_t under24 jmp short under24
over24: over24:
shr ebx, 24 shr ebx, 24
mov cx, word ptr shlookup[ebx*2+8192] mov cx, word ptr shlookup[ebx*2+8192]
@ -332,7 +332,7 @@ beg:
ror edx, cl ror edx, cl
adc eax, edx adc eax, edx
bswap eax bswap eax
loop int16_t beg loop short beg
pop ebx pop ebx
} }
} }
@ -5555,8 +5555,8 @@ static int32_t preinitcalled = 0;
#define DYNALLOC_ARRAYS #define DYNALLOC_ARRAYS
#ifndef DYNALLOC_ARRAYS #ifndef DYNALLOC_ARRAYS
static spriteexttype spriteext_s[MAXSPRITES+MAXUNIQHUDID]; static spriteext_t spriteext_s[MAXSPRITES+MAXUNIQHUDID];
static spritesmoothtype spritesmooth_s[MAXSPRITES+MAXUNIQHUDID]; static spritesmooth_t spritesmooth_s[MAXSPRITES+MAXUNIQHUDID];
static sectortype sector_s[MAXSECTORS]; static sectortype sector_s[MAXSECTORS];
static walltype wall_s[MAXWALLS]; static walltype wall_s[MAXWALLS];
static spritetype sprite_s[MAXSPRITES]; static spritetype sprite_s[MAXSPRITES];
@ -5577,8 +5577,8 @@ int32_t preinitengine(void)
wall = Bcalloc(MAXWALLS,sizeof(walltype)); wall = Bcalloc(MAXWALLS,sizeof(walltype));
sprite = Bcalloc(MAXSPRITES,sizeof(spritetype)); sprite = Bcalloc(MAXSPRITES,sizeof(spritetype));
tsprite = Bcalloc(MAXSPRITESONSCREEN,sizeof(spritetype)); tsprite = Bcalloc(MAXSPRITESONSCREEN,sizeof(spritetype));
spriteext = Bcalloc(MAXSPRITES+MAXUNIQHUDID,sizeof(spriteexttype)); spriteext = Bcalloc(MAXSPRITES+MAXUNIQHUDID,sizeof(spriteext_t));
spritesmooth = Bcalloc(MAXSPRITES+MAXUNIQHUDID,sizeof(spritesmoothtype)); spritesmooth = Bcalloc(MAXSPRITES+MAXUNIQHUDID,sizeof(spritesmooth_t));
if (!sector || !wall || !sprite || !tsprite || !spriteext || !spritesmooth) if (!sector || !wall || !sprite || !tsprite || !spriteext || !spritesmooth)
return 1; return 1;
@ -6817,7 +6817,7 @@ int32_t loadboard(char *filename, char fromwhere, int32_t *daposx, int32_t *dapo
kclose(fil); kclose(fil);
#if defined(POLYMOST) && defined(USE_OPENGL) #if defined(POLYMOST) && defined(USE_OPENGL)
memset(spriteext, 0, sizeof(spriteexttype) * MAXSPRITES); memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth)); memset(spritesmooth, 0, sizeof(spritesmooth));
# ifdef POLYMER # ifdef POLYMER
@ -7300,7 +7300,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d
kclose(fil); kclose(fil);
#if defined(POLYMOST) && defined(USE_OPENGL) #if defined(POLYMOST) && defined(USE_OPENGL)
memset(spriteext, 0, sizeof(spriteexttype) * MAXSPRITES); memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth)); memset(spritesmooth, 0, sizeof(spritesmooth));
#endif #endif
guniqhudid = 0; guniqhudid = 0;
@ -7361,7 +7361,7 @@ int32_t loadmaphack(char *filename)
script = scriptfile_fromfile(filename); script = scriptfile_fromfile(filename);
if (!script) return -1; if (!script) return -1;
memset(spriteext, 0, sizeof(spriteexttype) * MAXSPRITES); memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth)); memset(spritesmooth, 0, sizeof(spritesmooth));
while (1) while (1)
@ -9952,7 +9952,7 @@ void setvgapalette(void)
// //
// setbrightness // setbrightness
// //
void setbrightness(char dabrightness, char *dapal, char noapply) void setbrightness(char dabrightness, uint8_t *dapal, char noapply)
{ {
int32_t i, k, j; int32_t i, k, j;
// uint32_t lastbright = curbrightness; // uint32_t lastbright = curbrightness;
@ -12129,15 +12129,15 @@ void setpolymost2dview(void)
#endif #endif
} }
void HASH_init(HASH_table *t) void hash_init(hashtable_t *t)
{ {
HASH_free(t); hash_free(t);
t->items=Bcalloc(1, t->size * sizeof(HASH_item)); t->items=Bcalloc(1, t->size * sizeof(hashitem_t));
} }
void HASH_free(HASH_table *t) void hash_free(hashtable_t *t)
{ {
HASH_item *cur, *tmp; hashitem_t *cur, *tmp;
int32_t i; int32_t i;
int32_t num; int32_t num;
@ -12192,16 +12192,16 @@ inline uint32_t HASH_getcode(const char *s)
} }
#endif #endif
void HASH_add(HASH_table *t, const char *s, int32_t key) void hash_add(hashtable_t *t, const char *s, int32_t key)
{ {
HASH_item *cur, *prev=NULL; hashitem_t *cur, *prev=NULL;
int32_t code; int32_t code;
if (!s) if (!s)
return; return;
if (t->items == NULL) if (t->items == NULL)
{ {
initprintf("HASH_add(): table not initialized!\n"); initprintf("hash_add(): table not initialized!\n");
return; return;
} }
code = HASH_getcode(s)%t->size; code = HASH_getcode(s)%t->size;
@ -12209,7 +12209,7 @@ void HASH_add(HASH_table *t, const char *s, int32_t key)
if (!cur) if (!cur)
{ {
cur=Bcalloc(1,sizeof(HASH_item)); cur=Bcalloc(1,sizeof(hashitem_t));
cur->string=Bstrdup(s); cur->string=Bstrdup(s);
cur->key=key; cur->key=key;
cur->next=NULL; cur->next=NULL;
@ -12226,21 +12226,21 @@ void HASH_add(HASH_table *t, const char *s, int32_t key)
} }
while (cur); while (cur);
cur=Bcalloc(1,sizeof(HASH_item)); cur=Bcalloc(1,sizeof(hashitem_t));
cur->string=Bstrdup(s); cur->string=Bstrdup(s);
cur->key=key; cur->key=key;
cur->next=NULL; cur->next=NULL;
prev->next=cur; prev->next=cur;
} }
void HASH_replace(HASH_table *t, const char *s, int32_t key) void hash_replace(hashtable_t *t, const char *s, int32_t key)
{ {
HASH_item *cur, *prev=NULL; hashitem_t *cur, *prev=NULL;
int32_t code; int32_t code;
if (t->items==NULL) if (t->items==NULL)
{ {
initprintf("HASH_replace(): table not initialized!\n"); initprintf("hash_replace(): table not initialized!\n");
return; return;
} }
code=HASH_getcode(s)%t->size; code=HASH_getcode(s)%t->size;
@ -12248,7 +12248,7 @@ void HASH_replace(HASH_table *t, const char *s, int32_t key)
if (!cur) if (!cur)
{ {
cur=Bcalloc(1,sizeof(HASH_item)); cur=Bcalloc(1,sizeof(hashitem_t));
cur->string=Bstrdup(s); cur->string=Bstrdup(s);
cur->key=key; cur->key=key;
cur->next=NULL; cur->next=NULL;
@ -12268,20 +12268,20 @@ void HASH_replace(HASH_table *t, const char *s, int32_t key)
} }
while (cur); while (cur);
cur=Bcalloc(1,sizeof(HASH_item)); cur=Bcalloc(1,sizeof(hashitem_t));
cur->string=Bstrdup(s); cur->string=Bstrdup(s);
cur->key=key; cur->key=key;
cur->next=NULL; cur->next=NULL;
prev->next=cur; prev->next=cur;
} }
int32_t HASH_find(HASH_table *t, const char *s) int32_t hash_find(hashtable_t *t, const char *s)
{ {
HASH_item *cur; hashitem_t *cur;
if (t->items==NULL) if (t->items==NULL)
{ {
initprintf("HASH_find(): table not initialized!\n"); initprintf("hash_find(): table not initialized!\n");
return -1; return -1;
} }
cur=t->items[HASH_getcode(s)%t->size]; cur=t->items[HASH_getcode(s)%t->size];
@ -12294,13 +12294,13 @@ int32_t HASH_find(HASH_table *t, const char *s)
return -1; return -1;
} }
int32_t HASH_findcase(HASH_table *t, const char *s) int32_t hash_findcase(hashtable_t *t, const char *s)
{ {
HASH_item *cur; hashitem_t *cur;
if (t->items==NULL) if (t->items==NULL)
{ {
initprintf("HASH_findcase(): table not initialized!\n"); initprintf("hash_findcase(): table not initialized!\n");
return -1; return -1;
} }
cur=t->items[HASH_getcode(s)%t->size]; cur=t->items[HASH_getcode(s)%t->size];

View file

@ -9,55 +9,55 @@
#define MAXCLIPDIST 1024 #define MAXCLIPDIST 1024
extern char pow2char[8]; extern char pow2char[8];
extern int pow2int[32]; extern int32_t pow2int[32];
extern short thesector[MAXWALLSB], thewall[MAXWALLSB]; extern int16_t thesector[MAXWALLSB], thewall[MAXWALLSB];
extern short bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; extern int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB];
extern short maskwall[MAXWALLSB], maskwallcnt; extern int16_t maskwall[MAXWALLSB], maskwallcnt;
extern spritetype *tspriteptr[MAXSPRITESONSCREEN]; extern spritetype *tspriteptr[MAXSPRITESONSCREEN];
extern int xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen; extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen;
extern intptr_t frameoffset; extern intptr_t frameoffset;
extern int globalposx, globalposy, globalposz, globalhoriz; extern int32_t globalposx, globalposy, globalposz, globalhoriz;
extern short globalang, globalcursectnum; extern int16_t globalang, globalcursectnum;
extern int globalpal, cosglobalang, singlobalang; extern int32_t globalpal, cosglobalang, singlobalang;
extern int cosviewingrangeglobalang, sinviewingrangeglobalang; extern int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
extern int globalvisibility; extern int32_t globalvisibility;
extern int xyaspect; extern int32_t xyaspect;
extern intptr_t asm1, asm2, asm3, asm4; extern intptr_t asm1, asm2, asm3, asm4;
extern int globalshade; extern int32_t globalshade;
extern short globalpicnum; extern int16_t globalpicnum;
extern int globalx1, globaly2; extern int32_t globalx1, globaly2;
extern int globalorientation; extern int32_t globalorientation;
extern short searchit; extern int16_t searchit;
extern int searchx, searchy; extern int32_t searchx, searchy;
extern short searchsector, searchwall, searchstat; extern int16_t searchsector, searchwall, searchstat;
extern char inpreparemirror; extern char inpreparemirror;
extern int curbrightness, gammabrightness; extern int32_t curbrightness, gammabrightness;
extern char britable[16][256]; extern char britable[16][256];
extern char picsiz[MAXTILES]; extern char picsiz[MAXTILES];
extern int lastx[MAXYDIM]; extern int32_t lastx[MAXYDIM];
extern char *transluc; extern char *transluc;
extern short sectorborder[256], sectorbordercnt; extern int16_t sectorborder[256], sectorbordercnt;
extern int qsetmode; extern int32_t qsetmode;
extern int hitallsprites; extern int32_t hitallsprites;
extern int xb1[MAXWALLSB]; extern int32_t xb1[MAXWALLSB];
extern int rx1[MAXWALLSB], ry1[MAXWALLSB]; extern int32_t rx1[MAXWALLSB], ry1[MAXWALLSB];
extern short p2[MAXWALLSB]; extern int16_t p2[MAXWALLSB];
extern short numscans, numhits, numbunches; extern int16_t numscans, numhits, numbunches;
#ifdef USE_OPENGL #ifdef USE_OPENGL
extern palette_t palookupfog[MAXPALOOKUPS]; extern palette_t palookupfog[MAXPALOOKUPS];
#endif #endif
int wallmost(short *mostbuf, int w, int sectnum, char dastat); int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat);
int wallfront(int l1, int l2); int32_t wallfront(int32_t l1, int32_t l2);
int animateoffs(short tilenum, short fakevar); int32_t animateoffs(int16_t tilenum, int16_t fakevar);
extern int indrawroomsandmasks; extern int32_t indrawroomsandmasks;
#if defined(__WATCOMC__) && !defined(NOASM) #if defined(__WATCOMC__) && !defined(NOASM)
@ -75,11 +75,11 @@ extern int indrawroomsandmasks;
"mov byte ptr gotpic[eax], dl",\ "mov byte ptr gotpic[eax], dl",\
parm [eax]\ parm [eax]\
modify exact [eax ebx ecx edx] modify exact [eax ebx ecx edx]
void setgotpic(int); void setgotpic(int32_t);
#elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__ #elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__
static inline void setgotpic(int a) static inline void setgotpic(int32_t a)
{ {
_asm { _asm {
push ebx push ebx
@ -102,7 +102,7 @@ skipit:
#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // _MSC_VER #elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // _MSC_VER
#define setgotpic(a) \ #define setgotpic(a) \
({ int __a=(a); \ ({ int32_t __a=(a); \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"movl %%eax, %%ebx\n\t" \ "movl %%eax, %%ebx\n\t" \
"cmpb $200, "ASMSYM("walock")"(%%eax)\n\t" \ "cmpb $200, "ASMSYM("walock")"(%%eax)\n\t" \
@ -121,7 +121,7 @@ skipit:
#else // __GNUC__ && __i386__ #else // __GNUC__ && __i386__
static inline void setgotpic(int tilenume) static inline void setgotpic(int32_t tilenume)
{ {
if (walock[tilenume] < 200) walock[tilenume] = 199; if (walock[tilenume] < 200) walock[tilenume] = 199;
gotpic[tilenume>>3] |= pow2char[tilenume&7]; gotpic[tilenume>>3] |= pow2char[tilenume&7];

View file

@ -24,7 +24,7 @@ int32_t gtkbuild_msgbox(char *name, char *msg)
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO, GTK_MESSAGE_INFO,
GTK_BUTTONS_OK, GTK_BUTTONS_OK,
msg); "%s", msg);
gtk_window_set_title(GTK_WINDOW(dialog), name); gtk_window_set_title(GTK_WINDOW(dialog), name);
gtk_dialog_run(GTK_DIALOG(dialog)); gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
@ -43,7 +43,7 @@ int32_t gtkbuild_ynbox(char *name, char *msg)
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO, GTK_MESSAGE_INFO,
GTK_BUTTONS_YES_NO, GTK_BUTTONS_YES_NO,
msg); "%s", msg);
gtk_window_set_title(GTK_WINDOW(dialog), name); gtk_window_set_title(GTK_WINDOW(dialog), name);
r = gtk_dialog_run(GTK_DIALOG(dialog)); r = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);

View file

@ -265,7 +265,7 @@ beg:
shr edx, 1 shr edx, 1
adc eax, eax adc eax, eax
sub ecx, 1 sub ecx, 1
jnz int16_t beg jnz short beg
} }
} }
@ -684,29 +684,29 @@ static _inline void rgbhlineasm(int32_t c, int32_t d, int32_t t, int32_t b)
mov edi, t mov edi, t
mov ebx, b mov ebx, b
sub ecx, edx sub ecx, edx
jle int16_t endit jle short endit
add edx, offset olinbuf add edx, offset olinbuf
cmp dword ptr trnsrgb, 0 cmp dword ptr trnsrgb, 0
jz int16_t begit2 jz short begit2
begit: begit:
mov eax, dword ptr [ecx+edx] mov eax, dword ptr [ecx+edx]
or eax, 0xff000000 or eax, 0xff000000
cmp eax, dword ptr trnsrgb cmp eax, dword ptr trnsrgb
jne int16_t skipit jne short skipit
and eax, 0xffffff and eax, 0xffffff
skipit: skipit:
sub ecx, 3 sub ecx, 3
mov [edi], eax mov [edi], eax
lea edi, [edi+ebx] lea edi, [edi+ebx]
jnz int16_t begit jnz short begit
jmp int16_t endit jmp short endit
begit2: begit2:
mov eax, dword ptr [ecx+edx] mov eax, dword ptr [ecx+edx]
or eax, 0xff000000 or eax, 0xff000000
sub ecx, 3 sub ecx, 3
mov [edi], eax mov [edi], eax
lea edi, [edi+ebx] lea edi, [edi+ebx]
jnz int16_t begit2 jnz short begit2
endit: endit:
} }
} }
@ -720,7 +720,7 @@ static _inline void pal8hlineasm(int32_t c, int32_t d, int32_t t, int32_t b)
mov edi, t mov edi, t
mov ebx, b mov ebx, b
sub ecx, edx sub ecx, edx
jle int16_t endit jle short endit
add edx, offset olinbuf add edx, offset olinbuf
begit: begit:
movzx eax, byte ptr [ecx+edx] movzx eax, byte ptr [ecx+edx]
@ -728,7 +728,7 @@ begit:
sub ecx, 1 sub ecx, 1
mov [edi], eax mov [edi], eax
lea edi, [edi+ebx] lea edi, [edi+ebx]
jnz int16_t begit jnz short begit
endit: endit:
} }
} }

View file

@ -1,4 +1,5 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
#include "compat.h"
#if defined(__POWERPC__) #if defined(__POWERPC__)
static uint32_t LSWAPIB(uint32_t a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } static uint32_t LSWAPIB(uint32_t a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); }
static uint16_t SSWAPIB(uint16_t a) { return((a>>8)+(a<<8)); } static uint16_t SSWAPIB(uint16_t a) { return((a>>8)+(a<<8)); }

View file

@ -15,7 +15,7 @@
#include "kplib.h" #include "kplib.h"
#include "md4.h" #include "md4.h"
voxmodel *voxmodels[MAXVOXELS]; voxmodel_t *voxmodels[MAXVOXELS];
int32_t curextra=MAXTILES; int32_t curextra=MAXTILES;
int32_t addtileP(int32_t model,int32_t tile,int32_t pallet) int32_t addtileP(int32_t model,int32_t tile,int32_t pallet)
@ -57,9 +57,9 @@ static int32_t allocvbos = 0, curvbo = 0;
static GLuint* vertvbos = NULL; static GLuint* vertvbos = NULL;
static GLuint* indexvbos = NULL; static GLuint* indexvbos = NULL;
mdmodel *mdload(const char *); mdmodel_t *mdload(const char *);
int32_t mddraw(spritetype *); int32_t mddraw(spritetype *);
void mdfree(mdmodel *); void mdfree(mdmodel_t *);
int32_t globalnoeffect=0; int32_t globalnoeffect=0;
extern int32_t timerticspersec; extern int32_t timerticspersec;
@ -104,7 +104,7 @@ void freevbos()
for (i=0;i<nextmodelid;i++) for (i=0;i<nextmodelid;i++)
if (models[i]->mdnum == 3) if (models[i]->mdnum == 3)
{ {
md3model *m = (md3model *)models[i]; md3model_t *m = (md3model_t *)models[i];
if (m->vbos) if (m->vbos)
{ {
// OSD_Printf("freeing model %d vbo\n",i); // OSD_Printf("freeing model %d vbo\n",i);
@ -129,7 +129,7 @@ void freevbos()
void clearskins() void clearskins()
{ {
mdmodel *m; mdmodel_t *m;
int32_t i, j; int32_t i, j;
for (i=0;i<nextmodelid;i++) for (i=0;i<nextmodelid;i++)
@ -137,7 +137,7 @@ void clearskins()
m = models[i]; m = models[i];
if (m->mdnum == 1) if (m->mdnum == 1)
{ {
voxmodel *v = (voxmodel*)m; voxmodel_t *v = (voxmodel_t*)m;
for (j=0;j<MAXPALOOKUPS;j++) for (j=0;j<MAXPALOOKUPS;j++)
{ {
if (v->texid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); if (v->texid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]);
@ -146,7 +146,7 @@ void clearskins()
} }
else if (m->mdnum == 2 || m->mdnum == 3) else if (m->mdnum == 2 || m->mdnum == 3)
{ {
md2model *m2 = (md2model*)m; md2model_t *m2 = (md2model_t*)m;
mdskinmap_t *sk; mdskinmap_t *sk;
for (j=0;j<m2->numskins*(HICEFFECTMASK+1);j++) for (j=0;j<m2->numskins*(HICEFFECTMASK+1);j++)
{ {
@ -165,7 +165,7 @@ void clearskins()
for (i=0;i<MAXVOXELS;i++) for (i=0;i<MAXVOXELS;i++)
{ {
voxmodel *v = (voxmodel*)voxmodels[i]; if (!v) continue; voxmodel_t *v = (voxmodel_t*)voxmodels[i]; if (!v) continue;
for (j=0;j<MAXPALOOKUPS;j++) for (j=0;j<MAXPALOOKUPS;j++)
{ {
if (v->texid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); if (v->texid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]);
@ -183,13 +183,13 @@ void mdinit()
int32_t md_loadmodel(const char *fn) int32_t md_loadmodel(const char *fn)
{ {
mdmodel *vm, **ml; mdmodel_t *vm, **ml;
if (!mdinited) mdinit(); if (!mdinited) mdinit();
if (nextmodelid >= nummodelsalloced) if (nextmodelid >= nummodelsalloced)
{ {
ml = (mdmodel **)realloc(models,(nummodelsalloced+MODELALLOCGROUP)*sizeof(void*)); if (!ml) return(-1); ml = (mdmodel_t **)realloc(models,(nummodelsalloced+MODELALLOCGROUP)*sizeof(void*)); if (!ml) return(-1);
models = ml; nummodelsalloced += MODELALLOCGROUP; models = ml; nummodelsalloced += MODELALLOCGROUP;
} }
@ -200,7 +200,7 @@ int32_t md_loadmodel(const char *fn)
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, int32_t flags) int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, int32_t flags)
{ {
mdmodel *m; mdmodel_t *m;
if (!mdinited) mdinit(); if (!mdinited) mdinit();
@ -220,7 +220,7 @@ int32_t md_tilehasmodel(int32_t tilenume,int32_t pal)
return tile2model[Ptile2tile(tilenume,pal)].modelid; return tile2model[Ptile2tile(tilenume,pal)].modelid;
} }
static int32_t framename2index(mdmodel *vm, const char *nam) static int32_t framename2index(mdmodel_t *vm, const char *nam)
{ {
int32_t i = 0; int32_t i = 0;
@ -228,7 +228,7 @@ static int32_t framename2index(mdmodel *vm, const char *nam)
{ {
case 2: case 2:
{ {
md2model *m = (md2model *)vm; md2model_t *m = (md2model_t *)vm;
md2frame_t *fr; md2frame_t *fr;
for (i=0;i<m->numframes;i++) for (i=0;i<m->numframes;i++)
{ {
@ -239,7 +239,7 @@ static int32_t framename2index(mdmodel *vm, const char *nam)
break; break;
case 3: case 3:
{ {
md3model *m = (md3model *)vm; md3model_t *m = (md3model_t *)vm;
for (i=0;i<m->numframes;i++) for (i=0;i<m->numframes;i++)
if (!Bstrcmp(m->head.frames[i].nam,nam)) break; if (!Bstrcmp(m->head.frames[i].nam,nam)) break;
} }
@ -250,7 +250,7 @@ static int32_t framename2index(mdmodel *vm, const char *nam)
int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, int32_t skinnum, float smoothduration, int32_t pal) int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, int32_t skinnum, float smoothduration, int32_t pal)
{ {
md2model *m; md2model_t *m;
int32_t i; int32_t i;
if (!mdinited) mdinit(); if (!mdinited) mdinit();
@ -260,7 +260,7 @@ int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
if (!framename) return(-3); if (!framename) return(-3);
tilenume=addtileP(modelid,tilenume,pal); tilenume=addtileP(modelid,tilenume,pal);
m = (md2model *)models[modelid]; m = (md2model_t *)models[modelid];
if (m->mdnum == 1) if (m->mdnum == 1)
{ {
tile2model[tilenume].modelid = modelid; tile2model[tilenume].modelid = modelid;
@ -268,7 +268,7 @@ int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
return 0; return 0;
} }
i = framename2index((mdmodel*)m,framename); i = framename2index((mdmodel_t*)m,framename);
if (i == m->numframes) return(-3); // frame name invalid if (i == m->numframes) return(-3); // frame name invalid
tile2model[tilenume].modelid = modelid; tile2model[tilenume].modelid = modelid;
@ -281,7 +281,7 @@ int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend, int32_t fpssc, int32_t flags) int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend, int32_t fpssc, int32_t flags)
{ {
md2model *m; md2model_t *m;
mdanim_t ma, *map; mdanim_t ma, *map;
int32_t i; int32_t i;
@ -290,16 +290,16 @@ int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *
if ((uint32_t)modelid >= (uint32_t)nextmodelid) return(-1); if ((uint32_t)modelid >= (uint32_t)nextmodelid) return(-1);
memset(&ma, 0, sizeof(ma)); memset(&ma, 0, sizeof(ma));
m = (md2model *)models[modelid]; m = (md2model_t *)models[modelid];
if (m->mdnum < 2) return 0; if (m->mdnum < 2) return 0;
//find index of start frame //find index of start frame
i = framename2index((mdmodel*)m,framestart); i = framename2index((mdmodel_t*)m,framestart);
if (i == m->numframes) return -2; if (i == m->numframes) return -2;
ma.startframe = i; ma.startframe = i;
//find index of finish frame which must trail start frame //find index of finish frame which must trail start frame
i = framename2index((mdmodel*)m,frameend); i = framename2index((mdmodel_t*)m,frameend);
if (i == m->numframes) return -3; if (i == m->numframes) return -3;
ma.endframe = i; ma.endframe = i;
@ -319,7 +319,7 @@ int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param) int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param)
{ {
mdskinmap_t *sk, *skl; mdskinmap_t *sk, *skl;
md2model *m; md2model_t *m;
if (!mdinited) mdinit(); if (!mdinited) mdinit();
@ -327,7 +327,7 @@ int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32
if (!skinfn) return -2; if (!skinfn) return -2;
if ((unsigned)palnum >= (unsigned)MAXPALOOKUPS) return -3; if ((unsigned)palnum >= (unsigned)MAXPALOOKUPS) return -3;
m = (md2model *)models[modelid]; m = (md2model_t *)models[modelid];
if (m->mdnum < 2) return 0; if (m->mdnum < 2) return 0;
if (m->mdnum == 2) surfnum = 0; if (m->mdnum == 2) surfnum = 0;
@ -401,7 +401,7 @@ int32_t md_undefinemodel(int32_t modelid)
return 0; return 0;
} }
md2model *modelhead; md2model_t *modelhead;
mdskinmap_t *skhead; mdskinmap_t *skhead;
typedef struct typedef struct
@ -481,7 +481,7 @@ void applypalmap(char *pic, char *palmap, int32_t size, int32_t pal)
} }
} }
static void applypalmapSkin(char *pic, int32_t sizx, int32_t sizy, md2model *m, int32_t number, int32_t pal, int32_t surf) static void applypalmapSkin(char *pic, int32_t sizx, int32_t sizy, md2model_t *m, int32_t number, int32_t pal, int32_t surf)
{ {
int32_t stage; int32_t stage;
@ -493,7 +493,7 @@ static void applypalmapSkin(char *pic, int32_t sizx, int32_t sizy, md2model *m,
getpalmap(&stage,&pal1,&pal2); getpalmap(&stage,&pal1,&pal2);
if (!pal1)return; if (!pal1)return;
mdloadskin((md2model *)m,number,pal1,surf); mdloadskin((md2model_t *)m,number,pal1,surf);
for (; sk; sk = sk->next) for (; sk; sk = sk->next)
if ((int32_t)sk->palette == pal1&&sk->palmap)break; if ((int32_t)sk->palette == pal1&&sk->palmap)break;
if (!sk||sk->size!=sizx*sizy)continue; if (!sk||sk->size!=sizx*sizy)continue;
@ -502,7 +502,7 @@ static void applypalmapSkin(char *pic, int32_t sizx, int32_t sizy, md2model *m,
} }
} }
static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t *sizx, int32_t *sizy, int32_t *osizx, int32_t *osizy, char *hasalpha, int32_t pal, char effect, md2model *m, int32_t number, int32_t surf) static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t *sizx, int32_t *sizy, int32_t *osizx, int32_t *osizy, char *hasalpha, int32_t pal, char effect, md2model_t *m, int32_t number, int32_t surf)
{ {
int32_t picfillen, j,y,x; int32_t picfillen, j,y,x;
char *picfil,*cptr,al=255; char *picfil,*cptr,al=255;
@ -644,7 +644,7 @@ int32_t mdloadskin_trytexcache(char *fn, int32_t len, int32_t pal, char effect,
} }
while (cacheindexptr->next); while (cacheindexptr->next);
*/ */
i = HASH_find(&cacheH,cachefn); i = hash_find(&cacheH,cachefn);
if (i != -1) if (i != -1)
{ {
texcacheindex *cacheindexptr = cacheptrs[i]; texcacheindex *cacheindexptr = cacheptrs[i];
@ -746,7 +746,7 @@ failure:
// --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF // --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF
//Note: even though it says md2model, it works for both md2model&md3model //Note: even though it says md2model, it works for both md2model&md3model
int32_t mdloadskin(md2model *m, int32_t number, int32_t pal, int32_t surf) int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
{ {
int32_t i,j, bpl, xsiz=0, ysiz=0, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA; int32_t i,j, bpl, xsiz=0, ysiz=0, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA;
intptr_t fptr=0; intptr_t fptr=0;
@ -809,7 +809,7 @@ int32_t mdloadskin(md2model *m, int32_t number, int32_t pal, int32_t surf)
// possibly fetch an already loaded multitexture :_) // possibly fetch an already loaded multitexture :_)
if (pal >= (MAXPALOOKUPS - RESERVEDPALS)) if (pal >= (MAXPALOOKUPS - RESERVEDPALS))
for (i=0;i<nextmodelid;i++) for (i=0;i<nextmodelid;i++)
for (skzero = ((md2model *)models[i])->skinmap; skzero; skzero = skzero->next) for (skzero = ((md2model_t *)models[i])->skinmap; skzero; skzero = skzero->next)
if (!Bstrcasecmp(skzero->fn, sk->fn) && skzero->texid[(globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK)]) if (!Bstrcasecmp(skzero->fn, sk->fn) && skzero->texid[(globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK)])
{ {
sk->texid[(globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK)] = skzero->texid[(globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK)]; sk->texid[(globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK)] = skzero->texid[(globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK)];
@ -897,7 +897,7 @@ int32_t mdloadskin(md2model *m, int32_t number, int32_t pal, int32_t surf)
} }
else if (m->mdnum == 3) else if (m->mdnum == 3)
{ {
md3model *m3 = (md3model *)m; md3model_t *m3 = (md3model_t *)m;
md3surf_t *s; md3surf_t *s;
int32_t surfi; int32_t surfi;
for (surfi=0;surfi<m3->head.numsurfs;surfi++) for (surfi=0;surfi<m3->head.numsurfs;surfi++)
@ -944,7 +944,7 @@ int32_t mdloadskin(md2model *m, int32_t number, int32_t pal, int32_t surf)
} }
//Note: even though it says md2model, it works for both md2model&md3model //Note: even though it says md2model, it works for both md2model&md3model
void updateanimation(md2model *m, spritetype *tspr) void updateanimation(md2model_t *m, spritetype *tspr)
{ {
mdanim_t *anim; mdanim_t *anim;
int32_t i, j, k; int32_t i, j, k;
@ -1066,7 +1066,7 @@ void updateanimation(md2model *m, spritetype *tspr)
} }
// VBO generation and allocation // VBO generation and allocation
static void mdloadvbos(md3model *m) static void mdloadvbos(md3model_t *m)
{ {
int32_t i; int32_t i;
@ -1084,17 +1084,17 @@ static void mdloadvbos(md3model *m)
} }
//--------------------------------------- MD2 LIBRARY BEGINS --------------------------------------- //--------------------------------------- MD2 LIBRARY BEGINS ---------------------------------------
static md2model *md2load(int32_t fil, const char *filnam) static md2model_t *md2load(int32_t fil, const char *filnam)
{ {
md2model *m; md2model_t *m;
md3model *m3; md3model_t *m3;
md3surf_t *s; md3surf_t *s;
md2frame_t *f; md2frame_t *f;
md2head_t head; md2head_t head;
char st[BMAX_PATH]; char st[BMAX_PATH];
int32_t i, j, k; int32_t i, j, k;
m = (md2model *)calloc(1,sizeof(md2model)); if (!m) return(0); m = (md2model_t *)calloc(1,sizeof(md2model_t)); if (!m) return(0);
m->mdnum = 2; m->scale = .01f; m->mdnum = 2; m->scale = .01f;
kread(fil,(char *)&head,sizeof(md2head_t)); kread(fil,(char *)&head,sizeof(md2head_t));
@ -1181,7 +1181,7 @@ static md2model *md2load(int32_t fil, const char *filnam)
// the MD2 is now loaded internally - let's begin the MD3 conversion process // the MD2 is now loaded internally - let's begin the MD3 conversion process
//OSD_Printf("Beginning md3 conversion.\n"); //OSD_Printf("Beginning md3 conversion.\n");
m3 = (md3model *)calloc(1, sizeof(md3model)); if (!m3) { free(m->skinfn); free(m->basepath); free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } m3 = (md3model_t *)calloc(1, sizeof(md3model_t)); if (!m3) { free(m->skinfn); free(m->basepath); free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); }
m3->mdnum = 3; m3->texid = 0; m3->scale = m->scale; m3->mdnum = 3; m3->texid = 0; m3->scale = m->scale;
m3->head.id = 0x33504449; m3->head.vers = 15; m3->head.id = 0x33504449; m3->head.vers = 15;
// this changes the conversion code to do real MD2->MD3 conversion // this changes the conversion code to do real MD2->MD3 conversion
@ -1315,7 +1315,7 @@ static md2model *md2load(int32_t fil, const char *filnam)
// die MD2 ! DIE ! // die MD2 ! DIE !
free(m->texid); free(m->skinfn); free(m->basepath); free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); free(m->texid); free(m->skinfn); free(m->basepath); free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m);
return((md2model *)m3); return((md2model_t *)m3);
} }
//---------------------------------------- MD2 LIBRARY ENDS ---------------------------------------- //---------------------------------------- MD2 LIBRARY ENDS ----------------------------------------
@ -1367,14 +1367,14 @@ void quicksort(uint16_t *indexes, float *depths, int32_t first, int32_t last)
//--------------------------------------- MD3 LIBRARY BEGINS --------------------------------------- //--------------------------------------- MD3 LIBRARY BEGINS ---------------------------------------
static md3model *md3load(int32_t fil) static md3model_t *md3load(int32_t fil)
{ {
int32_t i, surfi, ofsurf, offs[4], leng[4]; int32_t i, surfi, ofsurf, offs[4], leng[4];
int32_t maxtrispersurf; int32_t maxtrispersurf;
md3model *m; md3model_t *m;
md3surf_t *s; md3surf_t *s;
m = (md3model *)calloc(1,sizeof(md3model)); if (!m) return(0); m = (md3model_t *)calloc(1,sizeof(md3model_t)); if (!m) return(0);
m->mdnum = 3; m->texid = 0; m->scale = .01; m->mdnum = 3; m->texid = 0; m->scale = .01;
m->muladdframes = NULL; m->muladdframes = NULL;
@ -1533,7 +1533,7 @@ static md3model *md3load(int32_t fil)
return(m); return(m);
} }
static int32_t md3draw(md3model *m, spritetype *tspr) static int32_t md3draw(md3model_t *m, spritetype *tspr)
{ {
point3d fp, fp1, fp2, m0, m1, a0; point3d fp, fp1, fp2, m0, m1, a0;
md3xyzn_t *v0, *v1; md3xyzn_t *v0, *v1;
@ -1554,7 +1554,7 @@ static int32_t md3draw(md3model *m, spritetype *tspr)
// if ((tspr->cstat&48) == 32) return 0; // if ((tspr->cstat&48) == 32) return 0;
updateanimation((md2model *)m,tspr); updateanimation((md2model_t *)m,tspr);
//create current&next frame's vertex list from whole list //create current&next frame's vertex list from whole list
@ -1801,12 +1801,12 @@ static int32_t md3draw(md3model *m, spritetype *tspr)
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; bglLoadMatrixf(mat); mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; bglLoadMatrixf(mat);
// PLAG: End // PLAG: End
i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,globalpal,surfi); if (!i) continue; i = mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,globalpal,surfi); if (!i) continue;
//i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,surfi); //hack for testing multiple surfaces per MD3 //i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,surfi); //hack for testing multiple surfaces per MD3
bglBindTexture(GL_TEXTURE_2D, i); bglBindTexture(GL_TEXTURE_2D, i);
if (r_detailmapping && !r_depthpeeling && !(tspr->cstat&1024)) if (r_detailmapping && !r_depthpeeling && !(tspr->cstat&1024))
i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,DETAILPAL,surfi); i = mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,DETAILPAL,surfi);
else else
i = 0; i = 0;
@ -1846,7 +1846,7 @@ static int32_t md3draw(md3model *m, spritetype *tspr)
} }
if (r_glowmapping && !r_depthpeeling && !(tspr->cstat&1024)) if (r_glowmapping && !r_depthpeeling && !(tspr->cstat&1024))
i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,GLOWPAL,surfi); i = mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,GLOWPAL,surfi);
else else
i = 0; i = 0;
@ -2052,7 +2052,7 @@ static int32_t md3draw(md3model *m, spritetype *tspr)
return 1; return 1;
} }
static void md3free(md3model *m) static void md3free(md3model_t *m)
{ {
mdanim_t *anim, *nanim = NULL; mdanim_t *anim, *nanim = NULL;
mdskinmap_t *sk, *nsk = NULL; mdskinmap_t *sk, *nsk = NULL;
@ -2127,7 +2127,7 @@ typedef struct { int16_t x, y; } spoint2d;
static spoint2d *shp; static spoint2d *shp;
static int32_t *shcntmal, *shcnt = 0, shcntp; static int32_t *shcntmal, *shcnt = 0, shcntp;
static int32_t mytexo5, *zbit, gmaxx, gmaxy, garea, pow2m1[33]; static int32_t mytexo5, *zbit, gmaxx, gmaxy, garea, pow2m1[33];
static voxmodel *gvox; static voxmodel_t *gvox;
//pitch must equal xsiz*4 //pitch must equal xsiz*4
unsigned gloadtex(int32_t *picbuf, int32_t xsiz, int32_t ysiz, int32_t is8bit, int32_t dapal) unsigned gloadtex(int32_t *picbuf, int32_t xsiz, int32_t ysiz, int32_t is8bit, int32_t dapal)
@ -2384,13 +2384,13 @@ static int32_t isolid(int32_t x, int32_t y, int32_t z)
z += x*yzsiz + y*zsiz; return(vbit[z>>5]&(1<<SHIFTMOD32(z))); z += x*yzsiz + y*zsiz; return(vbit[z>>5]&(1<<SHIFTMOD32(z)));
} }
static voxmodel *vox2poly() static voxmodel_t *vox2poly()
{ {
int32_t i, j, x, y, z, v, ov, oz = 0, cnt, sc, x0, y0, dx, dy,*bx0, *by0; int32_t i, j, x, y, z, v, ov, oz = 0, cnt, sc, x0, y0, dx, dy,*bx0, *by0;
void (*daquad)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t); void (*daquad)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t);
gvox = (voxmodel *)malloc(sizeof(voxmodel)); if (!gvox) return(0); gvox = (voxmodel_t *)malloc(sizeof(voxmodel_t)); if (!gvox) return(0);
memset(gvox,0,sizeof(voxmodel)); memset(gvox,0,sizeof(voxmodel_t));
//x is largest dimension, y is 2nd largest dimension //x is largest dimension, y is 2nd largest dimension
x = xsiz; y = ysiz; z = zsiz; x = xsiz; y = ysiz; z = zsiz;
@ -2742,7 +2742,7 @@ static int32_t loadvxl(const char *filnam)
} }
#endif #endif
void voxfree(voxmodel *m) void voxfree(voxmodel_t *m)
{ {
if (!m) return; if (!m) return;
if (m->mytex) free(m->mytex); if (m->mytex) free(m->mytex);
@ -2751,10 +2751,10 @@ void voxfree(voxmodel *m)
free(m); free(m);
} }
voxmodel *voxload(const char *filnam) voxmodel_t *voxload(const char *filnam)
{ {
int32_t i, is8bit, ret; int32_t i, is8bit, ret;
voxmodel *vm; voxmodel_t *vm;
i = strlen(filnam)-4; if (i < 0) return(0); i = strlen(filnam)-4; if (i < 0) return(0);
if (!Bstrcasecmp(&filnam[i],".vox")) { ret = loadvox(filnam); is8bit = 1; } if (!Bstrcasecmp(&filnam[i],".vox")) { ret = loadvox(filnam); is8bit = 1; }
@ -2782,7 +2782,7 @@ voxmodel *voxload(const char *filnam)
} }
//Draw voxel model as perfect cubes //Draw voxel model as perfect cubes
int32_t voxdraw(voxmodel *m, spritetype *tspr) int32_t voxdraw(voxmodel_t *m, spritetype *tspr)
{ {
point3d fp, m0, a0; point3d fp, m0, a0;
int32_t i, j, fi, xx, yy, zz; int32_t i, j, fi, xx, yy, zz;
@ -2935,13 +2935,13 @@ int32_t voxdraw(voxmodel *m, spritetype *tspr)
//---------------------------------------- VOX LIBRARY ENDS ---------------------------------------- //---------------------------------------- VOX LIBRARY ENDS ----------------------------------------
//--------------------------------------- MD LIBRARY BEGINS --------------------------------------- //--------------------------------------- MD LIBRARY BEGINS ---------------------------------------
mdmodel *mdload(const char *filnam) mdmodel_t *mdload(const char *filnam)
{ {
mdmodel *vm; mdmodel_t *vm;
int32_t fil; int32_t fil;
int32_t i; int32_t i;
vm = (mdmodel*)voxload(filnam); if (vm) return(vm); vm = (mdmodel_t*)voxload(filnam); if (vm) return(vm);
fil = kopen4load((char *)filnam,0); if (fil < 0) return(0); fil = kopen4load((char *)filnam,0); if (fil < 0) return(0);
kread(fil,&i,4); klseek(fil,0,SEEK_SET); kread(fil,&i,4); klseek(fil,0,SEEK_SET);
@ -2949,11 +2949,11 @@ mdmodel *mdload(const char *filnam)
{ {
case 0x32504449: case 0x32504449:
// initprintf("Warning: model '%s' is version IDP2; wanted version IDP3\n",filnam); // initprintf("Warning: model '%s' is version IDP2; wanted version IDP3\n",filnam);
vm = (mdmodel*)md2load(fil,filnam); break; //IDP2 vm = (mdmodel_t*)md2load(fil,filnam); break; //IDP2
case 0x33504449: case 0x33504449:
vm = (mdmodel*)md3load(fil); break; //IDP3 vm = (mdmodel_t*)md3load(fil); break; //IDP3
default: default:
vm = (mdmodel*)0; break; vm = (mdmodel_t*)0; break;
} }
kclose(fil); kclose(fil);
return(vm); return(vm);
@ -2961,7 +2961,7 @@ mdmodel *mdload(const char *filnam)
int32_t mddraw(spritetype *tspr) int32_t mddraw(spritetype *tspr)
{ {
mdmodel *vm; mdmodel_t *vm;
int32_t i; int32_t i;
if (r_vbos && (r_vbocount > allocvbos)) if (r_vbos && (r_vbocount > allocvbos))
@ -2997,15 +2997,15 @@ int32_t mddraw(spritetype *tspr)
} }
vm = models[tile2model[Ptile2tile(tspr->picnum,(tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal)].modelid]; vm = models[tile2model[Ptile2tile(tspr->picnum,(tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal)].modelid];
if (vm->mdnum == 1) { return voxdraw((voxmodel *)vm,tspr); } if (vm->mdnum == 1) { return voxdraw((voxmodel_t *)vm,tspr); }
if (vm->mdnum == 3) { return md3draw((md3model *)vm,tspr); } if (vm->mdnum == 3) { return md3draw((md3model_t *)vm,tspr); }
return 0; return 0;
} }
void mdfree(mdmodel *vm) void mdfree(mdmodel_t *vm)
{ {
if (vm->mdnum == 1) { voxfree((voxmodel *)vm); return; } if (vm->mdnum == 1) { voxfree((voxmodel_t *)vm); return; }
if (vm->mdnum == 3) { md3free((md3model *)vm); return; } if (vm->mdnum == 3) { md3free((md3model_t *)vm); return; }
} }
#endif #endif

View file

@ -329,18 +329,17 @@ int32_t isvalidipaddress(char *st)
//---------------------------------- Obsolete variables&functions ---------------------------------- //---------------------------------- Obsolete variables&functions ----------------------------------
char syncstate = 0; char syncstate = 0;
void mmulti_setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount) { UNREFERENCED_PARAMETER(datimeoutcount); UNREFERENCED_PARAMETER(daresendagaincount); } void mmulti_setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount) { UNREFERENCED_PARAMETER(datimeoutcount); UNREFERENCED_PARAMETER(daresendagaincount); }
void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command) void mmulti_generic(int32_t other, char *bufptr, int32_t messleng, int32_t command)
{ {
UNREFERENCED_PARAMETER(other); UNREFERENCED_PARAMETER(other);
UNREFERENCED_PARAMETER(bufptr); UNREFERENCED_PARAMETER(bufptr);
UNREFERENCED_PARAMETER(messleng); UNREFERENCED_PARAMETER(messleng);
UNREFERENCED_PARAMETER(command); UNREFERENCED_PARAMETER(command);
} }
int32_t getoutputcirclesize() { return(0); } int32_t mmulti_getoutputcirclesize() { return(0); }
void setsocket(int32_t newsocket) { UNREFERENCED_PARAMETER(newsocket); }
void mmulti_flushpackets() {} void mmulti_flushpackets() {}
void sendlogon() {} void mmulti_sendlogon() {}
void sendlogoff() {} void mmulti_sendlogoff() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
static int32_t crctab16[256]; static int32_t crctab16[256];

View file

@ -42,23 +42,19 @@ void mmulti_uninitmultiplayers(void)
{ {
} }
void sendlogon(void) void mmulti_sendlogon(void)
{ {
} }
void sendlogoff(void) void mmulti_sendlogoff(void)
{ {
} }
int32_t getoutputcirclesize(void) int32_t mmulti_getoutputcirclesize(void)
{ {
return 0; return 0;
} }
void setsocket(int16_t newsocket)
{
}
void mmulti_sendpacket(int32_t other, char *bufptr, int32_t messleng) void mmulti_sendpacket(int32_t other, char *bufptr, int32_t messleng)
{ {
} }
@ -72,7 +68,7 @@ void mmulti_flushpackets(void)
{ {
} }
void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command) void mmulti_generic(int32_t other, char *bufptr, int32_t messleng, int32_t command)
{ {
} }

View file

@ -55,7 +55,8 @@ int32_t crctable[256];
int32_t tmpmax[8]; //addfaz variable addition (you could probs think of something better) int32_t tmpmax[8]; //addfaz variable addition (you could probs think of something better)
int32_t itmp = 0; //addfaz router fix STUN int32_t itmp = 0; //addfaz router fix STUN
static char lastpacket[576], inlastpacket = 0; static uint8_t lastpacket[576];
char inlastpacket = 0;
static int32_t lastpacketfrom, lastpacketleng; static int32_t lastpacketfrom, lastpacketleng;
extern int32_t totalclock; /* MUST EXTERN 1 ANNOYING VARIABLE FROM GAME */ extern int32_t totalclock; /* MUST EXTERN 1 ANNOYING VARIABLE FROM GAME */
@ -64,7 +65,7 @@ static int32_t timeoutcount = 60, resendagaincount = 4, lastsendtime[MAXPLAYERS]
int32_t natfree; //NatFree mode flag int32_t natfree; //NatFree mode flag
static int16_t bakpacketptr[MAXPLAYERS][256], bakpacketlen[MAXPLAYERS][256]; static int16_t bakpacketptr[MAXPLAYERS][256], bakpacketlen[MAXPLAYERS][256];
static char bakpacketbuf[BAKSIZ]; static uint16_t bakpacketbuf[BAKSIZ];
static int32_t bakpacketplc = 0; static int32_t bakpacketplc = 0;
int32_t myconnectindex, numplayers; int32_t myconnectindex, numplayers;
@ -74,18 +75,24 @@ char syncstate = 0;
#define MAXPACKETSIZE 2048 #define MAXPACKETSIZE 2048
#define PACKET_START_GAME 0x1337 #define PACKET_START_GAME 0x1337
enum commit_cmd_t
{
COMMIT_CMD_SEND = 1,
COMMIT_CMD_GET = 2,
COMMIT_CMD_SENDTOALL = 3,
COMMIT_CMD_SENDTOALLOTHERS = 4,
COMMIT_CMD_SCORE = 5,
};
typedef struct gcomtype_t typedef struct gcomtype_t
{ {
// short intnum; /* communication between Game and the driver */
int16_t command; /* 1-send, 2-get */ int16_t command; /* 1-send, 2-get */
int16_t other; /* dest for send, set by get (-1 = no packet) */ int16_t other; /* dest for send, set by get (-1 = no packet) */
int16_t numbytes; int16_t numbytes;
int16_t myconnectindex; int16_t myconnectindex;
int16_t numplayers; int16_t numplayers;
// short gametype; /* gametype: 1-serial,2-modem,3-net */
int16_t filler; int16_t filler;
char buffer[MAXPACKETSIZE]; char buffer[MAXPACKETSIZE];
// intptr_t longcalladdress;
} gcomtype; } gcomtype;
static gcomtype *gcom; static gcomtype *gcom;
@ -119,15 +126,6 @@ typedef struct
//typedef std::vector<PACKET> PacketQueue; //typedef std::vector<PACKET> PacketQueue;
enum ECommitCMDs
{
COMMIT_CMD_SEND = 1,
COMMIT_CMD_GET = 2,
COMMIT_CMD_SENDTOALL = 3,
COMMIT_CMD_SENDTOALLOTHERS = 4,
COMMIT_CMD_SCORE = 5,
};
static struct allowed_addr_t static struct allowed_addr_t
{ {
int32_t host; int32_t host;
@ -371,14 +369,14 @@ typedef enum
udpmode_peer, udpmode_peer,
udpmode_server, udpmode_server,
udpmode_client udpmode_client
} udpmodes; } udpmode_t;
static udpmodes udpmode = udpmode_peer; static udpmode_t udpmode = udpmode_peer;
void sendlogon(void) void mmulti_sendlogon(void)
{ {
} }
void sendlogoff(void) void mmulti_sendlogoff(void)
{ {
int32_t i; int32_t i;
char tempbuf[2]; char tempbuf[2];
@ -393,17 +391,11 @@ void sendlogoff(void)
} }
} }
int32_t getoutputcirclesize(void) int32_t mmulti_getoutputcirclesize(void)
{ {
return(0); return(0);
} }
void setsocket(int32_t newsocket)
{
UNREFERENCED_PARAMETER(newsocket);
}
int32_t mmulti_getpacket(int32_t *other, char *bufptr) int32_t mmulti_getpacket(int32_t *other, char *bufptr)
{ {
int32_t i, messleng; int32_t i, messleng;
@ -577,7 +569,7 @@ void mmulti_flushpackets()
#endif #endif
} }
void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t command) void mmulti_generic(int32_t other, char *bufptr, int32_t messleng, int32_t command)
{ {
if (numplayers < 2) return; if (numplayers < 2) return;
@ -589,8 +581,6 @@ void genericmultifunction(int32_t other, char *bufptr, int32_t messleng, int32_t
} }
#if UDP_NETWORKING
#if PLATFORM_WIN32 #if PLATFORM_WIN32
# include <winsock.h> # include <winsock.h>
# define EWOULDBLOCK WSAEWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK
@ -2169,9 +2159,5 @@ void callcommit(void)
} }
} }
#else
#error Please define a network transport for your platform.
#endif
/* end of mmulti.c ... */ /* end of mmulti.c ... */

View file

@ -105,7 +105,7 @@ static int32_t osdcursorpal=0; */
static symbol_t *osdsymbptrs[MAXSYMBOLS]; static symbol_t *osdsymbptrs[MAXSYMBOLS];
static int32_t osdnumsymbols = 0; static int32_t osdnumsymbols = 0;
static HASH_table osdsymbolsH = { MAXSYMBOLS<<1, NULL }; static hashtable_t osdsymbolsH = { MAXSYMBOLS<<1, NULL };
// application callbacks // application callbacks
static void (*drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar; static void (*drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar;
@ -623,7 +623,7 @@ void OSD_Cleanup(void)
{ {
symbol_t *s; symbol_t *s;
HASH_free(&osdsymbolsH); hash_free(&osdsymbolsH);
for (; symbols; symbols=s) for (; symbols; symbols=s)
{ {
@ -649,7 +649,7 @@ void OSD_Init(void)
osdnumsymbols = 0; osdnumsymbols = 0;
HASH_init(&osdsymbolsH); hash_init(&osdsymbolsH);
osdlines=1; osdlines=1;
@ -1823,9 +1823,9 @@ static symbol_t *addnewsymbol(const char *name)
newsymb->next = t; newsymb->next = t;
} }
} }
HASH_add(&osdsymbolsH, name, osdnumsymbols); hash_add(&osdsymbolsH, name, osdnumsymbols);
lname = strtolower(Bstrdup(name),Bstrlen(name)); lname = strtolower(Bstrdup(name),Bstrlen(name));
HASH_add(&osdsymbolsH, lname, osdnumsymbols); hash_add(&osdsymbolsH, lname, osdnumsymbols);
Bfree(lname); Bfree(lname);
osdsymbptrs[osdnumsymbols++] = newsymb; osdsymbptrs[osdnumsymbols++] = newsymb;
return newsymb; return newsymb;
@ -1855,7 +1855,7 @@ static symbol_t *findexactsymbol(const char *name)
char *lname = Bstrdup(name); char *lname = Bstrdup(name);
if (!symbols) return NULL; if (!symbols) return NULL;
i = HASH_find(&osdsymbolsH,lname); i = hash_find(&osdsymbolsH,lname);
if (i > -1) if (i > -1)
{ {
// if ((symbol_t *)osdsymbptrs[i]->func == (void *)OSD_UNALIASED) // if ((symbol_t *)osdsymbptrs[i]->func == (void *)OSD_UNALIASED)
@ -1866,7 +1866,7 @@ static symbol_t *findexactsymbol(const char *name)
// try it again // try it again
lname = strtolower(lname, Bstrlen(name)); lname = strtolower(lname, Bstrlen(name));
i = HASH_find(&osdsymbolsH,lname); i = hash_find(&osdsymbolsH,lname);
Bfree(lname); Bfree(lname);
if (i > -1) if (i > -1)

View file

@ -2308,7 +2308,7 @@ static void polymer_drawskybox(int16_t tilenum)
// MDSPRITES // MDSPRITES
static void polymer_drawmdsprite(spritetype *tspr) static void polymer_drawmdsprite(spritetype *tspr)
{ {
md3model* m; md3model_t* m;
mdskinmap_t* sk; mdskinmap_t* sk;
md3xyzn_t *v0, *v1; md3xyzn_t *v0, *v1;
md3surf_t *s; md3surf_t *s;
@ -2320,8 +2320,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
GLfloat* color; GLfloat* color;
int32_t materialbits; int32_t materialbits;
m = (md3model*)models[tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].modelid]; m = (md3model_t*)models[tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].modelid];
updateanimation((md2model *)m,tspr); updateanimation((md2model_t *)m,tspr);
lpal = (tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal; lpal = (tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal;
@ -2410,14 +2410,14 @@ static void polymer_drawmdsprite(spritetype *tspr)
v1 = &s->xyzn[m->nframe*s->numverts]; v1 = &s->xyzn[m->nframe*s->numverts];
mdspritematerial.diffusemap = mdspritematerial.diffusemap =
mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].skinnum,tspr->pal,surfi); mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].skinnum,tspr->pal,surfi);
if (!mdspritematerial.diffusemap) if (!mdspritematerial.diffusemap)
continue; continue;
if (r_detailmapping && !(tspr->cstat&1024)) if (r_detailmapping && !(tspr->cstat&1024))
{ {
mdspritematerial.detailmap = mdspritematerial.detailmap =
mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,DETAILPAL,surfi); mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,DETAILPAL,surfi);
for (sk = m->skinmap; sk; sk = sk->next) for (sk = m->skinmap; sk; sk = sk->next)
if ((int32_t)sk->palette == DETAILPAL && if ((int32_t)sk->palette == DETAILPAL &&
@ -2429,7 +2429,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
if (r_glowmapping && !(tspr->cstat&1024)) if (r_glowmapping && !(tspr->cstat&1024))
{ {
mdspritematerial.glowmap = mdspritematerial.glowmap =
mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,GLOWPAL,surfi); mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,GLOWPAL,surfi);
} }
if (pr_vbos > 1) if (pr_vbos > 1)
@ -2480,7 +2480,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
globalnoeffect=0; globalnoeffect=0;
} }
static void polymer_loadmodelvbos(md3model* m) static void polymer_loadmodelvbos(md3model_t* m)
{ {
int32_t i; int32_t i;
md3surf_t *s; md3surf_t *s;

View file

@ -339,7 +339,7 @@ void drawline2d(float x0, float y0, float x1, float y1, char col)
int32_t cachefilehandle = -1; // texture cache file handle int32_t cachefilehandle = -1; // texture cache file handle
FILE *cacheindexptr = NULL; FILE *cacheindexptr = NULL;
HASH_table cacheH = { 1024, NULL }; hashtable_t cacheH = { 1024, NULL };
char TEXCACHEFILE[BMAX_PATH] = "textures"; char TEXCACHEFILE[BMAX_PATH] = "textures";
@ -600,11 +600,11 @@ void gltexapplyprops(void)
{ {
int32_t j; int32_t j;
mdskinmap_t *sk; mdskinmap_t *sk;
md2model *m; md2model_t *m;
for (i=0;i<nextmodelid;i++) for (i=0;i<nextmodelid;i++)
{ {
m = (md2model *)models[i]; m = (md2model_t *)models[i];
if (m->mdnum < 2) continue; if (m->mdnum < 2) continue;
for (j=0;j<m->numskins*(HICEFFECTMASK+1);j++) for (j=0;j<m->numskins*(HICEFFECTMASK+1);j++)
{ {
@ -897,7 +897,7 @@ void polymost_glinit()
numcacheentries = 0; numcacheentries = 0;
Bmemset(&firstcacheindex, 0, sizeof(texcacheindex)); Bmemset(&firstcacheindex, 0, sizeof(texcacheindex));
Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs)); Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));
HASH_init(&cacheH); hash_init(&cacheH);
LoadCacheOffsets(); LoadCacheOffsets();
Bstrcpy(ptempbuf,TEXCACHEFILE); Bstrcpy(ptempbuf,TEXCACHEFILE);
@ -971,7 +971,7 @@ void invalidatecache(void)
numcacheentries = 0; numcacheentries = 0;
Bmemset(&firstcacheindex, 0, sizeof(texcacheindex)); Bmemset(&firstcacheindex, 0, sizeof(texcacheindex));
Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs)); Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));
HASH_init(&cacheH); hash_init(&cacheH);
// LoadCacheOffsets(); // LoadCacheOffsets();
Bstrcpy(ptempbuf,TEXCACHEFILE); Bstrcpy(ptempbuf,TEXCACHEFILE);
@ -1381,7 +1381,7 @@ static int32_t LoadCacheOffsets(void)
if (scriptfile_getnumber(script, &foffset)) break; // offset in cache if (scriptfile_getnumber(script, &foffset)) break; // offset in cache
if (scriptfile_getnumber(script, &fsize)) break; // size if (scriptfile_getnumber(script, &fsize)) break; // size
i = HASH_find(&cacheH,fname); i = hash_find(&cacheH,fname);
if (i > -1) if (i > -1)
{ {
// update an existing entry // update an existing entry
@ -1396,7 +1396,7 @@ static int32_t LoadCacheOffsets(void)
curcacheindex->offset = foffset; curcacheindex->offset = foffset;
curcacheindex->len = fsize; curcacheindex->len = fsize;
curcacheindex->next = Bcalloc(1, sizeof(texcacheindex)); curcacheindex->next = Bcalloc(1, sizeof(texcacheindex));
HASH_replace(&cacheH, Bstrdup(fname), numcacheentries); hash_replace(&cacheH, Bstrdup(fname), numcacheentries);
cacheptrs[numcacheentries++] = curcacheindex; cacheptrs[numcacheentries++] = curcacheindex;
curcacheindex = curcacheindex->next; curcacheindex = curcacheindex->next;
} }
@ -1445,7 +1445,7 @@ int32_t trytexcache(char *fn, int32_t len, int32_t dameth, char effect, texcache
int32_t len = 0; int32_t len = 0;
int32_t i; int32_t i;
i = HASH_find(&cacheH,cachefn); i = hash_find(&cacheH,cachefn);
if (i > -1) if (i > -1)
{ {
texcacheindex *t = cacheptrs[i]; texcacheindex *t = cacheptrs[i];
@ -1616,7 +1616,7 @@ void writexcache(char *fn, int32_t len, int32_t dameth, char effect, texcachehea
} }
{ {
int32_t i = HASH_find(&cacheH,cachefn); int32_t i = hash_find(&cacheH,cachefn);
if (i > -1) if (i > -1)
{ {
// update an existing entry // update an existing entry
@ -1638,7 +1638,7 @@ void writexcache(char *fn, int32_t len, int32_t dameth, char effect, texcachehea
if (cacheindexptr) if (cacheindexptr)
Bfprintf(cacheindexptr, "%s %d %d\n", curcacheindex->name, curcacheindex->offset, curcacheindex->len); Bfprintf(cacheindexptr, "%s %d %d\n", curcacheindex->name, curcacheindex->offset, curcacheindex->len);
HASH_add(&cacheH, Bstrdup(cachefn), numcacheentries); hash_add(&cacheH, Bstrdup(cachefn), numcacheentries);
cacheptrs[numcacheentries++] = curcacheindex; cacheptrs[numcacheentries++] = curcacheindex;
curcacheindex = curcacheindex->next; curcacheindex = curcacheindex->next;
} }
@ -6426,11 +6426,11 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype)
int32_t i,j=0; int32_t i,j=0;
if (models[mid]->mdnum == 3) if (models[mid]->mdnum == 3)
j = ((md3model *)models[mid])->head.numsurfs; j = ((md3model_t *)models[mid])->head.numsurfs;
for (i=0;i<=j;i++) for (i=0;i<=j;i++)
{ {
mdloadskin((md2model*)models[mid], 0, dapalnum, i); mdloadskin((md2model_t*)models[mid], 0, dapalnum, i);
} }
} }
#endif #endif

View file

@ -69,7 +69,7 @@ char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend;
char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend;
char remap[256]; char remap[256];
int32_t remapinit=0; int32_t remapinit=0;
static char keynames[256][24]; static char key_names[256][24];
volatile int32_t mousex=0,mousey=0,mouseb=0; volatile int32_t mousex=0,mousey=0,mouseb=0;
int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL; int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL;
char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0; char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0;
@ -412,18 +412,18 @@ int32_t initinput(void)
SDL_EnableUNICODE(1); // let's hope this doesn't hit us too hard SDL_EnableUNICODE(1); // let's hope this doesn't hit us too hard
memset(keynames,0,sizeof(keynames)); memset(key_names,0,sizeof(key_names));
#if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) #if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3)
for (i=0; i<SDLK_LAST; i++) for (i=0; i<SDLK_LAST; i++)
{ {
if (!keytranslation[i]) continue; if (!keytranslation[i]) continue;
strncpy((char *)keynames[ keytranslation[i] ], SDL_GetKeyName(i), sizeof(keynames[i])-1); strncpy((char *)key_names[ keytranslation[i] ], SDL_GetKeyName(i), sizeof(key_names[i])-1);
} }
#else #else
for (i=0; i<SDL_NUM_SCANCODES; i++) for (i=0; i<SDL_NUM_SCANCODES; i++)
{ {
if (!keytranslation[i]) continue; if (!keytranslation[i]) continue;
strncpy((char *)keynames[ keytranslation[i] ], SDL_GetKeyName(SDL_SCANCODE_TO_KEYCODE(i)), sizeof(keynames[i])-1); strncpy((char *)key_names[ keytranslation[i] ], SDL_GetKeyName(SDL_SCANCODE_TO_KEYCODE(i)), sizeof(key_names[i])-1);
} }
#endif #endif
@ -469,7 +469,7 @@ void uninitinput(void)
const char *getkeyname(int32_t num) const char *getkeyname(int32_t num)
{ {
if ((unsigned)num >= 256) return NULL; if ((unsigned)num >= 256) return NULL;
return keynames[num]; return key_names[num];
} }
const char *getjoyname(int32_t what, int32_t num) const char *getjoyname(int32_t what, int32_t num)

View file

@ -108,8 +108,8 @@ intptr_t frameplace=0;
int32_t lockcount=0; int32_t lockcount=0;
static int32_t curvidmode = -1; static int32_t curvidmode = -1;
static int32_t customxdim = 640, customydim = 480, custombpp = 8, customfs = 0; static int32_t customxdim = 640, customydim = 480, custombpp = 8, customfs = 0;
static unsigned modeschecked=0; static uint32_t modeschecked=0;
unsigned maxrefreshfreq=60; uint32_t maxrefreshfreq=60;
char modechange=1, repaintneeded=0; char modechange=1, repaintneeded=0;
char offscreenrendering=0; char offscreenrendering=0;
int32_t glcolourdepth=32; int32_t glcolourdepth=32;
@ -131,7 +131,7 @@ char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend;
char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend;
char remap[256]; char remap[256];
int32_t remapinit=0; int32_t remapinit=0;
static char keynames[256][24]; static char key_names[256][24];
static uint32_t lastKeyDown = 0; static uint32_t lastKeyDown = 0;
static uint32_t lastKeyTime = 0; static uint32_t lastKeyTime = 0;
@ -640,7 +640,7 @@ void initprintf(const char *f, ...)
// //
void debugprintf(const char *f, ...) void debugprintf(const char *f, ...)
{ {
#ifdef DEBUGGINGAIDS #if 0 // def DEBUGGINGAIDS
va_list va; va_list va;
char buf[1024]; char buf[1024];
@ -731,7 +731,7 @@ static struct
static struct _joydef static struct _joydef
{ {
const char *name; const char *name;
unsigned ofs; // directinput 'dwOfs' value uint32_t ofs; // directinput 'dwOfs' value
} *axisdefs = NULL, *buttondefs = NULL, *hatdefs = NULL; } *axisdefs = NULL, *buttondefs = NULL, *hatdefs = NULL;
struct _joydevicefeature struct _joydevicefeature
@ -877,7 +877,7 @@ DWORD WINAPI ProcessMouse(LPVOID lpThreadParameter)
continue; continue;
{ {
DWORD i; DWORD i;
unsigned t; uint32_t t;
int32_t result; int32_t result;
DIDEVICEOBJECTDATA didod; DIDEVICEOBJECTDATA didod;
DWORD dwElements = 1; DWORD dwElements = 1;
@ -1557,7 +1557,7 @@ static void GetKeyNames(void)
HRESULT res; HRESULT res;
char tbuf[MAX_PATH]; char tbuf[MAX_PATH];
memset(keynames,0,sizeof(keynames)); memset(key_names,0,sizeof(key_names));
for (i=0;i<256;i++) for (i=0;i<256;i++)
{ {
ZeroMemory(&key,sizeof(key)); ZeroMemory(&key,sizeof(key));
@ -1567,19 +1567,19 @@ static void GetKeyNames(void)
if (FAILED(res)) continue; if (FAILED(res)) continue;
CharToOem(key.tszName, tbuf); CharToOem(key.tszName, tbuf);
strncpy((char *)keynames[i], tbuf, sizeof(keynames[i])-1); strncpy((char *)key_names[i], tbuf, sizeof(key_names[i])-1);
tbuf[0] = 0; tbuf[0] = 0;
GetKeyNameText((i>128?(i+128):i)<<16, tbuf, sizeof(keynames[i])-1); GetKeyNameText((i>128?(i+128):i)<<16, tbuf, sizeof(key_names[i])-1);
// initprintf("%d %15s %15s\n",i,keynames[i],tbuf); // initprintf("%d %15s %15s\n",i,key_names[i],tbuf);
if (*tbuf)strncpy(&keynames[i][0], tbuf, sizeof(keynames[i])-1); if (*tbuf)strncpy(&key_names[i][0], tbuf, sizeof(key_names[i])-1);
} }
} }
const char *getkeyname(int32_t num) const char *getkeyname(int32_t num)
{ {
if ((unsigned)num >= 256) return NULL; if ((unsigned)num >= 256) return NULL;
return keynames[num]; return key_names[num];
} }
const char *getjoyname(int32_t what, int32_t num) const char *getjoyname(int32_t what, int32_t num)
@ -1672,8 +1672,8 @@ static void ProcessInputDevices(void)
DIDEVICEOBJECTDATA didod[INPUT_BUFFER_SIZE]; DIDEVICEOBJECTDATA didod[INPUT_BUFFER_SIZE];
DWORD dwElements = INPUT_BUFFER_SIZE; DWORD dwElements = INPUT_BUFFER_SIZE;
DWORD ev; DWORD ev;
unsigned t,u; uint32_t t,u;
unsigned idevnums[NUM_INPUTS], numdevs = 0; uint32_t idevnums[NUM_INPUTS], numdevs = 0;
HANDLE waithnds[NUM_INPUTS]; HANDLE waithnds[NUM_INPUTS];
for (t = 0; t < NUM_INPUTS; t++) for (t = 0; t < NUM_INPUTS; t++)
@ -2260,9 +2260,9 @@ static void cdsenummodes(void)
DEVMODE dm; DEVMODE dm;
int32_t i = 0, j = 0; int32_t i = 0, j = 0;
struct { unsigned x,y,bpp,freq; } modes[MAXVALIDMODES]; struct { uint32_t x,y,bpp,freq; } modes[MAXVALIDMODES];
int32_t nmodes=0; int32_t nmodes=0;
unsigned maxx = MAXXDIM, maxy = MAXYDIM; uint32_t maxx = MAXXDIM, maxy = MAXYDIM;
ZeroMemory(&dm,sizeof(DEVMODE)); ZeroMemory(&dm,sizeof(DEVMODE));
@ -2307,7 +2307,7 @@ static void cdsenummodes(void)
// mode enumerator // mode enumerator
static HRESULT WINAPI getvalidmodes_enum(DDSURFACEDESC *ddsd, VOID *udata) static HRESULT WINAPI getvalidmodes_enum(DDSURFACEDESC *ddsd, VOID *udata)
{ {
unsigned maxx = MAXXDIM, maxy = MAXYDIM; uint32_t maxx = MAXXDIM, maxy = MAXYDIM;
UNREFERENCED_PARAMETER(udata); UNREFERENCED_PARAMETER(udata);

View file

@ -136,6 +136,10 @@
RelativePath=".\build\include\md4.h" RelativePath=".\build\include\md4.h"
> >
</File> </File>
<File
RelativePath=".\build\include\mdsprite.h"
>
</File>
<File <File
RelativePath=".\build\include\mmulti.h" RelativePath=".\build\include\mmulti.h"
> >
@ -248,6 +252,10 @@
RelativePath=".\build\src\engine.c" RelativePath=".\build\src\engine.c"
> >
</File> </File>
<File
RelativePath=".\build\src\engine_priv.h"
>
</File>
<File <File
RelativePath=".\build\src\glbuild.c" RelativePath=".\build\src\glbuild.c"
> >
@ -328,14 +336,6 @@
RelativePath=".\build\src\smalltextfont.c" RelativePath=".\build\src\smalltextfont.c"
> >
</File> </File>
<File
RelativePath=".\build\src\sound.c"
>
</File>
<File
RelativePath=".\build\src\sound_stub.c"
>
</File>
<File <File
RelativePath=".\build\src\startgtk.editor.c" RelativePath=".\build\src\startgtk.editor.c"
> >

View file

@ -2228,7 +2228,7 @@ CLEAR_THE_BOLT:
p = CheckPlayerInSector(sect); p = CheckPlayerInSector(sect);
if (p >= 0 && (g_player[p].ps->on_ground || s->ang == 512)) if (p >= 0 && (g_player[p].ps->on_ground || s->ang == 512))
{ {
if (t[0] == 0 && !check_activator_motion(s->lotag)) if (t[0] == 0 && !G_CheckActivatorMotion(s->lotag))
{ {
t[0] = 1; t[0] = 1;
t[1] = 1; t[1] = 1;

View file

@ -51,18 +51,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=================== ===================
*/ */
HASH_table gamefuncH = { NUMGAMEFUNCTIONS<<1, NULL }; hashtable_t gamefuncH = { NUMGAMEFUNCTIONS<<1, NULL };
int32 CONFIG_FunctionNameToNum(char * func) int32 CONFIG_FunctionNameToNum(char * func)
{ {
int32 i; int32 i;
i = HASH_find(&gamefuncH,func); i = hash_find(&gamefuncH,func);
if (i < 0) if (i < 0)
{ {
char *str = strtolower(Bstrdup(func),Bstrlen(func)); char *str = strtolower(Bstrdup(func),Bstrlen(func));
i = HASH_find(&gamefuncH,str); i = hash_find(&gamefuncH,str);
Bfree(str); Bfree(str);
return i; return i;
@ -150,8 +150,8 @@ void CONFIG_SetDefaultKeys(int32_t type)
int32 i,f; int32 i,f;
Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys)); Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys));
Bmemset(&boundkeys,0,sizeof(boundkeys)); Bmemset(&KeyBindings,0,sizeof(KeyBindings));
Bmemset(&mousebind,0,sizeof(mousebind)); Bmemset(&MouseBindings,0,sizeof(MouseBindings));
if (type == 1) if (type == 1)
{ {
@ -351,7 +351,7 @@ void CONFIG_ReadKeys(void)
numkeyentries = SCRIPT_NumberEntries(ud.config.scripthandle,"KeyDefinitions"); numkeyentries = SCRIPT_NumberEntries(ud.config.scripthandle,"KeyDefinitions");
Bmemset(&boundkeys,0,sizeof(boundkeys)); Bmemset(&KeyBindings,0,sizeof(KeyBindings));
for (i=0;i<numkeyentries;i++) for (i=0;i<numkeyentries;i++)
{ {
@ -405,14 +405,14 @@ void CONFIG_MapKey(int32 which, kb_scancode key1, kb_scancode oldkey1, kb_scanco
{ {
if (ii[k] == 0xff || !ii[k]) continue; if (ii[k] == 0xff || !ii[k]) continue;
for (j=0;keynames[j].name;j++) for (j=0;ConsoleKeys[j].name;j++)
if (ii[k] == keynames[j].id) if (ii[k] == ConsoleKeys[j].id)
break; break;
if (keynames[j].name) if (ConsoleKeys[j].name)
boundkeys[ii[k]].key=Bstrdup(keynames[j].name); KeyBindings[ii[k]].key=Bstrdup(ConsoleKeys[j].name);
boundkeys[ii[k]].repeat = 1; KeyBindings[ii[k]].repeat = 1;
boundkeys[ii[k]].cmd[0] = 0; KeyBindings[ii[k]].cmd[0] = 0;
tempbuf[0] = 0; tempbuf[0] = 0;
for (i=NUMGAMEFUNCTIONS-1;i>=0;i--) for (i=NUMGAMEFUNCTIONS-1;i>=0;i--)
@ -423,11 +423,11 @@ void CONFIG_MapKey(int32 which, kb_scancode key1, kb_scancode oldkey1, kb_scanco
Bstrcat(tempbuf,buf); Bstrcat(tempbuf,buf);
} }
} }
Bstrncpy(boundkeys[ii[k]].cmd,tempbuf, MAXBINDSTRINGLENGTH-1); Bstrncpy(KeyBindings[ii[k]].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
i = Bstrlen(boundkeys[ii[k]].cmd); i = Bstrlen(KeyBindings[ii[k]].cmd);
if (i) if (i)
boundkeys[ii[k]].cmd[i-2] = 0; // cut off the trailing "; " KeyBindings[ii[k]].cmd[i-2] = 0; // cut off the trailing "; "
} }
} }
@ -973,12 +973,12 @@ void CONFIG_WriteBinds(void) // save binds and aliases to disk
symbol_t *symb; symbol_t *symb;
fprintf(fp,"// this file automatically generated by EDuke32\n// do not modify if you lack common sense\n"); fprintf(fp,"// this file automatically generated by EDuke32\n// do not modify if you lack common sense\n");
for (i=0;i<MAXBOUNDKEYS;i++) for (i=0;i<MAXBOUNDKEYS;i++)
if (boundkeys[i].cmd[0] && boundkeys[i].key) if (KeyBindings[i].cmd[0] && KeyBindings[i].key)
fprintf(fp,"bind \"%s\"%s \"%s\"\n",boundkeys[i].key,boundkeys[i].repeat?"":" norepeat",boundkeys[i].cmd); fprintf(fp,"bind \"%s\"%s \"%s\"\n",KeyBindings[i].key,KeyBindings[i].repeat?"":" norepeat",KeyBindings[i].cmd);
for (i=0;i<MAXMOUSEBUTTONS;i++) for (i=0;i<MAXMOUSEBUTTONS;i++)
if (mousebind[i].cmd[0]) if (MouseBindings[i].cmd[0])
fprintf(fp,"bind \"%s\"%s \"%s\"\n",mousebind[i].key,mousebind[i].repeat?"":" norepeat",mousebind[i].cmd); fprintf(fp,"bind \"%s\"%s \"%s\"\n",MouseBindings[i].key,MouseBindings[i].repeat?"":" norepeat",MouseBindings[i].cmd);
for (symb=symbols; symb!=NULL; symb=symb->next) for (symb=symbols; symb!=NULL; symb=symb->next)
if (symb->func == (void *)OSD_ALIAS) if (symb->func == (void *)OSD_ALIAS)

View file

@ -438,7 +438,7 @@ typedef struct {
int32_t loogiex[64], loogiey[64], numloogs, loogcnt; int32_t loogiex[64], loogiey[64], numloogs, loogcnt;
char *palette; uint8_t *palette;
int16_t sbs, sound_pitch; int16_t sbs, sound_pitch;
@ -620,7 +620,7 @@ extern int32_t packetrate;
extern int32_t cachecount; extern int32_t cachecount;
extern char boardfilename[BMAX_PATH]; extern char boardfilename[BMAX_PATH];
extern char waterpal[768],slimepal[768],titlepal[768],drealms[768],endingpal[768],animpal[768]; extern uint8_t waterpal[768],slimepal[768],titlepal[768],drealms[768],endingpal[768],animpal[768];
extern char currentboardfilename[BMAX_PATH]; extern char currentboardfilename[BMAX_PATH];
extern char cachedebug,g_earthquakeTime; extern char cachedebug,g_earthquakeTime;
// 0: master/slave, 1: peer-to-peer // 0: master/slave, 1: peer-to-peer
@ -989,7 +989,7 @@ typedef struct {
int16_t numsectors; int16_t numsectors;
sectortype sector[MAXSECTORS]; sectortype sector[MAXSECTORS];
spritetype sprite[MAXSPRITES]; spritetype sprite[MAXSPRITES];
spriteexttype spriteext[MAXSPRITES]; spriteext_t spriteext[MAXSPRITES];
int16_t headspritesect[MAXSECTORS+1]; int16_t headspritesect[MAXSECTORS+1];
int16_t prevspritesect[MAXSPRITES]; int16_t prevspritesect[MAXSPRITES];
int16_t nextspritesect[MAXSPRITES]; int16_t nextspritesect[MAXSPRITES];
@ -1051,46 +1051,46 @@ typedef struct {
int32_t id; int32_t id;
} keydef_t; } keydef_t;
extern keydef_t keynames[]; extern keydef_t ConsoleKeys[];
extern char *mousenames[]; extern char *ConsoleButtons[];
extern char *duke3dgrp, *duke3dgrpstring; extern char *duke3dgrp, *duke3dgrpstring;
extern char mod_dir[BMAX_PATH]; extern char mod_dir[BMAX_PATH];
extern HASH_table gamevarH; extern hashtable_t gamevarH;
extern HASH_table arrayH; extern hashtable_t arrayH;
extern HASH_table keywH; extern hashtable_t keywH;
extern HASH_table gamefuncH; extern hashtable_t gamefuncH;
enum DukePacket_t enum DukePacket_t
{ {
PACKET_TYPE_MASTER_TO_SLAVE, PACKET_MASTER_TO_SLAVE,
PACKET_TYPE_SLAVE_TO_MASTER, PACKET_SLAVE_TO_MASTER,
PACKET_TYPE_BROADCAST, PACKET_BROADCAST,
SERVER_GENERATED_BROADCAST, SERVER_GENERATED_BROADCAST,
PACKET_TYPE_VERSION, PACKET_VERSION,
/* don't change anything above this line */ /* don't change anything above this line */
PACKET_TYPE_MESSAGE, PACKET_MESSAGE,
PACKET_TYPE_NEW_GAME, PACKET_NEW_GAME,
PACKET_TYPE_RTS, PACKET_RTS,
PACKET_TYPE_MENU_LEVEL_QUIT, PACKET_MENU_LEVEL_QUIT,
PACKET_TYPE_WEAPON_CHOICE, PACKET_WEAPON_CHOICE,
PACKET_TYPE_PLAYER_OPTIONS, PACKET_PLAYER_OPTIONS,
PACKET_TYPE_PLAYER_NAME, PACKET_PLAYER_NAME,
PACKET_TYPE_USER_MAP, PACKET_USER_MAP,
PACKET_TYPE_MAP_VOTE, PACKET_MAP_VOTE,
PACKET_TYPE_MAP_VOTE_INITIATE, PACKET_MAP_VOTE_INITIATE,
PACKET_TYPE_MAP_VOTE_CANCEL, PACKET_MAP_VOTE_CANCEL,
PACKET_TYPE_LOAD_GAME, PACKET_LOAD_GAME,
PACKET_TYPE_NULL_PACKET, PACKET_NULL_PACKET,
PACKET_TYPE_PLAYER_READY, PACKET_PLAYER_READY,
PACKET_TYPE_QUIT = 255 // should match mmulti I think PACKET_QUIT = 255 // should match mmulti I think
}; };
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -52,7 +52,7 @@ extern void pan3dsound(void);
extern void S_TestSoundCallback(uint32_t num); extern void S_TestSoundCallback(uint32_t num);
extern void S_ClearSoundLocks(void); extern void S_ClearSoundLocks(void);
extern int32_t A_CallSound(int32_t sn,int32_t whatsprite); extern int32_t A_CallSound(int32_t sn,int32_t whatsprite);
extern int32_t check_activator_motion(int32_t lotag); extern int32_t G_CheckActivatorMotion(int32_t lotag);
extern int32_t CheckDoorTile(int32_t dapic); extern int32_t CheckDoorTile(int32_t dapic);
extern int32_t isanunderoperator(int32_t lotag); extern int32_t isanunderoperator(int32_t lotag);
extern int32_t isanearoperator(int32_t lotag); extern int32_t isanearoperator(int32_t lotag);
@ -195,7 +195,7 @@ extern void A_MoveDummyPlayers(void);
// game.c // game.c
extern inline void G_SetStatusBarScale(int32_t sc); extern inline void G_SetStatusBarScale(int32_t sc);
extern void P_SetGamePalette(DukePlayer_t *player, char *pal, int32_t set); extern void P_SetGamePalette(DukePlayer_t *player, uint8_t *pal, int32_t set);
extern void fadepal(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_t step); extern void fadepal(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_t step);
extern int32_t gametext_z(int32_t small, int32_t starttile, int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t orientation,int32_t x1, int32_t y1, int32_t x2, int32_t y2,int32_t z); extern int32_t gametext_z(int32_t small, int32_t starttile, int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t orientation,int32_t x1, int32_t y1, int32_t x2, int32_t y2,int32_t z);

View file

@ -86,7 +86,7 @@ static struct strllist
char boardfilename[BMAX_PATH] = {0}, currentboardfilename[BMAX_PATH] = {0}; char boardfilename[BMAX_PATH] = {0}, currentboardfilename[BMAX_PATH] = {0};
char root[BMAX_PATH]; char root[BMAX_PATH];
char waterpal[768], slimepal[768], titlepal[768], drealms[768], endingpal[768], animpal[768]; uint8_t waterpal[768], slimepal[768], titlepal[768], drealms[768], endingpal[768], animpal[768];
static char firstdemofile[80] = { '\0' }; static char firstdemofile[80] = { '\0' };
static int32_t userconfiles = 0; static int32_t userconfiles = 0;
@ -285,7 +285,7 @@ static void G_PatchStatusBar(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
// else rotatesprite(tx,ty,scl,0,BOTTOMSTATUSBAR,4,0,10+16+64,clx1,cly1,clx2+clofx-1,cly2+clofy-1); // else rotatesprite(tx,ty,scl,0,BOTTOMSTATUSBAR,4,0,10+16+64,clx1,cly1,clx2+clofx-1,cly2+clofy-1);
} }
void P_SetGamePalette(DukePlayer_t *player, char *pal, int32_t set) void P_SetGamePalette(DukePlayer_t *player, uint8_t *pal, int32_t set)
{ {
if (player != g_player[screenpeek].ps) if (player != g_player[screenpeek].ps)
{ {
@ -513,32 +513,6 @@ int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t
return (x); return (x);
} }
static void allowtimetocorrecterrorswhenquitting(void)
{
int32_t i, j, oldtotalclock;
ready2send = 0;
for (j=MAXPLAYERS-1;j>=0;j--)
{
oldtotalclock = totalclock;
while (totalclock < oldtotalclock+TICSPERFRAME)
{
handleevents();
Net_GetPackets();
}
if (KB_KeyPressed(sc_Escape)) return;
packbuf[0] = PACKET_TYPE_NULL_PACKET;
TRAVERSE_CONNECT(i)
{
if (i != myconnectindex) mmulti_sendpacket(i,packbuf,1);
if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
}
}
}
void G_AddUserQuote(const char *daquote) void G_AddUserQuote(const char *daquote)
{ {
int32_t i; int32_t i;
@ -619,7 +593,7 @@ void Net_GetPackets(void)
#endif #endif
switch (packbuf[0]) switch (packbuf[0])
{ {
case PACKET_TYPE_MASTER_TO_SLAVE: //[0] (receive master sync buffer) case PACKET_MASTER_TO_SLAVE: //[0] (receive master sync buffer)
j = 1; j = 1;
if ((g_player[other].movefifoend&(TIMERUPDATESIZ-1)) == 0) if ((g_player[other].movefifoend&(TIMERUPDATESIZ-1)) == 0)
@ -710,7 +684,7 @@ void Net_GetPackets(void)
movefifosendplc += g_movesPerPacket; movefifosendplc += g_movesPerPacket;
break; break;
case PACKET_TYPE_SLAVE_TO_MASTER: //[1] (receive slave sync buffer) case PACKET_SLAVE_TO_MASTER: //[1] (receive slave sync buffer)
j = 3; j = 3;
k = packbuf[1] + (int32_t)(packbuf[2]<<8); k = packbuf[1] + (int32_t)(packbuf[2]<<8);
@ -748,7 +722,7 @@ void Net_GetPackets(void)
break; break;
case PACKET_TYPE_BROADCAST: case PACKET_BROADCAST:
g_player[other].movefifoend = movefifoplc = movefifosendplc = predictfifoplc = 0; g_player[other].movefifoend = movefifoplc = movefifosendplc = predictfifoplc = 0;
g_player[other].syncvalhead = syncvaltottail = 0L; g_player[other].syncvalhead = syncvaltottail = 0L;
case SERVER_GENERATED_BROADCAST: case SERVER_GENERATED_BROADCAST:
@ -804,21 +778,21 @@ void Net_GetPackets(void)
initprintf("INVALID GAME PACKET!!! (packet %d, %d too many bytes (%d %d))\n",packbuf[0],j-packbufleng,packbufleng,k); initprintf("INVALID GAME PACKET!!! (packet %d, %d too many bytes (%d %d))\n",packbuf[0],j-packbufleng,packbufleng,k);
break; break;
case PACKET_TYPE_NULL_PACKET: case PACKET_NULL_PACKET:
break; break;
case PACKET_TYPE_PLAYER_READY: case PACKET_PLAYER_READY:
if (g_player[other].playerreadyflag == 0) if (g_player[other].playerreadyflag == 0)
initprintf("Player %d is ready\n", other); initprintf("Player %d is ready\n", other);
g_player[other].playerreadyflag++; g_player[other].playerreadyflag++;
return; return;
case PACKET_TYPE_QUIT: case PACKET_QUIT:
G_GameExit(" "); G_GameExit(" ");
break; break;
default: default:
switch (packbuf[0]) switch (packbuf[0])
{ {
case PACKET_TYPE_MESSAGE: case PACKET_MESSAGE:
//slaves in M/S mode only send to master //slaves in M/S mode only send to master
if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) if ((!g_networkBroadcastMode) && (myconnectindex == connecthead))
{ {
@ -848,7 +822,7 @@ void Net_GetPackets(void)
break; break;
case PACKET_TYPE_NEW_GAME: case PACKET_NEW_GAME:
//Slaves in M/S mode only send to master //Slaves in M/S mode only send to master
//Master re-transmits message to all others //Master re-transmits message to all others
if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) if ((!g_networkBroadcastMode) && (myconnectindex == connecthead))
@ -883,7 +857,7 @@ void Net_GetPackets(void)
break; break;
case PACKET_TYPE_VERSION: case PACKET_VERSION:
//slaves in M/S mode only send to master //slaves in M/S mode only send to master
//Master re-transmits message to all others //Master re-transmits message to all others
if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) if ((!g_networkBroadcastMode) && (myconnectindex == connecthead))
@ -908,7 +882,7 @@ void Net_GetPackets(void)
break; break;
case PACKET_TYPE_PLAYER_OPTIONS: case PACKET_PLAYER_OPTIONS:
//slaves in M/S mode only send to master //slaves in M/S mode only send to master
//Master re-transmits message to all others //Master re-transmits message to all others
if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) if ((!g_networkBroadcastMode) && (myconnectindex == connecthead))
@ -926,7 +900,7 @@ void Net_GetPackets(void)
break; break;
case PACKET_TYPE_PLAYER_NAME: case PACKET_PLAYER_NAME:
//slaves in M/S mode only send to master //slaves in M/S mode only send to master
//Master re-transmits message to all others //Master re-transmits message to all others
if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) if ((!g_networkBroadcastMode) && (myconnectindex == connecthead))
@ -942,7 +916,7 @@ void Net_GetPackets(void)
break; break;
case PACKET_TYPE_WEAPON_CHOICE: case PACKET_WEAPON_CHOICE:
//slaves in M/S mode only send to master //slaves in M/S mode only send to master
//Master re-transmits message to all others //Master re-transmits message to all others
if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) if ((!g_networkBroadcastMode) && (myconnectindex == connecthead))
@ -957,7 +931,7 @@ void Net_GetPackets(void)
for (;i-j<10;i++) g_player[other].wchoice[i-j] = packbuf[i]; for (;i-j<10;i++) g_player[other].wchoice[i-j] = packbuf[i];
break; break;
case PACKET_TYPE_RTS: case PACKET_RTS:
//slaves in M/S mode only send to master //slaves in M/S mode only send to master
//Master re-transmits message to all others //Master re-transmits message to all others
if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) if ((!g_networkBroadcastMode) && (myconnectindex == connecthead))
@ -976,7 +950,7 @@ void Net_GetPackets(void)
g_RTSPlaying = 7; g_RTSPlaying = 7;
break; break;
case PACKET_TYPE_MENU_LEVEL_QUIT: case PACKET_MENU_LEVEL_QUIT:
//slaves in M/S mode only send to master //slaves in M/S mode only send to master
if (myconnectindex == connecthead) if (myconnectindex == connecthead)
{ {
@ -1012,7 +986,7 @@ void Net_GetPackets(void)
break; break;
case PACKET_TYPE_USER_MAP: case PACKET_USER_MAP:
//slaves in M/S mode only send to master //slaves in M/S mode only send to master
if (myconnectindex == connecthead) if (myconnectindex == connecthead)
{ {
@ -1040,9 +1014,9 @@ void Net_GetPackets(void)
break; break;
case PACKET_TYPE_MAP_VOTE: case PACKET_MAP_VOTE:
case PACKET_TYPE_MAP_VOTE_INITIATE: case PACKET_MAP_VOTE_INITIATE:
case PACKET_TYPE_MAP_VOTE_CANCEL: case PACKET_MAP_VOTE_CANCEL:
if (myconnectindex == connecthead) if (myconnectindex == connecthead)
{ {
@ -1054,7 +1028,7 @@ void Net_GetPackets(void)
switch (packbuf[0]) switch (packbuf[0])
{ {
case PACKET_TYPE_MAP_VOTE: case PACKET_MAP_VOTE:
if (voting == myconnectindex && g_player[(uint8_t)packbuf[1]].gotvote == 0) if (voting == myconnectindex && g_player[(uint8_t)packbuf[1]].gotvote == 0)
{ {
g_player[(uint8_t)packbuf[1]].gotvote = 1; g_player[(uint8_t)packbuf[1]].gotvote = 1;
@ -1064,7 +1038,7 @@ void Net_GetPackets(void)
} }
break; break;
case PACKET_TYPE_MAP_VOTE_INITIATE: // call map vote case PACKET_MAP_VOTE_INITIATE: // call map vote
/* if (g_networkBroadcastMode == 0 && packbuf[1] == connecthead) /* if (g_networkBroadcastMode == 0 && packbuf[1] == connecthead)
break; // ignore this from master */ break; // ignore this from master */
voting = packbuf[1]; voting = packbuf[1];
@ -1088,7 +1062,7 @@ void Net_GetPackets(void)
g_player[voting].gotvote = g_player[voting].vote = 1; g_player[voting].gotvote = g_player[voting].vote = 1;
break; break;
case PACKET_TYPE_MAP_VOTE_CANCEL: // cancel map vote case PACKET_MAP_VOTE_CANCEL: // cancel map vote
if (voting == packbuf[1]) if (voting == packbuf[1])
{ {
voting = -1; voting = -1;
@ -1110,7 +1084,7 @@ void Net_GetPackets(void)
} }
break; break;
case PACKET_TYPE_LOAD_GAME: case PACKET_LOAD_GAME:
//Slaves in M/S mode only send to master //Slaves in M/S mode only send to master
//Master re-transmits message to all others //Master re-transmits message to all others
if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) if ((!g_networkBroadcastMode) && (myconnectindex == connecthead))
@ -1228,7 +1202,7 @@ void faketimerhandler(void)
if (g_networkBroadcastMode == 1) if (g_networkBroadcastMode == 1)
{ {
packbuf[0] = SERVER_GENERATED_BROADCAST; packbuf[0] = SERVER_GENERATED_BROADCAST;
if ((g_player[myconnectindex].movefifoend-1) == 0) packbuf[0] = PACKET_TYPE_BROADCAST; if ((g_player[myconnectindex].movefifoend-1) == 0) packbuf[0] = PACKET_BROADCAST;
j = 1; j = 1;
//Fix timers and buffer/jitter value //Fix timers and buffer/jitter value
@ -1377,7 +1351,7 @@ void faketimerhandler(void)
} }
} }
packbuf[0] = PACKET_TYPE_SLAVE_TO_MASTER; packbuf[0] = PACKET_SLAVE_TO_MASTER;
packbuf[1] = 0; packbuf[1] = 0;
packbuf[2] = 0; packbuf[2] = 0;
j = 3; j = 3;
@ -1433,7 +1407,7 @@ void faketimerhandler(void)
TRAVERSE_CONNECT(i) TRAVERSE_CONNECT(i)
if (g_player[i].movefifoend <= movefifosendplc) if (g_player[i].movefifoend <= movefifosendplc)
{ {
packbuf[0] = PACKET_TYPE_NULL_PACKET; packbuf[0] = PACKET_NULL_PACKET;
for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
mmulti_sendpacket(i,packbuf,1); mmulti_sendpacket(i,packbuf,1);
return; return;
@ -1448,7 +1422,7 @@ void faketimerhandler(void)
nsyn = (input_t *)&inputfifo[(movefifosendplc)&(MOVEFIFOSIZ-1)][0]; nsyn = (input_t *)&inputfifo[(movefifosendplc)&(MOVEFIFOSIZ-1)][0];
//MASTER -> SLAVE packet //MASTER -> SLAVE packet
packbuf[0] = PACKET_TYPE_MASTER_TO_SLAVE; packbuf[0] = PACKET_MASTER_TO_SLAVE;
j = 1; j = 1;
//Fix timers and buffer/jitter value //Fix timers and buffer/jitter value
@ -2878,10 +2852,33 @@ extern int32_t g_doQuickSave;
void G_GameExit(const char *t) void G_GameExit(const char *t)
{ {
if (*t != 0) g_player[myconnectindex].ps->palette = (char *) &palette[0]; if (*t != 0) g_player[myconnectindex].ps->palette = (unsigned char *) &palette[0];
if (numplayers > 1) if (numplayers > 1)
allowtimetocorrecterrorswhenquitting(); {
int32_t i, j, oldtotalclock;
ready2send = 0;
for (j=MAXPLAYERS-1;j>=0;j--)
{
oldtotalclock = totalclock;
while (totalclock < oldtotalclock+TICSPERFRAME)
{
handleevents();
Net_GetPackets();
}
if (KB_KeyPressed(sc_Escape)) return;
packbuf[0] = PACKET_NULL_PACKET;
TRAVERSE_CONNECT(i)
{
if (i != myconnectindex) mmulti_sendpacket(i,packbuf,1);
if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
}
}
}
mmulti_uninitmultiplayers(); mmulti_uninitmultiplayers();
@ -3016,7 +3013,7 @@ static void Net_EnterMessage(void)
{ {
if (g_chatPlayer != -1 || ud.multimode < 3 || g_movesPerPacket == 4) if (g_chatPlayer != -1 || ud.multimode < 3 || g_movesPerPacket == 4)
{ {
tempbuf[0] = PACKET_TYPE_MESSAGE; tempbuf[0] = PACKET_MESSAGE;
tempbuf[2] = 0; tempbuf[2] = 0;
recbuf[0] = 0; recbuf[0] = 0;
@ -4756,8 +4753,8 @@ int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int3
if (show2dsector[SECT>>3]&(1<<(SECT&7))) show2dsprite[i>>3] |= (1<<(i&7)); if (show2dsector[SECT>>3]&(1<<(SECT&7))) show2dsprite[i>>3] |= (1<<(i&7));
else show2dsprite[i>>3] &= ~(1<<(i&7)); else show2dsprite[i>>3] &= ~(1<<(i&7));
clearbufbyte(&spriteext[i], sizeof(spriteexttype), 0); clearbufbyte(&spriteext[i], sizeof(spriteext_t), 0);
clearbufbyte(&spritesmooth[i], sizeof(spritesmoothtype), 0); clearbufbyte(&spritesmooth[i], sizeof(spritesmooth_t), 0);
/* /*
if(s->sectnum < 0) if(s->sectnum < 0)
@ -8221,7 +8218,7 @@ static void G_HandleLocalKeys(void)
{ {
if (KB_UnBoundKeyPressed(sc_F1) || KB_UnBoundKeyPressed(sc_F2) || ud.autovote) if (KB_UnBoundKeyPressed(sc_F1) || KB_UnBoundKeyPressed(sc_F2) || ud.autovote)
{ {
tempbuf[0] = PACKET_TYPE_MAP_VOTE; tempbuf[0] = PACKET_MAP_VOTE;
tempbuf[1] = myconnectindex; tempbuf[1] = myconnectindex;
tempbuf[2] = (KB_UnBoundKeyPressed(sc_F1) || ud.autovote?ud.autovote-1:0); tempbuf[2] = (KB_UnBoundKeyPressed(sc_F1) || ud.autovote?ud.autovote-1:0);
@ -8407,7 +8404,7 @@ static void G_HandleLocalKeys(void)
ch = 0; ch = 0;
tempbuf[ch] = PACKET_TYPE_MESSAGE; tempbuf[ch] = PACKET_MESSAGE;
tempbuf[ch+1] = 255; tempbuf[ch+1] = 255;
tempbuf[ch+2] = 0; tempbuf[ch+2] = 0;
Bstrcat(tempbuf+2,ud.ridecule[i-1]); Bstrcat(tempbuf+2,ud.ridecule[i-1]);
@ -8440,7 +8437,7 @@ static void G_HandleLocalKeys(void)
if (ud.multimode > 1) if (ud.multimode > 1)
{ {
tempbuf[0] = PACKET_TYPE_RTS; tempbuf[0] = PACKET_RTS;
tempbuf[1] = i; tempbuf[1] = i;
TRAVERSE_CONNECT(ch) TRAVERSE_CONNECT(ch)
@ -9083,25 +9080,25 @@ static char *makename(char *destname, char *OGGname, char *origname)
if (!origname) if (!origname)
return destname; return destname;
if (destname) destname = Brealloc(destname, Bstrlen(OGGname) + Bstrlen(origname) + 1);
Bfree(destname);
destname = Bcalloc(Bstrlen(OGGname) + Bstrlen(origname) + 1, sizeof(uint8_t));
if (!destname) if (!destname)
return NULL; return NULL;
Bstrcpy(destname,(*OGGname)?OGGname:origname); Bstrcpy(destname, (*OGGname)?OGGname:origname);
if (*OGGname&&OGGname[Bstrlen(OGGname)-1]=='/') if (*OGGname && OGGname[Bstrlen(OGGname)-1] == '/')
{ {
while (*origname=='/') while (*origname == '/')
origname++; origname++;
Bstrcat(destname,origname); Bstrcat(destname, origname);
} }
OGGname=Bstrchr(destname,'.'); OGGname = Bstrchr(destname, '.');
if (OGGname) if (OGGname)
Bstrcpy(OGGname,".ogg"); Bstrcpy(OGGname, ".ogg");
else Bstrcat(destname,".ogg"); else Bstrcat(destname, ".ogg");
return destname; return destname;
} }
@ -10186,7 +10183,7 @@ static void G_FreeMemory(void)
// if (MusicPtr != NULL) Bfree(MusicPtr); // if (MusicPtr != NULL) Bfree(MusicPtr);
// C_FreeHashes(); // C_FreeHashes();
HASH_free(&gamefuncH); hash_free(&gamefuncH);
} }
/* /*
@ -10534,7 +10531,7 @@ void Net_SendQuit(void)
{ {
int32_t i; int32_t i;
tempbuf[0] = PACKET_TYPE_MENU_LEVEL_QUIT; tempbuf[0] = PACKET_MENU_LEVEL_QUIT;
tempbuf[1] = myconnectindex; tempbuf[1] = myconnectindex;
TRAVERSE_CONNECT(i) TRAVERSE_CONNECT(i)
@ -10556,7 +10553,7 @@ static void Net_SendWeaponChoice(void)
{ {
int32_t i,l; int32_t i,l;
buf[0] = PACKET_TYPE_WEAPON_CHOICE; buf[0] = PACKET_WEAPON_CHOICE;
buf[1] = myconnectindex; buf[1] = myconnectindex;
l = 2; l = 2;
@ -10579,7 +10576,7 @@ static void Net_SendVersion(void)
if (numplayers < 2) return; if (numplayers < 2) return;
buf[0] = PACKET_TYPE_VERSION; buf[0] = PACKET_VERSION;
buf[1] = myconnectindex; buf[1] = myconnectindex;
buf[2] = (uint8_t)atoi(s_buildDate); buf[2] = (uint8_t)atoi(s_buildDate);
buf[3] = BYTEVERSION; buf[3] = BYTEVERSION;
@ -10597,7 +10594,7 @@ static void Net_SendPlayerOptions(void)
{ {
int32_t i,l; int32_t i,l;
buf[0] = PACKET_TYPE_PLAYER_OPTIONS; buf[0] = PACKET_PLAYER_OPTIONS;
buf[1] = myconnectindex; buf[1] = myconnectindex;
l = 2; l = 2;
@ -10628,7 +10625,7 @@ void Net_SendPlayerName(void)
if (numplayers < 2) return; if (numplayers < 2) return;
buf[0] = PACKET_TYPE_PLAYER_NAME; buf[0] = PACKET_PLAYER_NAME;
buf[1] = myconnectindex; buf[1] = myconnectindex;
l = 2; l = 2;
@ -10650,7 +10647,7 @@ void Net_SendUserMapName(void)
int32_t j; int32_t j;
int32_t ch; int32_t ch;
packbuf[0] = PACKET_TYPE_USER_MAP; packbuf[0] = PACKET_USER_MAP;
packbuf[1] = 0; packbuf[1] = 0;
Bcorrectfilename(boardfilename,0); Bcorrectfilename(boardfilename,0);
@ -10671,7 +10668,7 @@ void Net_NewGame(int32_t volume, int32_t level)
{ {
int32_t i; int32_t i;
packbuf[0] = PACKET_TYPE_NEW_GAME; packbuf[0] = PACKET_NEW_GAME;
packbuf[1] = ud.m_level_number = level; packbuf[1] = ud.m_level_number = level;
packbuf[2] = ud.m_volume_number = volume; packbuf[2] = ud.m_volume_number = volume;
packbuf[3] = ud.m_player_skill+1; packbuf[3] = ud.m_player_skill+1;
@ -10691,27 +10688,6 @@ void Net_NewGame(int32_t volume, int32_t level)
} }
} }
#if 0
static void getnames(void)
{
int32_t l;
if (numplayers > 1)
{
Net_SendVersion();
Net_SendPlayerName();
Net_SendPlayerOptions();
Net_SendWeaponChoice();
Net_SendUserMapName();
getpackets();
waitforeverybody();
}
if (cp == 1 && numplayers < 2)
G_GameExit("Please put the Duke Nukem 3D Atomic Edition CD in the CD-ROM drive.");
}
#endif
void G_UpdatePlayerFromMenu(void) void G_UpdatePlayerFromMenu(void)
{ {
if (ud.recstat != 0) if (ud.recstat != 0)
@ -10725,13 +10701,13 @@ void G_UpdatePlayerFromMenu(void)
} }
else else
{ {
int32_t j; /*int32_t j = g_player[myconnectindex].ps->team;*/
g_player[myconnectindex].ps->aim_mode = ud.mouseaiming; g_player[myconnectindex].ps->aim_mode = ud.mouseaiming;
g_player[myconnectindex].ps->auto_aim = ud.config.AutoAim; g_player[myconnectindex].ps->auto_aim = ud.config.AutoAim;
g_player[myconnectindex].ps->weaponswitch = ud.weaponswitch; g_player[myconnectindex].ps->weaponswitch = ud.weaponswitch;
g_player[myconnectindex].ps->palookup = g_player[myconnectindex].pcolor = ud.color; g_player[myconnectindex].ps->palookup = g_player[myconnectindex].pcolor = ud.color;
j = g_player[myconnectindex].ps->team;
g_player[myconnectindex].pteam = ud.team; g_player[myconnectindex].pteam = ud.team;
if (sprite[g_player[myconnectindex].ps->i].picnum == APLAYER && sprite[g_player[myconnectindex].ps->i].pal != 1) if (sprite[g_player[myconnectindex].ps->i].picnum == APLAYER && sprite[g_player[myconnectindex].ps->i].pal != 1)
@ -10928,12 +10904,12 @@ void app_main(int32_t argc,const char **argv)
ud.config.CheckForUpdates = -1; ud.config.CheckForUpdates = -1;
#endif #endif
HASH_init(&gamefuncH); hash_init(&gamefuncH);
for (i=NUMGAMEFUNCTIONS-1;i>=0;i--) for (i=NUMGAMEFUNCTIONS-1;i>=0;i--)
{ {
char *str = strtolower(Bstrdup(gamefunctions[i]),Bstrlen(gamefunctions[i])); char *str = strtolower(Bstrdup(gamefunctions[i]),Bstrlen(gamefunctions[i]));
HASH_add(&gamefuncH,gamefunctions[i],i); hash_add(&gamefuncH,gamefunctions[i],i);
HASH_add(&gamefuncH,str,i); hash_add(&gamefuncH,str,i);
Bfree(str); Bfree(str);
} }
@ -10990,10 +10966,12 @@ void app_main(int32_t argc,const char **argv)
if (!ShellExecuteExA(&sinfo)) if (!ShellExecuteExA(&sinfo))
initprintf("update: error launching browser!\n"); initprintf("update: error launching browser!\n");
/*
CONFIG_SetupMouse(); CONFIG_SetupMouse();
CONFIG_SetupJoystick(); CONFIG_SetupJoystick();
CONFIG_WriteSetup(); CONFIG_WriteSetup();
G_GameExit(" "); G_GameExit(" ");
*/
} }
} }
else initprintf("... no updates available\n"); else initprintf("... no updates available\n");
@ -11280,7 +11258,7 @@ CLEAN_DIRECTORY:
g_player[i].sync = (input_t *) Bcalloc(1,sizeof(input_t)); g_player[i].sync = (input_t *) Bcalloc(1,sizeof(input_t));
} }
g_player[myconnectindex].ps->palette = (char *) &palette[0]; g_player[myconnectindex].ps->palette = (uint8_t *) &palette[0];
i = 1; i = 1;
for (j=numplayers;j<ud.multimode;j++) for (j=numplayers;j<ud.multimode;j++)
@ -11303,9 +11281,14 @@ CLEAN_DIRECTORY:
Net_SendVersion(); Net_SendVersion();
Net_SendPlayerName(); Net_SendPlayerName();
#if 0
if (cp == 1 && numplayers < 2)
G_GameExit("Please put the Duke Nukem 3D Atomic Edition CD in the CD-ROM drive.");
#endif
if (numplayers > 1) if (numplayers > 1)
{ {
sendlogon(); mmulti_sendlogon();
Net_SendPlayerOptions(); Net_SendPlayerOptions();
Net_SendWeaponChoice(); Net_SendWeaponChoice();
Net_SendUserMapName(); Net_SendUserMapName();

View file

@ -940,20 +940,20 @@ const memberlabel_t InputLabels[]=
char *bitptr; // pointer to bitmap of which bytecode positions contain pointers char *bitptr; // pointer to bitmap of which bytecode positions contain pointers
#define BITPTR_POINTER 1 #define BITPTR_POINTER 1
HASH_table gamevarH = { MAXGAMEVARS>>1, NULL }; hashtable_t gamevarH = { MAXGAMEVARS>>1, NULL };
HASH_table arrayH = { MAXGAMEARRAYS>>1, NULL }; hashtable_t arrayH = { MAXGAMEARRAYS>>1, NULL };
HASH_table labelH = { 11264>>1, NULL }; hashtable_t labelH = { 11264>>1, NULL };
HASH_table keywH = { CON_END>>1, NULL }; hashtable_t keywH = { CON_END>>1, NULL };
HASH_table sectorH = { SECTOR_END>>1, NULL }; hashtable_t sectorH = { SECTOR_END>>1, NULL };
HASH_table wallH = { WALL_END>>1, NULL }; hashtable_t wallH = { WALL_END>>1, NULL };
HASH_table userdefH = { USERDEFS_END>>1, NULL }; hashtable_t userdefH = { USERDEFS_END>>1, NULL };
HASH_table projectileH = { PROJ_END>>1, NULL }; hashtable_t projectileH = { PROJ_END>>1, NULL };
HASH_table playerH = { PLAYER_END>>1, NULL }; hashtable_t playerH = { PLAYER_END>>1, NULL };
HASH_table inputH = { INPUT_END>>1, NULL }; hashtable_t inputH = { INPUT_END>>1, NULL };
HASH_table actorH = { ACTOR_END>>1, NULL }; hashtable_t actorH = { ACTOR_END>>1, NULL };
HASH_table tspriteH = { ACTOR_END>>1, NULL }; hashtable_t tspriteH = { ACTOR_END>>1, NULL };
void inithashnames(); void inithashnames();
void freehashnames(); void freehashnames();
@ -962,47 +962,47 @@ void C_InitHashes()
{ {
int32_t i; int32_t i;
HASH_init(&gamevarH); hash_init(&gamevarH);
HASH_init(&arrayH); hash_init(&arrayH);
HASH_init(&labelH); hash_init(&labelH);
inithashnames(); inithashnames();
HASH_init(&keywH); hash_init(&keywH);
for (i=NUMKEYWORDS-1;i>=0;i--) for (i=NUMKEYWORDS-1;i>=0;i--)
HASH_add(&keywH,keyw[i],i); hash_add(&keywH,keyw[i],i);
HASH_init(&sectorH); hash_init(&sectorH);
for (i=0;SectorLabels[i].lId >=0 ; i++) for (i=0;SectorLabels[i].lId >=0 ; i++)
HASH_add(&sectorH,SectorLabels[i].name,i); hash_add(&sectorH,SectorLabels[i].name,i);
HASH_init(&wallH); hash_init(&wallH);
for (i=0;WallLabels[i].lId >=0 ; i++) for (i=0;WallLabels[i].lId >=0 ; i++)
HASH_add(&wallH,WallLabels[i].name,i); hash_add(&wallH,WallLabels[i].name,i);
HASH_init(&userdefH); hash_init(&userdefH);
for (i=0;UserdefsLabels[i].lId >=0 ; i++) for (i=0;UserdefsLabels[i].lId >=0 ; i++)
HASH_add(&userdefH,UserdefsLabels[i].name,i); hash_add(&userdefH,UserdefsLabels[i].name,i);
HASH_init(&projectileH); hash_init(&projectileH);
for (i=0;ProjectileLabels[i].lId >=0 ; i++) for (i=0;ProjectileLabels[i].lId >=0 ; i++)
HASH_add(&projectileH,ProjectileLabels[i].name,i); hash_add(&projectileH,ProjectileLabels[i].name,i);
HASH_init(&playerH); hash_init(&playerH);
for (i=0;PlayerLabels[i].lId >=0 ; i++) for (i=0;PlayerLabels[i].lId >=0 ; i++)
HASH_add(&playerH,PlayerLabels[i].name,i); hash_add(&playerH,PlayerLabels[i].name,i);
HASH_init(&inputH); hash_init(&inputH);
for (i=0;InputLabels[i].lId >=0 ; i++) for (i=0;InputLabels[i].lId >=0 ; i++)
HASH_add(&inputH,InputLabels[i].name,i); hash_add(&inputH,InputLabels[i].name,i);
HASH_init(&actorH); hash_init(&actorH);
for (i=0;ActorLabels[i].lId >=0 ; i++) for (i=0;ActorLabels[i].lId >=0 ; i++)
HASH_add(&actorH,ActorLabels[i].name,i); hash_add(&actorH,ActorLabels[i].name,i);
HASH_init(&tspriteH); hash_init(&tspriteH);
for (i=0;TsprLabels[i].lId >=0 ; i++) for (i=0;TsprLabels[i].lId >=0 ; i++)
HASH_add(&tspriteH,TsprLabels[i].name,i); hash_add(&tspriteH,TsprLabels[i].name,i);
} }
void C_FreeHashes(void) void C_FreeHashes(void)
{ {
HASH_free(&gamevarH); hash_free(&gamevarH);
HASH_free(&arrayH); hash_free(&arrayH);
HASH_free(&labelH); hash_free(&labelH);
} }
#define IFELSE_MAGIC 31337 #define IFELSE_MAGIC 31337
@ -1031,15 +1031,14 @@ static int32_t C_IncreaseScriptSize(int32_t size)
scriptptrs = Bcalloc(1,g_scriptSize * sizeof(uint8_t)); scriptptrs = Bcalloc(1,g_scriptSize * sizeof(uint8_t));
for (i=g_scriptSize-1;i>=0;i--) for (i=g_scriptSize-1;i>=0;i--)
{ {
// initprintf("%d\n",i); if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)) && !((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize])))
/* if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)) && !((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize])))
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
initprintf("Internal compiler error at %d (0x%x)\n",i,i); initprintf("Internal compiler error at %d (0x%x)\n",i,i);
} */ }
// if (bitptr[i] == 0 && ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize]))) // if (bitptr[i] == 0 && ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize])))
// initprintf("oh no!\n"); // initprintf("oh no!\n");
if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)) /*&& ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize]))*/) if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)))
{ {
scriptptrs[i] = 1; scriptptrs[i] = 1;
script[i] -= (intptr_t)&script[0]; script[i] -= (intptr_t)&script[0];
@ -1381,8 +1380,8 @@ static int32_t C_CheckEventSync(int32_t iEventID)
return 1; return 1;
} }
#define GetDefID(szGameLabel) HASH_find(&gamevarH,szGameLabel) #define GetDefID(szGameLabel) hash_find(&gamevarH,szGameLabel)
#define GetADefID(szGameLabel) HASH_find(&arrayH,szGameLabel) #define GetADefID(szGameLabel) hash_find(&arrayH,szGameLabel)
static inline int32_t ispecial(char c) static inline int32_t ispecial(char c)
{ {
@ -1403,25 +1402,25 @@ static inline int32_t isaltok(char c)
return (isalnum(c) || c == '{' || c == '}' || c == '/' || c == '*' || c == '-' || c == '_' || c == '.'); return (isalnum(c) || c == '{' || c == '}' || c == '/' || c == '*' || c == '-' || c == '_' || c == '.');
} }
static inline int32_t C_GetLabelNameID(const memberlabel_t *pLabel, HASH_table *tH, const char *psz) static inline int32_t C_GetLabelNameID(const memberlabel_t *pLabel, hashtable_t *tH, const char *psz)
{ {
// find the label psz in the table pLabel. // find the label psz in the table pLabel.
// returns the ID for the label, or -1 // returns the ID for the label, or -1
int32_t l=-1; int32_t l=-1;
l = HASH_findcase(tH,psz); l = hash_findcase(tH,psz);
if (l>=0) l= pLabel[l].lId; if (l>=0) l= pLabel[l].lId;
return l; return l;
} }
static inline int32_t C_GetLabelNameOffset(HASH_table *tH, const char *psz) static inline int32_t C_GetLabelNameOffset(hashtable_t *tH, const char *psz)
{ {
// find the label psz in the table pLabel. // find the label psz in the table pLabel.
// returns the offset in the array for the label, or -1 // returns the offset in the array for the label, or -1
return HASH_findcase(tH,psz); return hash_findcase(tH,psz);
} }
static void C_GetNextLabelName(void) static void C_GetNextLabelName(void)
@ -1467,7 +1466,7 @@ static int32_t C_GetKeyword(void)
while (isaltok(*temptextptr)) while (isaltok(*temptextptr))
tempbuf[i++] = *(temptextptr++); tempbuf[i++] = *(temptextptr++);
tempbuf[i] = 0; tempbuf[i] = 0;
return HASH_find(&keywH,tempbuf); return hash_find(&keywH,tempbuf);
} }
static int32_t C_GetNextKeyword(void) //Returns its code # static int32_t C_GetNextKeyword(void) //Returns its code #
@ -1497,7 +1496,7 @@ static int32_t C_GetNextKeyword(void) //Returns its code #
} }
tempbuf[l] = 0; tempbuf[l] = 0;
i = HASH_find(&keywH,tempbuf); i = hash_find(&keywH,tempbuf);
if (i>=0) if (i>=0)
{ {
if (i == CON_LEFTBRACE || i == CON_RIGHTBRACE || i == CON_NULLOP) if (i == CON_LEFTBRACE || i == CON_RIGHTBRACE || i == CON_NULLOP)
@ -1516,12 +1515,12 @@ static int32_t C_GetNextKeyword(void) //Returns its code #
if (tempbuf[0] == '{' && tempbuf[1] != 0) if (tempbuf[0] == '{' && tempbuf[1] != 0)
{ {
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: error: expected a SPACE or CR between `{' and `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf+1); initprintf("%s:%d: error: expected whitespace between `{' and `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf+1);
} }
else if (tempbuf[0] == '}' && tempbuf[1] != 0) else if (tempbuf[0] == '}' && tempbuf[1] != 0)
{ {
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: error: expected a SPACE or CR between `}' and `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf+1); initprintf("%s:%d: error: expected whitespace between `}' and `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf+1);
} }
else C_ReportError(ERROR_EXPECTEDKEYWORD); else C_ReportError(ERROR_EXPECTEDKEYWORD);
g_numCompilerErrors++; g_numCompilerErrors++;
@ -1542,7 +1541,7 @@ static void C_GetNextVarType(int32_t type)
if (tolower(textptr[1])=='x') if (tolower(textptr[1])=='x')
sscanf(textptr+2,"%" PRIxPTR "",g_scriptPtr); sscanf(textptr+2,"%" PRIxPTR "",g_scriptPtr);
else else
*g_scriptPtr=atol(textptr); *g_scriptPtr=atoi(textptr);
bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7));
g_scriptPtr++; g_scriptPtr++;
C_GetNextLabelName(); C_GetNextLabelName();
@ -1566,7 +1565,7 @@ static void C_GetNextVarType(int32_t type)
} }
C_GetNextLabelName(); C_GetNextLabelName();
if (!g_skipKeywordCheck && HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (!g_skipKeywordCheck && hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
@ -1579,7 +1578,6 @@ static void C_GetNextVarType(int32_t type)
int32_t lLabelID = -1; int32_t lLabelID = -1;
f |= (MAXGAMEVARS<<2); f |= (MAXGAMEVARS<<2);
// initprintf("got an array");
textptr++; textptr++;
i=GetADefID(label+(g_numLabels<<6)); i=GetADefID(label+(g_numLabels<<6));
if (i < 0) if (i < 0)
@ -1696,7 +1694,7 @@ static void C_GetNextVarType(int32_t type)
{ {
//try looking for a define instead //try looking for a define instead
Bstrcpy(tempbuf,label+(g_numLabels<<6)); Bstrcpy(tempbuf,label+(g_numLabels<<6));
i = HASH_find(&labelH,tempbuf); i = hash_find(&labelH,tempbuf);
if (i>=0) if (i>=0)
{ {
if (labeltype[i] & LABEL_DEFINE) if (labeltype[i] & LABEL_DEFINE)
@ -1735,7 +1733,9 @@ static void C_GetNextVarType(int32_t type)
if ((aGameVars[i].dwFlags & GAMEVAR_SYNCCHECK) && g_parsingActorPtr && C_CheckEventSync(g_currentEvent)) if ((aGameVars[i].dwFlags & GAMEVAR_SYNCCHECK) && g_parsingActorPtr && C_CheckEventSync(g_currentEvent))
{ {
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: warning: found local gamevar `%s' used within %s; expect multiplayer synchronization issues.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6),g_parsingEventPtr?"a synced event":"an actor"); initprintf("%s:%d: warning: found local gamevar `%s' used within %s; "
"expect multiplayer synchronization issues.\n",g_szScriptFileName,
g_lineNumber,label+(g_numLabels<<6),g_parsingEventPtr?"a synced event":"an actor");
g_numCompilerWarnings++; g_numCompilerWarnings++;
} }
if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
@ -1745,10 +1745,7 @@ static void C_GetNextVarType(int32_t type)
*g_scriptPtr++=(i|f); *g_scriptPtr++=(i|f);
} }
static inline void C_GetNextVar(void) #define C_GetNextVar() C_GetNextVarType(0)
{
C_GetNextVarType(0);
}
static inline void C_GetManyVarsType(int32_t type, int32_t num) static inline void C_GetManyVarsType(int32_t type, int32_t num)
{ {
@ -1757,10 +1754,7 @@ static inline void C_GetManyVarsType(int32_t type, int32_t num)
C_GetNextVarType(type); C_GetNextVarType(type);
} }
static inline void C_GetManyVars(int32_t num) #define C_GetManyVars(num) C_GetManyVarsType(0,num)
{
C_GetManyVarsType(0,num);
}
static int32_t C_GetNextValue(int32_t type) static int32_t C_GetNextValue(int32_t type)
{ {
@ -1784,14 +1778,14 @@ static int32_t C_GetNextValue(int32_t type)
} }
tempbuf[l] = 0; tempbuf[l] = 0;
if (!g_skipKeywordCheck && HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (!g_skipKeywordCheck && hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
textptr+=l; textptr+=l;
} }
i = HASH_find(&labelH,tempbuf); i = hash_find(&labelH,tempbuf);
if (i>=0) if (i>=0)
{ {
char *el,*gl; char *el,*gl;
@ -1817,7 +1811,7 @@ static int32_t C_GetNextValue(int32_t type)
el = (char *)C_GetLabelType(type); el = (char *)C_GetLabelType(type);
gl = (char *)C_GetLabelType(labeltype[i]); gl = (char *)C_GetLabelType(labeltype[i]);
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: warning: expected a %s, found a %s.\n",g_szScriptFileName,g_lineNumber,el,gl); initprintf("%s:%d: warning: expected %s, found %s.\n",g_szScriptFileName,g_lineNumber,el,gl);
g_numCompilerWarnings++; g_numCompilerWarnings++;
Bfree(el); Bfree(el);
Bfree(gl); Bfree(gl);
@ -1844,11 +1838,12 @@ static int32_t C_GetNextValue(int32_t type)
i = l-1; i = l-1;
do do
{ {
// FIXME: check for 0-9 A-F for hex
if (textptr[0] == '0' && textptr[1] == 'x') break; // kill the warning for hex if (textptr[0] == '0' && textptr[1] == 'x') break; // kill the warning for hex
if (!isdigit(textptr[i--])) if (!isdigit(textptr[i--]))
{ {
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: warning: invalid character in definition: '%c'!\n",g_szScriptFileName,g_lineNumber,textptr[i+1]); initprintf("%s:%d: warning: invalid character `%c' in definition!\n",g_szScriptFileName,g_lineNumber,textptr[i+1]);
g_numCompilerWarnings++; g_numCompilerWarnings++;
break; break;
} }
@ -1980,28 +1975,28 @@ static int32_t C_ParseCommand(void)
g_processingState = 1; g_processingState = 1;
Bsprintf(g_szCurrentBlockName,"%s",label+(g_numLabels<<6)); Bsprintf(g_szCurrentBlockName,"%s",label+(g_numLabels<<6));
HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); hash_add(&labelH,label+(g_numLabels<<6),g_numLabels);
g_numLabels++; g_numLabels++;
return 0; return 0;
} }
C_GetNextLabelName(); C_GetNextLabelName();
if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
return 0; return 0;
} }
i = HASH_find(&gamevarH,label+(g_numLabels<<6)); i = hash_find(&gamevarH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
C_ReportError(WARNING_NAMEMATCHESVAR); C_ReportError(WARNING_NAMEMATCHESVAR);
} }
j = HASH_find(&labelH,label+(g_numLabels<<6)); j = hash_find(&labelH,label+(g_numLabels<<6));
if (j>=0) if (j>=0)
{ {
if (labeltype[j] & LABEL_STATE) if (labeltype[j] & LABEL_STATE)
@ -2019,7 +2014,7 @@ static int32_t C_ParseCommand(void)
{ {
char *gl = (char *)C_GetLabelType(labeltype[j]); char *gl = (char *)C_GetLabelType(labeltype[j]);
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: warning: expected a state, found a %s.\n",g_szScriptFileName,g_lineNumber,gl); initprintf("%s:%d: warning: expected state, found %s.\n",g_szScriptFileName,g_lineNumber,gl);
g_numCompilerWarnings++; g_numCompilerWarnings++;
Bfree(gl); Bfree(gl);
*(g_scriptPtr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions *(g_scriptPtr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions
@ -2166,7 +2161,7 @@ static int32_t C_ParseCommand(void)
//printf("Got Label '%.20s'\n",textptr); //printf("Got Label '%.20s'\n",textptr);
// Check to see it's already defined // Check to see it's already defined
if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
@ -2211,14 +2206,14 @@ static int32_t C_ParseCommand(void)
//printf("Got Label '%.20s'\n",textptr); //printf("Got Label '%.20s'\n",textptr);
// Check to see it's already defined // Check to see it's already defined
if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
return 0; return 0;
} }
i = HASH_find(&gamevarH,label+(g_numLabels<<6)); i = hash_find(&gamevarH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
@ -2239,21 +2234,21 @@ static int32_t C_ParseCommand(void)
//printf("Got label. '%.20s'\n",textptr); //printf("Got label. '%.20s'\n",textptr);
// Check to see it's already defined // Check to see it's already defined
if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
return 0; return 0;
} }
i = HASH_find(&gamevarH,label+(g_numLabels<<6)); i = hash_find(&gamevarH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
C_ReportError(WARNING_NAMEMATCHESVAR); C_ReportError(WARNING_NAMEMATCHESVAR);
} }
i = HASH_find(&labelH,label+(g_numLabels<<6)); i = hash_find(&labelH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
/* if (i >= g_numDefaultLabels) /* if (i >= g_numDefaultLabels)
@ -2269,7 +2264,7 @@ static int32_t C_ParseCommand(void)
if (i == -1) if (i == -1)
{ {
// printf("Defining Definition '%s' to be '%d'\n",label+(g_numLabels<<6),*(g_scriptPtr-1)); // printf("Defining Definition '%s' to be '%d'\n",label+(g_numLabels<<6),*(g_scriptPtr-1));
HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); hash_add(&labelH,label+(g_numLabels<<6),g_numLabels);
labeltype[g_numLabels] = LABEL_DEFINE; labeltype[g_numLabels] = LABEL_DEFINE;
labelcode[g_numLabels++] = *(g_scriptPtr-1); labelcode[g_numLabels++] = *(g_scriptPtr-1);
if (*(g_scriptPtr-1) >= 0 && *(g_scriptPtr-1) < MAXTILES && g_dynamicTileMapping) if (*(g_scriptPtr-1) >= 0 && *(g_scriptPtr-1) < MAXTILES && g_dynamicTileMapping)
@ -2332,21 +2327,21 @@ static int32_t C_ParseCommand(void)
C_GetNextLabelName(); C_GetNextLabelName();
// Check to see it's already defined // Check to see it's already defined
if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
return 0; return 0;
} }
i = HASH_find(&gamevarH,label+(g_numLabels<<6)); i = hash_find(&gamevarH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
C_ReportError(WARNING_NAMEMATCHESVAR); C_ReportError(WARNING_NAMEMATCHESVAR);
} }
i = HASH_find(&labelH,label+(g_numLabels<<6)); i = hash_find(&labelH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
@ -2354,7 +2349,7 @@ static int32_t C_ParseCommand(void)
} }
if (i == -1) if (i == -1)
{ {
HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); hash_add(&labelH,label+(g_numLabels<<6),g_numLabels);
labeltype[g_numLabels] = LABEL_MOVE; labeltype[g_numLabels] = LABEL_MOVE;
labelcode[g_numLabels++] = (intptr_t) g_scriptPtr; labelcode[g_numLabels++] = (intptr_t) g_scriptPtr;
} }
@ -2534,21 +2529,21 @@ static int32_t C_ParseCommand(void)
g_scriptPtr--; g_scriptPtr--;
C_GetNextLabelName(); C_GetNextLabelName();
if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
return 0; return 0;
} }
i = HASH_find(&gamevarH,label+(g_numLabels<<6)); i = hash_find(&gamevarH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
C_ReportError(WARNING_NAMEMATCHESVAR); C_ReportError(WARNING_NAMEMATCHESVAR);
} }
i = HASH_find(&labelH,label+(g_numLabels<<6)); i = hash_find(&labelH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
@ -2558,7 +2553,7 @@ static int32_t C_ParseCommand(void)
if (i == -1) if (i == -1)
{ {
labeltype[g_numLabels] = LABEL_AI; labeltype[g_numLabels] = LABEL_AI;
HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); hash_add(&labelH,label+(g_numLabels<<6),g_numLabels);
labelcode[g_numLabels++] = (intptr_t) g_scriptPtr; labelcode[g_numLabels++] = (intptr_t) g_scriptPtr;
} }
@ -2615,21 +2610,21 @@ static int32_t C_ParseCommand(void)
C_GetNextLabelName(); C_GetNextLabelName();
// Check to see it's already defined // Check to see it's already defined
if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
return 0; return 0;
} }
i = HASH_find(&gamevarH,label+(g_numLabels<<6)); i = hash_find(&gamevarH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
C_ReportError(WARNING_NAMEMATCHESVAR); C_ReportError(WARNING_NAMEMATCHESVAR);
} }
i = HASH_find(&labelH,label+(g_numLabels<<6)); i = hash_find(&labelH,label+(g_numLabels<<6));
if (i>=0) if (i>=0)
{ {
g_numCompilerWarnings++; g_numCompilerWarnings++;
@ -2640,7 +2635,7 @@ static int32_t C_ParseCommand(void)
{ {
labeltype[g_numLabels] = LABEL_ACTION; labeltype[g_numLabels] = LABEL_ACTION;
labelcode[g_numLabels] = (intptr_t) g_scriptPtr; labelcode[g_numLabels] = (intptr_t) g_scriptPtr;
HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); hash_add(&labelH,label+(g_numLabels<<6),g_numLabels);
g_numLabels++; g_numLabels++;
} }
@ -3535,7 +3530,7 @@ static int32_t C_ParseCommand(void)
//printf("found label of '%s'\n", label+(g_numLabels<<6)); //printf("found label of '%s'\n", label+(g_numLabels<<6));
// Check to see if it's a keyword // Check to see if it's a keyword
if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) if (hash_find(&keywH,label+(g_numLabels<<6))>=0)
{ {
g_numCompilerErrors++; g_numCompilerErrors++;
C_ReportError(ERROR_ISAKEYWORD); C_ReportError(ERROR_ISAKEYWORD);
@ -4947,10 +4942,10 @@ repeatcase:
} }
gamefunctions[j][i] = '\0'; gamefunctions[j][i] = '\0';
keydefaults[j*3][i] = '\0'; keydefaults[j*3][i] = '\0';
HASH_add(&gamefuncH,gamefunctions[j],j); hash_add(&gamefuncH,gamefunctions[j],j);
{ {
char *str = strtolower(Bstrdup(gamefunctions[j]),Bstrlen(gamefunctions[j])); char *str = strtolower(Bstrdup(gamefunctions[j]),Bstrlen(gamefunctions[j]));
HASH_add(&gamefuncH,str,j); hash_add(&gamefuncH,str,j);
Bfree(str); Bfree(str);
} }
@ -5321,7 +5316,7 @@ repeatcase:
if (k > 25) if (k > 25)
{ {
initprintf("%s:%d: error: cheat redefinition attempts to redefine nonexistant cheat.\n",g_szScriptFileName,g_lineNumber); initprintf("%s:%d: error: cheat redefinition attempts to redefine nonexistent cheat.\n",g_szScriptFileName,g_lineNumber);
g_numCompilerErrors++; g_numCompilerErrors++;
while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++;
break; break;
@ -5597,6 +5592,7 @@ repeatcase:
return 0; return 0;
} }
/*
#define NUM_DEFAULT_CONS 4 #define NUM_DEFAULT_CONS 4
static const char *defaultcons[NUM_DEFAULT_CONS] = static const char *defaultcons[NUM_DEFAULT_CONS] =
{ {
@ -5633,145 +5629,146 @@ void copydefaultcons(void)
fclose(fpo); fclose(fpo);
} }
} }
*/
/* Anything added with AddDefinition() cannot be overwritten in the CONs */ /* Anything added with C_AddDefinition() cannot be overwritten in the CONs */
static void AddDefinition(const char *lLabel,int32_t lValue,int32_t lType) static void C_AddDefinition(const char *lLabel,int32_t lValue,int32_t lType)
{ {
Bstrcpy(label+(g_numLabels<<6),lLabel); Bstrcpy(label+(g_numLabels<<6),lLabel);
labeltype[g_numLabels] = lType; labeltype[g_numLabels] = lType;
HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); hash_add(&labelH,label+(g_numLabels<<6),g_numLabels);
labelcode[g_numLabels++] = lValue; labelcode[g_numLabels++] = lValue;
g_numDefaultLabels++; g_numDefaultLabels++;
} }
static void C_AddDefaultDefinitions(void) static void C_AddDefaultDefinitions(void)
{ {
AddDefinition("EVENT_AIMDOWN",EVENT_AIMDOWN,LABEL_DEFINE); C_AddDefinition("EVENT_AIMDOWN",EVENT_AIMDOWN,LABEL_DEFINE);
AddDefinition("EVENT_AIMUP",EVENT_AIMUP,LABEL_DEFINE); C_AddDefinition("EVENT_AIMUP",EVENT_AIMUP,LABEL_DEFINE);
AddDefinition("EVENT_ANIMATESPRITES",EVENT_ANIMATESPRITES,LABEL_DEFINE); C_AddDefinition("EVENT_ANIMATESPRITES",EVENT_ANIMATESPRITES,LABEL_DEFINE);
AddDefinition("EVENT_CHANGEWEAPON",EVENT_CHANGEWEAPON,LABEL_DEFINE); C_AddDefinition("EVENT_CHANGEWEAPON",EVENT_CHANGEWEAPON,LABEL_DEFINE);
AddDefinition("EVENT_CHEATGETBOOT",EVENT_CHEATGETBOOT,LABEL_DEFINE); C_AddDefinition("EVENT_CHEATGETBOOT",EVENT_CHEATGETBOOT,LABEL_DEFINE);
AddDefinition("EVENT_CHEATGETFIRSTAID",EVENT_CHEATGETFIRSTAID,LABEL_DEFINE); C_AddDefinition("EVENT_CHEATGETFIRSTAID",EVENT_CHEATGETFIRSTAID,LABEL_DEFINE);
AddDefinition("EVENT_CHEATGETHEAT",EVENT_CHEATGETHEAT,LABEL_DEFINE); C_AddDefinition("EVENT_CHEATGETHEAT",EVENT_CHEATGETHEAT,LABEL_DEFINE);
AddDefinition("EVENT_CHEATGETHOLODUKE",EVENT_CHEATGETHOLODUKE,LABEL_DEFINE); C_AddDefinition("EVENT_CHEATGETHOLODUKE",EVENT_CHEATGETHOLODUKE,LABEL_DEFINE);
AddDefinition("EVENT_CHEATGETJETPACK",EVENT_CHEATGETJETPACK,LABEL_DEFINE); C_AddDefinition("EVENT_CHEATGETJETPACK",EVENT_CHEATGETJETPACK,LABEL_DEFINE);
AddDefinition("EVENT_CHEATGETSCUBA",EVENT_CHEATGETSCUBA,LABEL_DEFINE); C_AddDefinition("EVENT_CHEATGETSCUBA",EVENT_CHEATGETSCUBA,LABEL_DEFINE);
AddDefinition("EVENT_CHEATGETSHIELD",EVENT_CHEATGETSHIELD,LABEL_DEFINE); C_AddDefinition("EVENT_CHEATGETSHIELD",EVENT_CHEATGETSHIELD,LABEL_DEFINE);
AddDefinition("EVENT_CHEATGETSTEROIDS",EVENT_CHEATGETSTEROIDS,LABEL_DEFINE); C_AddDefinition("EVENT_CHEATGETSTEROIDS",EVENT_CHEATGETSTEROIDS,LABEL_DEFINE);
AddDefinition("EVENT_CROUCH",EVENT_CROUCH,LABEL_DEFINE); C_AddDefinition("EVENT_CROUCH",EVENT_CROUCH,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYCROSSHAIR",EVENT_DISPLAYCROSSHAIR,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYCROSSHAIR",EVENT_DISPLAYCROSSHAIR,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYREST",EVENT_DISPLAYREST,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYREST",EVENT_DISPLAYREST,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYBONUSSCREEN",EVENT_DISPLAYBONUSSCREEN,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYBONUSSCREEN",EVENT_DISPLAYBONUSSCREEN,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYMENU",EVENT_DISPLAYMENU,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYMENU",EVENT_DISPLAYMENU,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYMENUREST",EVENT_DISPLAYMENUREST,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYMENUREST",EVENT_DISPLAYMENUREST,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYLOADINGSCREEN",EVENT_DISPLAYLOADINGSCREEN,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYLOADINGSCREEN",EVENT_DISPLAYLOADINGSCREEN,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYROOMS",EVENT_DISPLAYROOMS,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYROOMS",EVENT_DISPLAYROOMS,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYSBAR",EVENT_DISPLAYSBAR,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYSBAR",EVENT_DISPLAYSBAR,LABEL_DEFINE);
AddDefinition("EVENT_DISPLAYWEAPON",EVENT_DISPLAYWEAPON,LABEL_DEFINE); C_AddDefinition("EVENT_DISPLAYWEAPON",EVENT_DISPLAYWEAPON,LABEL_DEFINE);
AddDefinition("EVENT_DOFIRE",EVENT_DOFIRE,LABEL_DEFINE); C_AddDefinition("EVENT_DOFIRE",EVENT_DOFIRE,LABEL_DEFINE);
AddDefinition("EVENT_DRAWWEAPON",EVENT_DRAWWEAPON,LABEL_DEFINE); C_AddDefinition("EVENT_DRAWWEAPON",EVENT_DRAWWEAPON,LABEL_DEFINE);
AddDefinition("EVENT_EGS",EVENT_EGS,LABEL_DEFINE); C_AddDefinition("EVENT_EGS",EVENT_EGS,LABEL_DEFINE);
AddDefinition("EVENT_ENTERLEVEL",EVENT_ENTERLEVEL,LABEL_DEFINE); C_AddDefinition("EVENT_ENTERLEVEL",EVENT_ENTERLEVEL,LABEL_DEFINE);
AddDefinition("EVENT_FAKEDOMOVETHINGS",EVENT_FAKEDOMOVETHINGS,LABEL_DEFINE); C_AddDefinition("EVENT_FAKEDOMOVETHINGS",EVENT_FAKEDOMOVETHINGS,LABEL_DEFINE);
AddDefinition("EVENT_FIRE",EVENT_FIRE,LABEL_DEFINE); C_AddDefinition("EVENT_FIRE",EVENT_FIRE,LABEL_DEFINE);
AddDefinition("EVENT_FIREWEAPON",EVENT_FIREWEAPON,LABEL_DEFINE); C_AddDefinition("EVENT_FIREWEAPON",EVENT_FIREWEAPON,LABEL_DEFINE);
AddDefinition("EVENT_GAME",EVENT_GAME,LABEL_DEFINE); C_AddDefinition("EVENT_GAME",EVENT_GAME,LABEL_DEFINE);
AddDefinition("EVENT_GETAUTOAIMANGLE",EVENT_GETAUTOAIMANGLE,LABEL_DEFINE); C_AddDefinition("EVENT_GETAUTOAIMANGLE",EVENT_GETAUTOAIMANGLE,LABEL_DEFINE);
AddDefinition("EVENT_GETLOADTILE",EVENT_GETLOADTILE,LABEL_DEFINE); C_AddDefinition("EVENT_GETLOADTILE",EVENT_GETLOADTILE,LABEL_DEFINE);
AddDefinition("EVENT_GETMENUTILE",EVENT_GETMENUTILE,LABEL_DEFINE); C_AddDefinition("EVENT_GETMENUTILE",EVENT_GETMENUTILE,LABEL_DEFINE);
AddDefinition("EVENT_GETSHOTRANGE",EVENT_GETSHOTRANGE,LABEL_DEFINE); C_AddDefinition("EVENT_GETSHOTRANGE",EVENT_GETSHOTRANGE,LABEL_DEFINE);
AddDefinition("EVENT_HOLODUKEOFF",EVENT_HOLODUKEOFF,LABEL_DEFINE); C_AddDefinition("EVENT_HOLODUKEOFF",EVENT_HOLODUKEOFF,LABEL_DEFINE);
AddDefinition("EVENT_HOLODUKEON",EVENT_HOLODUKEON,LABEL_DEFINE); C_AddDefinition("EVENT_HOLODUKEON",EVENT_HOLODUKEON,LABEL_DEFINE);
AddDefinition("EVENT_HOLSTER",EVENT_HOLSTER,LABEL_DEFINE); C_AddDefinition("EVENT_HOLSTER",EVENT_HOLSTER,LABEL_DEFINE);
AddDefinition("EVENT_INCURDAMAGE",EVENT_INCURDAMAGE,LABEL_DEFINE); C_AddDefinition("EVENT_INCURDAMAGE",EVENT_INCURDAMAGE,LABEL_DEFINE);
AddDefinition("EVENT_INIT",EVENT_INIT,LABEL_DEFINE); C_AddDefinition("EVENT_INIT",EVENT_INIT,LABEL_DEFINE);
AddDefinition("EVENT_INVENTORY",EVENT_INVENTORY,LABEL_DEFINE); C_AddDefinition("EVENT_INVENTORY",EVENT_INVENTORY,LABEL_DEFINE);
AddDefinition("EVENT_INVENTORYLEFT",EVENT_INVENTORYLEFT,LABEL_DEFINE); C_AddDefinition("EVENT_INVENTORYLEFT",EVENT_INVENTORYLEFT,LABEL_DEFINE);
AddDefinition("EVENT_INVENTORYRIGHT",EVENT_INVENTORYRIGHT,LABEL_DEFINE); C_AddDefinition("EVENT_INVENTORYRIGHT",EVENT_INVENTORYRIGHT,LABEL_DEFINE);
AddDefinition("EVENT_JUMP",EVENT_JUMP,LABEL_DEFINE); C_AddDefinition("EVENT_JUMP",EVENT_JUMP,LABEL_DEFINE);
AddDefinition("EVENT_LOGO",EVENT_LOGO,LABEL_DEFINE); C_AddDefinition("EVENT_LOGO",EVENT_LOGO,LABEL_DEFINE);
AddDefinition("EVENT_LOOKDOWN",EVENT_LOOKDOWN,LABEL_DEFINE); C_AddDefinition("EVENT_LOOKDOWN",EVENT_LOOKDOWN,LABEL_DEFINE);
AddDefinition("EVENT_LOOKLEFT",EVENT_LOOKLEFT,LABEL_DEFINE); C_AddDefinition("EVENT_LOOKLEFT",EVENT_LOOKLEFT,LABEL_DEFINE);
AddDefinition("EVENT_LOOKRIGHT",EVENT_LOOKRIGHT,LABEL_DEFINE); C_AddDefinition("EVENT_LOOKRIGHT",EVENT_LOOKRIGHT,LABEL_DEFINE);
AddDefinition("EVENT_LOOKUP",EVENT_LOOKUP,LABEL_DEFINE); C_AddDefinition("EVENT_LOOKUP",EVENT_LOOKUP,LABEL_DEFINE);
AddDefinition("EVENT_MOVEBACKWARD",EVENT_MOVEBACKWARD,LABEL_DEFINE); C_AddDefinition("EVENT_MOVEBACKWARD",EVENT_MOVEBACKWARD,LABEL_DEFINE);
AddDefinition("EVENT_MOVEFORWARD",EVENT_MOVEFORWARD,LABEL_DEFINE); C_AddDefinition("EVENT_MOVEFORWARD",EVENT_MOVEFORWARD,LABEL_DEFINE);
AddDefinition("EVENT_NEXTWEAPON",EVENT_NEXTWEAPON,LABEL_DEFINE); C_AddDefinition("EVENT_NEXTWEAPON",EVENT_NEXTWEAPON,LABEL_DEFINE);
AddDefinition("EVENT_PREVIOUSWEAPON",EVENT_PREVIOUSWEAPON,LABEL_DEFINE); C_AddDefinition("EVENT_PREVIOUSWEAPON",EVENT_PREVIOUSWEAPON,LABEL_DEFINE);
AddDefinition("EVENT_PRESSEDFIRE",EVENT_PRESSEDFIRE,LABEL_DEFINE); C_AddDefinition("EVENT_PRESSEDFIRE",EVENT_PRESSEDFIRE,LABEL_DEFINE);
AddDefinition("EVENT_PROCESSINPUT",EVENT_PROCESSINPUT,LABEL_DEFINE); C_AddDefinition("EVENT_PROCESSINPUT",EVENT_PROCESSINPUT,LABEL_DEFINE);
AddDefinition("EVENT_QUICKKICK",EVENT_QUICKKICK,LABEL_DEFINE); C_AddDefinition("EVENT_QUICKKICK",EVENT_QUICKKICK,LABEL_DEFINE);
AddDefinition("EVENT_RESETINVENTORY",EVENT_RESETINVENTORY,LABEL_DEFINE); C_AddDefinition("EVENT_RESETINVENTORY",EVENT_RESETINVENTORY,LABEL_DEFINE);
AddDefinition("EVENT_RESETPLAYER",EVENT_RESETPLAYER,LABEL_DEFINE); C_AddDefinition("EVENT_RESETPLAYER",EVENT_RESETPLAYER,LABEL_DEFINE);
AddDefinition("EVENT_RESETWEAPONS",EVENT_RESETWEAPONS,LABEL_DEFINE); C_AddDefinition("EVENT_RESETWEAPONS",EVENT_RESETWEAPONS,LABEL_DEFINE);
AddDefinition("EVENT_RETURNTOCENTER",EVENT_RETURNTOCENTER,LABEL_DEFINE); C_AddDefinition("EVENT_RETURNTOCENTER",EVENT_RETURNTOCENTER,LABEL_DEFINE);
AddDefinition("EVENT_SELECTWEAPON",EVENT_SELECTWEAPON,LABEL_DEFINE); C_AddDefinition("EVENT_SELECTWEAPON",EVENT_SELECTWEAPON,LABEL_DEFINE);
AddDefinition("EVENT_SOARDOWN",EVENT_SOARDOWN,LABEL_DEFINE); C_AddDefinition("EVENT_SOARDOWN",EVENT_SOARDOWN,LABEL_DEFINE);
AddDefinition("EVENT_SOARUP",EVENT_SOARUP,LABEL_DEFINE); C_AddDefinition("EVENT_SOARUP",EVENT_SOARUP,LABEL_DEFINE);
AddDefinition("EVENT_SPAWN",EVENT_SPAWN,LABEL_DEFINE); C_AddDefinition("EVENT_SPAWN",EVENT_SPAWN,LABEL_DEFINE);
AddDefinition("EVENT_STRAFELEFT",EVENT_STRAFELEFT,LABEL_DEFINE); C_AddDefinition("EVENT_STRAFELEFT",EVENT_STRAFELEFT,LABEL_DEFINE);
AddDefinition("EVENT_STRAFERIGHT",EVENT_STRAFERIGHT,LABEL_DEFINE); C_AddDefinition("EVENT_STRAFERIGHT",EVENT_STRAFERIGHT,LABEL_DEFINE);
AddDefinition("EVENT_SWIMDOWN",EVENT_SWIMDOWN,LABEL_DEFINE); C_AddDefinition("EVENT_SWIMDOWN",EVENT_SWIMDOWN,LABEL_DEFINE);
AddDefinition("EVENT_SWIMUP",EVENT_SWIMUP,LABEL_DEFINE); C_AddDefinition("EVENT_SWIMUP",EVENT_SWIMUP,LABEL_DEFINE);
AddDefinition("EVENT_TURNAROUND",EVENT_TURNAROUND,LABEL_DEFINE); C_AddDefinition("EVENT_TURNAROUND",EVENT_TURNAROUND,LABEL_DEFINE);
AddDefinition("EVENT_TURNLEFT",EVENT_TURNLEFT,LABEL_DEFINE); C_AddDefinition("EVENT_TURNLEFT",EVENT_TURNLEFT,LABEL_DEFINE);
AddDefinition("EVENT_TURNRIGHT",EVENT_TURNRIGHT,LABEL_DEFINE); C_AddDefinition("EVENT_TURNRIGHT",EVENT_TURNRIGHT,LABEL_DEFINE);
AddDefinition("EVENT_USE",EVENT_USE,LABEL_DEFINE); C_AddDefinition("EVENT_USE",EVENT_USE,LABEL_DEFINE);
AddDefinition("EVENT_USEJETPACK",EVENT_USEJETPACK,LABEL_DEFINE); C_AddDefinition("EVENT_USEJETPACK",EVENT_USEJETPACK,LABEL_DEFINE);
AddDefinition("EVENT_USEMEDKIT",EVENT_USEMEDKIT,LABEL_DEFINE); C_AddDefinition("EVENT_USEMEDKIT",EVENT_USEMEDKIT,LABEL_DEFINE);
AddDefinition("EVENT_USENIGHTVISION",EVENT_USENIGHTVISION,LABEL_DEFINE); C_AddDefinition("EVENT_USENIGHTVISION",EVENT_USENIGHTVISION,LABEL_DEFINE);
AddDefinition("EVENT_USESTEROIDS",EVENT_USESTEROIDS,LABEL_DEFINE); C_AddDefinition("EVENT_USESTEROIDS",EVENT_USESTEROIDS,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY10",EVENT_WEAPKEY10,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY10",EVENT_WEAPKEY10,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY1",EVENT_WEAPKEY1,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY1",EVENT_WEAPKEY1,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY2",EVENT_WEAPKEY2,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY2",EVENT_WEAPKEY2,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY3",EVENT_WEAPKEY3,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY3",EVENT_WEAPKEY3,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY4",EVENT_WEAPKEY4,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY4",EVENT_WEAPKEY4,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY5",EVENT_WEAPKEY5,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY5",EVENT_WEAPKEY5,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY6",EVENT_WEAPKEY6,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY6",EVENT_WEAPKEY6,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY7",EVENT_WEAPKEY7,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY7",EVENT_WEAPKEY7,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY8",EVENT_WEAPKEY8,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY8",EVENT_WEAPKEY8,LABEL_DEFINE);
AddDefinition("EVENT_WEAPKEY9",EVENT_WEAPKEY9,LABEL_DEFINE); C_AddDefinition("EVENT_WEAPKEY9",EVENT_WEAPKEY9,LABEL_DEFINE);
AddDefinition("EVENT_KILLIT",EVENT_KILLIT,LABEL_DEFINE); C_AddDefinition("EVENT_KILLIT",EVENT_KILLIT,LABEL_DEFINE);
AddDefinition("EVENT_LOADACTOR",EVENT_LOADACTOR,LABEL_DEFINE); C_AddDefinition("EVENT_LOADACTOR",EVENT_LOADACTOR,LABEL_DEFINE);
AddDefinition("EVENT_NEWGAME",EVENT_NEWGAME,LABEL_DEFINE); C_AddDefinition("EVENT_NEWGAME",EVENT_NEWGAME,LABEL_DEFINE);
AddDefinition("STR_MAPNAME",STR_MAPNAME,LABEL_DEFINE); C_AddDefinition("STR_MAPNAME",STR_MAPNAME,LABEL_DEFINE);
AddDefinition("STR_MAPFILENAME",STR_MAPFILENAME,LABEL_DEFINE); C_AddDefinition("STR_MAPFILENAME",STR_MAPFILENAME,LABEL_DEFINE);
AddDefinition("STR_PLAYERNAME",STR_PLAYERNAME,LABEL_DEFINE); C_AddDefinition("STR_PLAYERNAME",STR_PLAYERNAME,LABEL_DEFINE);
AddDefinition("STR_VERSION",STR_VERSION,LABEL_DEFINE); C_AddDefinition("STR_VERSION",STR_VERSION,LABEL_DEFINE);
AddDefinition("STR_GAMETYPE",STR_GAMETYPE,LABEL_DEFINE); C_AddDefinition("STR_GAMETYPE",STR_GAMETYPE,LABEL_DEFINE);
AddDefinition("NO",0,LABEL_DEFINE|LABEL_ACTION|LABEL_AI|LABEL_MOVE); C_AddDefinition("NO",0,LABEL_DEFINE|LABEL_ACTION|LABEL_AI|LABEL_MOVE);
AddDefinition("PROJ_BOUNCES",PROJ_BOUNCES,LABEL_DEFINE); C_AddDefinition("PROJ_BOUNCES",PROJ_BOUNCES,LABEL_DEFINE);
AddDefinition("PROJ_BSOUND",PROJ_BSOUND,LABEL_DEFINE); C_AddDefinition("PROJ_BSOUND",PROJ_BSOUND,LABEL_DEFINE);
AddDefinition("PROJ_CLIPDIST",PROJ_CLIPDIST,LABEL_DEFINE); C_AddDefinition("PROJ_CLIPDIST",PROJ_CLIPDIST,LABEL_DEFINE);
AddDefinition("PROJ_CSTAT",PROJ_CSTAT,LABEL_DEFINE); C_AddDefinition("PROJ_CSTAT",PROJ_CSTAT,LABEL_DEFINE);
AddDefinition("PROJ_DECAL",PROJ_DECAL,LABEL_DEFINE); C_AddDefinition("PROJ_DECAL",PROJ_DECAL,LABEL_DEFINE);
AddDefinition("PROJ_DROP",PROJ_DROP,LABEL_DEFINE); C_AddDefinition("PROJ_DROP",PROJ_DROP,LABEL_DEFINE);
AddDefinition("PROJ_EXTRA",PROJ_EXTRA,LABEL_DEFINE); C_AddDefinition("PROJ_EXTRA",PROJ_EXTRA,LABEL_DEFINE);
AddDefinition("PROJ_EXTRA_RAND",PROJ_EXTRA_RAND,LABEL_DEFINE); C_AddDefinition("PROJ_EXTRA_RAND",PROJ_EXTRA_RAND,LABEL_DEFINE);
AddDefinition("PROJ_HITRADIUS",PROJ_HITRADIUS,LABEL_DEFINE); C_AddDefinition("PROJ_HITRADIUS",PROJ_HITRADIUS,LABEL_DEFINE);
AddDefinition("PROJ_ISOUND",PROJ_ISOUND,LABEL_DEFINE); C_AddDefinition("PROJ_ISOUND",PROJ_ISOUND,LABEL_DEFINE);
AddDefinition("PROJ_OFFSET",PROJ_OFFSET,LABEL_DEFINE); C_AddDefinition("PROJ_OFFSET",PROJ_OFFSET,LABEL_DEFINE);
AddDefinition("PROJ_PAL",PROJ_PAL,LABEL_DEFINE); C_AddDefinition("PROJ_PAL",PROJ_PAL,LABEL_DEFINE);
AddDefinition("PROJ_RANGE",PROJ_RANGE,LABEL_DEFINE); C_AddDefinition("PROJ_RANGE",PROJ_RANGE,LABEL_DEFINE);
AddDefinition("PROJ_SHADE",PROJ_SHADE,LABEL_DEFINE); C_AddDefinition("PROJ_SHADE",PROJ_SHADE,LABEL_DEFINE);
AddDefinition("PROJ_SOUND",PROJ_SOUND,LABEL_DEFINE); C_AddDefinition("PROJ_SOUND",PROJ_SOUND,LABEL_DEFINE);
AddDefinition("PROJ_SPAWNS",PROJ_SPAWNS,LABEL_DEFINE); C_AddDefinition("PROJ_SPAWNS",PROJ_SPAWNS,LABEL_DEFINE);
AddDefinition("PROJ_SXREPEAT",PROJ_SXREPEAT,LABEL_DEFINE); C_AddDefinition("PROJ_SXREPEAT",PROJ_SXREPEAT,LABEL_DEFINE);
AddDefinition("PROJ_SYREPEAT",PROJ_SYREPEAT,LABEL_DEFINE); C_AddDefinition("PROJ_SYREPEAT",PROJ_SYREPEAT,LABEL_DEFINE);
AddDefinition("PROJ_TNUM",PROJ_TNUM,LABEL_DEFINE); C_AddDefinition("PROJ_TNUM",PROJ_TNUM,LABEL_DEFINE);
AddDefinition("PROJ_TOFFSET",PROJ_TOFFSET,LABEL_DEFINE); C_AddDefinition("PROJ_TOFFSET",PROJ_TOFFSET,LABEL_DEFINE);
AddDefinition("PROJ_TRAIL",PROJ_TRAIL,LABEL_DEFINE); C_AddDefinition("PROJ_TRAIL",PROJ_TRAIL,LABEL_DEFINE);
AddDefinition("PROJ_TXREPEAT",PROJ_TXREPEAT,LABEL_DEFINE); C_AddDefinition("PROJ_TXREPEAT",PROJ_TXREPEAT,LABEL_DEFINE);
AddDefinition("PROJ_TYREPEAT",PROJ_TYREPEAT,LABEL_DEFINE); C_AddDefinition("PROJ_TYREPEAT",PROJ_TYREPEAT,LABEL_DEFINE);
AddDefinition("PROJ_VEL_MULT",PROJ_VEL_MULT,LABEL_DEFINE); C_AddDefinition("PROJ_VEL_MULT",PROJ_VEL_MULT,LABEL_DEFINE);
AddDefinition("PROJ_VEL",PROJ_VEL,LABEL_DEFINE); C_AddDefinition("PROJ_VEL",PROJ_VEL,LABEL_DEFINE);
AddDefinition("PROJ_WORKSLIKE",PROJ_WORKSLIKE,LABEL_DEFINE); C_AddDefinition("PROJ_WORKSLIKE",PROJ_WORKSLIKE,LABEL_DEFINE);
AddDefinition("PROJ_XREPEAT",PROJ_XREPEAT,LABEL_DEFINE); C_AddDefinition("PROJ_XREPEAT",PROJ_XREPEAT,LABEL_DEFINE);
AddDefinition("PROJ_YREPEAT",PROJ_YREPEAT,LABEL_DEFINE); C_AddDefinition("PROJ_YREPEAT",PROJ_YREPEAT,LABEL_DEFINE);
} }
static void C_InitProjectiles(void) static void C_InitProjectiles(void)
@ -5791,7 +5788,7 @@ static void C_InitProjectiles(void)
// this will only happen if I forget to update this function... // this will only happen if I forget to update this function...
if (sizeof(projectile_t) != sizeof(DefaultProjectile)) if (sizeof(projectile_t) != sizeof(DefaultProjectile))
G_GameExit("ERROR: C_InitProjectiles() projectile_t mismatch!"); G_GameExit("ERROR: C_InitProjectiles(): projectile_t mismatch!");
for (i=MAXTILES-1;i>=0;i--) for (i=MAXTILES-1;i>=0;i--)
Bmemcpy(&ProjectileData[i],&DefaultProjectile,sizeof(projectile_t)); Bmemcpy(&ProjectileData[i],&DefaultProjectile,sizeof(projectile_t));
@ -5966,18 +5963,18 @@ void C_Compile(const char *filenam)
{ {
int32_t j=0, k=0; int32_t j=0, k=0;
HASH_free(&keywH); hash_free(&keywH);
freehashnames(); freehashnames();
HASH_free(&sectorH); hash_free(&sectorH);
HASH_free(&wallH); hash_free(&wallH);
HASH_free(&userdefH); hash_free(&userdefH);
HASH_free(&projectileH); hash_free(&projectileH);
HASH_free(&playerH); hash_free(&playerH);
HASH_free(&inputH); hash_free(&inputH);
HASH_free(&actorH); hash_free(&actorH);
HASH_free(&tspriteH); hash_free(&tspriteH);
g_totalLines += g_lineNumber; g_totalLines += g_lineNumber;
@ -5985,11 +5982,16 @@ void C_Compile(const char *filenam)
flushlogwindow = 0; flushlogwindow = 0;
initprintf("Script compiled in %dms\n",getticks()-startcompiletime); initprintf("Script compiled in %dms\n", getticks() - startcompiletime);
initprintf("Compiled code size: %ld*%d bytes, version %s\n",
(unsigned)(g_scriptPtr-script), sizeof(intptr_t), (g_scriptVersion == 14?"1.4+":"1.3D"));
initprintf("Compiled code size: %ld*%d bytes, version %s\n",(unsigned)(g_scriptPtr-script),sizeof(intptr_t),(g_scriptVersion == 14?"1.4+":"1.3D"));
initprintf("Pointer bitmap size: %ld bytes\n",(g_scriptSize+7)>>3); initprintf("Pointer bitmap size: %ld bytes\n",(g_scriptSize+7)>>3);
initprintf("%ld/%ld labels, %d/%d variables\n",g_numLabels,min((MAXSECTORS * sizeof(sectortype)/sizeof(int32_t)),(MAXSPRITES * sizeof(spritetype)/(1<<6))),g_gameVarCount,MAXGAMEVARS); initprintf("%ld/%ld labels, %d/%d variables\n", g_numLabels,
min((MAXSECTORS * sizeof(sectortype)/sizeof(int32_t)),
MAXSPRITES * sizeof(spritetype)/(1<<6)),
g_gameVarCount, MAXGAMEVARS);
for (i=MAXQUOTES-1;i>=0;i--) for (i=MAXQUOTES-1;i>=0;i--)
if (ScriptQuotes[i]) if (ScriptQuotes[i])
@ -6011,9 +6013,6 @@ void C_Compile(const char *filenam)
if (ScriptQuotes[i] == NULL) if (ScriptQuotes[i] == NULL)
ScriptQuotes[i] = Bcalloc(MAXQUOTELEN,sizeof(uint8_t)); ScriptQuotes[i] = Bcalloc(MAXQUOTELEN,sizeof(uint8_t));
// if (!Bstrcmp(ScriptQuotes[13],"PRESS SPACE TO RESTART LEVEL"))
// Bstrcpy(ScriptQuotes[13],"PRESS USE TO RESTART LEVEL");
for (i=MAXQUOTELEN-7;i>=0;i--) for (i=MAXQUOTELEN-7;i>=0;i--)
if (Bstrncmp(&ScriptQuotes[13][i],"SPACE",5) == 0) if (Bstrncmp(&ScriptQuotes[13][i],"SPACE",5) == 0)
{ {
@ -6125,7 +6124,7 @@ void C_ReportError(int32_t iError)
initprintf("%s:%d: error: found more `}' than `{' before `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); initprintf("%s:%d: error: found more `}' than `{' before `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf);
break; break;
case ERROR_EVENTONLY: case ERROR_EVENTONLY:
initprintf("%s:%d: error: command `%s' only valid during events.\n",g_szScriptFileName,g_lineNumber,tempbuf); initprintf("%s:%d: error: `%s' only valid during events.\n",g_szScriptFileName,g_lineNumber,tempbuf);
break; break;
case ERROR_EXCEEDSMAXTILES: case ERROR_EXCEEDSMAXTILES:
initprintf("%s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",g_szScriptFileName,g_lineNumber,tempbuf,MAXTILES-1); initprintf("%s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",g_szScriptFileName,g_lineNumber,tempbuf,MAXTILES-1);
@ -6158,7 +6157,7 @@ void C_ReportError(int32_t iError)
initprintf("%s:%d: error: square brackets for index of game array not opened, expected [ found %c\n",g_szScriptFileName,g_lineNumber,*textptr); initprintf("%s:%d: error: square brackets for index of game array not opened, expected [ found %c\n",g_szScriptFileName,g_lineNumber,*textptr);
break; break;
case ERROR_INVALIDARRAYWRITE: case ERROR_INVALIDARRAYWRITE:
initprintf("%s:%d: error: arrays can only be written using setarray %c\n",g_szScriptFileName,g_lineNumber,*textptr); initprintf("%s:%d: error: arrays can only be written to using `setarray' %c\n",g_szScriptFileName,g_lineNumber,*textptr);
break; break;
case ERROR_OPENBRACKET: case ERROR_OPENBRACKET:
initprintf("%s:%d: error: found more `{' than `}' before `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); initprintf("%s:%d: error: found more `{' than `}' before `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf);

View file

@ -1402,7 +1402,7 @@ static int32_t X_DoExecute(void)
G_OperateMasterSwitches(var1); G_OperateMasterSwitches(var1);
break; break;
case CON_CHECKACTIVATORMOTION: case CON_CHECKACTIVATORMOTION:
Gv_SetVarX(g_iReturnVarID, check_activator_motion(var1)); Gv_SetVarX(g_iReturnVarID, G_CheckActivatorMotion(var1));
break; break;
} }
break; break;
@ -4385,7 +4385,7 @@ void G_SaveMapState(mapstate_t *save)
Bmemcpy(&save->numsectors,&numsectors,sizeof(numsectors)); Bmemcpy(&save->numsectors,&numsectors,sizeof(numsectors));
Bmemcpy(&save->sector[0],&sector[0],sizeof(sectortype)*MAXSECTORS); Bmemcpy(&save->sector[0],&sector[0],sizeof(sectortype)*MAXSECTORS);
Bmemcpy(&save->sprite[0],&sprite[0],sizeof(spritetype)*MAXSPRITES); Bmemcpy(&save->sprite[0],&sprite[0],sizeof(spritetype)*MAXSPRITES);
Bmemcpy(&save->spriteext[0],&spriteext[0],sizeof(spriteexttype)*MAXSPRITES); Bmemcpy(&save->spriteext[0],&spriteext[0],sizeof(spriteext_t)*MAXSPRITES);
Bmemcpy(&save->headspritesect[0],&headspritesect[0],sizeof(headspritesect)); Bmemcpy(&save->headspritesect[0],&headspritesect[0],sizeof(headspritesect));
Bmemcpy(&save->prevspritesect[0],&prevspritesect[0],sizeof(prevspritesect)); Bmemcpy(&save->prevspritesect[0],&prevspritesect[0],sizeof(prevspritesect));
Bmemcpy(&save->nextspritesect[0],&nextspritesect[0],sizeof(nextspritesect)); Bmemcpy(&save->nextspritesect[0],&nextspritesect[0],sizeof(nextspritesect));
@ -4509,7 +4509,7 @@ void G_RestoreMapState(mapstate_t *save)
Bmemcpy(&numsectors,&save->numsectors,sizeof(numsectors)); Bmemcpy(&numsectors,&save->numsectors,sizeof(numsectors));
Bmemcpy(&sector[0],&save->sector[0],sizeof(sectortype)*MAXSECTORS); Bmemcpy(&sector[0],&save->sector[0],sizeof(sectortype)*MAXSECTORS);
Bmemcpy(&sprite[0],&save->sprite[0],sizeof(spritetype)*MAXSPRITES); Bmemcpy(&sprite[0],&save->sprite[0],sizeof(spritetype)*MAXSPRITES);
Bmemcpy(&spriteext[0],&save->spriteext[0],sizeof(spriteexttype)*MAXSPRITES); Bmemcpy(&spriteext[0],&save->spriteext[0],sizeof(spriteext_t)*MAXSPRITES);
Bmemcpy(&headspritesect[0],&save->headspritesect[0],sizeof(headspritesect)); Bmemcpy(&headspritesect[0],&save->headspritesect[0],sizeof(headspritesect));
Bmemcpy(&prevspritesect[0],&save->prevspritesect[0],sizeof(prevspritesect)); Bmemcpy(&prevspritesect[0],&save->prevspritesect[0],sizeof(prevspritesect));
Bmemcpy(&nextspritesect[0],&save->nextspritesect[0],sizeof(nextspritesect)); Bmemcpy(&nextspritesect[0],&save->nextspritesect[0],sizeof(nextspritesect));

View file

@ -54,8 +54,8 @@ static void Gv_Free(void) /* called from Gv_ReadSave() and Gv_ResetVars() */
aGameArrays[i].bReset=1; aGameArrays[i].bReset=1;
} }
g_gameVarCount=g_gameArrayCount=0; g_gameVarCount=g_gameArrayCount=0;
HASH_init(&gamevarH); hash_init(&gamevarH);
HASH_init(&arrayH); hash_init(&arrayH);
return; return;
} }
@ -92,8 +92,8 @@ static void Gv_Clear(void)
aGameArrays[i].bReset=1; aGameArrays[i].bReset=1;
} }
g_gameVarCount=g_gameArrayCount=0; g_gameVarCount=g_gameArrayCount=0;
HASH_init(&gamevarH); hash_init(&gamevarH);
HASH_init(&arrayH); hash_init(&arrayH);
return; return;
} }
@ -118,7 +118,7 @@ int32_t Gv_ReadSave(int32_t fil)
if (kdfread(&(aGameVars[i]),sizeof(gamevar_t),1,fil) != 1) goto corrupt; if (kdfread(&(aGameVars[i]),sizeof(gamevar_t),1,fil) != 1) goto corrupt;
aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(uint8_t)); aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(uint8_t));
if (kdfread(aGameVars[i].szLabel,sizeof(uint8_t) * MAXVARLABEL, 1, fil) != 1) goto corrupt; if (kdfread(aGameVars[i].szLabel,sizeof(uint8_t) * MAXVARLABEL, 1, fil) != 1) goto corrupt;
HASH_replace(&gamevarH,aGameVars[i].szLabel,i); hash_replace(&gamevarH,aGameVars[i].szLabel,i);
if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER)
{ {
@ -146,7 +146,7 @@ int32_t Gv_ReadSave(int32_t fil)
if (kdfread(&(aGameArrays[i]),sizeof(gamearray_t),1,fil) != 1) goto corrupt; if (kdfread(&(aGameArrays[i]),sizeof(gamearray_t),1,fil) != 1) goto corrupt;
aGameArrays[i].szLabel=Bcalloc(MAXARRAYLABEL,sizeof(uint8_t)); aGameArrays[i].szLabel=Bcalloc(MAXARRAYLABEL,sizeof(uint8_t));
if (kdfread(aGameArrays[i].szLabel,sizeof(uint8_t) * MAXARRAYLABEL, 1, fil) != 1) goto corrupt; if (kdfread(aGameArrays[i].szLabel,sizeof(uint8_t) * MAXARRAYLABEL, 1, fil) != 1) goto corrupt;
HASH_replace(&arrayH,aGameArrays[i].szLabel,i); hash_replace(&arrayH,aGameArrays[i].szLabel,i);
aGameArrays[i].plValues=Bcalloc(aGameArrays[i].size,sizeof(intptr_t)); aGameArrays[i].plValues=Bcalloc(aGameArrays[i].size,sizeof(intptr_t));
if (kdfread(aGameArrays[i].plValues,sizeof(intptr_t) * aGameArrays[i].size, 1, fil) < 1) goto corrupt; if (kdfread(aGameArrays[i].plValues,sizeof(intptr_t) * aGameArrays[i].size, 1, fil) < 1) goto corrupt;
@ -384,7 +384,7 @@ int32_t Gv_NewArray(const char *pszLabel, int32_t asize)
initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXARRAYLABEL); initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXARRAYLABEL);
return 0; return 0;
} }
i = HASH_find(&arrayH,pszLabel); i = hash_find(&arrayH,pszLabel);
if (i >=0 && !aGameArrays[i].bReset) if (i >=0 && !aGameArrays[i].bReset)
{ {
// found it it's a duplicate in error // found it it's a duplicate in error
@ -403,7 +403,7 @@ int32_t Gv_NewArray(const char *pszLabel, int32_t asize)
aGameArrays[i].size=asize; aGameArrays[i].size=asize;
aGameArrays[i].bReset=0; aGameArrays[i].bReset=0;
g_gameArrayCount++; g_gameArrayCount++;
HASH_replace(&arrayH,aGameArrays[i].szLabel,i); hash_replace(&arrayH,aGameArrays[i].szLabel,i);
return 1; return 1;
} }
@ -430,7 +430,7 @@ int32_t Gv_NewVar(const char *pszLabel, int32_t lValue, uint32_t dwFlags)
return 0; return 0;
} }
i = HASH_find(&gamevarH,pszLabel); i = hash_find(&gamevarH,pszLabel);
if (i >= 0 && !(aGameVars[i].dwFlags & GAMEVAR_RESET)) if (i >= 0 && !(aGameVars[i].dwFlags & GAMEVAR_RESET))
{ {
@ -480,7 +480,7 @@ int32_t Gv_NewVar(const char *pszLabel, int32_t lValue, uint32_t dwFlags)
if (i == g_gameVarCount) if (i == g_gameVarCount)
{ {
// we're adding a new one. // we're adding a new one.
HASH_add(&gamevarH, aGameVars[i].szLabel, g_gameVarCount++); hash_add(&gamevarH, aGameVars[i].szLabel, g_gameVarCount++);
} }
if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER)
@ -512,7 +512,7 @@ void A_ResetVars(int32_t iActor)
static int32_t Gv_GetVarIndex(const char *szGameLabel) static int32_t Gv_GetVarIndex(const char *szGameLabel)
{ {
int32_t i = HASH_find(&gamevarH,szGameLabel); int32_t i = hash_find(&gamevarH,szGameLabel);
if (i == -1) if (i == -1)
{ {
OSD_Printf(OSD_ERROR "Gv_GetVarDataPtr(): INTERNAL ERROR: couldn't find gamevar %s!\n",szGameLabel); OSD_Printf(OSD_ERROR "Gv_GetVarDataPtr(): INTERNAL ERROR: couldn't find gamevar %s!\n",szGameLabel);
@ -863,7 +863,7 @@ void __fastcall Gv_SetVarX(int32_t id, int32_t lValue)
int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iActor, int32_t iPlayer) int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iActor, int32_t iPlayer)
{ {
int32_t i = HASH_find(&gamevarH,szGameLabel); int32_t i = hash_find(&gamevarH,szGameLabel);
if (i < 0) if (i < 0)
return lDefault; return lDefault;
@ -873,7 +873,7 @@ int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iAct
static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel) static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel)
{ {
int32_t i = HASH_find(&gamevarH,szGameLabel); int32_t i = hash_find(&gamevarH,szGameLabel);
if (i < 0) if (i < 0)
return NULL; return NULL;

View file

@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "dsound.h"
#include "dsoundout.h" #include "dsoundout.h"
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
@ -32,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <mmsystem.h> #include <mmsystem.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "dsound.h"
#ifdef USE_OPENAL #ifdef USE_OPENAL
#include "openal.h" #include "openal.h"
#endif #endif

View file

@ -312,8 +312,7 @@ int32_t MUSIC_PlaySong(char *song, int32_t loopflag)
if (music_musicchunk != NULL) if (music_musicchunk != NULL)
{ {
// !!! FIXME: I set the music to loop. Hope that's okay. --ryan. Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_LoopSong)?-1:0);
Mix_PlayMusic(music_musicchunk, -1);
} // if } // if
return MUSIC_Ok; return MUSIC_Ok;
} }

View file

@ -55,7 +55,7 @@ static int32 ticrate;
static int32 CONTROL_DoubleClickSpeed; static int32 CONTROL_DoubleClickSpeed;
int32_t extinput[CONTROL_NUM_FLAGS]; int32_t extinput[CONTROL_NUM_FLAGS];
keybind boundkeys[MAXBOUNDKEYS], mousebind[MAXMOUSEBUTTONS]; keybind KeyBindings[MAXBOUNDKEYS], MouseBindings[MAXMOUSEBUTTONS];
int32_t bindsenabled = 0; int32_t bindsenabled = 0;
int32_t control_smoothmouse = 0; int32_t control_smoothmouse = 0;
@ -167,10 +167,10 @@ boolean CONTROL_KeyboardFunctionPressed(int32 which)
if (!CONTROL_Flags[which].used) return false; if (!CONTROL_Flags[which].used) return false;
if (CONTROL_KeyMapping[which].key1 != KEYUNDEFINED && !boundkeys[CONTROL_KeyMapping[which].key1].cmd[0]) if (CONTROL_KeyMapping[which].key1 != KEYUNDEFINED && !KeyBindings[CONTROL_KeyMapping[which].key1].cmd[0])
key1 = KB_KeyDown[ CONTROL_KeyMapping[which].key1 ] ? true : false; key1 = KB_KeyDown[ CONTROL_KeyMapping[which].key1 ] ? true : false;
if (CONTROL_KeyMapping[which].key2 != KEYUNDEFINED && !boundkeys[CONTROL_KeyMapping[which].key2].cmd[0]) if (CONTROL_KeyMapping[which].key2 != KEYUNDEFINED && !KeyBindings[CONTROL_KeyMapping[which].key2].cmd[0])
key2 = KB_KeyDown[ CONTROL_KeyMapping[which].key2 ] ? true : false; key2 = KB_KeyDown[ CONTROL_KeyMapping[which].key2 ] ? true : false;
return (key1 | key2); return (key1 | key2);
@ -723,7 +723,7 @@ void CONTROL_ButtonFunctionState(int32 *p1)
do do
{ {
if (!mousebind[i].cmd[0]) if (!MouseBindings[i].cmd[0])
{ {
j = CONTROL_MouseButtonMapping[i].doubleclicked; j = CONTROL_MouseButtonMapping[i].doubleclicked;
if (j != KEYUNDEFINED) if (j != KEYUNDEFINED)
@ -737,12 +737,12 @@ void CONTROL_ButtonFunctionState(int32 *p1)
if (!bindsenabled) if (!bindsenabled)
continue; continue;
if (mousebind[i].cmd[0] && CONTROL_MouseButtonState[i]) if (MouseBindings[i].cmd[0] && CONTROL_MouseButtonState[i])
{ {
if (mousebind[i].repeat || (mousebind[i].laststate == 0)) if (MouseBindings[i].repeat || (MouseBindings[i].laststate == 0))
OSD_Dispatch(mousebind[i].cmd); OSD_Dispatch(MouseBindings[i].cmd);
} }
mousebind[i].laststate = CONTROL_MouseButtonState[i]; MouseBindings[i].laststate = CONTROL_MouseButtonState[i];
} }
while (i--); while (i--);
} }
@ -867,22 +867,22 @@ void CONTROL_ProcessBinds(void)
do do
{ {
if (boundkeys[i].cmd[0] && KB_KeyPressed(i)) if (KeyBindings[i].cmd[0] && KB_KeyPressed(i))
{ {
if (boundkeys[i].repeat || (boundkeys[i].laststate == 0)) if (KeyBindings[i].repeat || (KeyBindings[i].laststate == 0))
OSD_Dispatch(boundkeys[i].cmd); OSD_Dispatch(KeyBindings[i].cmd);
} }
boundkeys[i].laststate = KB_KeyPressed(i); KeyBindings[i].laststate = KB_KeyPressed(i);
} }
while (--i); while (--i);
} }
if (boundkeys[0].cmd[0] && KB_KeyPressed(0)) if (KeyBindings[0].cmd[0] && KB_KeyPressed(0))
{ {
if (boundkeys[0].repeat || (boundkeys[0].laststate == 0)) if (KeyBindings[0].repeat || (KeyBindings[0].laststate == 0))
OSD_Dispatch(boundkeys[0].cmd); OSD_Dispatch(KeyBindings[0].cmd);
} }
boundkeys[0].laststate = KB_KeyPressed(0); KeyBindings[0].laststate = KB_KeyPressed(0);
} }

View file

@ -213,7 +213,7 @@ typedef struct binding {
#define MAXMOUSEBUTTONS 10 #define MAXMOUSEBUTTONS 10
extern keybind boundkeys[MAXBOUNDKEYS], mousebind[MAXMOUSEBUTTONS]; extern keybind KeyBindings[MAXBOUNDKEYS], MouseBindings[MAXMOUSEBUTTONS];
extern int32_t bindsenabled; extern int32_t bindsenabled;
void CONTROL_ProcessBinds(void); void CONTROL_ProcessBinds(void);

View file

@ -199,7 +199,7 @@ extern kb_scancode KB_LastScan;
#define KB_ClearKeyDown( scan ) { keystatus[ ( scan ) ] = FALSE; } #define KB_ClearKeyDown( scan ) { keystatus[ ( scan ) ] = FALSE; }
#define KB_UnBoundKeyPressed( scan ) ( keystatus[ ( scan ) ] != 0 && !boundkeys[scan].cmd[0]) #define KB_UnBoundKeyPressed( scan ) ( keystatus[ ( scan ) ] != 0 && !KeyBindings[scan].cmd[0])
/* /*
============================================================================= =============================================================================

View file

@ -52,11 +52,11 @@ static int32_t ototalclock = 0;
char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0}; char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0};
uint8_t keys[NUMBUILDKEYS] = uint8_t keys[NUMBUILDKEYS] =
{ {
0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39,
0x1e,0x2c,0xd1,0xc9,0x47,0x49, 0x1e,0x2c,0xd1,0xc9,0x47,0x49,
0x9c,0x1c,0xd,0xc,0xf,0x29 0x9c,0x1c,0xd,0xc,0xf,0x29
}; };
int32_t nextvoxid = 0; int32_t nextvoxid = 0;
@ -111,12 +111,8 @@ static void EditWallData(int16_t wallnum);
static void EditSectorData(int16_t sectnum); static void EditSectorData(int16_t sectnum);
static void FuncMenu(void); static void FuncMenu(void);
char GAMEpalette[768]; uint8_t GAMEpalette[768], WATERpalette[768], SLIMEpalette[768], TITLEpalette[768];
char WATERpalette[768]; uint8_t REALMSpalette[768], BOSS1palette[768];
char SLIMEpalette[768];
char TITLEpalette[768];
char REALMSpalette[768];
char BOSS1palette[768];
char num_tables; char num_tables;

View file

@ -1477,7 +1477,7 @@ void M_DisplayMenus(void)
} }
else else
{ {
tempbuf[0] = PACKET_TYPE_LOAD_GAME; tempbuf[0] = PACKET_LOAD_GAME;
tempbuf[1] = g_lastSaveSlot; tempbuf[1] = g_lastSaveSlot;
tempbuf[2] = myconnectindex; tempbuf[2] = myconnectindex;
TRAVERSE_CONNECT(x) TRAVERSE_CONNECT(x)
@ -3790,13 +3790,13 @@ cheat_for_port_credits:
{ {
ud.config.MouseFunctions[whichkey>>1][whichkey&1] = x; ud.config.MouseFunctions[whichkey>>1][whichkey&1] = x;
CONTROL_MapButton(x, whichkey>>1, whichkey&1, controldevice_mouse); CONTROL_MapButton(x, whichkey>>1, whichkey&1, controldevice_mouse);
mousebind[whichkey>>1].cmd[0] = 0; // kill the bind when changing the button in the menu MouseBindings[whichkey>>1].cmd[0] = 0; // kill the bind when changing the button in the menu
} }
else else
{ {
ud.config.MouseFunctions[whichkey-(MAXMOUSEBUTTONS-2)][0] = x; ud.config.MouseFunctions[whichkey-(MAXMOUSEBUTTONS-2)][0] = x;
CONTROL_MapButton(x, whichkey-(MAXMOUSEBUTTONS-2), 0, controldevice_mouse); CONTROL_MapButton(x, whichkey-(MAXMOUSEBUTTONS-2), 0, controldevice_mouse);
mousebind[whichkey-(MAXMOUSEBUTTONS-2)].cmd[0] = 0; MouseBindings[whichkey-(MAXMOUSEBUTTONS-2)].cmd[0] = 0;
} }
ChangeToMenu(205); ChangeToMenu(205);
probey = whichkey; probey = whichkey;
@ -5107,7 +5107,7 @@ VOLUME_ALL_40x:
g_player[i].gotvote = 0; g_player[i].gotvote = 0;
} }
tempbuf[0] = PACKET_TYPE_MAP_VOTE_CANCEL; tempbuf[0] = PACKET_MAP_VOTE_CANCEL;
tempbuf[1] = myconnectindex; tempbuf[1] = myconnectindex;
TRAVERSE_CONNECT(c) TRAVERSE_CONNECT(c)
@ -5164,7 +5164,7 @@ VOLUME_ALL_40x:
voting = -1; voting = -1;
tempbuf[0] = PACKET_TYPE_MAP_VOTE_CANCEL; tempbuf[0] = PACKET_MAP_VOTE_CANCEL;
tempbuf[1] = myconnectindex; tempbuf[1] = myconnectindex;
tempbuf[2] = 1; tempbuf[2] = 1;
@ -5315,7 +5315,7 @@ VOLUME_ALL_40x:
g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1; g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
voting = myconnectindex; voting = myconnectindex;
tempbuf[0] = PACKET_TYPE_MAP_VOTE_INITIATE; tempbuf[0] = PACKET_MAP_VOTE_INITIATE;
tempbuf[1] = myconnectindex; tempbuf[1] = myconnectindex;
tempbuf[2] = ud.m_volume_number; tempbuf[2] = ud.m_volume_number;
tempbuf[3] = ud.m_level_number; tempbuf[3] = ud.m_level_number;

View file

@ -35,7 +35,7 @@ struct dynitem
int16_t vstat; int16_t vstat;
int16_t val; int16_t val;
}; };
HASH_table dynnamesH = {512, NULL}; hashtable_t dynnamesH = {512, NULL};
struct dynitem list[]= struct dynitem list[]=
{ {
@ -1525,21 +1525,21 @@ void G_ProcessDynamicTileMapping(const char *szLabel, int32_t lValue)
if (lValue >= MAXTILES || !szLabel) if (lValue >= MAXTILES || !szLabel)
return; return;
i = HASH_find(&dynnamesH,szLabel); i = hash_find(&dynnamesH,szLabel);
if (i>=0) *(list[i].v)=lValue; if (i>=0) *(list[i].v)=lValue;
} }
void inithashnames() void inithashnames()
{ {
int32_t i; int32_t i;
HASH_init(&dynnamesH); hash_init(&dynnamesH);
for (i=0;list[i].val;i++) for (i=0;list[i].val;i++)
HASH_add(&dynnamesH,list[i].s,i); hash_add(&dynnamesH,list[i].s,i);
} }
void freehashnames() void freehashnames()
{ {
HASH_free(&dynnamesH); hash_free(&dynnamesH);
} }
void G_InitDynamicTiles(void) void G_InitDynamicTiles(void)

View file

@ -122,7 +122,7 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm)
voting = myconnectindex; voting = myconnectindex;
tempbuf[0] = PACKET_TYPE_MAP_VOTE_INITIATE; tempbuf[0] = PACKET_MAP_VOTE_INITIATE;
tempbuf[1] = myconnectindex; tempbuf[1] = myconnectindex;
tempbuf[2] = ud.m_volume_number; tempbuf[2] = ud.m_volume_number;
tempbuf[3] = ud.m_level_number; tempbuf[3] = ud.m_level_number;
@ -280,7 +280,7 @@ static int32_t osdcmd_map(const osdfuncparm_t *parm)
g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1; g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
voting = myconnectindex; voting = myconnectindex;
tempbuf[0] = PACKET_TYPE_MAP_VOTE_INITIATE; tempbuf[0] = PACKET_MAP_VOTE_INITIATE;
tempbuf[1] = myconnectindex; tempbuf[1] = myconnectindex;
tempbuf[2] = ud.m_volume_number; tempbuf[2] = ud.m_volume_number;
tempbuf[3] = ud.m_level_number; tempbuf[3] = ud.m_level_number;
@ -614,12 +614,12 @@ static int32_t osdcmd_setvar(const osdfuncparm_t *parm)
strcpy(varname,parm->parms[1]); strcpy(varname,parm->parms[1]);
varval = Batol(varname); varval = Batol(varname);
i = HASH_find(&gamevarH,varname); i = hash_find(&gamevarH,varname);
if (i >= 0) if (i >= 0)
varval=Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex); varval=Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex);
strcpy(varname,parm->parms[0]); strcpy(varname,parm->parms[0]);
i = HASH_find(&gamevarH,varname); i = hash_find(&gamevarH,varname);
if (i >= 0) if (i >= 0)
Gv_SetVar(i, varval, g_player[myconnectindex].ps->i, myconnectindex); Gv_SetVar(i, varval, g_player[myconnectindex].ps->i, myconnectindex);
return OSDCMD_OK; return OSDCMD_OK;
@ -639,7 +639,7 @@ static int32_t osdcmd_addlogvar(const osdfuncparm_t *parm)
} }
strcpy(varname,parm->parms[0]); strcpy(varname,parm->parms[0]);
i = HASH_find(&gamevarH,varname); i = hash_find(&gamevarH,varname);
if (i >= 0) if (i >= 0)
OSD_Printf("%s = %d\n", varname, Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex)); OSD_Printf("%s = %d\n", varname, Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex));
return OSDCMD_OK; return OSDCMD_OK;
@ -668,12 +668,12 @@ static int32_t osdcmd_setactorvar(const osdfuncparm_t *parm)
varval = Batol(parm->parms[2]); varval = Batol(parm->parms[2]);
strcpy(varname,parm->parms[2]); strcpy(varname,parm->parms[2]);
varval = Batol(varname); varval = Batol(varname);
i = HASH_find(&gamevarH,varname); i = hash_find(&gamevarH,varname);
if (i >= 0) if (i >= 0)
varval=Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex); varval=Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex);
strcpy(varname,parm->parms[1]); strcpy(varname,parm->parms[1]);
i = HASH_find(&gamevarH,varname); i = hash_find(&gamevarH,varname);
if (i >= 0) if (i >= 0)
Gv_SetVar(i, varval, ID, -1); Gv_SetVar(i, varval, ID, -1);
return OSDCMD_OK; return OSDCMD_OK;
@ -717,7 +717,7 @@ static int32_t osdcmd_cmenu(const osdfuncparm_t *parm)
return OSDCMD_OK; return OSDCMD_OK;
} }
cvarmappings cvar[] = cvar_t cvars[] =
{ {
{ "crosshair", "crosshair: enable/disable crosshair", (void*)&ud.crosshair, CVAR_BOOL, 0, 0, 1 }, { "crosshair", "crosshair: enable/disable crosshair", (void*)&ud.crosshair, CVAR_BOOL, 0, 0, 1 },
@ -789,18 +789,18 @@ static int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
int32_t showval = (parm->numparms == 0); int32_t showval = (parm->numparms == 0);
uint32_t i; uint32_t i;
for (i = 0; i < sizeof(cvar)/sizeof(cvarmappings); i++) for (i = 0; i < sizeof(cvars)/sizeof(cvar_t); i++)
{ {
if (!Bstrcasecmp(parm->name, cvar[i].name)) if (!Bstrcasecmp(parm->name, cvars[i].name))
{ {
if ((cvar[i].type & CVAR_NOMULTI) && numplayers > 1) if ((cvars[i].type & CVAR_NOMULTI) && numplayers > 1)
{ {
// sound the alarm // sound the alarm
OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvar[i].name); OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvars[i].name);
return OSDCMD_OK; return OSDCMD_OK;
} }
else else
switch (cvar[i].type&0x7f) switch (cvars[i].type&0x7f)
{ {
case CVAR_INT: case CVAR_INT:
case CVAR_UNSIGNEDINT: case CVAR_UNSIGNEDINT:
@ -809,41 +809,41 @@ static int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
int32_t val; int32_t val;
if (showval) if (showval)
{ {
OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int32_t*)cvar[i].var,(char*)cvar[i].helpstr); OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvars[i].name,*(int32_t*)cvars[i].var,(char*)cvars[i].helpstr);
return OSDCMD_OK; return OSDCMD_OK;
} }
val = atoi(parm->parms[0]); val = atoi(parm->parms[0]);
if (cvar[i].type == CVAR_BOOL) val = val != 0; if (cvars[i].type == CVAR_BOOL) val = val != 0;
if (val < cvar[i].min || val > cvar[i].max) if (val < cvars[i].min || val > cvars[i].max)
{ {
OSD_Printf("%s value out of range\n",cvar[i].name); OSD_Printf("%s value out of range\n",cvars[i].name);
return OSDCMD_OK; return OSDCMD_OK;
} }
*(int32_t*)cvar[i].var = val; *(int32_t*)cvars[i].var = val;
OSD_Printf("%s %d",cvar[i].name,val); OSD_Printf("%s %d",cvars[i].name,val);
} }
break; break;
case CVAR_STRING: case CVAR_STRING:
{ {
if (showval) if (showval)
{ {
OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr); OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvars[i].name,(char*)cvars[i].var,(char*)cvars[i].helpstr);
return OSDCMD_OK; return OSDCMD_OK;
} }
else else
{ {
Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1); Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].extra-1);
((char*)cvar[i].var)[cvar[i].extra-1] = 0; ((char*)cvars[i].var)[cvars[i].extra-1] = 0;
OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var); OSD_Printf("%s %s",cvars[i].name,(char*)cvars[i].var);
} }
} }
break; break;
default: default:
break; break;
} }
if (cvar[i].type&CVAR_MULTI) if (cvars[i].type&CVAR_MULTI)
G_UpdatePlayerFromMenu(); G_UpdatePlayerFromMenu();
} }
} }
@ -932,7 +932,7 @@ static int32_t osdcmd_give(const osdfuncparm_t *parm)
void onvideomodechange(int32_t newmode) void onvideomodechange(int32_t newmode)
{ {
char *pal; uint8_t *pal;
extern int32_t g_crosshairSum; extern int32_t g_crosshairSum;
if (newmode) if (newmode)
@ -1023,7 +1023,7 @@ static int32_t osdcmd_button(const osdfuncparm_t *parm)
return OSDCMD_OK; return OSDCMD_OK;
} }
keydef_t keynames[]= keydef_t ConsoleKeys[]=
{ {
{ "Escape", 0x1 }, { "Escape", 0x1 },
{ "1", 0x2 }, { "1", 0x2 },
@ -1130,7 +1130,7 @@ keydef_t keynames[]=
{0,0} {0,0}
}; };
char *mousenames[] = { "mouse1", "mouse2", "mouse3", "mouse4", "mwheelup", "mwheeldn", "mouse5", "mouse6", "mouse7", "mouse8" }; char *ConsoleButtons[] = { "mouse1", "mouse2", "mouse3", "mouse4", "mwheelup", "mwheeldn", "mouse5", "mouse6", "mouse7", "mouse8" };
static int32_t osdcmd_bind(const osdfuncparm_t *parm) static int32_t osdcmd_bind(const osdfuncparm_t *parm)
{ {
@ -1138,8 +1138,8 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm)
if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys")) if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys"))
{ {
for (i=0;keynames[i].name;i++)OSD_Printf("%s\n",keynames[i].name); for (i=0;ConsoleKeys[i].name;i++)OSD_Printf("%s\n",ConsoleKeys[i].name);
for (i=0;i<MAXMOUSEBUTTONS;i++)OSD_Printf("%s\n",mousenames[i]); for (i=0;i<MAXMOUSEBUTTONS;i++)OSD_Printf("%s\n",ConsoleButtons[i]);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -1149,17 +1149,17 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm)
OSD_Printf("Current key bindings:\n"); OSD_Printf("Current key bindings:\n");
for (i=0;i<MAXBOUNDKEYS;i++) for (i=0;i<MAXBOUNDKEYS;i++)
if (boundkeys[i].cmd[0] && boundkeys[i].key) if (KeyBindings[i].cmd[0] && KeyBindings[i].key)
{ {
j++; j++;
OSD_Printf("%-9s %s\"%s\"\n",boundkeys[i].key, boundkeys[i].repeat?"":"norepeat ", boundkeys[i].cmd); OSD_Printf("%-9s %s\"%s\"\n",KeyBindings[i].key, KeyBindings[i].repeat?"":"norepeat ", KeyBindings[i].cmd);
} }
for (i=0;i<MAXMOUSEBUTTONS;i++) for (i=0;i<MAXMOUSEBUTTONS;i++)
if (mousebind[i].cmd[0] && mousebind[i].key) if (MouseBindings[i].cmd[0] && MouseBindings[i].key)
{ {
j++; j++;
OSD_Printf("%-9s %s\"%s\"\n",mousebind[i].key, mousebind[i].repeat?"":"norepeat ",mousebind[i].cmd); OSD_Printf("%-9s %s\"%s\"\n",MouseBindings[i].key, MouseBindings[i].repeat?"":"norepeat ",MouseBindings[i].cmd);
} }
if (j == 0) if (j == 0)
@ -1168,30 +1168,30 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm)
return OSDCMD_OK; return OSDCMD_OK;
} }
for (i=0;keynames[i].name;i++) for (i=0;ConsoleKeys[i].name;i++)
if (!Bstrcasecmp(parm->parms[0],keynames[i].name)) if (!Bstrcasecmp(parm->parms[0],ConsoleKeys[i].name))
break; break;
if (!keynames[i].name) if (!ConsoleKeys[i].name)
{ {
for (i=0;i<MAXMOUSEBUTTONS;i++) for (i=0;i<MAXMOUSEBUTTONS;i++)
if (!Bstrcasecmp(parm->parms[0],mousenames[i])) if (!Bstrcasecmp(parm->parms[0],ConsoleButtons[i]))
break; break;
if (i >= MAXMOUSEBUTTONS) if (i >= MAXMOUSEBUTTONS)
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
if (parm->numparms < 2) if (parm->numparms < 2)
{ {
OSD_Printf("%-9s %s\"%s\"\n",mousenames[i], mousebind[i].repeat?"":"norepeat ",mousebind[i].cmd); OSD_Printf("%-9s %s\"%s\"\n",ConsoleButtons[i], MouseBindings[i].repeat?"":"norepeat ",MouseBindings[i].cmd);
return OSDCMD_OK; return OSDCMD_OK;
} }
j = 1; j = 1;
mousebind[i].repeat = 1; MouseBindings[i].repeat = 1;
if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat")) if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat"))
{ {
mousebind[i].repeat = 0; MouseBindings[i].repeat = 0;
j++; j++;
} }
@ -1201,9 +1201,9 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm)
Bstrcat(tempbuf," "); Bstrcat(tempbuf," ");
Bstrcat(tempbuf,parm->parms[j++]); Bstrcat(tempbuf,parm->parms[j++]);
} }
Bstrncpy(mousebind[i].cmd,tempbuf, MAXBINDSTRINGLENGTH-1); Bstrncpy(MouseBindings[i].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
mousebind[i].key=mousenames[i]; MouseBindings[i].key=ConsoleButtons[i];
if (!OSD_ParsingScript()) if (!OSD_ParsingScript())
OSD_Printf("%s\n",parm->raw); OSD_Printf("%s\n",parm->raw);
return OSDCMD_OK; return OSDCMD_OK;
@ -1211,16 +1211,16 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm)
if (parm->numparms < 2) if (parm->numparms < 2)
{ {
OSD_Printf("%-9s %s\"%s\"\n",keynames[i].name, boundkeys[keynames[i].id].repeat?"":"norepeat ", boundkeys[keynames[i].id].cmd); OSD_Printf("%-9s %s\"%s\"\n",ConsoleKeys[i].name, KeyBindings[ConsoleKeys[i].id].repeat?"":"norepeat ", KeyBindings[ConsoleKeys[i].id].cmd);
return OSDCMD_OK; return OSDCMD_OK;
} }
j = 1; j = 1;
boundkeys[keynames[i].id].repeat = 1; KeyBindings[ConsoleKeys[i].id].repeat = 1;
if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat")) if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat"))
{ {
boundkeys[keynames[i].id].repeat = 0; KeyBindings[ConsoleKeys[i].id].repeat = 0;
j++; j++;
} }
@ -1230,9 +1230,9 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm)
Bstrcat(tempbuf," "); Bstrcat(tempbuf," ");
Bstrcat(tempbuf,parm->parms[j++]); Bstrcat(tempbuf,parm->parms[j++]);
} }
Bstrncpy(boundkeys[keynames[i].id].cmd,tempbuf, MAXBINDSTRINGLENGTH-1); Bstrncpy(KeyBindings[ConsoleKeys[i].id].cmd,tempbuf, MAXBINDSTRINGLENGTH-1);
boundkeys[keynames[i].id].key=keynames[i].name; KeyBindings[ConsoleKeys[i].id].key=ConsoleKeys[i].name;
if (!OSD_ParsingScript()) if (!OSD_ParsingScript())
OSD_Printf("%s\n",parm->raw); OSD_Printf("%s\n",parm->raw);
return OSDCMD_OK; return OSDCMD_OK;
@ -1245,11 +1245,11 @@ static int32_t osdcmd_unbindall(const osdfuncparm_t *parm)
UNREFERENCED_PARAMETER(parm); UNREFERENCED_PARAMETER(parm);
for (i=0;i<MAXBOUNDKEYS;i++) for (i=0;i<MAXBOUNDKEYS;i++)
if (boundkeys[i].cmd[0]) if (KeyBindings[i].cmd[0])
boundkeys[i].cmd[0] = 0; KeyBindings[i].cmd[0] = 0;
for (i=0;i<MAXMOUSEBUTTONS;i++) for (i=0;i<MAXMOUSEBUTTONS;i++)
if (mousebind[i].cmd[0]) if (MouseBindings[i].cmd[0])
mousebind[i].cmd[0] = 0; MouseBindings[i].cmd[0] = 0;
OSD_Printf("unbound all keys\n"); OSD_Printf("unbound all keys\n");
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -1259,24 +1259,24 @@ static int32_t osdcmd_unbind(const osdfuncparm_t *parm)
int32_t i; int32_t i;
if (parm->numparms < 1) return OSDCMD_SHOWHELP; if (parm->numparms < 1) return OSDCMD_SHOWHELP;
for (i=0;keynames[i].name;i++) for (i=0;ConsoleKeys[i].name;i++)
if (!Bstrcasecmp(parm->parms[0],keynames[i].name)) if (!Bstrcasecmp(parm->parms[0],ConsoleKeys[i].name))
break; break;
if (!keynames[i].name) if (!ConsoleKeys[i].name)
{ {
for (i=0;i<MAXMOUSEBUTTONS;i++) for (i=0;i<MAXMOUSEBUTTONS;i++)
if (!Bstrcasecmp(parm->parms[0],mousenames[i])) if (!Bstrcasecmp(parm->parms[0],ConsoleButtons[i]))
break; break;
if (i >= MAXMOUSEBUTTONS) if (i >= MAXMOUSEBUTTONS)
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
mousebind[i].repeat = 0; MouseBindings[i].repeat = 0;
mousebind[i].cmd[0] = 0; MouseBindings[i].cmd[0] = 0;
OSD_Printf("unbound %s\n",mousenames[i]); OSD_Printf("unbound %s\n",ConsoleButtons[i]);
return OSDCMD_OK; return OSDCMD_OK;
} }
boundkeys[keynames[i].id].repeat = 0; KeyBindings[ConsoleKeys[i].id].repeat = 0;
boundkeys[keynames[i].id].cmd[0] = 0; KeyBindings[ConsoleKeys[i].id].cmd[0] = 0;
OSD_Printf("unbound key %s\n",keynames[i].name); OSD_Printf("unbound key %s\n",ConsoleKeys[i].name);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -1463,9 +1463,9 @@ int32_t registerosdcommands(void)
osdcmd_cheatsinfo_stat.cheatnum = -1; osdcmd_cheatsinfo_stat.cheatnum = -1;
for (i=0; i<sizeof(cvar)/sizeof(cvar[0]); i++) for (i=0; i<sizeof(cvars)/sizeof(cvars[0]); i++)
{ {
OSD_RegisterFunction(cvar[i].name, cvar[i].helpstr, osdcmd_cvar_set); OSD_RegisterFunction(cvars[i].name, cvars[i].helpstr, osdcmd_cvar_set);
} }
if (VOLUMEONE) if (VOLUMEONE)

View file

@ -32,9 +32,9 @@ typedef struct
int32_t extra; // for string, is the length int32_t extra; // for string, is the length
int32_t min; int32_t min;
int32_t max; int32_t max;
} cvarmappings; } cvar_t;
extern cvarmappings cvar[]; extern cvar_t cvars[];
#endif // __osdcmds_h__ #endif // __osdcmds_h__

View file

@ -682,7 +682,7 @@ static void P_ResetStatus(int32_t snum)
p->on_warping_sector = 0; p->on_warping_sector = 0;
p->spritebridge = 0; p->spritebridge = 0;
p->sbs = 0; p->sbs = 0;
p->palette = (char *) &palette[0]; p->palette = (uint8_t *) &palette[0];
if (p->steroids_amount < 400) if (p->steroids_amount < 400)
{ {
@ -1531,7 +1531,7 @@ void waitforeverybody()
int32_t i; int32_t i;
if (numplayers < 2) return; if (numplayers < 2) return;
packbuf[0] = PACKET_TYPE_PLAYER_READY; packbuf[0] = PACKET_PLAYER_READY;
g_player[myconnectindex].playerreadyflag++; g_player[myconnectindex].playerreadyflag++;
@ -1579,7 +1579,7 @@ void waitforeverybody()
if (!g_networkBroadcastMode && myconnectindex == connecthead) if (!g_networkBroadcastMode && myconnectindex == connecthead)
TRAVERSE_CONNECT(i) TRAVERSE_CONNECT(i)
{ {
packbuf[0] = PACKET_TYPE_PLAYER_READY; packbuf[0] = PACKET_PLAYER_READY;
if (i != myconnectindex) mmulti_sendpacket(i,packbuf,1); if (i != myconnectindex) mmulti_sendpacket(i,packbuf,1);
} }

View file

@ -239,7 +239,7 @@ int32_t G_LoadPlayer(int32_t spot)
if (kdfread(&numsectors,2,1,fil) != 1) goto corrupt; if (kdfread(&numsectors,2,1,fil) != 1) goto corrupt;
if (kdfread(&sector[0],sizeof(sectortype),MAXSECTORS,fil) != MAXSECTORS) goto corrupt; if (kdfread(&sector[0],sizeof(sectortype),MAXSECTORS,fil) != MAXSECTORS) goto corrupt;
if (kdfread(&sprite[0],sizeof(spritetype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; if (kdfread(&sprite[0],sizeof(spritetype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt;
if (kdfread(&spriteext[0],sizeof(spriteexttype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; if (kdfread(&spriteext[0],sizeof(spriteext_t),MAXSPRITES,fil) != MAXSPRITES) goto corrupt;
#if defined(POLYMOST) && defined(USE_OPENGL) #if defined(POLYMOST) && defined(USE_OPENGL)
for (i=0;i<MAXSPRITES;i++) for (i=0;i<MAXSPRITES;i++)
if (spriteext[i].mdanimtims) if (spriteext[i].mdanimtims)
@ -672,7 +672,7 @@ int32_t G_SavePlayer(int32_t spot)
spriteext[i].mdanimtims++; spriteext[i].mdanimtims++;
} }
#endif #endif
dfwrite(&spriteext[0],sizeof(spriteexttype),MAXSPRITES,fil); dfwrite(&spriteext[0],sizeof(spriteext_t),MAXSPRITES,fil);
#if defined(POLYMOST) && defined(USE_OPENGL) #if defined(POLYMOST) && defined(USE_OPENGL)
for (i=0;i<MAXSPRITES;i++)if (spriteext[i].mdanimtims)spriteext[i].mdanimtims+=mdtims; for (i=0;i<MAXSPRITES;i++)if (spriteext[i].mdanimtims)spriteext[i].mdanimtims+=mdtims;
#endif #endif

View file

@ -27,15 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// PRIMITIVE // PRIMITIVE
static int32_t haltsoundhack; static int32_t g_haltSoundHack = 0;
// this function activates a sector's MUSICANDSFX sprite // this function activates a sector's MUSICANDSFX sprite
int32_t A_CallSound(int32_t sn,int32_t whatsprite) int32_t A_CallSound(int32_t sn,int32_t whatsprite)
{ {
int32_t i; int32_t i;
if (haltsoundhack) if (g_haltSoundHack)
{ {
haltsoundhack = 0; g_haltSoundHack = 0;
return -1; return -1;
} }
i = headspritesect[sn]; i = headspritesect[sn];
@ -76,12 +76,11 @@ int32_t A_CallSound(int32_t sn,int32_t whatsprite)
return -1; return -1;
} }
int32_t check_activator_motion(int32_t lotag) int32_t G_CheckActivatorMotion(int32_t lotag)
{ {
int32_t i, j; int32_t i = headspritestat[STAT_ACTIVATOR], j;
spritetype *s; spritetype *s;
i = headspritestat[STAT_ACTIVATOR];
while (i >= 0) while (i >= 0)
{ {
if (sprite[i].lotag == lotag) if (sprite[i].lotag == lotag)
@ -578,7 +577,7 @@ void G_OperateSectors(int32_t sn,int32_t ii)
i = GetAnimationGoal(&sptr->ceilingz); i = GetAnimationGoal(&sptr->ceilingz);
if (i == -1) //if the door has stopped if (i == -1) //if the door has stopped
{ {
haltsoundhack = 1; g_haltSoundHack = 1;
sptr->lotag &= 0xff00; sptr->lotag &= 0xff00;
sptr->lotag |= 22; sptr->lotag |= 22;
G_OperateSectors(sn,ii); G_OperateSectors(sn,ii);
@ -1271,7 +1270,7 @@ int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchtype)
//case LOCKSWITCH1+1: //case LOCKSWITCH1+1:
case POWERSWITCH2__STATIC: case POWERSWITCH2__STATIC:
//case POWERSWITCH2+1: //case POWERSWITCH2+1:
if (check_activator_motion(lotag)) return 0; if (G_CheckActivatorMotion(lotag)) return 0;
break; break;
default: default:
if (CheckDoorTile(picnum) == 0) return 0; if (CheckDoorTile(picnum) == 0) return 0;

View file

@ -7,9 +7,9 @@
#define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n')) #define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n'))
int32_t WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int32_t nCmdShow) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{ {
int32_t i=0,j=0; int i=0,j=0;
char CmdLine[1024], sCmdLine[1024], szFileName[255]; char CmdLine[1024], sCmdLine[1024], szFileName[255];
LPTSTR szCmdLine; LPTSTR szCmdLine;