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

This commit is contained in:
terminx 2009-08-06 10:12:13 +00:00
parent b2e2ba8868
commit 0358aee38e
15 changed files with 262 additions and 503 deletions

View file

@ -1810,7 +1810,7 @@ struct win32_mlock_t {
};
#define MLOCK_T struct win32_mlock_t
#define CURRENT_THREAD GetCurrentThreadId()
#define CURRENT_THREAD ((long)GetCurrentThreadId())
#define INITIAL_LOCK(sl) ((sl)->threadid = 0, (sl)->l = (sl)->c = 0, 0)
#define ACQUIRE_LOCK(sl) win32_acquire_lock(sl)
#define RELEASE_LOCK(sl) win32_release_lock(sl)

View file

@ -53,13 +53,13 @@ ACQUIRE_LOCK, RELEASE_LOCK, TRY_LOCK, IS_LOCKED and NULL_LOCK_INITIALIZER.
#endif
#if defined(_MSC_VER) && _MSC_VER>=1400
#define MALLOCATTR __declspec(restrict)
#define NEDMALLOCPTRATTR __declspec(restrict)
#endif
#ifdef __GNUC__
#define MALLOCATTR __attribute__ ((malloc))
#define NEDMALLOCPTRATTR __attribute__ ((malloc))
#endif
#ifndef MALLOCATTR
#define MALLOCATTR
#ifndef NEDMALLOCPTRATTR
#define NEDMALLOCPTRATTR
#endif
#ifdef REPLACE_SYSTEM_ALLOCATOR
@ -120,11 +120,11 @@ EXTSPEC size_t nedblksize(void *mem) THROWSPEC;
EXTSPEC void nedsetvalue(void *v) THROWSPEC;
EXTSPEC MALLOCATTR void * nedmalloc(size_t size) THROWSPEC;
EXTSPEC MALLOCATTR void * nedcalloc(size_t no, size_t size) THROWSPEC;
EXTSPEC MALLOCATTR void * nedrealloc(void *mem, size_t size) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void * nedmalloc(size_t size) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void * nedcalloc(size_t no, size_t size) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void * nedrealloc(void *mem, size_t size) THROWSPEC;
EXTSPEC void nedfree(void *mem) THROWSPEC;
EXTSPEC MALLOCATTR void * nedmemalign(size_t alignment, size_t bytes) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void * nedmemalign(size_t alignment, size_t bytes) THROWSPEC;
#if !NO_MALLINFO
EXTSPEC struct mallinfo nedmallinfo(void) THROWSPEC;
#endif
@ -132,8 +132,8 @@ EXTSPEC int nedmallopt(int parno, int value) THROWSPEC;
EXTSPEC int nedmalloc_trim(size_t pad) THROWSPEC;
EXTSPEC void nedmalloc_stats(void) THROWSPEC;
EXTSPEC size_t nedmalloc_footprint(void) THROWSPEC;
EXTSPEC MALLOCATTR void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC;
EXTSPEC MALLOCATTR void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC;
/* Destroys the system memory pool used by the functions above.
Useful for when you have nedmalloc in a DLL you're about to unload.
@ -153,7 +153,7 @@ will *normally* be accessing the pool concurrently. Setting this to zero means i
extends on demand, but be careful of this as it can rapidly consume system resources
where bursts of concurrent threads use a pool at once.
*/
EXTSPEC MALLOCATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC;
/* Destroys a memory pool previously created by nedcreatepool().
*/
@ -180,11 +180,11 @@ system pool.
*/
EXTSPEC void neddisablethreadcache(nedpool *p) THROWSPEC;
EXTSPEC MALLOCATTR void * nedpmalloc(nedpool *p, size_t size) THROWSPEC;
EXTSPEC MALLOCATTR void * nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC;
EXTSPEC MALLOCATTR void * nedprealloc(nedpool *p, void *mem, size_t size) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void * nedpmalloc(nedpool *p, size_t size) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void * nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void * nedprealloc(nedpool *p, void *mem, size_t size) THROWSPEC;
EXTSPEC void nedpfree(nedpool *p, void *mem) THROWSPEC;
EXTSPEC MALLOCATTR void * nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void * nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC;
#if !NO_MALLINFO
EXTSPEC struct mallinfo nedpmallinfo(nedpool *p) THROWSPEC;
#endif
@ -192,14 +192,13 @@ EXTSPEC int nedpmallopt(nedpool *p, int parno, int value) THROWSPEC;
EXTSPEC int nedpmalloc_trim(nedpool *p, size_t pad) THROWSPEC;
EXTSPEC void nedpmalloc_stats(nedpool *p) THROWSPEC;
EXTSPEC size_t nedpmalloc_footprint(nedpool *p) THROWSPEC;
EXTSPEC MALLOCATTR void **nedpindependent_calloc(nedpool *p, size_t elemsno, size_t elemsize, void **chunks) THROWSPEC;
EXTSPEC MALLOCATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void **nedpindependent_calloc(nedpool *p, size_t elemsno, size_t elemsize, void **chunks) THROWSPEC;
EXTSPEC NEDMALLOCPTRATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC;
#if defined(__cplusplus)
}
#endif
#undef MALLOCATTR
#undef EXTSPEC
#endif

View file

@ -29,6 +29,10 @@ DEALINGS IN THE SOFTWARE.
#ifdef _MSC_VER
/* Enable full aliasing on MSVC */
/*#pragma optimize("a", on)*/
#pragma warning(push)
#pragma warning(disable:4100) /* unreferenced formal parameter */
#pragma warning(disable:4127) /* conditional expression is constant */
#pragma warning(disable:4706) /* assignment within conditional expression */
#endif
/*#define FULLSANITYCHECKS*/
@ -172,21 +176,21 @@ size_t nedblksize(void *mem) THROWSPEC
#endif
}
void nedsetvalue(void *v) THROWSPEC { nedpsetvalue(0, v); }
void * nedmalloc(size_t size) THROWSPEC { return nedpmalloc(0, size); }
void * nedcalloc(size_t no, size_t size) THROWSPEC { return nedpcalloc(0, no, size); }
void * nedrealloc(void *mem, size_t size) THROWSPEC { return nedprealloc(0, mem, size); }
void nedfree(void *mem) THROWSPEC { nedpfree(0, mem); }
void * nedmemalign(size_t alignment, size_t bytes) THROWSPEC { return nedpmemalign(0, alignment, bytes); }
void nedsetvalue(void *v) THROWSPEC { nedpsetvalue((nedpool *) 0, v); }
NEDMALLOCPTRATTR void * nedmalloc(size_t size) THROWSPEC { return nedpmalloc((nedpool *) 0, size); }
NEDMALLOCPTRATTR void * nedcalloc(size_t no, size_t size) THROWSPEC { return nedpcalloc((nedpool *) 0, no, size); }
NEDMALLOCPTRATTR void * nedrealloc(void *mem, size_t size) THROWSPEC { return nedprealloc((nedpool *) 0, mem, size); }
void nedfree(void *mem) THROWSPEC { nedpfree((nedpool *) 0, mem); }
NEDMALLOCPTRATTR void * nedmemalign(size_t alignment, size_t bytes) THROWSPEC { return nedpmemalign((nedpool *) 0, alignment, bytes); }
#if !NO_MALLINFO
struct mallinfo nedmallinfo(void) THROWSPEC { return nedpmallinfo(0); }
struct mallinfo nedmallinfo(void) THROWSPEC { return nedpmallinfo((nedpool *) 0); }
#endif
int nedmallopt(int parno, int value) THROWSPEC { return nedpmallopt(0, parno, value); }
int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim(0, pad); }
void nedmalloc_stats() THROWSPEC { nedpmalloc_stats(0); }
size_t nedmalloc_footprint() THROWSPEC { return nedpmalloc_footprint(0); }
void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC { return nedpindependent_calloc(0, elemsno, elemsize, chunks); }
void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc(0, elems, sizes, chunks); }
int nedmallopt(int parno, int value) THROWSPEC { return nedpmallopt((nedpool *) 0, parno, value); }
int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim((nedpool *) 0, pad); }
void nedmalloc_stats() THROWSPEC { nedpmalloc_stats((nedpool *) 0); }
size_t nedmalloc_footprint() THROWSPEC { return nedpmalloc_footprint((nedpool *) 0); }
NEDMALLOCPTRATTR void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC { return nedpindependent_calloc((nedpool *) 0, elemsno, elemsize, chunks); }
NEDMALLOCPTRATTR void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc((nedpool *) 0, elems, sizes, chunks); }
struct threadcacheblk_t;
typedef struct threadcacheblk_t threadcacheblk;
@ -654,7 +658,7 @@ else
return p->m[n];
}
nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC
NEDMALLOCPTRATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC
{
nedpool *ret;
if (!(ret=(nedpool *) nedpcalloc(0, 1, sizeof(nedpool)))) return 0;
@ -823,7 +827,7 @@ static FORCEINLINE void GetThreadCache(nedpool **p, threadcache **tc, int *mymsp
#endif
}
void * nedpmalloc(nedpool *p, size_t size) THROWSPEC
NEDMALLOCPTRATTR void * nedpmalloc(nedpool *p, size_t size) THROWSPEC
{
void *ret=0;
threadcache *tc;
@ -842,7 +846,7 @@ void * nedpmalloc(nedpool *p, size_t size) THROWSPEC
}
return ret;
}
void * nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC
NEDMALLOCPTRATTR void * nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC
{
size_t rsize=size*no;
void *ret=0;
@ -863,7 +867,7 @@ void * nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC
}
return ret;
}
void * nedprealloc(nedpool *p, void *mem, size_t size) THROWSPEC
NEDMALLOCPTRATTR void * nedprealloc(nedpool *p, void *mem, size_t size) THROWSPEC
{
void *ret=0;
threadcache *tc;
@ -899,6 +903,12 @@ void nedpfree(nedpool *p, void *mem) THROWSPEC
int mymspace;
size_t memsize;
assert(mem);
if(!mem)
{ /* You'd be surprised the number of times this happens as so many
allocators are non-conformant here */
fprintf(stderr, "nedpfree() called with zero!\n");
abort();
}
GetThreadCache(&p, &tc, &mymspace, 0);
#if THREADCACHEMAX
memsize=nedblksize(mem);
@ -909,18 +919,20 @@ void nedpfree(nedpool *p, void *mem) THROWSPEC
#endif
mspace_free(0, mem);
}
void * nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC
{
void *ret;
threadcache *tc;
int mymspace;
GetThreadCache(&p, &tc, &mymspace, &bytes);
{ /* Use this thread's mspace */
GETMSPACE(m, p, tc, mymspace, bytes,
ret=mspace_memalign(m, alignment, bytes));
}
return ret;
NEDMALLOCPTRATTR void * nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC
{
void *ret;
threadcache *tc;
int mymspace;
GetThreadCache(&p, &tc, &mymspace, &bytes);
{ /* Use this thread's mspace */
GETMSPACE(m, p, tc, mymspace, bytes,
ret=mspace_memalign(m, alignment, bytes));
}
return ret;
}
#if !NO_MALLINFO
struct mallinfo nedpmallinfo(nedpool *p) THROWSPEC
{
@ -976,7 +988,7 @@ size_t nedpmalloc_footprint(nedpool *p) THROWSPEC
}
return ret;
}
void **nedpindependent_calloc(nedpool *p, size_t elemsno, size_t elemsize, void **chunks) THROWSPEC
NEDMALLOCPTRATTR void **nedpindependent_calloc(nedpool *p, size_t elemsno, size_t elemsize, void **chunks) THROWSPEC
{
void **ret;
threadcache *tc;
@ -986,7 +998,7 @@ void **nedpindependent_calloc(nedpool *p, size_t elemsno, size_t elemsize, void
ret=mspace_independent_calloc(m, elemsno, elemsize, chunks));
return ret;
}
void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC
NEDMALLOCPTRATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC
{
void **ret;
threadcache *tc;
@ -1004,3 +1016,7 @@ void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **
#if defined(__cplusplus)
}
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif

View file

@ -292,7 +292,7 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype)
int32_t bg = A_CheckEnemySprite(&sprite[spritenum]);
int32_t daz;
if (sprite[spritenum].statnum == 5 || (bg && sprite[spritenum].xrepeat < 4))
if (sprite[spritenum].statnum == STAT_MISC || (bg && sprite[spritenum].xrepeat < 4))
{
sprite[spritenum].x += (change->x*TICSPERFRAME)>>2;
sprite[spritenum].y += (change->y*TICSPERFRAME)>>2;
@ -363,9 +363,9 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype)
int32_t oz = sprite[spritenum].z;
sprite[spritenum].z = daz;
if (sprite[spritenum].statnum == 4)
if (sprite[spritenum].statnum == STAT_PROJECTILE && (SpriteProjectile[spritenum].workslike & PROJECTILE_REALCLIPDIST) == 0)
retval =
clipmove((vec3_t *)&sprite[spritenum],&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),(int32_t)(sprite[spritenum].clipdist<<2),(4<<8),(4<<8),cliptype);
clipmove((vec3_t *)&sprite[spritenum],&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),8L,(4<<8),(4<<8),cliptype);
else
retval =
clipmove((vec3_t *)&sprite[spritenum],&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),(int32_t)(sprite[spritenum].clipdist<<2),(4<<8),(4<<8),cliptype);
@ -1375,10 +1375,10 @@ static void G_MoveStandables(void)
nextj = nextspritesect[j];
switch (sprite[j].statnum)
{
case 1:
case 2:
case 6:
case 10:
case STAT_ACTOR:
case STAT_ZOMBIEACTOR:
case STAT_STANDABLE:
case STAT_PLAYER:
{
vec3_t vect;
@ -1459,8 +1459,8 @@ static void G_MoveStandables(void)
{
switch (sprite[j].statnum)
{
case 1:
case 6:
case STAT_ACTOR:
case STAT_STANDABLE:
s->owner = j;
break;
}
@ -1966,7 +1966,7 @@ DETONATE:
j = headspritesect[sect];
while (j >= 0)
{
if (sprite[j].statnum == 3)
if (sprite[j].statnum == STAT_EFFECTOR)
{
switch (sprite[j].lotag)
{
@ -1982,7 +1982,7 @@ DETONATE:
break;
}
}
else if (sprite[j].statnum == 6)
else if (sprite[j].statnum == STAT_STANDABLE)
{
switch (DynamicTileMap[sprite[j].picnum])
{
@ -3115,7 +3115,7 @@ static void G_MoveTransports(void)
switch (sprite[j].statnum)
{
case 10: // Player
case STAT_PLAYER:
if (sprite[j].owner != -1)
{
@ -3268,18 +3268,18 @@ static void G_MoveTransports(void)
}
break;
case 4:
case STAT_PROJECTILE:
if (sectlotag != 0) goto JBOLT;
case 1:
case STAT_ACTOR:
if ((sprite[j].picnum == SHARK) || (sprite[j].picnum == COMMANDER) || (sprite[j].picnum == OCTABRAIN)
|| ((sprite[j].picnum >= GREENSLIME) && (sprite[j].picnum <= GREENSLIME+7)))
{
if (sprite[j].extra > 0)
goto JBOLT;
}
case 5:
case 12:
case 13:
case STAT_MISC:
case STAT_FALLER:
case STAT_DUMMYPLAYER:
ll = klabs(sprite[j].zvel);
@ -3294,7 +3294,7 @@ static void G_MoveTransports(void)
if (sectlotag == 0 && (onfloorz || klabs(sprite[j].z-SZ) < 4096))
{
if (sprite[OW].owner != OW && onfloorz && T1 > 0 && sprite[j].statnum != 5)
if (sprite[OW].owner != OW && onfloorz && T1 > 0 && sprite[j].statnum != STAT_MISC)
{
T1++;
goto BOLT;
@ -3325,7 +3325,7 @@ static void G_MoveTransports(void)
break;
}
default:
if (sprite[j].statnum == 5 && !(sectlotag == 1 || sectlotag == 2))
if (sprite[j].statnum == STAT_MISC && !(sectlotag == 1 || sectlotag == 2))
break;
case WATERBUBBLE__STATIC:
@ -3335,7 +3335,7 @@ static void G_MoveTransports(void)
if (sectlotag > 0)
{
k = A_Spawn(j,WATERSPLASH2);
if (sectlotag == 1 && sprite[j].statnum == 4)
if (sectlotag == 1 && sprite[j].statnum == STAT_PROJECTILE)
{
sprite[k].xvel = sprite[j].xvel>>1;
sprite[k].ang = sprite[j].ang;
@ -3348,7 +3348,8 @@ static void G_MoveTransports(void)
case 0:
if (onfloorz)
{
if (sprite[j].statnum == 4 || (G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW].sectnum) == -1))
if (sprite[j].statnum == STAT_PROJECTILE ||
(G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW].sectnum) == -1))
{
sprite[j].x += (sprite[OW].x-SX);
sprite[j].y += (sprite[OW].y-SY);
@ -5508,7 +5509,7 @@ static void G_MoveEffectors(void) //STATNUM 3
p = headspritesect[s->sectnum];
while (p >= 0)
{
if (sprite[p].statnum != 3 && sprite[p].statnum != 4)
if (sprite[p].statnum != STAT_EFFECTOR && sprite[p].statnum != STAT_PROJECTILE)
if (sprite[p].picnum != LASERLINE)
{
if (sprite[p].picnum == APLAYER && sprite[p].owner >= 0)
@ -5709,7 +5710,7 @@ static void G_MoveEffectors(void) //STATNUM 3
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].statnum != 10 && sector[sprite[j].sectnum].lotag != 2 &&
if (sprite[j].statnum != STAT_PLAYER && sector[sprite[j].sectnum].lotag != 2 &&
(sprite[j].picnum != SECTOREFFECTOR ||
(sprite[j].picnum == SECTOREFFECTOR && (sprite[j].lotag == 49||sprite[j].lotag == 50)))
&& sprite[j].picnum != LOCATORS)
@ -5756,7 +5757,8 @@ static void G_MoveEffectors(void) //STATNUM 3
while (j >= 0)
{
l = nextspritesect[j];
if (sprite[j].statnum == 1 && A_CheckEnemySprite(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS)
if (sprite[j].statnum == STAT_ACTOR && A_CheckEnemySprite(&sprite[j]) &&
sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS)
{
k = sprite[j].sectnum;
updatesector(sprite[j].x,sprite[j].y,&k);
@ -5928,7 +5930,8 @@ static void G_MoveEffectors(void) //STATNUM 3
while (j >= 0)
{
l = nextspritesect[j];
if (sprite[j].statnum == 1 && A_CheckEnemySprite(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS)
if (sprite[j].statnum == STAT_ACTOR && A_CheckEnemySprite(&sprite[j]) &&
sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS)
{
// if(sprite[j].sectnum != s->sectnum)
{
@ -6565,7 +6568,7 @@ static void G_MoveEffectors(void) //STATNUM 3
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].statnum == 10 && sprite[j].owner >= 0)
if (sprite[j].statnum == STAT_PLAYER && sprite[j].owner >= 0)
{
p = sprite[j].yvel;
if (numplayers < 2)
@ -6576,7 +6579,7 @@ static void G_MoveEffectors(void) //STATNUM 3
if (numplayers > 1)
g_player[p].ps->oposz = g_player[p].ps->posz;
}
if (sprite[j].statnum != 3)
if (sprite[j].statnum != STAT_EFFECTOR)
{
ActorExtra[j].bposz = sprite[j].z;
sprite[j].z += q;
@ -6624,7 +6627,7 @@ static void G_MoveEffectors(void) //STATNUM 3
{
nextk = nextspritesect[k];
if (sprite[k].statnum == 10 && sprite[k].owner >= 0)
if (sprite[k].statnum == STAT_PLAYER && sprite[k].owner >= 0)
{
p = sprite[k].yvel;
@ -6646,7 +6649,7 @@ static void G_MoveEffectors(void) //STATNUM 3
changespritesect(k,sprite[j].sectnum);
g_player[p].ps->cursectnum = sprite[j].sectnum;
}
else if (sprite[k].statnum != 3)
else if (sprite[k].statnum != STAT_EFFECTOR)
{
sprite[k].x +=
sprite[j].x-s->x;
@ -6694,7 +6697,7 @@ static void G_MoveEffectors(void) //STATNUM 3
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (g_player[sprite[j].yvel].ps->on_ground == 1)
g_player[sprite[j].yvel].ps->posz += sc->extra;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE)
{
ActorExtra[j].bposz = sprite[j].z += sc->extra;
ActorExtra[j].floorz = sc->floorz;
@ -6728,7 +6731,7 @@ static void G_MoveEffectors(void) //STATNUM 3
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (g_player[sprite[j].yvel].ps->on_ground == 1)
g_player[sprite[j].yvel].ps->posz -= sc->extra;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE)
{
ActorExtra[j].bposz = sprite[j].z -= sc->extra;
ActorExtra[j].floorz = sc->floorz;
@ -6874,13 +6877,13 @@ static void G_MoveEffectors(void) //STATNUM 3
{
nextj = nextspritesect[j];
if (sprite[j].statnum != 3 && sprite[j].zvel == 0)
if (sprite[j].statnum != STAT_EFFECTOR && sprite[j].zvel == 0)
{
sprite[j].x += x;
sprite[j].y += l;
setsprite(j,(vec3_t *)&sprite[j]);
if (sector[sprite[j].sectnum].floorstat&2)
if (sprite[j].statnum == 2)
if (sprite[j].statnum == STAT_ZOMBIEACTOR)
A_Fall(j);
}
j = nextj;
@ -6967,7 +6970,7 @@ static void G_MoveEffectors(void) //STATNUM 3
if (sprite[j].zvel >= 0)
switch (sprite[j].statnum)
{
case 5:
case STAT_MISC:
switch (DynamicTileMap[sprite[j].picnum])
{
case BLOODPOOL__STATIC:
@ -6988,10 +6991,10 @@ static void G_MoveEffectors(void) //STATNUM 3
j = nextj;
continue;
}
case 6:
case STAT_STANDABLE:
if (sprite[j].picnum == TRIPBOMB) break;
case 1:
case 0:
case STAT_ACTOR:
case STAT_DEFAULT:
if (
sprite[j].picnum == BOLT1 ||
sprite[j].picnum == BOLT1+1 ||
@ -7018,7 +7021,7 @@ static void G_MoveEffectors(void) //STATNUM 3
setsprite(j,(vec3_t *)&sprite[j]);
if (sector[sprite[j].sectnum].floorstat&2)
if (sprite[j].statnum == 2)
if (sprite[j].statnum == STAT_ZOMBIEACTOR)
A_Fall(j);
}
}
@ -7117,7 +7120,7 @@ static void G_MoveEffectors(void) //STATNUM 3
while (j >= 0)
{
nextj = nextspritesect[j];
if (sprite[j].statnum != 3 && sprite[j].statnum != 10)
if (sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PLAYER)
{
ActorExtra[j].bposx = sprite[j].x;
ActorExtra[j].bposy = sprite[j].y;
@ -7323,7 +7326,7 @@ static void G_MoveEffectors(void) //STATNUM 3
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (g_player[sprite[j].yvel].ps->on_ground == 1)
g_player[sprite[j].yvel].ps->posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE)
{
ActorExtra[j].bposz = sprite[j].z += l;
ActorExtra[j].floorz = sc->floorz;
@ -7353,7 +7356,7 @@ static void G_MoveEffectors(void) //STATNUM 3
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (g_player[sprite[j].yvel].ps->on_ground == 1)
g_player[sprite[j].yvel].ps->posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE)
{
ActorExtra[j].bposz = sprite[j].z += l;
ActorExtra[j].floorz = sc->floorz;
@ -7385,7 +7388,7 @@ static void G_MoveEffectors(void) //STATNUM 3
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (g_player[sprite[j].yvel].ps->on_ground == 1)
g_player[sprite[j].yvel].ps->posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE)
{
ActorExtra[j].bposz = sprite[j].z += l;
ActorExtra[j].floorz = sc->floorz;
@ -7414,7 +7417,7 @@ static void G_MoveEffectors(void) //STATNUM 3
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (g_player[sprite[j].yvel].ps->on_ground == 1)
g_player[sprite[j].yvel].ps->posz -= l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE)
{
ActorExtra[j].bposz = sprite[j].z -= l;
ActorExtra[j].floorz = sc->floorz;

View file

@ -970,7 +970,8 @@ enum ProjectileFlags_t {
PROJECTILE_RPG_IMPACT = 32768,
PROJECTILE_RADIUS_PICNUM = 65536,
PROJECTILE_ACCURATE_AUTOAIM = 131072,
PROJECTILE_FORCEIMPACT = 262144
PROJECTILE_FORCEIMPACT = 262144,
PROJECTILE_REALCLIPDIST = 524288,
};
extern projectile_t ProjectileData[MAXTILES], DefaultProjectileData[MAXTILES], SpriteProjectile[MAXSPRITES];

View file

@ -35,8 +35,8 @@ extern void S_MenuSound(void);
extern int32_t S_PlayMusic(const char *fn, const int32_t sel);
extern void S_StopMusic(void);
extern void S_PauseMusic(int32_t);
extern int32_t S_LoadSound(unsigned num);
extern int32_t S_PlaySoundXYZ(int32_t num,int32_t i,const vec3_t *pos);
extern int32_t S_LoadSound(uint32_t num);
extern int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos);
extern int32_t S_PlaySound(int32_t num);
extern int32_t A_PlaySound(uint32_t num,int32_t i);
extern void S_StopSound(int32_t num);
@ -254,18 +254,12 @@ extern int32_t SpriteFlags[MAXTILES];
static inline int32_t G_GetTeamPalette(int32_t team)
{
switch (team)
{
case 0:
return 3;
case 1:
return 10;
case 2:
return 11;
case 3:
return 12;
}
return 0;
int8_t pal[] = { 3, 10, 11, 12 };
if (team > (int32_t)(sizeof(pal)/sizeof(pal[0])) || team < 0)
return 0;
return pal[team];
}
extern inline void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority);

View file

@ -4951,7 +4951,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
else
{
if (sprite[j].statnum == 4)
if (sprite[j].statnum == STAT_PROJECTILE)
{
sp->xrepeat = 8;
sp->yrepeat = 8;
@ -4960,7 +4960,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
{
sp->xrepeat = 48;
sp->yrepeat = 64;
if (sprite[j].statnum == 10 || A_CheckEnemySprite(&sprite[j]))
if (sprite[j].statnum == STAT_PLAYER || A_CheckEnemySprite(&sprite[j]))
sp->z -= (32<<8);
}
}
@ -5608,7 +5608,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
case WATERDRIP__STATIC:
if (j >= 0 && (sprite[j].statnum == 10 || sprite[j].statnum == 1))
if (j >= 0 && (sprite[j].statnum == STAT_PLAYER || sprite[j].statnum == STAT_ACTOR))
{
sp->shade = 32;
if (sprite[j].pal != 1)
@ -6725,7 +6725,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio)
//case GREENSLIME+7:
// break;
default:
if (((t->cstat&16)) || (A_CheckEnemySprite(t) && t->extra > 0) || t->statnum == 10)
if (((t->cstat&16)) || (A_CheckEnemySprite(t) && t->extra > 0) || t->statnum == STAT_PLAYER)
continue;
}
@ -6832,14 +6832,15 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio)
}
if (t->statnum == TSPR_TEMP) continue;
if (s->statnum != 1 && s->picnum == APLAYER && g_player[s->yvel].ps->newowner == -1 && s->owner >= 0)
if (s->statnum != STAT_ACTOR && s->picnum == APLAYER && g_player[s->yvel].ps->newowner == -1 && s->owner >= 0)
{
t->x -= mulscale16(65536-smoothratio,g_player[s->yvel].ps->posx-g_player[s->yvel].ps->oposx);
t->y -= mulscale16(65536-smoothratio,g_player[s->yvel].ps->posy-g_player[s->yvel].ps->oposy);
t->z += /*g_player[s->yvel].ps->oposz +*/ mulscale16(smoothratio,g_player[s->yvel].ps->posz-g_player[s->yvel].ps->oposz) - PHEIGHT;
t->z += (40<<8);
}
else if ((s->statnum == 0 && s->picnum != CRANEPOLE) || s->statnum == 10 || s->statnum == 6 || s->statnum == 4 || s->statnum == 5 || s->statnum == 1)
else if ((s->statnum == STAT_DEFAULT && s->picnum != CRANEPOLE) || s->statnum == STAT_PLAYER ||
s->statnum == STAT_STANDABLE || s->statnum == STAT_PROJECTILE || s->statnum == STAT_MISC || s->statnum == STAT_ACTOR)
{
t->x -= mulscale16(65536-smoothratio,s->x-ActorExtra[i].bposx);
t->y -= mulscale16(65536-smoothratio,s->y-ActorExtra[i].bposy);
@ -6905,7 +6906,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio)
continue;
case BURNING__STATIC:
case BURNING2__STATIC:
if (sprite[s->owner].statnum == 10)
if (sprite[s->owner].statnum == STAT_PLAYER)
{
if (display_mirror == 0 && sprite[s->owner].yvel == screenpeek && g_player[sprite[s->owner].yvel].ps->over_shoulder_on == 0)
t->xrepeat = 0;
@ -7318,13 +7319,13 @@ PALONLY:
}
if (g_player[screenpeek].ps->heat_amount > 0 && g_player[screenpeek].ps->heat_on &&
(A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SPRITE_NVG) || s->picnum == APLAYER || s->statnum == 13))
(A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SPRITE_NVG) || s->picnum == APLAYER || s->statnum == STAT_DUMMYPLAYER))
{
t->pal = 6;
t->shade = 0;
}
if (s->statnum == 13 || A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SPRITE_SHADOW) || (s->picnum == APLAYER && s->owner >= 0))
if (s->statnum == STAT_DUMMYPLAYER || A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SPRITE_SHADOW) || (s->picnum == APLAYER && s->owner >= 0))
if (t->statnum != TSPR_TEMP && s->picnum != EXPLOSION2 && s->picnum != HANGLIGHT && s->picnum != DOMELITE)
if (s->picnum != HOTMEAT)
{
@ -7337,7 +7338,7 @@ PALONLY:
{
int32_t daz,xrep,yrep;
if ((sector[sect].lotag&0xff) > 2 || s->statnum == 4 || s->statnum == 5 || s->picnum == DRONE || s->picnum == COMMANDER)
if ((sector[sect].lotag&0xff) > 2 || s->statnum == STAT_PROJECTILE || s->statnum == 5 || s->picnum == DRONE || s->picnum == COMMANDER)
daz = sector[sect].floorz;
else
daz = ActorExtra[i].floorz;
@ -8318,8 +8319,7 @@ static void G_HandleLocalKeys(void)
if (ud.multimode > 1 && BUTTON(gamefunc_Show_Opponents_Weapon))
{
CONTROL_ClearButton(gamefunc_Show_Opponents_Weapon);
ud.showweapons = 1-ud.showweapons;
ud.config.ShowOpponentWeapons = ud.showweapons;
ud.config.ShowOpponentWeapons = ud.showweapons = 1-ud.showweapons;
P_DoQuote(82-ud.showweapons,g_player[screenpeek].ps);
}
@ -8327,9 +8327,7 @@ static void G_HandleLocalKeys(void)
{
CONTROL_ClearButton(gamefunc_Toggle_Crosshair);
ud.crosshair = !ud.crosshair;
if (ud.crosshair)
P_DoQuote(20,g_player[screenpeek].ps);
else P_DoQuote(21,g_player[screenpeek].ps);
P_DoQuote(21-ud.crosshair,g_player[screenpeek].ps);
}
if (ud.overhead_on && BUTTON(gamefunc_Map_Follow_Mode))
@ -8348,57 +8346,18 @@ static void G_HandleLocalKeys(void)
if (SHIFTS_IS_PRESSED || ALT_IS_PRESSED)
{
i = 0;
if (KB_UnBoundKeyPressed(sc_F1))
{
KB_ClearKeyDown(sc_F1);
i = 1;
}
if (KB_UnBoundKeyPressed(sc_F2))
{
KB_ClearKeyDown(sc_F2);
i = 2;
}
if (KB_UnBoundKeyPressed(sc_F3))
{
KB_ClearKeyDown(sc_F3);
i = 3;
}
if (KB_UnBoundKeyPressed(sc_F4))
{
KB_ClearKeyDown(sc_F4);
i = 4;
}
if (KB_UnBoundKeyPressed(sc_F5))
{
KB_ClearKeyDown(sc_F5);
i = 5;
}
if (KB_UnBoundKeyPressed(sc_F6))
{
KB_ClearKeyDown(sc_F6);
i = 6;
}
if (KB_UnBoundKeyPressed(sc_F7))
{
KB_ClearKeyDown(sc_F7);
i = 7;
}
if (KB_UnBoundKeyPressed(sc_F8))
{
KB_ClearKeyDown(sc_F8);
i = 8;
}
if (KB_UnBoundKeyPressed(sc_F9))
{
KB_ClearKeyDown(sc_F9);
i = 9;
}
if (KB_UnBoundKeyPressed(sc_F10))
{
KB_ClearKeyDown(sc_F10);
i = 10;
}
j = sc_F1;
do
{
if (KB_UnBoundKeyPressed(j))
{
KB_ClearKeyDown(j);
i = j - sc_F1 + 1;
}
}
while (++j < sc_F11);
if (i)
{
if (SHIFTS_IS_PRESSED)
@ -8859,193 +8818,6 @@ static void G_ShowDebugHelp(void)
#endif
}
#ifndef RANCID_NETWORKING
static int32_t rancid_players = 0;
static char rancid_ip_strings[MAXPLAYERS][32], rancid_local_port_string[8];
extern int32_t getexternaladdress(char *buffer, const char *host, int32_t port);
static int32_t load_rancid_net(const char *fn)
{
int32_t tokn;
char *cmdtokptr;
tokenlist rancidtokens[] =
{
{ "interface", T_INTERFACE },
{ "mode", T_MODE },
{ "allow", T_ALLOW },
};
scriptfile *script;
script = scriptfile_fromfile((char *)fn);
if (!script) return -1;
while (1)
{
tokn = getatoken(script,rancidtokens,sizeof(rancidtokens)/sizeof(tokenlist));
cmdtokptr = script->ltextptr;
switch (tokn)
{
case T_INTERFACE:
{
char *ip;
if (scriptfile_getstring(script,&ip)) break;
Bstrcpy(rancid_ip_strings[MAXPLAYERS-1],ip);
Bstrcpy(rancid_ip_strings[rancid_players++],ip);
if (strtok(ip,":"))
{
char *p = strtok(NULL,":");
if (p != NULL)
{
if (atoi(p) > 1024)
Bsprintf(rancid_local_port_string,"-p %s",p);
}
}
}
break;
case T_MODE:
{
char *mode;
if (scriptfile_getstring(script,&mode)) break;
}
break;
case T_ALLOW:
{
char *ip;
if (scriptfile_getstring(script,&ip)) break;
Bstrcpy(rancid_ip_strings[rancid_players++],ip);
}
break;
case T_EOF:
return(0);
default:
break;
}
}
scriptfile_close(script);
scriptfile_clearsymbols();
return 0;
}
static inline int32_t stringsort(const char *p1, const char *p2)
{
return Bstrcmp(&p1[0],&p2[0]);
}
// Not supported with the enet network backend currently
static void setup_rancid_net(const char *fn)
{
int32_t i;
if (load_rancid_net(fn) != -1)
{
char tmp[32];
if (!Bstrlen(rancid_ip_strings[MAXPLAYERS-1])||!Bstrlen(rancid_ip_strings[1]))
{
if (!Bstrlen(rancid_ip_strings[MAXPLAYERS-1]))
initprintf("rmnet: Interface not defined!\n");
if (!Bstrlen(rancid_ip_strings[1]))
initprintf("rmnet: No peers configured!\n");
G_GameExit("Malformed network configuration file!");
return;
}
if (g_keepAddr == 0)
{
for (i=0; i<rancid_players; i++)
{
if (Bstrcmp(rancid_ip_strings[i],rancid_ip_strings[MAXPLAYERS-1]))
{
Bstrncpy(tempbuf,rancid_ip_strings[i], 8);
Bstrcpy(tmp,strtok(tempbuf,"."));
if (Bstrcmp(tmp,"10") == 0)
{
i = 0;
break;
}
else if (Bstrcmp(tmp,"192") == 0)
{
Bstrcpy(tmp,strtok(NULL,"."));
if (Bstrcmp(tmp,"168") == 0)
{
i = 0;
break;
}
}
else if (Bstrcmp(tmp,"172") == 0)
{
Bstrcpy(tmp,strtok(NULL,"."));
if (Bstrcmp(tmp,"16") == 0)
{
i = 0;
break;
}
}
else if (Bstrcmp(tmp,"169") == 0)
{
Bstrcpy(tmp,strtok(NULL,"."));
if (Bstrcmp(tmp,"254") == 0)
{
i = 0;
break;
}
}
}
}
Bstrcpy(tempbuf,rancid_ip_strings[MAXPLAYERS-1]);
Bstrcpy(tmp,strtok(tempbuf,"."));
if (i == rancid_players && ((Bstrcmp(tmp,"192") == 0) || (Bstrcmp(tmp,"172") == 0) || (Bstrcmp(tmp,"169") == 0) || (Bstrcmp(tmp,"10") == 0)))
{
int32_t ii = getexternaladdress(tempbuf, "checkip.dyndns.org", 8245);
if (!ii) ii = getexternaladdress(tempbuf, "checkip.dyndns.org", 80);
if (ii)
{
if (tempbuf[0])
{
for (i=0; i<rancid_players; i++)
{
if (Bstrcmp(rancid_ip_strings[i],rancid_ip_strings[MAXPLAYERS-1]) == 0)
{
Bstrcpy(rancid_ip_strings[MAXPLAYERS-1],tempbuf);
Bstrcpy(rancid_ip_strings[i],tempbuf);
}
}
}
}
else initprintf("rmnet: Unable to get external interface address! Expect problems...\n");
}
}
qsort((char *)rancid_ip_strings, rancid_players, sizeof(rancid_ip_strings[0]), (int32_t(*)(const void*,const void*))stringsort);
g_networkBroadcastMode = 1;
netparamcount = rancid_players;
if (rancid_local_port_string[0] == '-')
netparamcount++;
netparam = (char **)Bcalloc(netparamcount, sizeof(char **));
for (i=0; i<rancid_players; i++)
{
if (Bstrcmp(rancid_ip_strings[i],rancid_ip_strings[MAXPLAYERS-1]) == 0)
Bsprintf(rancid_ip_strings[i],"/n1");
netparam[i] = (char *)&rancid_ip_strings[i];
}
if (i != netparamcount)
netparam[i] = (char *)&rancid_local_port_string;
}
}
#endif
static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *findfileshigh=NULL;
static int32_t numdirs=0, numfiles=0;
static int32_t currentlist=0;
@ -12171,7 +11943,7 @@ static void Net_DoPrediction(void)
if (hz >= 0 && (hz&49152) == 49152)
{
hz &= (MAXSPRITES-1);
if (sprite[hz].statnum == 1 && sprite[hz].extra >= 0)
if (sprite[hz].statnum == STAT_ACTOR && sprite[hz].extra >= 0)
{
hz = 0;
cz = getceilzofslope(psect,my.x,my.y);

View file

@ -271,14 +271,14 @@ void A_GetZLimits(int32_t iActor)
{
spritetype *s = &sprite[iActor];
if (s->statnum == 10 || s->statnum == 6 || s->statnum == 2 || s->statnum == 1 || s->statnum == 4)
if (s->statnum == STAT_PLAYER || s->statnum == STAT_STANDABLE || s->statnum == STAT_ZOMBIEACTOR || s->statnum == STAT_ACTOR || s->statnum == STAT_PROJECTILE)
{
int32_t hz,lz,zr = 127L;
int32_t cstat = s->cstat;
s->cstat = 0;
if (s->statnum == 4)
if (s->statnum == STAT_PROJECTILE)
zr = 4L;
s->z -= FOURSLEIGHT;
@ -305,7 +305,7 @@ void A_GetZLimits(int32_t iActor)
s->xvel = -256;
A_SetSprite(iActor,CLIPMASK0);
}
else if (s->statnum == 4 && sprite[lz].picnum == APLAYER)
else if (s->statnum == STAT_PROJECTILE && sprite[lz].picnum == APLAYER)
if (s->owner == lz)
{
ActorExtra[iActor].ceilingz = sector[s->sectnum].ceilingz;
@ -333,7 +333,7 @@ void A_Fall(int32_t iActor)
c = g_spriteGravity/6;
}
if ((s->statnum == 1 || s->statnum == 10 || s->statnum == 2 || s->statnum == 6))
if ((s->statnum == STAT_ACTOR || s->statnum == STAT_PLAYER || s->statnum == STAT_ZOMBIEACTOR || s->statnum == STAT_STANDABLE))
{
int32_t cstat = s->cstat;
s->cstat = 0;
@ -845,7 +845,7 @@ skip_check:
ActorExtra[vm.g_i].lastvy = s->y;
}
if (j && (vm.g_sp->statnum == 1 || vm.g_sp->statnum == 6))
if (j && (vm.g_sp->statnum == STAT_ACTOR || vm.g_sp->statnum == STAT_STANDABLE))
ActorExtra[vm.g_i].timetosleep = SLEEPTIME;
X_DoConditional(j);
@ -4766,7 +4766,7 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist)
}
}
*/
if (vm.g_sp->statnum == 6)
if (vm.g_sp->statnum == STAT_STANDABLE)
switch (DynamicTileMap[vm.g_sp->picnum])
{
case RUBBERCAN__STATIC:

View file

@ -134,7 +134,6 @@ const char *SDLDrv_ErrorString( int32_t ErrorNumber )
int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void * initdata)
{
// uint32_t inited;
int32_t err = 0;
int32_t chunksize;
uint16_t fmt;
@ -146,41 +145,23 @@ int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *sampleb
SDLDrv_PCM_Shutdown();
}
/*
inited = SDL_WasInit(SDL_INIT_EVERYTHING);
if (inited == 0) {
// nothing was initialised
err = SDL_Init(SDL_INIT_AUDIO);
StartedSDL = 0;
} else if (inited & SDL_INIT_AUDIO) {
err = SDL_InitSubSystem(SDL_INIT_AUDIO);
StartedSDL = 1;
}
if (err < 0) {
ErrorCode = SDLErr_InitSubSystem;
return SDLErr_Error;
}
*/
chunksize = 512;
if (*mixrate >= 16000) chunksize *= 2;
if (*mixrate >= 32000) chunksize *= 2;
// allocate 4 channels: 2 for the game's SFX, 1 for music, and 1 for fillData()
err = Mix_OpenAudio(*mixrate, (*samplebits == 8) ? AUDIO_U8 : AUDIO_S16SYS, 4, chunksize);
err = Mix_OpenAudio(*mixrate, (*samplebits == 8) ? AUDIO_U8 : AUDIO_S16SYS, *numchannels, chunksize);
if (err < 0) {
ErrorCode = SDLErr_OpenAudio;
return SDLErr_Error;
}
Mix_QuerySpec(mixrate, &fmt, numchannels);
if (fmt == AUDIO_U8) *samplebits = 8;
else *samplebits = 16;
if (Mix_QuerySpec(mixrate, &fmt, numchannels))
{
if (fmt == AUDIO_U8 || fmt == AUDIO_S8) *samplebits = 8;
else *samplebits = 16;
}
//Mix_SetPostMix(fillData, NULL);
@ -202,45 +183,24 @@ int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *sampleb
void SDLDrv_PCM_Shutdown(void)
{
if (!Initialised) {
if (!Initialised)
return;
else Mix_HaltChannel(-1);
if (DummyChunk != NULL)
{
Mix_FreeChunk(DummyChunk);
DummyChunk = NULL;
}
// if (StartedSDL > 0) {
if (Initialised)
{
Mix_HaltChannel(-1);
}
if (DummyChunk != NULL)
{
Mix_FreeChunk(DummyChunk);
DummyChunk = NULL;
}
if (DummyBuffer != NULL)
{
free(DummyBuffer);
DummyBuffer = NULL;
}
if (Initialised)
{
Mix_CloseAudio();
Initialised = 0;
}
/*
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
else if (StartedSDL == 0) {
SDL_Quit();
if (DummyBuffer != NULL)
{
free(DummyBuffer);
DummyBuffer = NULL;
}
StartedSDL = -1;
*/
Mix_CloseAudio();
Initialised = 0;
}
int32_t SDLDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,

View file

@ -977,17 +977,25 @@ int32_t FX_PlayAuto(char *ptr, uint32_t length, int32_t pitchoffset, int32_t vol
{
int32_t handle = -1;
if (!memcmp("Creative Voice File\x1a", ptr, 20))
switch (*(int32_t *)ptr)
{
case 'C'+('r'<<8)+('e'<<16)+('a'<<24):
handle = MV_PlayVOC(ptr, length, pitchoffset, vol, left, right, priority, callbackval);
}
else if (!memcmp("RIFF", ptr, 4) && !memcmp("WAVE", ptr + 8, 4))
{
break;
case 'R'+('I'<<8)+('F'<<16)+('F'<<24):
handle = MV_PlayWAV(ptr, length, pitchoffset, vol, left, right, priority, callbackval);
}
else if (!memcmp("OggS", ptr, 4))
{
break;
case 'O'+('g'<<8)+('g'<<16)+('S'<<24):
handle = MV_PlayVorbis(ptr, length, pitchoffset, vol, left, right, priority, callbackval);
break;
default:
switch (*(int32_t *)(ptr + 8))
{
case 'W'+('A'<<8)+('V'<<16)+('E'<<24):
handle = MV_PlayWAV(ptr, length, pitchoffset, vol, left, right, priority, callbackval);
break;
}
break;
}
if (handle < MV_Ok)
@ -1010,22 +1018,28 @@ int32_t FX_PlayLoopedAuto(char *ptr, uint32_t length, int32_t loopstart, int32_t
{
int32_t handle = -1;
if (!memcmp("Creative Voice File\x1a", ptr, 20))
switch (*(int32_t *)ptr)
{
handle = MV_PlayLoopedVOC(ptr, length, loopstart, loopend, pitchoffset,
vol, left, right, priority, callbackval);
}
else if (!memcmp("RIFF", ptr, 4) && !memcmp("WAVE", ptr + 8, 4))
{
handle = MV_PlayLoopedWAV(ptr, length, loopstart, loopend, pitchoffset,
vol, left, right, priority, callbackval);
}
else if (!memcmp("OggS", ptr, 4))
{
handle = MV_PlayLoopedVorbis(ptr, length, loopstart, loopend, pitchoffset,
vol, left, right, priority, callbackval);
case 'C'+('r'<<8)+('e'<<16)+('a'<<24):
handle = MV_PlayLoopedVOC(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval);
break;
case 'R'+('I'<<8)+('F'<<16)+('F'<<24):
handle = MV_PlayLoopedWAV(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval);
break;
case 'O'+('g'<<8)+('g'<<16)+('S'<<24):
handle = MV_PlayLoopedVorbis(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval);
break;
default:
switch (*(int32_t *)(ptr + 8))
{
case 'W'+('A'<<8)+('V'<<16)+('E'<<24):
handle = MV_PlayLoopedWAV(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval);
break;
}
break;
}
if (handle < MV_Ok)
{
FX_SetErrorCode(FX_MultiVocError);
@ -1045,17 +1059,25 @@ int32_t FX_PlayAuto3D(char *ptr, uint32_t length, int32_t pitchoffset, int32_t a
{
int32_t handle = -1;
if (!memcmp("Creative Voice File\x1a", ptr, 20))
switch (*(int32_t *)ptr)
{
case 'C'+('r'<<8)+('e'<<16)+('a'<<24): // Crea
handle = MV_PlayVOC3D(ptr, length, pitchoffset, angle, distance, priority, callbackval);
}
else if (!memcmp("RIFF", ptr, 4) && !memcmp("WAVE", ptr + 8, 4))
{
break;
case 'R'+('I'<<8)+('F'<<16)+('F'<<24): // RIFF
handle = MV_PlayWAV3D(ptr, length, pitchoffset, angle, distance, priority, callbackval);
}
else if (!memcmp("OggS", ptr, 4))
{
break;
case 'O'+('g'<<8)+('g'<<16)+('S'<<24): // OggS
handle = MV_PlayVorbis3D(ptr, length, pitchoffset, angle, distance, priority, callbackval);
break;
default:
switch (*(int32_t *)(ptr + 8))
{
case 'W'+('A'<<8)+('V'<<16)+('E'<<24): // WAVE
handle = MV_PlayWAV3D(ptr, length, pitchoffset, angle, distance, priority, callbackval);
break;
}
break;
}
if (handle < MV_Ok)

View file

@ -687,7 +687,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
zvel<<6,&hitinfo,CLIPMASK1);
if (hitinfo.hitsprite != -1)
{
if (sprite[hitinfo.hitsprite].statnum == 1 || sprite[hitinfo.hitsprite].statnum == 2 || sprite[hitinfo.hitsprite].statnum == 10 || sprite[hitinfo.hitsprite].statnum == 13)
if (sprite[hitinfo.hitsprite].statnum == STAT_ACTOR || sprite[hitinfo.hitsprite].statnum == STAT_ZOMBIEACTOR || sprite[hitinfo.hitsprite].statnum == STAT_PLAYER || sprite[hitinfo.hitsprite].statnum == STAT_DUMMYPLAYER)
j = hitinfo.hitsprite;
}
}
@ -962,7 +962,7 @@ DOSKIPBULLETHOLE:
if ((krand()&255) < 4)
if (ProjectileData[atwith].isound >= 0)
{
S_PlaySoundXYZ(ProjectileData[atwith].isound,k,&hitinfo.pos);
S_PlaySound3D(ProjectileData[atwith].isound,k,&hitinfo.pos);
}
return -1;
@ -1275,7 +1275,7 @@ DOSKIPBULLETHOLE:
zvel<<6,&hitinfo,CLIPMASK1);
if (hitinfo.hitsprite != -1)
{
if (sprite[hitinfo.hitsprite].statnum == 1 || sprite[hitinfo.hitsprite].statnum == 2 || sprite[hitinfo.hitsprite].statnum == 10 || sprite[hitinfo.hitsprite].statnum == 13)
if (sprite[hitinfo.hitsprite].statnum == STAT_ACTOR || sprite[hitinfo.hitsprite].statnum == STAT_ZOMBIEACTOR || sprite[hitinfo.hitsprite].statnum == STAT_PLAYER || sprite[hitinfo.hitsprite].statnum == STAT_DUMMYPLAYER)
j = hitinfo.hitsprite;
}
}
@ -1499,7 +1499,7 @@ SKIPBULLETHOLE:
}
if ((krand()&255) < 4)
S_PlaySoundXYZ(PISTOL_RICOCHET,k, &hitinfo.pos);
S_PlaySound3D(PISTOL_RICOCHET,k, &hitinfo.pos);
return -1;
@ -3880,7 +3880,7 @@ void P_ProcessInput(int32_t snum)
{
hz &= (MAXSPRITES-1);
if (sprite[hz].statnum == 1 && sprite[hz].extra >= 0)
if (sprite[hz].statnum == STAT_ACTOR && sprite[hz].extra >= 0)
{
hz = 0;
cz = p->truecz;

View file

@ -1471,17 +1471,17 @@ int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchtype)
if (picnum == ALIENSWITCH || picnum == ALIENSWITCH+1)
{
if (switchtype == 1)
S_PlaySoundXYZ(ALIEN_SWITCH1, w, &davector);
else S_PlaySoundXYZ(ALIEN_SWITCH1,g_player[snum].ps->i,&davector);
S_PlaySound3D(ALIEN_SWITCH1, w, &davector);
else S_PlaySound3D(ALIEN_SWITCH1,g_player[snum].ps->i,&davector);
}
else
{
if (switchtype == 1)
S_PlaySoundXYZ(SWITCH_ON, w, &davector);
else S_PlaySoundXYZ(SWITCH_ON,g_player[snum].ps->i,&davector);
S_PlaySound3D(SWITCH_ON, w, &davector);
else S_PlaySound3D(SWITCH_ON,g_player[snum].ps->i,&davector);
}
if (numdips != correctdips) break;
S_PlaySoundXYZ(END_OF_LEVEL_WARN,g_player[snum].ps->i,&davector);
S_PlaySound3D(END_OF_LEVEL_WARN,g_player[snum].ps->i,&davector);
}
case DIPSWITCH2__STATIC:
//case DIPSWITCH2+1:
@ -1561,13 +1561,13 @@ int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchtype)
if (hitag == 0 && CheckDoorTile(picnum) == 0)
{
if (switchtype == 1)
S_PlaySoundXYZ(SWITCH_ON,w,&davector);
else S_PlaySoundXYZ(SWITCH_ON,g_player[snum].ps->i,&davector);
S_PlaySound3D(SWITCH_ON,w,&davector);
else S_PlaySound3D(SWITCH_ON,g_player[snum].ps->i,&davector);
}
else if (hitag != 0)
{
if (switchtype == 1 && (g_sounds[hitag].m&4) == 0)
S_PlaySoundXYZ(hitag,w,&davector);
S_PlaySound3D(hitag,w,&davector);
else A_PlaySound(hitag,g_player[snum].ps->i);
}
@ -2315,7 +2315,7 @@ void A_DamageObject(int32_t i,int32_t sn)
case PLAYERONWATER__STATIC:
i = OW;
default:
if ((sprite[i].cstat&16) && SHT == 0 && SLT == 0 && sprite[i].statnum == 0)
if ((sprite[i].cstat&16) && SHT == 0 && SLT == 0 && sprite[i].statnum == STAT_DEFAULT)
break;
if ((sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != 4)
@ -2362,7 +2362,7 @@ void A_DamageObject(int32_t i,int32_t sn)
}
}
if (sprite[i].statnum == 2)
if (sprite[i].statnum == STAT_ZOMBIEACTOR)
{
changespritestat(i, STAT_ACTOR);
ActorExtra[i].timetosleep = SLEEPTIME;
@ -2370,7 +2370,7 @@ void A_DamageObject(int32_t i,int32_t sn)
if ((RX < 24 || PN == SHARK) && sprite[sn].picnum == SHRINKSPARK) return;
}
if (sprite[i].statnum != 2)
if (sprite[i].statnum != STAT_ZOMBIEACTOR)
{
if (sprite[sn].picnum == FREEZEBLAST && ((PN == APLAYER && sprite[i].pal == 1) || (g_freezerSelfDamage == 0 && sprite[sn].owner == i)))
return;
@ -2381,7 +2381,7 @@ void A_DamageObject(int32_t i,int32_t sn)
ActorExtra[i].owner = sprite[sn].owner;
}
if (sprite[i].statnum == 10)
if (sprite[i].statnum == STAT_PLAYER)
{
p = sprite[i].yvel;
if (g_player[p].ps->newowner >= 0)
@ -2670,7 +2670,7 @@ CHECKINV1:
X_OnEvent(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, -1);
dainv=aGameVars[g_iReturnVarID].val.lValue;
}
if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right
else if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right
{
/*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/
aGameVars[g_iReturnVarID].val.lValue = dainv;
@ -2678,11 +2678,15 @@ CHECKINV1:
dainv=aGameVars[g_iReturnVarID].val.lValue;
}
p->inven_icon = dainv;
if (dainv > -1)
{
static const int32_t i[8] = { 3, 90, 91, 88, 101, 89, 6, 0 };
P_DoQuote(i[dainv], p);
p->inven_icon = dainv;
if (dainv || p->firstaid_amount)
{
static const int32_t i[8] = { 3, 90, 91, 88, 101, 89, 6, 0 };
P_DoQuote(i[dainv], p);
}
}
}

View file

@ -58,31 +58,17 @@ void S_SoundStartup(void)
int32_t fxdevicetype;
void * initdata = 0;
// if they chose None lets return
if (ud.config.FXDevice < 0)
{
return;
}
else if (ud.config.FXDevice == 0)
{
if (ud.config.FXDevice >= 0)
fxdevicetype = ASS_AutoDetect;
}
else
{
fxdevicetype = ud.config.FXDevice - 1;
}
else return;
#ifdef WIN32
initdata = (void *) win_gethwnd();
#endif
initprintf("Initializing sound...\n");
status = FX_Init(fxdevicetype, ud.config.NumVoices, ud.config.NumChannels, ud.config.NumBits, ud.config.MixRate, initdata);
if (status == FX_Ok)
{
FX_SetVolume(ud.config.FXVolume);
FX_SetReverseStereo(ud.config.ReverseStereo);
status = FX_SetCallBack(S_TestSoundCallback);
}
if (status != FX_Ok)
{
@ -90,7 +76,9 @@ void S_SoundStartup(void)
G_GameExit(tempbuf);
}
ud.config.FXDevice = 0;
FX_SetVolume(ud.config.FXVolume);
FX_SetReverseStereo(ud.config.ReverseStereo);
status = FX_SetCallBack(S_TestSoundCallback);
}
/*
@ -366,8 +354,8 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel)
}
else
{
MusicVoice = FX_PlayLoopedAuto(MusicPtr, MusicLen, 0, 0, 0,
ud.config.MusicVolume, ud.config.MusicVolume, ud.config.MusicVolume,
MusicVoice = FX_PlayLoopedAuto(MusicPtr, MusicLen, 0, 0, 0, ud.config.MusicVolume,
ud.config.MusicVolume, ud.config.MusicVolume,
FX_MUSIC_PRIORITY, MUSIC_ID);
MusicIsWaveform = 1;
}
@ -387,7 +375,7 @@ void S_StopMusic(void)
if (MusicPtr)
{
Bfree(MusicPtr);
MusicPtr = 0;
MusicPtr = NULL;
g_musicSize = MusicLen = 0;
}
}
@ -427,7 +415,7 @@ int32_t S_LoadSound(uint32_t num)
return 1;
}
int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos)
int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
{
vec3_t c;
int32_t sndist,j,k;
@ -644,7 +632,7 @@ int32_t A_PlaySound(uint32_t num, int32_t i)
return 0;
}
return S_PlaySoundXYZ(num, i, (vec3_t *)&sprite[i]);
return S_PlaySound3D(num, i, (vec3_t *)&sprite[i]);
}
void S_StopSound(int32_t num)
@ -771,8 +759,8 @@ void S_TestSoundCallback(uint32_t num)
if((int32_t)num < 0)
{
if(lumplockbyte[-num] >= 200)
lumplockbyte[-num]--;
if(lumplockbyte[-(int32_t)num] >= 200)
lumplockbyte[-(int32_t)num]--;
return;
}

View file

@ -164,7 +164,7 @@ int32_t S_LoadSound(uint32_t num)
extern vec3_t pos;
extern int16_t ang, cursectnum;
int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos)
int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
{
int32_t sndist, cx, cy, cz, j/*,k*/;
int32_t pitche,pitchs,cs;
@ -355,7 +355,7 @@ int32_t A_PlaySound(uint32_t num, int32_t i)
return 0;
}
return S_PlaySoundXYZ(num,i, (vec3_t *)&sprite[i]);
return S_PlaySound3D(num,i, (vec3_t *)&sprite[i]);
}
void S_StopSound(int32_t num)

View file

@ -23,7 +23,7 @@ typedef struct {
int32_t S_SoundStartup(void);
void S_SoundShutdown(void);
int32_t S_PlaySoundXYZ(int32_t, int32_t, const vec3_t*);
int32_t S_PlaySound3D(int32_t, int32_t, const vec3_t*);
void S_PlaySound(int32_t);
int32_t A_PlaySound(uint32_t num, int32_t i);
void S_StopSound(int32_t num);