mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
Generic non-descript commit message
git-svn-id: https://svn.eduke32.com/eduke32@1440 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
5fcbdf3dd1
commit
3d0c34863d
21 changed files with 2867 additions and 3538 deletions
|
@ -1522,7 +1522,7 @@ void overheadeditor(void)
|
|||
drawlinepat = 0xffffffff;
|
||||
|
||||
Bsprintf(tempbuf,"(%d,%d)",mousxplc,mousyplc);
|
||||
/*
|
||||
/*
|
||||
i = (Bstrlen(tempbuf)<<3)+6;
|
||||
if ((searchx+i) < (xdim2d-1))
|
||||
i = 0;
|
||||
|
@ -1531,7 +1531,7 @@ void overheadeditor(void)
|
|||
j = 0;
|
||||
else j = (searchy+16)-(ydim2d-STATUS2DSIZ2-1);
|
||||
printext16(searchx+6-i,searchy+6-j,editorcolors[11],-1,tempbuf,0);
|
||||
*/
|
||||
*/
|
||||
_printmessage16(tempbuf);
|
||||
}
|
||||
drawline16(searchx,0,searchx,8,editorcolors[15]);
|
||||
|
|
|
@ -6826,7 +6826,7 @@ int32_t loadboard(char *filename, char fromwhere, int32_t *daposx, int32_t *dapo
|
|||
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
Bmemset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
||||
Bmemset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID));
|
||||
Bmemset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID));
|
||||
|
||||
# ifdef POLYMER
|
||||
if (rendmode == 4)
|
||||
|
@ -7309,7 +7309,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d
|
|||
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID));
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID));
|
||||
#endif
|
||||
guniqhudid = 0;
|
||||
|
||||
|
@ -7372,7 +7372,7 @@ int32_t loadmaphack(char *filename)
|
|||
if (!script) return -1;
|
||||
|
||||
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID));
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID));
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1458,7 +1458,9 @@ static void md3postload(md3model_t* m)
|
|||
m->head.frames[framei].max.x = frameverts[verti].x;
|
||||
m->head.frames[framei].max.y = frameverts[verti].y;
|
||||
m->head.frames[framei].max.z = frameverts[verti].z;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m->head.frames[framei].min.x > frameverts[verti].x)
|
||||
m->head.frames[framei].min.x = frameverts[verti].x;
|
||||
if (m->head.frames[framei].max.x < frameverts[verti].x)
|
||||
|
|
|
@ -35,28 +35,28 @@ DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include "nedmalloc.h"
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#define MSPACES 1
|
||||
#define ONLY_MSPACES 1
|
||||
#ifndef USE_LOCKS
|
||||
#define USE_LOCKS 1
|
||||
#define USE_LOCKS 1
|
||||
#endif
|
||||
#define FOOTERS 1 /* Need to enable footers so frees lock the right mspace */
|
||||
#if defined(DEBUG) && !defined(_DEBUG)
|
||||
#define _DEBUG
|
||||
#define _DEBUG
|
||||
#elif !defined(NDEBUG) && !defined(DEBUG) && !defined(_DEBUG)
|
||||
#define NDEBUG
|
||||
#define NDEBUG
|
||||
#endif
|
||||
#undef DEBUG /* dlmalloc wants DEBUG either 0 or 1 */
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG 1
|
||||
#define DEBUG 1
|
||||
#else
|
||||
#define DEBUG 0
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
#ifdef NDEBUG /* Disable assert checking on release builds */
|
||||
#undef DEBUG
|
||||
#undef DEBUG
|
||||
#endif
|
||||
/* The default of 64Kb means we spend too much time kernel-side */
|
||||
#ifndef DEFAULT_GRANULARITY
|
||||
|
@ -68,7 +68,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
/*#define FORCEINLINE*/
|
||||
#include "malloc.c.h"
|
||||
#ifdef NDEBUG /* Disable assert checking on release builds */
|
||||
#undef DEBUG
|
||||
#undef DEBUG
|
||||
#endif
|
||||
#if defined(__GNUC__) && defined(DEBUG)
|
||||
#warning DEBUG is defined so allocator will run with assert checking! Define NDEBUG to run at full speed.
|
||||
|
@ -86,7 +86,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
#ifndef THREADCACHEMAX
|
||||
#define THREADCACHEMAX 8192
|
||||
#endif
|
||||
#if 0
|
||||
#if 1
|
||||
/* The number of cache entries for finer grained bins. This is (topbitpos(THREADCACHEMAX)-4)*2 */
|
||||
#define THREADCACHEMAXBINS ((13-4)*2)
|
||||
#else
|
||||
|
@ -100,27 +100,27 @@ DEALINGS IN THE SOFTWARE.
|
|||
|
||||
|
||||
#ifdef WIN32
|
||||
#define TLSVAR DWORD
|
||||
#define TLSALLOC(k) (*(k)=TlsAlloc(), TLS_OUT_OF_INDEXES==*(k))
|
||||
#define TLSFREE(k) (!TlsFree(k))
|
||||
#define TLSGET(k) TlsGetValue(k)
|
||||
#define TLSSET(k, a) (!TlsSetValue(k, a))
|
||||
#ifdef DEBUG
|
||||
#define TLSVAR DWORD
|
||||
#define TLSALLOC(k) (*(k)=TlsAlloc(), TLS_OUT_OF_INDEXES==*(k))
|
||||
#define TLSFREE(k) (!TlsFree(k))
|
||||
#define TLSGET(k) TlsGetValue(k)
|
||||
#define TLSSET(k, a) (!TlsSetValue(k, a))
|
||||
#ifdef DEBUG
|
||||
static LPVOID ChkedTlsGetValue(DWORD idx)
|
||||
{
|
||||
LPVOID ret=TlsGetValue(idx);
|
||||
assert(S_OK==GetLastError());
|
||||
return ret;
|
||||
}
|
||||
#undef TLSGET
|
||||
#define TLSGET(k) ChkedTlsGetValue(k)
|
||||
#endif
|
||||
#undef TLSGET
|
||||
#define TLSGET(k) ChkedTlsGetValue(k)
|
||||
#endif
|
||||
#else
|
||||
#define TLSVAR pthread_key_t
|
||||
#define TLSALLOC(k) pthread_key_create(k, 0)
|
||||
#define TLSFREE(k) pthread_key_delete(k)
|
||||
#define TLSGET(k) pthread_getspecific(k)
|
||||
#define TLSSET(k, a) pthread_setspecific(k, a)
|
||||
#define TLSVAR pthread_key_t
|
||||
#define TLSALLOC(k) pthread_key_create(k, 0)
|
||||
#define TLSFREE(k) pthread_key_delete(k)
|
||||
#define TLSGET(k) pthread_getspecific(k)
|
||||
#define TLSSET(k, a) pthread_setspecific(k, a)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
@ -134,9 +134,11 @@ static LPVOID ChkedTlsGetValue(DWORD idx)
|
|||
|
||||
#if defined(__cplusplus)
|
||||
#if !defined(NO_NED_NAMESPACE)
|
||||
namespace nedalloc {
|
||||
namespace nedalloc
|
||||
{
|
||||
#else
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -146,12 +148,12 @@ size_t nedblksize(void *mem) THROWSPEC
|
|||
/* Only enable if testing with valgrind. Causes misoperation */
|
||||
return THREADCACHEMAX;
|
||||
#else
|
||||
if(mem)
|
||||
if (mem)
|
||||
{
|
||||
mchunkptr p=mem2chunk(mem);
|
||||
mstate fm = get_mstate_for(p);
|
||||
assert(ok_magic(fm)); /* If this fails, someone tried to free a block twice */
|
||||
if(ok_magic(fm))
|
||||
if (ok_magic(fm))
|
||||
return chunksize(p)-overhead_for(p);
|
||||
}
|
||||
return 0;
|
||||
|
@ -226,7 +228,8 @@ static FORCEINLINE unsigned int size2binidx(size_t _size) THROWSPEC
|
|||
}
|
||||
#else
|
||||
#if 0
|
||||
union {
|
||||
union
|
||||
{
|
||||
unsigned asInt[2];
|
||||
double asDouble;
|
||||
};
|
||||
|
@ -260,7 +263,7 @@ static FORCEINLINE unsigned int size2binidx(size_t _size) THROWSPEC
|
|||
static void tcsanitycheck(threadcacheblk **ptr) THROWSPEC
|
||||
{
|
||||
assert((ptr[0] && ptr[1]) || (!ptr[0] && !ptr[1]));
|
||||
if(ptr[0] && ptr[1])
|
||||
if (ptr[0] && ptr[1])
|
||||
{
|
||||
assert(nedblksize(ptr[0])>=sizeof(threadcacheblk));
|
||||
assert(nedblksize(ptr[1])>=sizeof(threadcacheblk));
|
||||
|
@ -268,7 +271,7 @@ static void tcsanitycheck(threadcacheblk **ptr) THROWSPEC
|
|||
assert(*(unsigned int *) "NEDN"==ptr[1]->magic);
|
||||
assert(!ptr[0]->prev);
|
||||
assert(!ptr[1]->next);
|
||||
if(ptr[0]==ptr[1])
|
||||
if (ptr[0]==ptr[1])
|
||||
{
|
||||
assert(!ptr[0]->next);
|
||||
assert(!ptr[1]->prev);
|
||||
|
@ -279,11 +282,11 @@ static void tcfullsanitycheck(threadcache *tc) THROWSPEC
|
|||
{
|
||||
threadcacheblk **tcbptr=tc->bins;
|
||||
int n;
|
||||
for(n=0; n<=THREADCACHEMAXBINS; n++, tcbptr+=2)
|
||||
for (n=0; n<=THREADCACHEMAXBINS; n++, tcbptr+=2)
|
||||
{
|
||||
threadcacheblk *b, *ob=0;
|
||||
tcsanitycheck(tcbptr);
|
||||
for(b=tcbptr[0]; b; ob=b, b=b->next)
|
||||
for (b=tcbptr[0]; b; ob=b, b=b->next)
|
||||
{
|
||||
assert(*(unsigned int *) "NEDN"==b->magic);
|
||||
assert(!ob || ob->next==b);
|
||||
|
@ -299,15 +302,15 @@ static NOINLINE void RemoveCacheEntries(nedpool *p, threadcache *tc, unsigned in
|
|||
#ifdef FULLSANITYCHECKS
|
||||
tcfullsanitycheck(tc);
|
||||
#endif
|
||||
if(tc->freeInCache)
|
||||
if (tc->freeInCache)
|
||||
{
|
||||
threadcacheblk **tcbptr=tc->bins;
|
||||
int n;
|
||||
for(n=0; n<=THREADCACHEMAXBINS; n++, tcbptr+=2)
|
||||
for (n=0; n<=THREADCACHEMAXBINS; n++, tcbptr+=2)
|
||||
{
|
||||
threadcacheblk **tcb=tcbptr+1; /* come from oldest end of list */
|
||||
/*tcsanitycheck(tcbptr);*/
|
||||
for(; *tcb && tc->frees-(*tcb)->lastUsed>=age; )
|
||||
for (; *tcb && tc->frees-(*tcb)->lastUsed>=age;)
|
||||
{
|
||||
threadcacheblk *f=*tcb;
|
||||
size_t blksize=f->size; /*nedblksize(f);*/
|
||||
|
@ -317,7 +320,7 @@ static NOINLINE void RemoveCacheEntries(nedpool *p, threadcache *tc, unsigned in
|
|||
assert(*(unsigned int *) "NEDN"==(*tcb)->magic);
|
||||
#endif
|
||||
*tcb=(*tcb)->prev;
|
||||
if(*tcb)
|
||||
if (*tcb)
|
||||
(*tcb)->next=0;
|
||||
else
|
||||
*tcbptr=0;
|
||||
|
@ -334,13 +337,13 @@ static NOINLINE void RemoveCacheEntries(nedpool *p, threadcache *tc, unsigned in
|
|||
}
|
||||
static void DestroyCaches(nedpool *p) THROWSPEC
|
||||
{
|
||||
if(p->caches)
|
||||
if (p->caches)
|
||||
{
|
||||
threadcache *tc;
|
||||
int n;
|
||||
for(n=0; n<THREADCACHEMAXCACHES; n++)
|
||||
for (n=0; n<THREADCACHEMAXCACHES; n++)
|
||||
{
|
||||
if((tc=p->caches[n]))
|
||||
if ((tc=p->caches[n]))
|
||||
{
|
||||
tc->frees++;
|
||||
RemoveCacheEntries(p, tc, 0);
|
||||
|
@ -359,14 +362,14 @@ static NOINLINE threadcache *AllocCache(nedpool *p) THROWSPEC
|
|||
threadcache *tc=0;
|
||||
int n, end;
|
||||
ACQUIRE_LOCK(&p->mutex);
|
||||
for(n=0; n<THREADCACHEMAXCACHES && p->caches[n]; n++);
|
||||
if(THREADCACHEMAXCACHES==n)
|
||||
for (n=0; n<THREADCACHEMAXCACHES && p->caches[n]; n++);
|
||||
if (THREADCACHEMAXCACHES==n)
|
||||
{ /* List exhausted, so disable for this thread */
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
return 0;
|
||||
}
|
||||
tc=p->caches[n]=(threadcache *) mspace_calloc(p->m[0], 1, sizeof(threadcache));
|
||||
if(!tc)
|
||||
if (!tc)
|
||||
{
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
return 0;
|
||||
|
@ -376,10 +379,10 @@ static NOINLINE threadcache *AllocCache(nedpool *p) THROWSPEC
|
|||
tc->magic2=*(unsigned int *)"NEDMALC2";
|
||||
#endif
|
||||
tc->threadid=(long)(size_t)CURRENT_THREAD;
|
||||
for(end=0; p->m[end]; end++);
|
||||
for (end=0; p->m[end]; end++);
|
||||
tc->mymspace=abs(tc->threadid) % end;
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
if(TLSSET(p->mycache, (void *)(size_t)(n+1))) abort();
|
||||
if (TLSSET(p->mycache, (void *)(size_t)(n+1))) abort();
|
||||
return tc;
|
||||
}
|
||||
|
||||
|
@ -399,48 +402,48 @@ static void *threadcache_malloc(nedpool *p, threadcache *tc, size_t *size) THROW
|
|||
#if 0
|
||||
/* Finer grained bin fit */
|
||||
idx<<=1;
|
||||
if(*size>bestsize)
|
||||
if (*size>bestsize)
|
||||
{
|
||||
idx++;
|
||||
bestsize+=bestsize>>1;
|
||||
}
|
||||
if(*size>bestsize)
|
||||
if (*size>bestsize)
|
||||
{
|
||||
idx++;
|
||||
bestsize=1<<(4+(idx>>1));
|
||||
}
|
||||
#else
|
||||
if(*size>bestsize)
|
||||
if (*size>bestsize)
|
||||
{
|
||||
idx++;
|
||||
bestsize<<=1;
|
||||
}
|
||||
#endif
|
||||
assert(bestsize>=*size);
|
||||
if(*size<bestsize) *size=bestsize;
|
||||
if (*size<bestsize) *size=bestsize;
|
||||
assert(*size<=THREADCACHEMAX);
|
||||
assert(idx<=THREADCACHEMAXBINS);
|
||||
binsptr=&tc->bins[idx*2];
|
||||
/* Try to match close, but move up a bin if necessary */
|
||||
blk=*binsptr;
|
||||
if(!blk || blk->size<*size)
|
||||
if (!blk || blk->size<*size)
|
||||
{ /* Bump it up a bin */
|
||||
if(idx<THREADCACHEMAXBINS)
|
||||
if (idx<THREADCACHEMAXBINS)
|
||||
{
|
||||
idx++;
|
||||
binsptr+=2;
|
||||
blk=*binsptr;
|
||||
}
|
||||
}
|
||||
if(blk)
|
||||
if (blk)
|
||||
{
|
||||
blksize=blk->size; /*nedblksize(blk);*/
|
||||
assert(nedblksize(blk)>=blksize);
|
||||
assert(blksize>=*size);
|
||||
if(blk->next)
|
||||
if (blk->next)
|
||||
blk->next->prev=0;
|
||||
*binsptr=blk->next;
|
||||
if(!*binsptr)
|
||||
if (!*binsptr)
|
||||
binsptr[1]=0;
|
||||
#ifdef FULLSANITYCHECKS
|
||||
blk->magic=0;
|
||||
|
@ -451,7 +454,7 @@ static void *threadcache_malloc(nedpool *p, threadcache *tc, size_t *size) THROW
|
|||
ret=(void *) blk;
|
||||
}
|
||||
++tc->mallocs;
|
||||
if(ret)
|
||||
if (ret)
|
||||
{
|
||||
assert(blksize>=*size);
|
||||
++tc->successes;
|
||||
|
@ -459,7 +462,7 @@ static void *threadcache_malloc(nedpool *p, threadcache *tc, size_t *size) THROW
|
|||
assert((long) tc->freeInCache>=0);
|
||||
}
|
||||
#if defined(DEBUG) && 0
|
||||
if(!(tc->mallocs & 0xfff))
|
||||
if (!(tc->mallocs & 0xfff))
|
||||
{
|
||||
printf("*** threadcache=%u, mallocs=%u (%f), free=%u (%f), freeInCache=%u\n", (unsigned int) tc->threadid, tc->mallocs,
|
||||
(float) tc->successes/tc->mallocs, tc->frees, (float) tc->successes/tc->frees, (unsigned int) tc->freeInCache);
|
||||
|
@ -475,7 +478,7 @@ static NOINLINE void ReleaseFreeInCache(nedpool *p, threadcache *tc, int mymspac
|
|||
unsigned int age=THREADCACHEMAXFREESPACE/8192;
|
||||
/*ACQUIRE_LOCK(&p->m[mymspace]->mutex);*/
|
||||
UNREFERENCED_PARAMETER(mymspace);
|
||||
while(age && tc->freeInCache>=THREADCACHEMAXFREESPACE)
|
||||
while (age && tc->freeInCache>=THREADCACHEMAXFREESPACE)
|
||||
{
|
||||
RemoveCacheEntries(p, tc, age);
|
||||
/*printf("*** Removing cache entries older than %u (%u)\n", age, (unsigned int) tc->freeInCache);*/
|
||||
|
@ -493,7 +496,8 @@ static void threadcache_free(nedpool *p, threadcache *tc, int mymspace, void *me
|
|||
{ /* Make sure this is a valid memory block */
|
||||
mchunkptr p = mem2chunk(mem);
|
||||
mstate fm = get_mstate_for(p);
|
||||
if (!ok_magic(fm)) {
|
||||
if (!ok_magic(fm))
|
||||
{
|
||||
USAGE_ERROR_ACTION(fm, p);
|
||||
return;
|
||||
}
|
||||
|
@ -507,21 +511,21 @@ static void threadcache_free(nedpool *p, threadcache *tc, int mymspace, void *me
|
|||
#if 0
|
||||
/* Finer grained bin fit */
|
||||
idx<<=1;
|
||||
if(size>bestsize)
|
||||
if (size>bestsize)
|
||||
{
|
||||
unsigned int biggerbestsize=bestsize+bestsize<<1;
|
||||
if(size>=biggerbestsize)
|
||||
if (size>=biggerbestsize)
|
||||
{
|
||||
idx++;
|
||||
bestsize=biggerbestsize;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(bestsize!=size) /* dlmalloc can round up, so we round down to preserve indexing */
|
||||
if (bestsize!=size) /* dlmalloc can round up, so we round down to preserve indexing */
|
||||
size=bestsize;
|
||||
binsptr=&tc->bins[idx*2];
|
||||
assert(idx<=THREADCACHEMAXBINS);
|
||||
if(tck==*binsptr)
|
||||
if (tck==*binsptr)
|
||||
{
|
||||
fprintf(stderr, "Attempt to free already freed memory block %p - aborting!\n", tck);
|
||||
abort();
|
||||
|
@ -533,7 +537,7 @@ static void threadcache_free(nedpool *p, threadcache *tc, int mymspace, void *me
|
|||
tck->size=(unsigned int) size;
|
||||
tck->next=*binsptr;
|
||||
tck->prev=0;
|
||||
if(tck->next)
|
||||
if (tck->next)
|
||||
tck->next->prev=tck;
|
||||
else
|
||||
binsptr[1]=tck;
|
||||
|
@ -547,7 +551,7 @@ static void threadcache_free(nedpool *p, threadcache *tc, int mymspace, void *me
|
|||
tcfullsanitycheck(tc);
|
||||
#endif
|
||||
#if 1
|
||||
if(tc->freeInCache>=THREADCACHEMAXFREESPACE)
|
||||
if (tc->freeInCache>=THREADCACHEMAXFREESPACE)
|
||||
ReleaseFreeInCache(p, tc, mymspace);
|
||||
#endif
|
||||
}
|
||||
|
@ -559,27 +563,27 @@ static NOINLINE int InitPool(nedpool *p, size_t capacity, int threads) THROWSPEC
|
|||
{ /* threads is -1 for system pool */
|
||||
ensure_initialization();
|
||||
ACQUIRE_MALLOC_GLOBAL_LOCK();
|
||||
if(p->threads) goto done;
|
||||
if(INITIAL_LOCK(&p->mutex)) goto err;
|
||||
if(TLSALLOC(&p->mycache)) goto err;
|
||||
if(!(p->m[0]=(mstate) create_mspace(capacity, 1))) goto err;
|
||||
if (p->threads) goto done;
|
||||
if (INITIAL_LOCK(&p->mutex)) goto err;
|
||||
if (TLSALLOC(&p->mycache)) goto err;
|
||||
if (!(p->m[0]=(mstate) create_mspace(capacity, 1))) goto err;
|
||||
p->m[0]->extp=p;
|
||||
p->threads=(threads<1 || threads>MAXTHREADSINPOOL) ? MAXTHREADSINPOOL : threads;
|
||||
done:
|
||||
RELEASE_MALLOC_GLOBAL_LOCK();
|
||||
return 1;
|
||||
err:
|
||||
if(threads<0)
|
||||
if (threads<0)
|
||||
abort(); /* If you can't allocate for system pool, we're screwed */
|
||||
DestroyCaches(p);
|
||||
if(p->m[0])
|
||||
if (p->m[0])
|
||||
{
|
||||
destroy_mspace(p->m[0]);
|
||||
p->m[0]=0;
|
||||
}
|
||||
if(p->mycache)
|
||||
if (p->mycache)
|
||||
{
|
||||
if(TLSFREE(p->mycache)) abort();
|
||||
if (TLSFREE(p->mycache)) abort();
|
||||
p->mycache=0;
|
||||
}
|
||||
RELEASE_MALLOC_GLOBAL_LOCK();
|
||||
|
@ -591,24 +595,24 @@ static NOINLINE mstate FindMSpace(nedpool *p, threadcache *tc, int *lastUsed, si
|
|||
unlocked one and if we fail, we create a new one so long as we don't
|
||||
exceed p->threads */
|
||||
int n, end;
|
||||
for(n=end=*lastUsed+1; p->m[n]; end=++n)
|
||||
{
|
||||
if(TRY_LOCK(&p->m[n]->mutex)) goto found;
|
||||
}
|
||||
for(n=0; n<*lastUsed && p->m[n]; n++)
|
||||
{
|
||||
if(TRY_LOCK(&p->m[n]->mutex)) goto found;
|
||||
}
|
||||
if(end<p->threads)
|
||||
{
|
||||
mstate temp;
|
||||
if(!(temp=(mstate) create_mspace(size, 1)))
|
||||
for (n=end=*lastUsed+1; p->m[n]; end=++n)
|
||||
{
|
||||
if (TRY_LOCK(&p->m[n]->mutex)) goto found;
|
||||
}
|
||||
for (n=0; n<*lastUsed && p->m[n]; n++)
|
||||
{
|
||||
if (TRY_LOCK(&p->m[n]->mutex)) goto found;
|
||||
}
|
||||
if (end<p->threads)
|
||||
{
|
||||
mstate temp;
|
||||
if (!(temp=(mstate) create_mspace(size, 1)))
|
||||
goto badexit;
|
||||
/* Now we're ready to modify the lists, we lock */
|
||||
ACQUIRE_LOCK(&p->mutex);
|
||||
while(p->m[end] && end<p->threads)
|
||||
while (p->m[end] && end<p->threads)
|
||||
end++;
|
||||
if(end>=p->threads)
|
||||
if (end>=p->threads)
|
||||
{ /* Drat, must destroy it now */
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
destroy_mspace((mspace) temp);
|
||||
|
@ -622,27 +626,27 @@ static NOINLINE mstate FindMSpace(nedpool *p, threadcache *tc, int *lastUsed, si
|
|||
RELEASE_LOCK(&p->mutex);
|
||||
n=end;
|
||||
goto found;
|
||||
}
|
||||
/* Let it lock on the last one it used */
|
||||
}
|
||||
/* Let it lock on the last one it used */
|
||||
badexit:
|
||||
ACQUIRE_LOCK(&p->m[*lastUsed]->mutex);
|
||||
return p->m[*lastUsed];
|
||||
ACQUIRE_LOCK(&p->m[*lastUsed]->mutex);
|
||||
return p->m[*lastUsed];
|
||||
found:
|
||||
*lastUsed=n;
|
||||
if(tc)
|
||||
tc->mymspace=n;
|
||||
else
|
||||
{
|
||||
if(TLSSET(p->mycache, (void *)(size_t)(-(n+1)))) abort();
|
||||
*lastUsed=n;
|
||||
if (tc)
|
||||
tc->mymspace=n;
|
||||
else
|
||||
{
|
||||
if (TLSSET(p->mycache, (void *)(size_t)(-(n+1)))) abort();
|
||||
}
|
||||
return p->m[n];
|
||||
return p->m[n];
|
||||
}
|
||||
|
||||
nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC
|
||||
{
|
||||
nedpool *ret;
|
||||
if(!(ret=(nedpool *) nedpcalloc(0, 1, sizeof(nedpool)))) return 0;
|
||||
if(!InitPool(ret, capacity, threads))
|
||||
if (!(ret=(nedpool *) nedpcalloc(0, 1, sizeof(nedpool)))) return 0;
|
||||
if (!InitPool(ret, capacity, threads))
|
||||
{
|
||||
nedpfree(0, ret);
|
||||
return 0;
|
||||
|
@ -654,13 +658,13 @@ void neddestroypool(nedpool *p) THROWSPEC
|
|||
int n;
|
||||
ACQUIRE_LOCK(&p->mutex);
|
||||
DestroyCaches(p);
|
||||
for(n=0; p->m[n]; n++)
|
||||
for (n=0; p->m[n]; n++)
|
||||
{
|
||||
destroy_mspace(p->m[n]);
|
||||
p->m[n]=0;
|
||||
}
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
if(TLSFREE(p->mycache)) abort();
|
||||
if (TLSFREE(p->mycache)) abort();
|
||||
nedpfree(0, p);
|
||||
}
|
||||
void neddestroysyspool() THROWSPEC
|
||||
|
@ -669,23 +673,23 @@ void neddestroysyspool() THROWSPEC
|
|||
int n;
|
||||
ACQUIRE_LOCK(&p->mutex);
|
||||
DestroyCaches(p);
|
||||
for(n=0; p->m[n]; n++)
|
||||
for (n=0; p->m[n]; n++)
|
||||
{
|
||||
destroy_mspace(p->m[n]);
|
||||
p->m[n]=0;
|
||||
}
|
||||
/* Render syspool unusable */
|
||||
for(n=0; n<THREADCACHEMAXCACHES; n++)
|
||||
for (n=0; n<THREADCACHEMAXCACHES; n++)
|
||||
p->caches[n]=(threadcache *) 0xdeadbeef;
|
||||
for(n=0; n<MAXTHREADSINPOOL+1; n++)
|
||||
for (n=0; n<MAXTHREADSINPOOL+1; n++)
|
||||
p->m[n]=(mstate) 0xdeadbeef;
|
||||
if(TLSFREE(p->mycache)) abort();
|
||||
if (TLSFREE(p->mycache)) abort();
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
}
|
||||
|
||||
void nedpsetvalue(nedpool *p, void *v) THROWSPEC
|
||||
{
|
||||
if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
p->uservalue=v;
|
||||
}
|
||||
void *nedgetvalue(nedpool **p, void *mem) THROWSPEC
|
||||
|
@ -693,43 +697,43 @@ void *nedgetvalue(nedpool **p, void *mem) THROWSPEC
|
|||
nedpool *np=0;
|
||||
mchunkptr mcp=mem2chunk(mem);
|
||||
mstate fm;
|
||||
if(!(is_aligned(chunk2mem(mcp))) && mcp->head != FENCEPOST_HEAD) return 0;
|
||||
if(!cinuse(mcp)) return 0;
|
||||
if(!next_pinuse(mcp)) return 0;
|
||||
if(!is_mmapped(mcp) && !pinuse(mcp))
|
||||
if (!(is_aligned(chunk2mem(mcp))) && mcp->head != FENCEPOST_HEAD) return 0;
|
||||
if (!cinuse(mcp)) return 0;
|
||||
if (!next_pinuse(mcp)) return 0;
|
||||
if (!is_mmapped(mcp) && !pinuse(mcp))
|
||||
{
|
||||
if(next_chunk(prev_chunk(mcp))!=mcp) return 0;
|
||||
if (next_chunk(prev_chunk(mcp))!=mcp) return 0;
|
||||
}
|
||||
fm=get_mstate_for(mcp);
|
||||
if(!ok_magic(fm)) return 0;
|
||||
if(!ok_address(fm, mcp)) return 0;
|
||||
if(!fm->extp) return 0;
|
||||
if (!ok_magic(fm)) return 0;
|
||||
if (!ok_address(fm, mcp)) return 0;
|
||||
if (!fm->extp) return 0;
|
||||
np=(nedpool *) fm->extp;
|
||||
if(p) *p=np;
|
||||
if (p) *p=np;
|
||||
return np->uservalue;
|
||||
}
|
||||
|
||||
void neddisablethreadcache(nedpool *p) THROWSPEC
|
||||
{
|
||||
int mycache;
|
||||
if(!p)
|
||||
if (!p)
|
||||
{
|
||||
p=&syspool;
|
||||
if(!syspool.threads) InitPool(&syspool, 0, -1);
|
||||
if (!syspool.threads) InitPool(&syspool, 0, -1);
|
||||
}
|
||||
mycache=(int)(size_t) TLSGET(p->mycache);
|
||||
if(!mycache)
|
||||
if (!mycache)
|
||||
{ /* Set to mspace 0 */
|
||||
if(TLSSET(p->mycache, (void *)-1)) abort();
|
||||
if (TLSSET(p->mycache, (void *)-1)) abort();
|
||||
}
|
||||
else if(mycache>0)
|
||||
else if (mycache>0)
|
||||
{ /* Set to last used mspace */
|
||||
threadcache *tc=p->caches[mycache-1];
|
||||
#if defined(DEBUG)
|
||||
printf("Threadcache utilisation: %lf%% in cache with %lf%% lost to other threads\n",
|
||||
100.0*tc->successes/tc->mallocs, 100.0*((double) tc->mallocs-tc->frees)/tc->mallocs);
|
||||
#endif
|
||||
if(TLSSET(p->mycache, (void *)(size_t)(-tc->mymspace))) abort();
|
||||
if (TLSSET(p->mycache, (void *)(size_t)(-tc->mymspace))) abort();
|
||||
tc->frees++;
|
||||
RemoveCacheEntries(p, tc, 0);
|
||||
assert(!tc->freeInCache);
|
||||
|
@ -752,31 +756,31 @@ static FORCEINLINE mstate GetMSpace(nedpool *p, threadcache *tc, int mymspace, s
|
|||
{ /* Returns a locked and ready for use mspace */
|
||||
mstate m=p->m[mymspace];
|
||||
assert(m);
|
||||
if(!TRY_LOCK(&p->m[mymspace]->mutex)) m=FindMSpace(p, tc, &mymspace, size);\
|
||||
if (!TRY_LOCK(&p->m[mymspace]->mutex)) m=FindMSpace(p, tc, &mymspace, size); \
|
||||
/*assert(IS_LOCKED(&p->m[mymspace]->mutex));*/
|
||||
return m;
|
||||
}
|
||||
static FORCEINLINE void GetThreadCache(nedpool **p, threadcache **tc, int *mymspace, size_t *size) THROWSPEC
|
||||
{
|
||||
int mycache;
|
||||
if(size && *size<sizeof(threadcacheblk)) *size=sizeof(threadcacheblk);
|
||||
if(!*p)
|
||||
if (size && *size<sizeof(threadcacheblk)) *size=sizeof(threadcacheblk);
|
||||
if (!*p)
|
||||
{
|
||||
*p=&syspool;
|
||||
if(!syspool.threads) InitPool(&syspool, 0, -1);
|
||||
if (!syspool.threads) InitPool(&syspool, 0, -1);
|
||||
}
|
||||
mycache=(int)(size_t) TLSGET((*p)->mycache);
|
||||
if(mycache>0)
|
||||
if (mycache>0)
|
||||
{
|
||||
*tc=(*p)->caches[mycache-1];
|
||||
*mymspace=(*tc)->mymspace;
|
||||
}
|
||||
else if(!mycache)
|
||||
else if (!mycache)
|
||||
{
|
||||
*tc=AllocCache(*p);
|
||||
if(!*tc)
|
||||
if (!*tc)
|
||||
{ /* Disable */
|
||||
if(TLSSET((*p)->mycache, (void *)-1)) abort();
|
||||
if (TLSSET((*p)->mycache, (void *)-1)) abort();
|
||||
*mymspace=0;
|
||||
}
|
||||
else
|
||||
|
@ -790,9 +794,9 @@ static FORCEINLINE void GetThreadCache(nedpool **p, threadcache **tc, int *mymsp
|
|||
assert(*mymspace>=0);
|
||||
assert((long)(size_t)CURRENT_THREAD==(*tc)->threadid);
|
||||
#ifdef FULLSANITYCHECKS
|
||||
if(*tc)
|
||||
if (*tc)
|
||||
{
|
||||
if(*(unsigned int *)"NEDMALC1"!=(*tc)->magic1 || *(unsigned int *)"NEDMALC2"!=(*tc)->magic2)
|
||||
if (*(unsigned int *)"NEDMALC1"!=(*tc)->magic1 || *(unsigned int *)"NEDMALC2"!=(*tc)->magic2)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
@ -807,12 +811,12 @@ void * nedpmalloc(nedpool *p, size_t size) THROWSPEC
|
|||
int mymspace;
|
||||
GetThreadCache(&p, &tc, &mymspace, &size);
|
||||
#if THREADCACHEMAX
|
||||
if(tc && size<=THREADCACHEMAX)
|
||||
if (tc && size<=THREADCACHEMAX)
|
||||
{ /* Use the thread cache */
|
||||
ret=threadcache_malloc(p, tc, &size);
|
||||
}
|
||||
#endif
|
||||
if(!ret)
|
||||
if (!ret)
|
||||
{ /* Use this thread's mspace */
|
||||
GETMSPACE(m, p, tc, mymspace, size,
|
||||
ret=mspace_malloc(m, size));
|
||||
|
@ -827,13 +831,13 @@ void * nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC
|
|||
int mymspace;
|
||||
GetThreadCache(&p, &tc, &mymspace, &rsize);
|
||||
#if THREADCACHEMAX
|
||||
if(tc && rsize<=THREADCACHEMAX)
|
||||
if (tc && rsize<=THREADCACHEMAX)
|
||||
{ /* Use the thread cache */
|
||||
if((ret=threadcache_malloc(p, tc, &rsize)))
|
||||
if ((ret=threadcache_malloc(p, tc, &rsize)))
|
||||
memset(ret, 0, rsize);
|
||||
}
|
||||
#endif
|
||||
if(!ret)
|
||||
if (!ret)
|
||||
{ /* Use this thread's mspace */
|
||||
GETMSPACE(m, p, tc, mymspace, rsize,
|
||||
ret=mspace_calloc(m, 1, rsize));
|
||||
|
@ -845,24 +849,24 @@ void * nedprealloc(nedpool *p, void *mem, size_t size) THROWSPEC
|
|||
void *ret=0;
|
||||
threadcache *tc;
|
||||
int mymspace;
|
||||
if(!mem) return nedpmalloc(p, size);
|
||||
if (!mem) return nedpmalloc(p, size);
|
||||
GetThreadCache(&p, &tc, &mymspace, &size);
|
||||
#if THREADCACHEMAX
|
||||
if(tc && size && size<=THREADCACHEMAX)
|
||||
if (tc && size && size<=THREADCACHEMAX)
|
||||
{ /* Use the thread cache */
|
||||
size_t memsize=nedblksize(mem);
|
||||
assert(memsize);
|
||||
if((ret=threadcache_malloc(p, tc, &size)))
|
||||
if ((ret=threadcache_malloc(p, tc, &size)))
|
||||
{
|
||||
memcpy(ret, mem, memsize<size ? memsize : size);
|
||||
if(memsize<=THREADCACHEMAX)
|
||||
if (memsize<=THREADCACHEMAX)
|
||||
threadcache_free(p, tc, mymspace, mem, memsize);
|
||||
else
|
||||
mspace_free(0, mem);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(!ret)
|
||||
if (!ret)
|
||||
{ /* Reallocs always happen in the mspace they happened in, so skip
|
||||
locking the preferred mspace for this thread */
|
||||
ret=mspace_realloc(0, mem, size);
|
||||
|
@ -880,14 +884,14 @@ void nedpfree(nedpool *p, void *mem) THROWSPEC
|
|||
#if THREADCACHEMAX
|
||||
memsize=nedblksize(mem);
|
||||
assert(memsize);
|
||||
if(mem && tc && memsize<=(THREADCACHEMAX+CHUNK_OVERHEAD))
|
||||
if (mem && tc && memsize<=(THREADCACHEMAX+CHUNK_OVERHEAD))
|
||||
threadcache_free(p, tc, mymspace, mem, memsize);
|
||||
else
|
||||
#endif
|
||||
mspace_free(0, mem);
|
||||
}
|
||||
void * nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC
|
||||
{
|
||||
}
|
||||
void * nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC
|
||||
{
|
||||
void *ret;
|
||||
threadcache *tc;
|
||||
int mymspace;
|
||||
|
@ -897,16 +901,16 @@ void * nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC
|
|||
ret=mspace_memalign(m, alignment, bytes));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#if !NO_MALLINFO
|
||||
struct mallinfo nedpmallinfo(nedpool *p) THROWSPEC
|
||||
{
|
||||
int n;
|
||||
struct mallinfo ret ={0,0,0,0,0,0,0,0,0,0};
|
||||
if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
for(n=0; p->m[n]; n++)
|
||||
{
|
||||
struct mallinfo t=mspace_mallinfo(p->m[n]);
|
||||
if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
for (n=0; p->m[n]; n++)
|
||||
{
|
||||
struct mallinfo t=mspace_mallinfo(p->m[n]);
|
||||
ret.arena+=t.arena;
|
||||
ret.ordblks+=t.ordblks;
|
||||
ret.hblkhd+=t.hblkhd;
|
||||
|
@ -914,8 +918,8 @@ struct mallinfo nedpmallinfo(nedpool *p) THROWSPEC
|
|||
ret.uordblks+=t.uordblks;
|
||||
ret.fordblks+=t.fordblks;
|
||||
ret.keepcost+=t.keepcost;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
int nedpmallopt(nedpool *p, int parno, int value) THROWSPEC
|
||||
|
@ -926,8 +930,8 @@ int nedpmallopt(nedpool *p, int parno, int value) THROWSPEC
|
|||
int nedpmalloc_trim(nedpool *p, size_t pad) THROWSPEC
|
||||
{
|
||||
int n, ret=0;
|
||||
if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
for(n=0; p->m[n]; n++)
|
||||
if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
for (n=0; p->m[n]; n++)
|
||||
{
|
||||
ret+=mspace_trim(p->m[n], pad);
|
||||
}
|
||||
|
@ -936,8 +940,8 @@ int nedpmalloc_trim(nedpool *p, size_t pad) THROWSPEC
|
|||
void nedpmalloc_stats(nedpool *p) THROWSPEC
|
||||
{
|
||||
int n;
|
||||
if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
for(n=0; p->m[n]; n++)
|
||||
if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
for (n=0; p->m[n]; n++)
|
||||
{
|
||||
mspace_malloc_stats(p->m[n]);
|
||||
}
|
||||
|
@ -946,8 +950,8 @@ size_t nedpmalloc_footprint(nedpool *p) THROWSPEC
|
|||
{
|
||||
size_t ret=0;
|
||||
int n;
|
||||
if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
for(n=0; p->m[n]; n++)
|
||||
if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); }
|
||||
for (n=0; p->m[n]; n++)
|
||||
{
|
||||
ret+=mspace_footprint(p->m[n]);
|
||||
}
|
||||
|
@ -969,8 +973,8 @@ void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **
|
|||
threadcache *tc;
|
||||
int mymspace;
|
||||
size_t i, *adjustedsizes=(size_t *) alloca(elems*sizeof(size_t));
|
||||
if(!adjustedsizes) return 0;
|
||||
for(i=0; i<elems; i++)
|
||||
if (!adjustedsizes) return 0;
|
||||
for (i=0; i<elems; i++)
|
||||
adjustedsizes[i]=sizes[i]<sizeof(threadcacheblk) ? sizeof(threadcacheblk) : sizes[i];
|
||||
GetThreadCache(&p, &tc, &mymspace, 0);
|
||||
GETMSPACE(m, p, tc, mymspace, 0,
|
||||
|
|
|
@ -5949,10 +5949,10 @@ void polymost_initosdfuncs(void)
|
|||
{ "r_downsize","r_downsize: controls downsizing factor for hires textures",(void *)&r_downsizevar, CVAR_INT|CVAR_FUNCPTR, 0, 0, 5 },
|
||||
{ "r_fullbrights","r_fullbrights: enable/disable fullbright textures",(void *)&r_fullbrights, CVAR_BOOL, 0, 0, 1 },
|
||||
{ "r_glowmapping","r_glowmapping: enable/disable glow mapping",(void *)&r_glowmapping, CVAR_BOOL, 0, 0, 1 },
|
||||
/*
|
||||
/*
|
||||
{ "r_multisample","r_multisample: sets the number of samples used for antialiasing (0 = off)",(void *)&r_glowmapping, CVAR_BOOL, 0, 0, 1 }
|
||||
{ "r_nvmultisamplehint","r_nvmultisamplehint: enable/disable Nvidia multisampling hinting",(void *)&glnvmultisamplehint, CVAR_BOOL, 0, 0, 1 }
|
||||
*/
|
||||
*/
|
||||
{ "r_parallaxskyclamping","r_parallaxskyclamping: enable/disable parallaxed floor/ceiling sky texture clamping",
|
||||
(void *)&r_parallaxskyclamping, CVAR_BOOL, 0, 0, 1 },
|
||||
{ "r_parallaxskypanning","r_parallaxskypanning: enable/disable parallaxed floor/ceiling panning when drawing a parallaxed sky",
|
||||
|
|
|
@ -5646,7 +5646,7 @@ static void G_MoveEffectors(void) //STATNUM 3
|
|||
{
|
||||
if (sprite[j].statnum != 10 && 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 == SECTOREFFECTOR && (sprite[j].lotag == 49||sprite[j].lotag == 50)))
|
||||
&& sprite[j].picnum != LOCATORS)
|
||||
{
|
||||
rotatepoint(s->x,s->y,sprite[j].x,sprite[j].y,q,&sprite[j].x,&sprite[j].y);
|
||||
|
@ -7853,7 +7853,7 @@ void G_MoveWorld(void)
|
|||
{
|
||||
spritetype *s = &sprite[i];
|
||||
|
||||
if(ActorExtra[i].lightptr != NULL && ActorExtra[i].lightcount)
|
||||
if (ActorExtra[i].lightptr != NULL && ActorExtra[i].lightcount)
|
||||
{
|
||||
if (!(--ActorExtra[i].lightcount))
|
||||
{
|
||||
|
|
|
@ -667,6 +667,8 @@ extern int32_t g_cameraDistance, g_cameraClock, g_playerFriction,g_showShareware
|
|||
extern int32_t g_networkBroadcastMode, g_movesPerPacket;
|
||||
extern int32_t g_gameQuit;
|
||||
|
||||
extern int32_t playerswhenstarted;
|
||||
|
||||
extern char pus,pub;
|
||||
extern int32_t g_damageCameras,g_freezerSelfDamage,g_tripbombLaserMode;
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ extern void G_DrawTXDigiNumZ(int32_t starttile, int32_t x,int32_t y,int32_t n,in
|
|||
extern void G_DrawTileSmall(int32_t x,int32_t y,int32_t tilenum,int32_t shade,int32_t orientation);
|
||||
extern void G_DrawTilePalSmall(int32_t x,int32_t y,int32_t tilenum,int32_t shade,int32_t orientation,int32_t p);
|
||||
extern void Gv_ResetVars(void);
|
||||
extern void A_ResetVars(int32_t iActor);
|
||||
extern void __fastcall A_ResetVars(register int32_t iActor);
|
||||
|
||||
extern int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb);
|
||||
|
||||
|
@ -219,10 +219,10 @@ extern void Gv_Init(void);
|
|||
extern void Gv_WriteSave(FILE *fil);
|
||||
extern int32_t Gv_ReadSave(int32_t fil);
|
||||
|
||||
extern int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer);
|
||||
extern void __fastcall Gv_SetVar(int32_t id, int32_t lValue, int32_t iActor, int32_t iPlayer);
|
||||
extern int32_t __fastcall Gv_GetVarX(int32_t id);
|
||||
extern void __fastcall Gv_SetVarX(int32_t id, int32_t lValue);
|
||||
extern int32_t __fastcall Gv_GetVar(register int32_t id, register int32_t iActor, register int32_t iPlayer);
|
||||
extern void __fastcall Gv_SetVar(register int32_t id, register int32_t lValue, register int32_t iActor, register int32_t iPlayer);
|
||||
extern int32_t __fastcall Gv_GetVarX(register int32_t id);
|
||||
extern void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue);
|
||||
|
||||
// extern void SetGameArrayID(int32_t id,int32_t index, int32_t lValue);
|
||||
|
||||
|
@ -232,7 +232,7 @@ extern void C_ReportError(int32_t iError);
|
|||
|
||||
extern void onvideomodechange(int32_t newmode);
|
||||
|
||||
extern void X_OnEvent(int32_t iEventID, int32_t sActor, int32_t sPlayer, int32_t lDist);
|
||||
extern void X_OnEvent(register int32_t iEventID, register int32_t sActor, register int32_t sPlayer, register int32_t lDist);
|
||||
|
||||
extern int32_t A_CheckSoundPlaying(int32_t i, int32_t num);
|
||||
extern int32_t S_CheckSoundPlaying(int32_t i, int32_t num);
|
||||
|
|
|
@ -63,7 +63,6 @@ int32_t g_scriptSanityChecks = 1;
|
|||
#define TIMERUPDATESIZ 32
|
||||
|
||||
int32_t g_cameraDistance = 0, g_cameraClock = 0;
|
||||
static int32_t playerswhenstarted;
|
||||
static int32_t qe,cp;
|
||||
static int32_t g_commandSetup = 0;
|
||||
int32_t g_noSetup = 0;
|
||||
|
@ -8892,7 +8891,7 @@ static void G_ShowDebugHelp(void)
|
|||
"-q#\t\tFake multiplayer with # (2-8) players\n"
|
||||
"-rmnet\t\tUse network config file (OBSOLETE, see -net)\n"
|
||||
"-stun\t\tUse UDP hole punching for multiplayer connections\n"
|
||||
"-unstable \tForce EDuke32 to execute unsafe CON commands (and crash)\n"
|
||||
/*"-unstable \tForce EDuke32 to execute unsafe CON commands (and crash)\n"*/
|
||||
"-w\t\tShow coordinates\n"
|
||||
"-z#/-condebug\tEnable line-by-line CON compile debugging at level #\n"
|
||||
;
|
||||
|
@ -9685,7 +9684,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
|||
continue;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
/*
|
||||
if (!Bstrcasecmp(c+1,"unstable"))
|
||||
{
|
||||
initprintf("WARNING WARNING WARNING WARNING\n"
|
||||
|
@ -9698,7 +9697,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
|||
i++;
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
if (!Bstrcasecmp(c+1,"cachesize"))
|
||||
{
|
||||
if (argc > i+1)
|
||||
|
@ -10379,7 +10378,8 @@ static void G_LoadExtraPalettes(void)
|
|||
|
||||
#if defined(__APPLE__) && B_BIG_ENDIAN != 0
|
||||
// this is almost as bad as just setting the value to 25 :P
|
||||
g_numRealPalettes = (g_numRealPalettes * (uint64)0x0202020202 & (uint64)0x010884422010) % 1023;
|
||||
g_numRealPalettes = ((g_numRealPalettes * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32;
|
||||
|
||||
#endif
|
||||
|
||||
for (j = 0; j < 256; j++)
|
||||
|
@ -11135,9 +11135,22 @@ void app_main(int32_t argc,const char **argv)
|
|||
|
||||
if (mod_dir[0] != '/')
|
||||
{
|
||||
char cwd[BMAX_PATH];
|
||||
|
||||
Bstrcat(root,mod_dir);
|
||||
addsearchpath(root);
|
||||
// addsearchpath(mod_dir);
|
||||
|
||||
if (getcwd(cwd,BMAX_PATH))
|
||||
{
|
||||
Bsprintf(cwd,"%s/%s",cwd,mod_dir);
|
||||
if (!Bstrcmp(root, cwd))
|
||||
{
|
||||
if (addsearchpath(cwd) == -2)
|
||||
if (Bmkdir(cwd,S_IRWXU) == 0) addsearchpath(cwd);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
Bsprintf(tempbuf,"%s/%s",mod_dir,TEXCACHEFILE);
|
||||
Bstrcpy(TEXCACHEFILE,tempbuf);
|
||||
|
@ -11390,8 +11403,6 @@ CLEAN_DIRECTORY:
|
|||
|
||||
if (ud.multimode > 1)
|
||||
{
|
||||
playerswhenstarted = ud.multimode;
|
||||
|
||||
if (ud.warp_on == 0)
|
||||
{
|
||||
ud.m_monsters_off = 1;
|
||||
|
@ -11399,6 +11410,7 @@ CLEAN_DIRECTORY:
|
|||
}
|
||||
}
|
||||
|
||||
playerswhenstarted = ud.multimode;
|
||||
ud.last_level = -1;
|
||||
|
||||
if (Bstrcasecmp(ud.rtsname,"DUKE.RTS") == 0 ||
|
||||
|
|
|
@ -1905,7 +1905,8 @@ static inline int32_t C_IntPow2(int32_t v)
|
|||
static inline uint32_t C_Pow2IntLogBase2(int32_t v)
|
||||
{
|
||||
static const uint32_t b[] = {0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0,
|
||||
0xFF00FF00, 0xFFFF0000};
|
||||
0xFF00FF00, 0xFFFF0000
|
||||
};
|
||||
register uint32_t r = (v & b[0]) != 0;
|
||||
int32_t i = 4;
|
||||
|
||||
|
@ -3919,6 +3920,13 @@ static int32_t C_ParseCommand(void)
|
|||
|
||||
C_GetNextValue(LABEL_DEFINE); // the number to check against...
|
||||
|
||||
if (tw == CON_MULVAR && *(g_scriptPtr-1) == -1)
|
||||
{
|
||||
*inst = CON_INV;
|
||||
g_scriptPtr--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tw == CON_DIVVAR || (tw == CON_MULVAR && *(g_scriptPtr-1) > 0))
|
||||
{
|
||||
int32_t i = *(g_scriptPtr-1);
|
||||
|
|
|
@ -39,7 +39,7 @@ vmstate_t vm;
|
|||
int32_t g_errorLineNum;
|
||||
int32_t g_tw;
|
||||
|
||||
static int32_t X_DoExecute(int32_t once);
|
||||
static int32_t X_DoExecute(register int32_t once);
|
||||
|
||||
#include "gamestructures.c"
|
||||
|
||||
|
@ -62,7 +62,7 @@ void X_ScriptInfo(void)
|
|||
}
|
||||
}
|
||||
|
||||
void X_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist)
|
||||
void X_OnEvent(register int32_t iEventID, register int32_t iActor, register int32_t iPlayer, register int32_t lDist)
|
||||
{
|
||||
if (iEventID<0 || iEventID >= MAXGAMEEVENTS)
|
||||
{
|
||||
|
@ -645,7 +645,7 @@ static void X_Move(void)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void __fastcall X_DoConditional(int32_t condition)
|
||||
static inline void __fastcall X_DoConditional(register int32_t condition)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
|
@ -664,9 +664,9 @@ static inline void __fastcall X_DoConditional(int32_t condition)
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t X_DoExecute(int32_t once)
|
||||
static int32_t X_DoExecute(register int32_t once)
|
||||
{
|
||||
int32_t tw;
|
||||
register int32_t tw;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -1402,7 +1402,7 @@ static int32_t X_DoExecute(int32_t once)
|
|||
G_OperateSectors(var1, var2);
|
||||
break;
|
||||
case CON_OPERATEACTIVATORS:
|
||||
if ((var2<0 || var2>=ud.multimode) /* && g_scriptSanityChecks */) {OSD_Printf(CON_ERROR "Invalid player %d\n",g_errorLineNum,keyw[g_tw],var2); break;}
|
||||
if ((var2<0 || var2>=playerswhenstarted) /* && g_scriptSanityChecks */) {OSD_Printf(CON_ERROR "Invalid player %d\n",g_errorLineNum,keyw[g_tw],var2); break;}
|
||||
G_OperateActivators(var1, var2);
|
||||
break;
|
||||
case CON_SETASPECT:
|
||||
|
@ -1590,24 +1590,42 @@ static int32_t X_DoExecute(int32_t once)
|
|||
case CON_QSUBSTR:
|
||||
insptr++;
|
||||
{
|
||||
char *s1,*s2;
|
||||
int32_t q1,q2,st,ln;
|
||||
int32_t q1 = Gv_GetVarX(*insptr++);
|
||||
int32_t q2 = Gv_GetVarX(*insptr++);
|
||||
int32_t st = Gv_GetVarX(*insptr++);
|
||||
int32_t ln = Gv_GetVarX(*insptr++);
|
||||
|
||||
q1 = Gv_GetVarX(*insptr++),
|
||||
q2 = Gv_GetVarX(*insptr++);
|
||||
st = Gv_GetVarX(*insptr++);
|
||||
ln = Gv_GetVarX(*insptr++);
|
||||
|
||||
if ((q1<0 || q1>=MAXQUOTES) /* && g_scriptSanityChecks */) OSD_Printf(CON_ERROR "invalid quote ID %d\n",g_errorLineNum,keyw[g_tw],q1);
|
||||
else if ((ScriptQuotes[q1] == NULL) /* && g_scriptSanityChecks */) OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q1);
|
||||
else if ((q2<0 || q2>=MAXQUOTES) /* && g_scriptSanityChecks */) OSD_Printf(CON_ERROR "invalid quote ID %d\n",g_errorLineNum,keyw[g_tw],q2);
|
||||
else if ((ScriptQuotes[q2] == NULL) /* && g_scriptSanityChecks */) OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q2);
|
||||
else
|
||||
if ((q1<0 || q1>=MAXQUOTES) /* && g_scriptSanityChecks */)
|
||||
{
|
||||
s1=ScriptQuotes[q1];
|
||||
s2=ScriptQuotes[q2];
|
||||
while (*s2&&st--)s2++;
|
||||
while ((*s1=*s2)&&ln--) {s1++; s2++;}
|
||||
OSD_Printf(CON_ERROR "invalid quote ID %d\n",g_errorLineNum,keyw[g_tw],q1);
|
||||
break;
|
||||
}
|
||||
if ((ScriptQuotes[q1] == NULL) /* && g_scriptSanityChecks */)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q1);
|
||||
break;
|
||||
}
|
||||
if ((q2<0 || q2>=MAXQUOTES) /* && g_scriptSanityChecks */)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "invalid quote ID %d\n",g_errorLineNum,keyw[g_tw],q2);
|
||||
break;
|
||||
}
|
||||
if ((ScriptQuotes[q2] == NULL) /* && g_scriptSanityChecks */)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q2);
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
char *s1 = ScriptQuotes[q1];
|
||||
char *s2 = ScriptQuotes[q2];
|
||||
|
||||
while (*s2 && st--) s2++;
|
||||
while ((*s1 = *s2) && ln--)
|
||||
{
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
*s1=0;
|
||||
}
|
||||
break;
|
||||
|
@ -1900,25 +1918,36 @@ static int32_t X_DoExecute(int32_t once)
|
|||
break;
|
||||
}
|
||||
|
||||
case CON_DIST:
|
||||
case CON_LDIST:
|
||||
insptr++;
|
||||
{
|
||||
int32_t distvar = *insptr++, xvar = Gv_GetVarX(*insptr++), yvar = Gv_GetVarX(*insptr++), distx=0;
|
||||
int32_t distvar = *insptr++, xvar = Gv_GetVarX(*insptr++), yvar = Gv_GetVarX(*insptr++);
|
||||
|
||||
if ((xvar < 0 || yvar < 0 || xvar >= MAXSPRITES || yvar >= MAXSPRITES) /* && g_scriptSanityChecks */)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "invalid sprite\n",g_errorLineNum,keyw[g_tw]);
|
||||
break;
|
||||
}
|
||||
if (tw == CON_DIST) distx = dist(&sprite[xvar],&sprite[yvar]);
|
||||
else distx = ldist(&sprite[xvar],&sprite[yvar]);
|
||||
|
||||
Gv_SetVarX(distvar, distx);
|
||||
Gv_SetVarX(distvar, ldist(&sprite[xvar],&sprite[yvar]));
|
||||
break;
|
||||
}
|
||||
|
||||
case CON_DIST:
|
||||
insptr++;
|
||||
{
|
||||
int32_t distvar = *insptr++, xvar = Gv_GetVarX(*insptr++), yvar = Gv_GetVarX(*insptr++);
|
||||
|
||||
if ((xvar < 0 || yvar < 0 || xvar >= MAXSPRITES || yvar >= MAXSPRITES) /* && g_scriptSanityChecks */)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "invalid sprite\n",g_errorLineNum,keyw[g_tw]);
|
||||
break;
|
||||
}
|
||||
|
||||
Gv_SetVarX(distvar, dist(&sprite[xvar],&sprite[yvar]));
|
||||
break;
|
||||
}
|
||||
|
||||
case CON_GETINCANGLE:
|
||||
case CON_GETANGLE:
|
||||
insptr++;
|
||||
{
|
||||
|
@ -1926,11 +1955,17 @@ static int32_t X_DoExecute(int32_t once)
|
|||
int32_t xvar = Gv_GetVarX(*insptr++);
|
||||
int32_t yvar = Gv_GetVarX(*insptr++);
|
||||
|
||||
if (tw==CON_GETANGLE)
|
||||
{
|
||||
Gv_SetVarX(angvar, getangle(xvar,yvar));
|
||||
break;
|
||||
}
|
||||
|
||||
case CON_GETINCANGLE:
|
||||
insptr++;
|
||||
{
|
||||
int32_t angvar = *insptr++;
|
||||
int32_t xvar = Gv_GetVarX(*insptr++);
|
||||
int32_t yvar = Gv_GetVarX(*insptr++);
|
||||
|
||||
Gv_SetVarX(angvar, G_GetAngleDelta(xvar,yvar));
|
||||
break;
|
||||
}
|
||||
|
@ -3440,6 +3475,22 @@ static int32_t X_DoExecute(int32_t once)
|
|||
break;
|
||||
|
||||
case CON_SETPLAYER:
|
||||
insptr++;
|
||||
{
|
||||
// syntax [gs]etplayer[<var>].x <VAR>
|
||||
// <varid> <xxxid> <varid>
|
||||
int32_t lVar1=*insptr++, lLabelID=*insptr++, lParm2 = 0, lVar2;
|
||||
// HACK: need to have access to labels structure at run-time...
|
||||
|
||||
if (PlayerLabels[lLabelID].flags & LABEL_HASPARM2)
|
||||
lParm2=Gv_GetVarX(*insptr++);
|
||||
lVar2=*insptr++;
|
||||
|
||||
X_SetPlayer(lVar1, lLabelID, lVar2, lParm2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case CON_GETPLAYER:
|
||||
insptr++;
|
||||
{
|
||||
|
@ -3452,7 +3503,7 @@ static int32_t X_DoExecute(int32_t once)
|
|||
lParm2=Gv_GetVarX(*insptr++);
|
||||
lVar2=*insptr++;
|
||||
|
||||
X_AccessPlayer(tw==CON_SETPLAYER, lVar1, lLabelID, lVar2, lParm2);
|
||||
X_GetPlayer(lVar1, lLabelID, lVar2, lParm2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3544,7 +3595,7 @@ static int32_t X_DoExecute(int32_t once)
|
|||
{
|
||||
int32_t lVar1=*insptr++, lVar2=*insptr++;
|
||||
|
||||
if ((iPlayer < 0 || iPlayer >= ud.multimode) /* && g_scriptSanityChecks */)
|
||||
if ((iPlayer < 0 || iPlayer >= playerswhenstarted) /* && g_scriptSanityChecks */)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "invalid player ID %d\n",g_errorLineNum,keyw[g_tw],iPlayer);
|
||||
if (lVar1 == MAXGAMEVARS || lVar1 & ((MAXGAMEVARS<<2)|(MAXGAMEVARS<<3))) insptr++;
|
||||
|
@ -3563,6 +3614,24 @@ static int32_t X_DoExecute(int32_t once)
|
|||
}
|
||||
|
||||
case CON_SETACTOR:
|
||||
insptr++;
|
||||
{
|
||||
// syntax [gs]etactor[<var>].x <VAR>
|
||||
// <varid> <xxxid> <varid>
|
||||
|
||||
int32_t lVar1=*insptr++, lLabelID=*insptr++, lParm2 = 0;
|
||||
|
||||
if (ActorLabels[lLabelID].flags & LABEL_HASPARM2)
|
||||
lParm2=Gv_GetVarX(*insptr++);
|
||||
|
||||
{
|
||||
int32_t lVar2=*insptr++;
|
||||
|
||||
X_SetSprite(lVar1, lLabelID, lVar2, lParm2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CON_GETACTOR:
|
||||
insptr++;
|
||||
{
|
||||
|
@ -3577,7 +3646,7 @@ static int32_t X_DoExecute(int32_t once)
|
|||
{
|
||||
int32_t lVar2=*insptr++;
|
||||
|
||||
X_AccessSprite(tw==CON_SETACTOR, lVar1, lLabelID, lVar2, lParm2);
|
||||
X_GetSprite(lVar1, lLabelID, lVar2, lParm2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3622,7 +3691,7 @@ static int32_t X_DoExecute(int32_t once)
|
|||
|
||||
insptr++;
|
||||
|
||||
if ((j < 0 || j >= ud.multimode) /* && g_scriptSanityChecks */)
|
||||
if ((j < 0 || j >= playerswhenstarted) /* && g_scriptSanityChecks */)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Invalid player ID %d\n",g_errorLineNum,keyw[g_tw],j);
|
||||
break;
|
||||
|
@ -4307,7 +4376,7 @@ static int32_t X_DoExecute(int32_t once)
|
|||
if (g_player[vm.g_p].ps->knee_incs == 0 && sprite[g_player[vm.g_p].ps->i].xrepeat >= 40)
|
||||
if (cansee(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z-(4<<8),vm.g_sp->sectnum,g_player[vm.g_p].ps->posx,g_player[vm.g_p].ps->posy,g_player[vm.g_p].ps->posz+(16<<8),sprite[g_player[vm.g_p].ps->i].sectnum))
|
||||
{
|
||||
int32_t j = ud.multimode-1;
|
||||
int32_t j = playerswhenstarted-1;
|
||||
for (; j>=0; j--)
|
||||
{
|
||||
if (g_player[j].ps->actorsqu == vm.g_i)
|
||||
|
@ -4479,7 +4548,7 @@ static int32_t X_DoExecute(int32_t once)
|
|||
break;
|
||||
}
|
||||
}
|
||||
while(!once);
|
||||
while (!once);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4745,7 +4814,7 @@ void G_RestoreMapState(mapstate_t *save)
|
|||
intptr_t j;
|
||||
char phealth[MAXPLAYERS];
|
||||
|
||||
for (i=0; i<ud.multimode; i++)
|
||||
for (i=0; i<playerswhenstarted; i++)
|
||||
phealth[i] = sprite[g_player[i].ps->i].extra;
|
||||
|
||||
pub = NUMPAGES;
|
||||
|
@ -4817,7 +4886,7 @@ void G_RestoreMapState(mapstate_t *save)
|
|||
|
||||
Gv_RefreshPointers();
|
||||
|
||||
for (i=0; i<ud.multimode; i++)
|
||||
for (i=0; i<playerswhenstarted; i++)
|
||||
sprite[g_player[i].ps->i].extra = phealth[i];
|
||||
|
||||
if (g_player[myconnectindex].ps->over_shoulder_on != 0)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -298,7 +298,7 @@ void Gv_WriteSave(FILE *fil)
|
|||
}
|
||||
|
||||
Bsprintf(g_szBuf,"EOF: EDuke32");
|
||||
l=strlen(g_szBuf);
|
||||
l=Bstrlen(g_szBuf);
|
||||
dfwrite(&l,sizeof(l),1,fil);
|
||||
dfwrite(g_szBuf,l,1,fil);
|
||||
}
|
||||
|
@ -503,12 +503,15 @@ int32_t Gv_NewVar(const char *pszLabel, int32_t lValue, uint32_t dwFlags)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void A_ResetVars(int32_t iActor)
|
||||
void __fastcall A_ResetVars(register int32_t iActor)
|
||||
{
|
||||
int32_t i=(MAXGAMEVARS-1);
|
||||
for (; i>=0; i--)
|
||||
if ((aGameVars[i].dwFlags & GAMEVAR_PERACTOR) && !(aGameVars[i].dwFlags & GAMEVAR_NODEFAULT))
|
||||
register int32_t i=(MAXGAMEVARS-1);
|
||||
do
|
||||
{
|
||||
if ((aGameVars[i].dwFlags & (GAMEVAR_PERACTOR|GAMEVAR_NODEFAULT)) == GAMEVAR_PERACTOR)
|
||||
aGameVars[i].val.plValues[iActor]=aGameVars[i].lDefault;
|
||||
}
|
||||
while (i--);
|
||||
}
|
||||
|
||||
static int32_t Gv_GetVarIndex(const char *szGameLabel)
|
||||
|
@ -522,25 +525,22 @@ static int32_t Gv_GetVarIndex(const char *szGameLabel)
|
|||
return i;
|
||||
}
|
||||
|
||||
int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer)
|
||||
int32_t __fastcall Gv_GetVar(register int32_t id, register int32_t iActor, register int32_t iPlayer)
|
||||
{
|
||||
if (id == MAXGAMEVARS)
|
||||
return(*insptr++);
|
||||
|
||||
if (id == g_iThisActorID)
|
||||
return iActor;
|
||||
|
||||
if (id == MAXGAMEVARS)
|
||||
return(*insptr++);
|
||||
|
||||
{
|
||||
int32_t negateResult = 0;
|
||||
register intptr_t negateResult = id&(MAXGAMEVARS<<1);
|
||||
|
||||
if (id >= g_gameVarCount || id < 0)
|
||||
{
|
||||
if (id&(MAXGAMEVARS<<2)) // array
|
||||
{
|
||||
int32_t index=Gv_GetVar(*insptr++,iActor,iPlayer);
|
||||
|
||||
if (id&(MAXGAMEVARS<<1)) // negative array access
|
||||
negateResult = 1;
|
||||
register int32_t index=Gv_GetVar(*insptr++,iActor,iPlayer);
|
||||
|
||||
id &= (MAXGAMEVARS-1);// ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
|
||||
|
||||
|
@ -549,174 +549,102 @@ int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer)
|
|||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return (-aGameArrays[id].plValues[index]);
|
||||
return (aGameArrays[id].plValues[index]);
|
||||
|
||||
return ((aGameArrays[id].plValues[index] ^ -negateResult) + negateResult);
|
||||
}
|
||||
|
||||
if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
|
||||
{
|
||||
int32_t index=Gv_GetVar(*insptr++, iActor, iPlayer), label;
|
||||
register int32_t index=Gv_GetVar(*insptr++, iActor, iPlayer);
|
||||
|
||||
if (id == g_iActorVarID)
|
||||
switch ((id&(MAXGAMEVARS-1)) - g_iSpriteVarID)
|
||||
{
|
||||
if (index >= MAXSPRITES || index < 0)
|
||||
case 0: //if (id == g_iSpriteVarID)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
label = Gv_GetVar(*insptr++, index, iPlayer);
|
||||
// OSD_Printf("actorvar returned %d\n",label);
|
||||
}
|
||||
else label = *insptr++;
|
||||
|
||||
if (id&(MAXGAMEVARS<<1)) // negative array access
|
||||
negateResult = 1;
|
||||
|
||||
id &= (MAXGAMEVARS-1); //~((MAXGAMEVARS<<3)|(MAXGAMEVARS<<1));
|
||||
|
||||
if (id == g_iSpriteVarID)
|
||||
{
|
||||
int32_t parm2 = 0;
|
||||
int32_t parm2 = 0, label = *insptr++;
|
||||
|
||||
/*OSD_Printf("%d %d %d\n",__LINE__,index,label);*/
|
||||
if (ActorLabels[label].flags & LABEL_HASPARM2)
|
||||
parm2 = Gv_GetVar(*insptr++, iActor, iPlayer);
|
||||
|
||||
if (index >= MAXSPRITES || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
return ((X_AccessSpriteX(index, label, parm2) ^ -negateResult) + negateResult);
|
||||
}
|
||||
if (negateResult) return (-X_AccessSpriteX(index, label, parm2));
|
||||
return (X_AccessSpriteX(index, label, parm2));
|
||||
}
|
||||
else if (id == g_iPlayerVarID)
|
||||
case 3: //else if (id == g_iPlayerVarID)
|
||||
{
|
||||
int32_t parm2 = 0;
|
||||
int32_t parm2 = 0, label = *insptr++;
|
||||
|
||||
if (PlayerLabels[label].flags & LABEL_HASPARM2)
|
||||
parm2 = Gv_GetVar(*insptr++, iActor, iPlayer);
|
||||
|
||||
if (index == vm.g_i) index = vm.g_p;
|
||||
if (index >= MAXPLAYERS || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
return ((X_AccessPlayerX(index, label, parm2) ^ -negateResult) + negateResult);
|
||||
}
|
||||
if (negateResult) return (-X_AccessPlayerX(index, label, parm2));
|
||||
return (X_AccessPlayerX(index, label, parm2));
|
||||
}
|
||||
else if (id == g_iActorVarID)
|
||||
{
|
||||
if (index >= MAXSPRITES || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return -label;
|
||||
return label;
|
||||
}
|
||||
else if (id == g_iSectorVarID)
|
||||
{
|
||||
case 4: //else if (id == g_iActorVarID)
|
||||
return ((Gv_GetVar(*insptr++, index, iPlayer) ^ -negateResult) + negateResult);
|
||||
case 1: //else if (id == g_iSectorVarID)
|
||||
if (index == vm.g_i) index = sprite[vm.g_i].sectnum;
|
||||
if (index >= MAXSECTORS || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return ((X_AccessSectorX(index, *insptr++) ^ -negateResult) + negateResult);
|
||||
case 2: //else if (id == g_iWallVarID)
|
||||
return ((X_AccessWallX(index, *insptr++) ^ -negateResult) + negateResult);
|
||||
default:
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return (-X_AccessSectorX(index, label));
|
||||
return (X_AccessSectorX(index, label));
|
||||
}
|
||||
else if (id == g_iWallVarID)
|
||||
{
|
||||
if (index >= MAXWALLS || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return (-X_AccessWallX(index, label));
|
||||
return (X_AccessWallX(index, label));
|
||||
}
|
||||
}
|
||||
|
||||
if ((id&(MAXGAMEVARS<<1)) == 0)
|
||||
id &= (MAXGAMEVARS-1);
|
||||
|
||||
if (!negateResult)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
negateResult = 1;
|
||||
id &= ~(MAXGAMEVARS<<1);
|
||||
}
|
||||
|
||||
switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_INTPTR|
|
||||
GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
switch (aGameVars[id].dwFlags &
|
||||
(GAMEVAR_USER_MASK|GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
{
|
||||
default:
|
||||
if (negateResult) return (-aGameVars[id].val.lValue);
|
||||
return (aGameVars[id].val.lValue);
|
||||
return ((aGameVars[id].val.lValue ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_PERPLAYER:
|
||||
if (iPlayer < 0 || iPlayer >= MAXPLAYERS)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid player ID (%d)\n",g_errorLineNum,keyw[g_tw],iPlayer);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return (-aGameVars[id].val.plValues[iPlayer]);
|
||||
return (aGameVars[id].val.plValues[iPlayer]);
|
||||
if (iPlayer < 0 || iPlayer >= MAXPLAYERS) goto bad_id;
|
||||
return ((aGameVars[id].val.plValues[iPlayer] ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_PERACTOR:
|
||||
if (iActor < 0 || iActor >= MAXSPRITES)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid sprite ID (%d)\n",g_errorLineNum,keyw[g_tw],iActor);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return (-aGameVars[id].val.plValues[iActor]);
|
||||
return (aGameVars[id].val.plValues[iActor]);
|
||||
if (iActor < 0 || iActor >= MAXSPRITES) goto bad_id;
|
||||
return ((aGameVars[id].val.plValues[iActor] ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_INTPTR:
|
||||
if (negateResult) return (-(*((int32_t*)aGameVars[id].val.lValue)));
|
||||
return ((*((int32_t*)aGameVars[id].val.lValue)));
|
||||
return (((*((int32_t*)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_SHORTPTR:
|
||||
if (negateResult) return (-(*((int16_t*)aGameVars[id].val.lValue)));
|
||||
return ((*((int16_t*)aGameVars[id].val.lValue)));
|
||||
return (((*((int16_t*)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_CHARPTR:
|
||||
if (negateResult) return (-(*((char*)aGameVars[id].val.lValue)));
|
||||
return ((*((char*)aGameVars[id].val.lValue)));
|
||||
return (((*((char*)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
|
||||
}
|
||||
|
||||
}
|
||||
bad_id:
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid sprite/player ID %d/%d\n",g_errorLineNum,keyw[g_tw],iActor,iPlayer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void __fastcall Gv_SetVar(int32_t id, int32_t lValue, int32_t iActor, int32_t iPlayer)
|
||||
void __fastcall Gv_SetVar(register int32_t id, register int32_t lValue, register int32_t iActor, register int32_t iPlayer)
|
||||
{
|
||||
if (id<0 || id >= g_gameVarCount)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_SetVar(): tried to set invalid gamevar ID (%d) from sprite %d (%d), player %d\n",g_errorLineNum,keyw[g_tw],id,vm.g_i,sprite[vm.g_i].picnum,vm.g_p);
|
||||
return;
|
||||
}
|
||||
if (id<0 || id >= g_gameVarCount) goto badvarid;
|
||||
|
||||
//Bsprintf(g_szBuf,"SGVI: %d ('%s') to %d for %d %d",id,aGameVars[id].szLabel,lValue,iActor,iPlayer);
|
||||
//AddLog(g_szBuf);
|
||||
|
||||
switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_INTPTR|
|
||||
GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
switch (aGameVars[id].dwFlags &
|
||||
(GAMEVAR_USER_MASK|GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
{
|
||||
default:
|
||||
aGameVars[id].val.lValue=lValue;
|
||||
return;
|
||||
case GAMEVAR_PERPLAYER:
|
||||
if (iPlayer < 0 || iPlayer > MAXPLAYERS-1)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid player (%d) for per-player gamevar %s from sprite %d, player %d\n",g_errorLineNum,keyw[g_tw],iPlayer,aGameVars[id].szLabel,vm.g_i,vm.g_p);
|
||||
return;
|
||||
}
|
||||
if (iPlayer < 0 || iPlayer > MAXPLAYERS-1) goto badplayer;
|
||||
// for the current player
|
||||
aGameVars[id].val.plValues[iPlayer]=lValue;
|
||||
return;
|
||||
case GAMEVAR_PERACTOR:
|
||||
if (iActor < 0 || iActor > MAXSPRITES-1)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid sprite (%d) for per-actor gamevar %s from sprite %d (%d), player %d\n",g_errorLineNum,keyw[g_tw],iActor,aGameVars[id].szLabel,vm.g_i,sprite[vm.g_i].picnum,vm.g_p);
|
||||
return;
|
||||
}
|
||||
// for the current actor
|
||||
if (iActor < 0 || iActor > MAXSPRITES-1) goto badactor;
|
||||
aGameVars[id].val.plValues[iActor]=lValue;
|
||||
return;
|
||||
case GAMEVAR_INTPTR:
|
||||
|
@ -726,30 +654,39 @@ void __fastcall Gv_SetVar(int32_t id, int32_t lValue, int32_t iActor, int32_t iP
|
|||
*((int16_t*)aGameVars[id].val.lValue)=(int16_t)lValue;
|
||||
return;
|
||||
case GAMEVAR_CHARPTR:
|
||||
*((char*)aGameVars[id].val.lValue)=(uint8_t)lValue;
|
||||
*((uint8_t*)aGameVars[id].val.lValue)=(uint8_t)lValue;
|
||||
return;
|
||||
}
|
||||
|
||||
badvarid:
|
||||
OSD_Printf(CON_ERROR "Gv_SetVar(): tried to set invalid gamevar ID (%d) from sprite %d (%d), player %d\n",g_errorLineNum,keyw[g_tw],id,vm.g_i,sprite[vm.g_i].picnum,vm.g_p);
|
||||
return;
|
||||
|
||||
badplayer:
|
||||
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid player (%d) for per-player gamevar %s from sprite %d, player %d\n",g_errorLineNum,keyw[g_tw],iPlayer,aGameVars[id].szLabel,vm.g_i,vm.g_p);
|
||||
return;
|
||||
|
||||
badactor:
|
||||
OSD_Printf(CON_ERROR "Gv_SetVar(): invalid sprite (%d) for per-actor gamevar %s from sprite %d (%d), player %d\n",g_errorLineNum,keyw[g_tw],iActor,aGameVars[id].szLabel,vm.g_i,sprite[vm.g_i].picnum,vm.g_p);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t __fastcall Gv_GetVarX(int32_t id)
|
||||
int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||
{
|
||||
if (id == MAXGAMEVARS)
|
||||
return(*insptr++);
|
||||
|
||||
if (id == g_iThisActorID)
|
||||
return vm.g_i;
|
||||
|
||||
if (id == MAXGAMEVARS)
|
||||
return(*insptr++);
|
||||
|
||||
{
|
||||
int32_t negateResult = 0;
|
||||
register intptr_t negateResult = id&(MAXGAMEVARS<<1);
|
||||
|
||||
if (id >= g_gameVarCount || id < 0)
|
||||
{
|
||||
if (id&(MAXGAMEVARS<<2)) // array
|
||||
{
|
||||
int32_t index=Gv_GetVarX(*insptr++);
|
||||
|
||||
if (id&(MAXGAMEVARS<<1)) // negative array access
|
||||
negateResult = 1;
|
||||
register int32_t index=Gv_GetVarX(*insptr++);
|
||||
|
||||
id &= (MAXGAMEVARS-1);// ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
|
||||
|
||||
|
@ -758,134 +695,80 @@ int32_t __fastcall Gv_GetVarX(int32_t id)
|
|||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return (-aGameArrays[id].plValues[index]);
|
||||
return (aGameArrays[id].plValues[index]);
|
||||
return ((aGameArrays[id].plValues[index] ^ -negateResult) + negateResult);
|
||||
}
|
||||
|
||||
if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
|
||||
{
|
||||
int32_t index=Gv_GetVarX(*insptr++), label;
|
||||
register int32_t index=Gv_GetVarX(*insptr++);
|
||||
|
||||
if (id&(MAXGAMEVARS<<1)) // negative array access
|
||||
negateResult = 1;
|
||||
|
||||
id &= (MAXGAMEVARS-1);// ~((MAXGAMEVARS<<3)|(MAXGAMEVARS<<1));
|
||||
|
||||
if (id == g_iActorVarID)
|
||||
switch ((id&(MAXGAMEVARS-1)) - g_iSpriteVarID)
|
||||
{
|
||||
if (index >= MAXSPRITES || index < 0)
|
||||
case 0: //if (id == g_iSpriteVarID)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
label = Gv_GetVar(*insptr++, index, vm.g_p);
|
||||
}
|
||||
else label = *insptr++;
|
||||
|
||||
if (id == g_iSpriteVarID)
|
||||
{
|
||||
int32_t parm2 = 0;
|
||||
int32_t parm2 = 0, label = *insptr++;
|
||||
|
||||
/*OSD_Printf("%d %d %d\n",__LINE__,index,label);*/
|
||||
if (ActorLabels[label].flags & LABEL_HASPARM2)
|
||||
parm2 = Gv_GetVarX(*insptr++);
|
||||
if (index >= MAXSPRITES || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (negateResult) return (-X_AccessSpriteX(index, label, parm2));
|
||||
return (X_AccessSpriteX(index, label, parm2));
|
||||
return ((X_AccessSpriteX(index, label, parm2) ^ -negateResult) + negateResult);
|
||||
}
|
||||
else if (id == g_iPlayerVarID)
|
||||
case 3: //else if (id == g_iPlayerVarID)
|
||||
{
|
||||
int32_t parm2 = 0;
|
||||
int32_t parm2 = 0, label = *insptr++;
|
||||
|
||||
if (PlayerLabels[label].flags & LABEL_HASPARM2)
|
||||
parm2 = Gv_GetVarX(*insptr++);
|
||||
|
||||
if (index == vm.g_i) index = vm.g_p;
|
||||
if (index >= MAXPLAYERS || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
return ((X_AccessPlayerX(index, label, parm2) ^ -negateResult) + negateResult);
|
||||
}
|
||||
if (negateResult) return (-X_AccessPlayerX(index, label, parm2));
|
||||
return (X_AccessPlayerX(index, label, parm2));
|
||||
}
|
||||
else if (id == g_iActorVarID)
|
||||
{
|
||||
if (index >= MAXSPRITES || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return -label;
|
||||
return label;
|
||||
}
|
||||
else if (id == g_iSectorVarID)
|
||||
{
|
||||
case 4: //else if (id == g_iActorVarID)
|
||||
return ((Gv_GetVar(*insptr++, index, vm.g_p) ^ -negateResult) + negateResult);
|
||||
case 1: //else if (id == g_iSectorVarID)
|
||||
if (index == vm.g_i) index = sprite[vm.g_i].sectnum;
|
||||
if (index >= MAXSECTORS || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return ((X_AccessSectorX(index, *insptr++) ^ -negateResult) + negateResult);
|
||||
case 2: //else if (id == g_iWallVarID)
|
||||
return ((X_AccessWallX(index, *insptr++) ^ -negateResult) + negateResult);
|
||||
default:
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return (-X_AccessSectorX(index, label));
|
||||
return (X_AccessSectorX(index, label));
|
||||
}
|
||||
else if (id == g_iWallVarID)
|
||||
{
|
||||
if (index >= MAXWALLS || index < 0)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
if (negateResult) return (-X_AccessWallX(index, label));
|
||||
return (X_AccessWallX(index, label));
|
||||
}
|
||||
}
|
||||
|
||||
if ((id&(MAXGAMEVARS<<1)) == 0)
|
||||
id &= (MAXGAMEVARS-1);
|
||||
|
||||
if (!negateResult)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVar(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
negateResult = 1;
|
||||
id &= ~(MAXGAMEVARS<<1);
|
||||
}
|
||||
|
||||
switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_INTPTR|
|
||||
GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
switch (aGameVars[id].dwFlags &
|
||||
(GAMEVAR_USER_MASK|GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
{
|
||||
default:
|
||||
if (negateResult) return (-aGameVars[id].val.lValue);
|
||||
return (aGameVars[id].val.lValue);
|
||||
return ((aGameVars[id].val.lValue ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_PERPLAYER:
|
||||
if (negateResult) return (-aGameVars[id].val.plValues[vm.g_p]);
|
||||
return (aGameVars[id].val.plValues[vm.g_p]);
|
||||
return ((aGameVars[id].val.plValues[vm.g_p] ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_PERACTOR:
|
||||
if (negateResult) return (-aGameVars[id].val.plValues[vm.g_i]);
|
||||
return (aGameVars[id].val.plValues[vm.g_i]);
|
||||
return ((aGameVars[id].val.plValues[vm.g_i] ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_INTPTR:
|
||||
if (negateResult) return (-(*((int32_t*)aGameVars[id].val.lValue)));
|
||||
return (*((int32_t*)aGameVars[id].val.lValue));
|
||||
return (((*((int32_t*)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_SHORTPTR:
|
||||
if (negateResult) return (-(*((int16_t*)aGameVars[id].val.lValue)));
|
||||
return (*((int16_t*)aGameVars[id].val.lValue));
|
||||
return (((*((int16_t*)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_CHARPTR:
|
||||
if (negateResult) return (-(*((char*)aGameVars[id].val.lValue)));
|
||||
return (*((char*)aGameVars[id].val.lValue));
|
||||
return (((*((uint8_t*)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall Gv_SetVarX(int32_t id, int32_t lValue)
|
||||
void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
|
||||
{
|
||||
switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_INTPTR|
|
||||
GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
switch (aGameVars[id].dwFlags &
|
||||
(GAMEVAR_USER_MASK|GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
{
|
||||
default:
|
||||
aGameVars[id].val.lValue=lValue;
|
||||
|
@ -903,7 +786,7 @@ void __fastcall Gv_SetVarX(int32_t id, int32_t lValue)
|
|||
*((int16_t*)aGameVars[id].val.lValue)=(int16_t)lValue;
|
||||
return;
|
||||
case GAMEVAR_CHARPTR:
|
||||
*((char*)aGameVars[id].val.lValue)=(uint8_t)lValue;
|
||||
*((uint8_t*)aGameVars[id].val.lValue)=(uint8_t)lValue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,8 @@ sound_t g_sounds[ MAXSOUNDS ];
|
|||
|
||||
char g_numPlayerSprites,g_loadFromGroupOnly=0,g_earthquakeTime;
|
||||
|
||||
int32_t playerswhenstarted;
|
||||
|
||||
int32_t fricxv,fricyv;
|
||||
playerdata_t g_player[MAXPLAYERS];
|
||||
input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
|
||||
|
|
|
@ -363,7 +363,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
|
|||
s-> y -= y;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = s->sectnum;
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = s->x+((sintable[(s->ang+512)&2047])>>4);
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = s->y+((sintable[(s->ang)&2047])>>4);
|
||||
|
@ -384,7 +384,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
|
|||
|
||||
if (gamelightcount < PR_MAXLIGHTS)
|
||||
gamelightcount++;
|
||||
*/
|
||||
*/
|
||||
break;
|
||||
}
|
||||
#endif // POLYMER
|
||||
|
@ -406,7 +406,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
|
|||
s-> x -= x;
|
||||
s-> y -= y;
|
||||
|
||||
/*
|
||||
/*
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = s->sectnum;
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = s->x+((sintable[(s->ang+512)&2047])>>4);
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = s->y+((sintable[(s->ang)&2047])>>4);
|
||||
|
@ -427,7 +427,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
|
|||
|
||||
if (gamelightcount < PR_MAXLIGHTS)
|
||||
gamelightcount++;
|
||||
*/
|
||||
*/
|
||||
}
|
||||
#endif // POLYMER
|
||||
|
||||
|
@ -2202,7 +2202,7 @@ void P_FireWeapon(DukePlayer_t *p)
|
|||
ActorExtra[p->i].lightcount = 2;
|
||||
s->x -= x;
|
||||
s->y -= y;
|
||||
/*
|
||||
/*
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = s->sectnum;
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = s->x+((sintable[(p->ang+512)&2047])>>4);
|
||||
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = s->y+((sintable[(p->ang)&2047])>>4);
|
||||
|
@ -2223,7 +2223,7 @@ void P_FireWeapon(DukePlayer_t *p)
|
|||
|
||||
if (gamelightcount < PR_MAXLIGHTS)
|
||||
gamelightcount++;
|
||||
*/
|
||||
*/
|
||||
#endif // POLYMER
|
||||
lastvisinc = totalclock+32;
|
||||
p->visibility = 0;
|
||||
|
|
|
@ -1868,7 +1868,10 @@ int32_t G_EnterLevel(int32_t g)
|
|||
}
|
||||
|
||||
if ((g&MODE_GAME) || (g&MODE_EOL))
|
||||
g_player[myconnectindex].ps->gm = MODE_GAME;
|
||||
{
|
||||
TRAVERSE_CONNECT(i)
|
||||
g_player[i].ps->gm = MODE_GAME;
|
||||
}
|
||||
else if (g&MODE_RESTART)
|
||||
{
|
||||
if (ud.recstat == 2)
|
||||
|
|
Loading…
Reference in a new issue