Run engine source through new version of astyle, add printf() call to OSD_Printf() to facilitate console access through stdin/stdout for dedicated server mode, minor changes to sdlayer to allow operating without actually initializing SDL

git-svn-id: https://svn.eduke32.com/eduke32@1762 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2011-01-16 02:50:27 +00:00
parent 1579d2edd3
commit ef912658a0
24 changed files with 3513 additions and 3445 deletions

View file

@ -2834,7 +2834,8 @@ void overheadeditor(void)
// visitedwall[j>>3] |= (1<<(j&7)); // visitedwall[j>>3] |= (1<<(j&7));
n--; n--;
} }
} while (j!=refwall && n>0); }
while (j!=refwall && n>0);
if (j!=refwall) if (j!=refwall)
{ {
message("internal error while trying to trace outer loop: j!=refwall"); message("internal error while trying to trace outer loop: j!=refwall");

View file

@ -538,7 +538,8 @@ int32_t clipmapinfo_load(const char *filename)
} }
} }
} }
} while (++scnt < numclipsects); }
while (++scnt < numclipsects);
if (outersect==-1) if (outersect==-1)
{ {

View file

@ -337,7 +337,8 @@ static void suckbitsnextblock()
if (!zipfilmode) if (!zipfilmode)
{ {
if (!nfilptr) if (!nfilptr)
{ //|===|===|crc|lng|typ|===|===| {
//|===|===|crc|lng|typ|===|===|
// \ fakebuf: / // \ fakebuf: /
// |===|===| // |===|===|
//----x O---x O-------- //----x O---x O--------
@ -1603,7 +1604,8 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
if (!dctbuf) quanptr = &quantab[lcompquantab[c]][0]; if (!dctbuf) quanptr = &quantab[lcompquantab[c]][0];
for (yy=0; yy<(lcompvsamp[c]<<3); yy+=8) for (yy=0; yy<(lcompvsamp[c]<<3); yy+=8)
for (xx=0; xx<(lcomphsamp[c]<<3); xx+=8) for (xx=0; xx<(lcomphsamp[c]<<3); xx+=8)
{ //NOTE: Might help to split this code into firstime vs. refinement (!Ah vs. Ah!=0) {
//NOTE: Might help to split this code into firstime vs. refinement (!Ah vs. Ah!=0)
if (dctbuf) dcs = &ldctptr[c][(((y+yy)>>lshy[c])*ldctx[c] + ((x+xx)>>lshx[c]))<<6]; if (dctbuf) dcs = &ldctptr[c][(((y+yy)>>lshy[c])*ldctx[c] + ((x+xx)>>lshx[c]))<<6];
@ -1825,7 +1827,8 @@ static int32_t kgifrend(const char *kfilebuf, int32_t kfilelength,
if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; } if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; }
transcol = -1; transcol = -1;
while ((chunkind = *ptr++) == '!') while ((chunkind = *ptr++) == '!')
{ //! 0xf9 leng flags ? ? transcol {
//! 0xf9 leng flags ? ? transcol
if (ptr[0] == 0xf9) { if (ptr[2]&1) transcol = (int32_t)(((uint8_t)ptr[5])); } if (ptr[0] == 0xf9) { if (ptr[2]&1) transcol = (int32_t)(((uint8_t)ptr[5])); }
ptr++; ptr++;
do { i = *ptr++; ptr += i; } do { i = *ptr++; ptr += i; }
@ -2479,7 +2482,8 @@ void kpgetdim(const char *buf, int32_t leng, int32_t *xsiz, int32_t *ysiz)
(*ysiz) = LSWAPIB(*(int32_t *)&buf[12]); (*ysiz) = LSWAPIB(*(int32_t *)&buf[12]);
} }
else else
{ //Unreliable .TGA identification - this MUST be final case! {
//Unreliable .TGA identification - this MUST be final case!
if ((leng >= 19) && (!(ubuf[1]&0xfe))) if ((leng >= 19) && (!(ubuf[1]&0xfe)))
if ((ubuf[2] < 12) && ((1<<ubuf[2])&0xe0e)) if ((ubuf[2] < 12) && ((1<<ubuf[2])&0xe0e))
if ((!(ubuf[16]&7)) && (ubuf[16] != 0) && (ubuf[16] <= 32)) if ((!(ubuf[16]&7)) && (ubuf[16] != 0) && (ubuf[16] <= 32))

View file

@ -1644,7 +1644,8 @@ static int md3postload_polymer_check(md3model_t *m)
// let the vertices know they're being referenced by a triangle // let the vertices know they're being referenced by a triangle
if (s->tris[trii].i[0] >= s->numverts || s->tris[trii].i[0] < 0 || if (s->tris[trii].i[0] >= s->numverts || s->tris[trii].i[0] < 0 ||
s->tris[trii].i[1] >= s->numverts || s->tris[trii].i[1] < 0 || s->tris[trii].i[1] >= s->numverts || s->tris[trii].i[1] < 0 ||
s->tris[trii].i[2] >= s->numverts || s->tris[trii].i[2] < 0) { s->tris[trii].i[2] >= s->numverts || s->tris[trii].i[2] < 0)
{
// corrupt model // corrupt model
OSD_Printf("Triangle index out of bounds!\n"); OSD_Printf("Triangle index out of bounds!\n");
return 0; return 0;
@ -1711,7 +1712,8 @@ int md3postload_polymer(md3model_t* m)
// let the vertices know they're being referenced by a triangle // let the vertices know they're being referenced by a triangle
if (s->tris[trii].i[0] >= s->numverts || s->tris[trii].i[0] < 0 || if (s->tris[trii].i[0] >= s->numverts || s->tris[trii].i[0] < 0 ||
s->tris[trii].i[1] >= s->numverts || s->tris[trii].i[1] < 0 || s->tris[trii].i[1] >= s->numverts || s->tris[trii].i[1] < 0 ||
s->tris[trii].i[2] >= s->numverts || s->tris[trii].i[2] < 0) { s->tris[trii].i[2] >= s->numverts || s->tris[trii].i[2] < 0)
{
// corrupt model // corrupt model
Bfree(numtris); Bfree(numtris);
OSD_Printf("Triangle index out of bounds!\n"); OSD_Printf("Triangle index out of bounds!\n");

View file

@ -172,7 +172,8 @@ static LPVOID ChkedTlsGetValue(DWORD idx)
#if defined(__cplusplus) #if defined(__cplusplus)
#if !defined(NO_NED_NAMESPACE) #if !defined(NO_NED_NAMESPACE)
namespace nedalloc { namespace nedalloc
{
#else #else
extern "C" { extern "C" {
#endif #endif
@ -290,7 +291,8 @@ static FORCEINLINE NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *CallRealloc(void
size_t *_ret=0, *_mem=(size_t *) mem-3; size_t *_ret=0, *_mem=(size_t *) mem-3;
#endif #endif
if (isforeign) if (isforeign)
{ /* Transfer */ {
/* Transfer */
#if USE_MAGIC_HEADERS #if USE_MAGIC_HEADERS
assert(_mem[0]!=*(size_t *) "NEDMALOC"); assert(_mem[0]!=*(size_t *) "NEDMALOC");
#endif #endif
@ -325,7 +327,8 @@ static FORCEINLINE NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *CallRealloc(void
#endif #endif
#endif #endif
if (!ret) if (!ret)
{ /* Put it back the way it was */ {
/* Put it back the way it was */
#if USE_MAGIC_HEADERS #if USE_MAGIC_HEADERS
for (; *_mem==0; *_mem++=*(size_t *) "NEDMALOC"); for (; *_mem==0; *_mem++=*(size_t *) "NEDMALOC");
#endif #endif
@ -412,7 +415,8 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC
result1=header & mask1; /* Positive testing for NT heap */ result1=header & mask1; /* Positive testing for NT heap */
result2=header & mask2; /* Positive testing for dlmalloc */ result2=header & mask2; /* Positive testing for dlmalloc */
if (result1==0x00000100 && result2!=0x00000102) if (result1==0x00000100 && result2!=0x00000102)
{ /* This is likely a NT heap block */ {
/* This is likely a NT heap block */
return 0; return 0;
} }
#endif #endif
@ -554,7 +558,8 @@ NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void **nedindependent_comalloc(size_t elem
struct threadcacheblk_t; struct threadcacheblk_t;
typedef struct threadcacheblk_t threadcacheblk; typedef struct threadcacheblk_t threadcacheblk;
struct threadcacheblk_t struct threadcacheblk_t
{ /* Keep less than 16 bytes on 32 bit systems and 32 bytes on 64 bit systems */ {
/* Keep less than 16 bytes on 32 bit systems and 32 bytes on 64 bit systems */
#ifdef FULLSANITYCHECKS #ifdef FULLSANITYCHECKS
unsigned int magic; unsigned int magic;
#endif #endif
@ -589,7 +594,8 @@ struct nedpool_t
static nedpool syspool; static nedpool syspool;
static FORCEINLINE NEDMALLOCNOALIASATTR unsigned int size2binidx(size_t _size) THROWSPEC static FORCEINLINE NEDMALLOCNOALIASATTR unsigned int size2binidx(size_t _size) THROWSPEC
{ /* 8=1000 16=10000 20=10100 24=11000 32=100000 48=110000 4096=1000000000000 */ {
/* 8=1000 16=10000 20=10100 24=11000 32=100000 48=110000 4096=1000000000000 */
unsigned int topbit, size=(unsigned int)(_size>>4); unsigned int topbit, size=(unsigned int)(_size>>4);
/* 16=1 20=1 24=1 32=10 48=11 64=100 96=110 128=1000 4096=100000000 */ /* 16=1 20=1 24=1 32=10 48=11 64=100 96=110 128=1000 4096=100000000 */
@ -741,7 +747,8 @@ static NOINLINE threadcache *AllocCache(nedpool *RESTRICT p) THROWSPEC
#endif #endif
for (n=0; n<THREADCACHEMAXCACHES && p->caches[n]; n++); for (n=0; n<THREADCACHEMAXCACHES && p->caches[n]; n++);
if (THREADCACHEMAXCACHES==n) if (THREADCACHEMAXCACHES==n)
{ /* List exhausted, so disable for this thread */ {
/* List exhausted, so disable for this thread */
#if USE_LOCKS #if USE_LOCKS
RELEASE_LOCK(&p->mutex); RELEASE_LOCK(&p->mutex);
#endif #endif
@ -814,7 +821,8 @@ static void *threadcache_malloc(nedpool *RESTRICT p, threadcache *RESTRICT tc, s
/* Try to match close, but move up a bin if necessary */ /* Try to match close, but move up a bin if necessary */
blk=*binsptr; blk=*binsptr;
if (!blk || blk->size<size) if (!blk || blk->size<size)
{ /* Bump it up a bin */ {
/* Bump it up a bin */
if (idx<THREADCACHEMAXBINS) if (idx<THREADCACHEMAXBINS)
{ {
idx++; idx++;
@ -944,7 +952,8 @@ static void threadcache_free(nedpool *RESTRICT p, threadcache *RESTRICT tc, int
static NOINLINE int InitPool(nedpool *RESTRICT p, size_t capacity, int threads) THROWSPEC static NOINLINE int InitPool(nedpool *RESTRICT p, size_t capacity, int threads) THROWSPEC
{ /* threads is -1 for system pool */ {
/* threads is -1 for system pool */
ensure_initialization(); ensure_initialization();
ACQUIRE_MALLOC_GLOBAL_LOCK(); ACQUIRE_MALLOC_GLOBAL_LOCK();
if (p->threads) goto done; if (p->threads) goto done;
@ -982,7 +991,8 @@ err:
return 0; return 0;
} }
static NOINLINE mstate FindMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc, int *RESTRICT lastUsed, size_t size) THROWSPEC static NOINLINE mstate FindMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc, int *RESTRICT lastUsed, size_t size) THROWSPEC
{ /* Gets called when thread's last used mspace is in use. The strategy {
/* Gets called when thread's last used mspace is in use. The strategy
is to run through the list of all available mspaces looking for an is to run through the list of all available mspaces looking for an
unlocked one and if we fail, we create a new one so long as we don't unlocked one and if we fail, we create a new one so long as we don't
exceed p->threads */ exceed p->threads */
@ -1011,7 +1021,8 @@ static NOINLINE mstate FindMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc,
while (p->m[end] && end<p->threads) while (p->m[end] && end<p->threads)
end++; end++;
if (end>=p->threads) if (end>=p->threads)
{ /* Drat, must destroy it now */ {
/* Drat, must destroy it now */
RELEASE_LOCK(&p->mutex); RELEASE_LOCK(&p->mutex);
#if USE_ALLOCATOR==1 #if USE_ALLOCATOR==1
destroy_mspace((mstate) temp); destroy_mspace((mstate) temp);
@ -1207,11 +1218,13 @@ void nedtrimthreadcache(nedpool *p, int disable) THROWSPEC
} }
mycache=(int)(size_t) TLSGET(p->mycache); mycache=(int)(size_t) TLSGET(p->mycache);
if (!mycache) if (!mycache)
{ /* Set to mspace 0 */ {
/* Set to mspace 0 */
if (disable && TLSSET(p->mycache, (void *)(size_t)-1)) abort(); if (disable && TLSSET(p->mycache, (void *)(size_t)-1)) abort();
} }
else if (mycache>0) else if (mycache>0)
{ /* Set to last used mspace */ {
/* Set to last used mspace */
threadcache *tc=p->caches[mycache-1]; threadcache *tc=p->caches[mycache-1];
#if defined(DEBUG) #if defined(DEBUG)
printf("Threadcache utilisation: %lf%% in cache with %lf%% lost to other threads\n", printf("Threadcache utilisation: %lf%% in cache with %lf%% lost to other threads\n",
@ -1253,7 +1266,8 @@ void neddisablethreadcache(nedpool *p) THROWSPEC
#endif #endif
static FORCEINLINE mstate GetMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace, size_t size) THROWSPEC static FORCEINLINE mstate GetMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace, size_t size) THROWSPEC
{ /* Returns a locked and ready for use mspace */ {
/* Returns a locked and ready for use mspace */
mstate m=p->m[mymspace]; mstate m=p->m[mymspace];
assert(m); assert(m);
#if USE_LOCKS && USE_ALLOCATOR==1 #if USE_LOCKS && USE_ALLOCATOR==1
@ -1270,10 +1284,12 @@ static NOINLINE void GetThreadCache_cold1(nedpool *RESTRICT *RESTRICT p) THROWSP
static NOINLINE void GetThreadCache_cold2(nedpool *RESTRICT *RESTRICT p, threadcache *RESTRICT *RESTRICT tc, int *RESTRICT mymspace, int mycache) THROWSPEC static NOINLINE void GetThreadCache_cold2(nedpool *RESTRICT *RESTRICT p, threadcache *RESTRICT *RESTRICT tc, int *RESTRICT mymspace, int mycache) THROWSPEC
{ {
if (!mycache) if (!mycache)
{ /* Need to allocate a new cache */ {
/* Need to allocate a new cache */
*tc=AllocCache(*p); *tc=AllocCache(*p);
if (!*tc) if (!*tc)
{ /* Disable */ {
/* Disable */
if (TLSSET((*p)->mycache, (void *)(size_t)-1)) abort(); if (TLSSET((*p)->mycache, (void *)(size_t)-1)) abort();
*mymspace=0; *mymspace=0;
} }
@ -1294,7 +1310,8 @@ static FORCEINLINE void GetThreadCache(nedpool *RESTRICT *RESTRICT p, threadcach
GetThreadCache_cold1(p); GetThreadCache_cold1(p);
mycache=(int)(size_t) TLSGET((*p)->mycache); mycache=(int)(size_t) TLSGET((*p)->mycache);
if (mycache>0) if (mycache>0)
{ /* Already have a cache */ {
/* Already have a cache */
*tc=(*p)->caches[mycache-1]; *tc=(*p)->caches[mycache-1];
*mymspace=(*tc)->mymspace; *mymspace=(*tc)->mymspace;
} }
@ -1322,12 +1339,14 @@ NEDMALLOCPTRATTR void * nedpmalloc(nedpool *p, size_t size) THROWSPEC
GetThreadCache(&p, &tc, &mymspace, &size); GetThreadCache(&p, &tc, &mymspace, &size);
#if THREADCACHEMAX #if THREADCACHEMAX
if (tc && size<=THREADCACHEMAX) if (tc && size<=THREADCACHEMAX)
{ /* Use the thread cache */ {
/* Use the thread cache */
ret=threadcache_malloc(p, tc, &size); ret=threadcache_malloc(p, tc, &size);
} }
#endif #endif
if (!ret) if (!ret)
{ /* Use this thread's mspace */ {
/* Use this thread's mspace */
GETMSPACE(m, p, tc, mymspace, size, GETMSPACE(m, p, tc, mymspace, size,
ret=CallMalloc(m, size, 0)); ret=CallMalloc(m, size, 0));
} }
@ -1342,13 +1361,15 @@ NEDMALLOCPTRATTR void * nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC
GetThreadCache(&p, &tc, &mymspace, &rsize); GetThreadCache(&p, &tc, &mymspace, &rsize);
#if THREADCACHEMAX #if THREADCACHEMAX
if (tc && rsize<=THREADCACHEMAX) if (tc && rsize<=THREADCACHEMAX)
{ /* Use the thread cache */ {
/* Use the thread cache */
if ((ret=threadcache_malloc(p, tc, &rsize))) if ((ret=threadcache_malloc(p, tc, &rsize)))
memset(ret, 0, rsize); memset(ret, 0, rsize);
} }
#endif #endif
if (!ret) if (!ret)
{ /* Use this thread's mspace */ {
/* Use this thread's mspace */
GETMSPACE(m, p, tc, mymspace, rsize, GETMSPACE(m, p, tc, mymspace, rsize,
ret=CallCalloc(m, rsize, 0)); ret=CallCalloc(m, rsize, 0));
} }
@ -1379,7 +1400,8 @@ NEDMALLOCPTRATTR void * nedprealloc(nedpool *p, void *mem, size_t size) THROWSPE
GetThreadCache(&p, &tc, &mymspace, &size); GetThreadCache(&p, &tc, &mymspace, &size);
#if THREADCACHEMAX #if THREADCACHEMAX
if (tc && size && size<=THREADCACHEMAX) if (tc && size && size<=THREADCACHEMAX)
{ /* Use the thread cache */ {
/* Use the thread cache */
if ((ret=threadcache_malloc(p, tc, &size))) if ((ret=threadcache_malloc(p, tc, &size)))
{ {
memcpy(ret, mem, memsize<size ? memsize : size); memcpy(ret, mem, memsize<size ? memsize : size);
@ -1391,20 +1413,23 @@ NEDMALLOCPTRATTR void * nedprealloc(nedpool *p, void *mem, size_t size) THROWSPE
} }
#endif #endif
if (!ret) if (!ret)
{ /* Reallocs always happen in the mspace they happened in, so skip {
/* Reallocs always happen in the mspace they happened in, so skip
locking the preferred mspace for this thread */ locking the preferred mspace for this thread */
ret=CallRealloc(p->m[mymspace], mem, isforeign, memsize, size); ret=CallRealloc(p->m[mymspace], mem, isforeign, memsize, size);
} }
return ret; return ret;
} }
void nedpfree(nedpool *p, void *mem) THROWSPEC void nedpfree(nedpool *p, void *mem) THROWSPEC
{ /* Frees always happen in the mspace they happened in, so skip {
/* Frees always happen in the mspace they happened in, so skip
locking the preferred mspace for this thread */ locking the preferred mspace for this thread */
threadcache *tc; threadcache *tc;
int mymspace, isforeign=1; int mymspace, isforeign=1;
size_t memsize; size_t memsize;
if (!mem) if (!mem)
{ /* If you tried this on FreeBSD you'd be sorry! */ {
/* If you tried this on FreeBSD you'd be sorry! */
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nedmalloc: WARNING nedpfree() called with zero. This is not portable behaviour!\n"); fprintf(stderr, "nedmalloc: WARNING nedpfree() called with zero. This is not portable behaviour!\n");
#endif #endif

View file

@ -283,17 +283,17 @@ int32_t OSD_OSDKey(void)
char *OSD_GetTextPtr(void) char *OSD_GetTextPtr(void)
{ {
return (&osdtext[0]); return osdtext;
} }
char *OSD_GetFmtPtr(void) char *OSD_GetFmtPtr(void)
{ {
return (&osdfmt[0]); return osdfmt;
} }
char *OSD_GetFmt(char *ptr) char *OSD_GetFmt(char *ptr)
{ {
return (ptr - &osdtext[0] + &osdfmt[0]); return (ptr - osdtext + osdfmt);
} }
int32_t OSD_GetCols(void) int32_t OSD_GetCols(void)
@ -603,13 +603,9 @@ static int32_t _internal_osdfunc_help(const osdfuncparm_t *parm)
if (parm->numparms != 1) return OSDCMD_SHOWHELP; if (parm->numparms != 1) return OSDCMD_SHOWHELP;
symb = findexactsymbol(parm->parms[0]); symb = findexactsymbol(parm->parms[0]);
if (!symb) if (!symb)
{ OSD_Printf("Error: no help for undefined symbol \"%s\"\n", parm->parms[0]);
OSD_Printf("Help Error: \"%s\" is not a defined variable or function\n", parm->parms[0]);
}
else else
{
OSD_Printf("%s\n", symb->help); OSD_Printf("%s\n", symb->help);
}
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -653,8 +649,11 @@ void OSD_Cleanup(void)
Bfree(symbols); Bfree(symbols);
} }
if (osdlog) Bfclose(osdlog); if (osdlog)
{
Bfclose(osdlog);
osdlog = NULL; osdlog = NULL;
}
if (cvars) if (cvars)
{ {
@ -770,8 +769,12 @@ void OSD_Init(void)
// //
void OSD_SetLogFile(char *fn) void OSD_SetLogFile(char *fn)
{ {
if (osdlog) Bfclose(osdlog); if (osdlog)
{
Bfclose(osdlog);
osdlog = NULL; osdlog = NULL;
}
if (fn) osdlog = Bfopen(fn,"w"); if (fn) osdlog = Bfopen(fn,"w");
if (osdlog) setvbuf(osdlog, (char *)NULL, _IONBF, 0); if (osdlog) setvbuf(osdlog, (char *)NULL, _IONBF, 0);
} }
@ -1505,11 +1508,6 @@ void OSD_Printf(const char *fmt, ...)
char *chp, p=osdtextpal, s=osdtextshade; char *chp, p=osdtextpal, s=osdtextshade;
va_list va; va_list va;
/*
if ((osdflags & OSD_INITIALIZED) == 0)
OSD_Init();
*/
mutex_lock(&m_osdprintf); mutex_lock(&m_osdprintf);
va_start(va, fmt); va_start(va, fmt);
@ -1518,7 +1516,8 @@ void OSD_Printf(const char *fmt, ...)
if (tmpstr[0]=='^' && tmpstr[1]=='1' && tmpstr[2]=='0' && ++OSD_errors > MAX_ERRORS) if (tmpstr[0]=='^' && tmpstr[1]=='1' && tmpstr[2]=='0' && ++OSD_errors > MAX_ERRORS)
{ {
if (OSD_errors == MAX_ERRORS+1) Bstrcpy(tmpstr,OSD_ERROR "\nToo many errors. Logging errors stopped.\n"); if (OSD_errors == MAX_ERRORS + 1)
Bstrcpy(tmpstr, OSD_ERROR "\nToo many errors. Logging errors stopped.\n");
else else
{ {
OSD_errors = MAX_ERRORS + 2; OSD_errors = MAX_ERRORS + 2;
@ -1533,6 +1532,7 @@ void OSD_Printf(const char *fmt, ...)
{ {
chp = Bstrdup(tmpstr); chp = Bstrdup(tmpstr);
Bfputs(OSD_StripColors(chp, tmpstr), osdlog); Bfputs(OSD_StripColors(chp, tmpstr), osdlog);
Bprintf("%s", chp);
Bfree(chp); Bfree(chp);
} }
} }
@ -1552,11 +1552,13 @@ void OSD_Printf(const char *fmt, ...)
OSD_LineFeed(); OSD_LineFeed();
continue; continue;
} }
if (*chp == '\r') if (*chp == '\r')
{ {
osdpos=0; osdpos=0;
continue; continue;
} }
if (*chp == '^') if (*chp == '^')
{ {
if (isdigit(*(chp+1))) if (isdigit(*(chp+1)))
@ -1569,12 +1571,14 @@ void OSD_Printf(const char *fmt, ...)
p = atol(smallbuf); p = atol(smallbuf);
continue; continue;
} }
smallbuf[0] = *(chp++); smallbuf[0] = *(chp++);
smallbuf[1] = *(chp); smallbuf[1] = *(chp);
smallbuf[2] = '\0'; smallbuf[2] = '\0';
p = atol(smallbuf); p = atol(smallbuf);
continue; continue;
} }
if (Btoupper(*(chp+1)) == 'S') if (Btoupper(*(chp+1)) == 'S')
{ {
chp++; chp++;
@ -1582,6 +1586,7 @@ void OSD_Printf(const char *fmt, ...)
s = *chp; s = *chp;
continue; continue;
} }
if (Btoupper(*(chp+1)) == 'O') if (Btoupper(*(chp+1)) == 'O')
{ {
chp++; chp++;
@ -1590,8 +1595,10 @@ void OSD_Printf(const char *fmt, ...)
continue; continue;
} }
} }
osdtext[osdpos] = *chp; osdtext[osdpos] = *chp;
osdfmt[osdpos++] = p+(s<<5); osdfmt[osdpos++] = p+(s<<5);
if (osdpos == osdcols) if (osdpos == osdcols)
{ {
osdpos = 0; osdpos = 0;

View file

@ -5305,13 +5305,16 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (dastat&4) { x1 = -x1; y1 = -y1; } if (dastat&4) { x1 = -x1; y1 = -y1; }
// In Polymost, we don't care if the model is very big // In Polymost, we don't care if the model is very big
if (rendmode < 4) { if (rendmode < 4)
{
tspr.xrepeat = tspr.yrepeat = 32; tspr.xrepeat = tspr.yrepeat = 32;
tspr.x = (int32_t)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx); tspr.x = (int32_t)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx);
tspr.y = (int32_t)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy); tspr.y = (int32_t)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy);
tspr.z = (int32_t)(globalposz + y1*16384.0*0.8); tspr.z = (int32_t)(globalposz + y1*16384.0*0.8);
} else { }
else
{
float x, y, z; float x, y, z;
tspr.xrepeat = tspr.yrepeat = 5; tspr.xrepeat = tspr.yrepeat = 5;
@ -5373,7 +5376,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (!nofog) bglDisable(GL_FOG); if (!nofog) bglDisable(GL_FOG);
if (rendmode < 4) if (rendmode < 4)
mddraw(&tspr); mddraw(&tspr);
else { else
{
tspriteptr[MAXSPRITESONSCREEN] = &tspr; tspriteptr[MAXSPRITESONSCREEN] = &tspr;
bglEnable(GL_ALPHA_TEST); bglEnable(GL_ALPHA_TEST);

View file

@ -54,7 +54,7 @@ int32_t _buildargc = 1;
const char **_buildargv = NULL; const char **_buildargv = NULL;
extern int32_t app_main(int32_t argc, const char *argv[]); extern int32_t app_main(int32_t argc, const char *argv[]);
char quitevent=0, appactive=1; char quitevent=0, appactive=1, novideo=0;
// video // video
static SDL_Surface *sdl_surface; static SDL_Surface *sdl_surface;
@ -294,10 +294,17 @@ int32_t initsystem(void)
| SDL_INIT_NOPARACHUTE | SDL_INIT_NOPARACHUTE
#endif #endif
)) ))
{
initprintf("Initialization failed! (%s)\nNon-interactive mode enabled\n", SDL_GetError());
/* if (SDL_Init(0))
{ {
initprintf("Initialization failed! (%s)\n", SDL_GetError()); initprintf("Initialization failed! (%s)\n", SDL_GetError());
return -1; return -1;
} }
else
*/
novideo = nogl = 1;
}
signal(SIGSEGV, sighandler); signal(SIGSEGV, sighandler);
signal(SIGABRT, sighandler); signal(SIGABRT, sighandler);
@ -309,7 +316,7 @@ int32_t initsystem(void)
lockcount = 0; lockcount = 0;
#ifdef USE_OPENGL #ifdef USE_OPENGL
if (loadgldriver(getenv("BUILD_GLDRV"))) if (!novideo && loadgldriver(getenv("BUILD_GLDRV")))
{ {
initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n"); initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n");
nogl = 1; nogl = 1;
@ -319,11 +326,16 @@ int32_t initsystem(void)
#ifndef __APPLE__ #ifndef __APPLE__
//icon = loadtarga("icon.tga"); //icon = loadtarga("icon.tga");
if (!novideo)
{
appicon = loadappicon(); appicon = loadappicon();
if (appicon) if (appicon)
SDL_WM_SetIcon(appicon, 0); SDL_WM_SetIcon(appicon, 0);
}
#endif #endif
if (!novideo)
if (SDL_VideoDriverName(drvname, 32)) if (SDL_VideoDriverName(drvname, 32))
initprintf("Using \"%s\" video driver\n", drvname); initprintf("Using \"%s\" video driver\n", drvname);
@ -384,8 +396,8 @@ void initprintf(const char *f, ...)
Bvsnprintf(buf, sizeof(buf), f, va); Bvsnprintf(buf, sizeof(buf), f, va);
va_end(va); va_end(va);
OSD_Printf(buf); OSD_Printf("%s", buf);
Bprintf("%s", buf); // Bprintf("%s", buf);
mutex_lock(&m_initprintf); mutex_lock(&m_initprintf);
if (Bstrlen(dabuf) + Bstrlen(buf) > 1022) if (Bstrlen(dabuf) + Bstrlen(buf) > 1022)
@ -793,7 +805,7 @@ void getvalidmodes(void)
#endif #endif
int32_t i, j, maxx=0, maxy=0; int32_t i, j, maxx=0, maxy=0;
if (modeschecked) return; if (modeschecked || novideo) return;
validmodecnt=0; validmodecnt=0;
// initprintf("Detecting video modes:\n"); // initprintf("Detecting video modes:\n");
@ -1131,28 +1143,33 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
glinfo.extensions = (const char *)bglGetString(GL_EXTENSIONS); glinfo.extensions = (const char *)bglGetString(GL_EXTENSIONS);
#ifdef POLYMER #ifdef POLYMER
if (!Bstrcmp(glinfo.vendor,"ATI Technologies Inc.")) { if (!Bstrcmp(glinfo.vendor,"ATI Technologies Inc."))
{
pr_ati_fboworkaround = 1; pr_ati_fboworkaround = 1;
initprintf("Enabling ATI FBO color attachment workaround.\n"); initprintf("Enabling ATI FBO color attachment workaround.\n");
if (!Bstrncmp(glinfo.renderer,"Radeon X1", 9)) { if (Bstrstr(glinfo.renderer,"Radeon X1"))
{
pr_ati_nodepthoffset = 1; pr_ati_nodepthoffset = 1;
initprintf("Enabling ATI R520 polygon offset workaround.\n"); initprintf("Enabling ATI R520 polygon offset workaround.\n");
} else }
else
pr_ati_nodepthoffset = 0; pr_ati_nodepthoffset = 0;
#ifdef __APPLE__ #ifdef __APPLE__
//See bug description at http://lists.apple.com/archives/mac-opengl/2005/Oct/msg00169.html //See bug description at http://lists.apple.com/archives/mac-opengl/2005/Oct/msg00169.html
if (!Bstrncmp(glinfo.renderer,"ATI Radeon 9600", 15)) { if (!Bstrncmp(glinfo.renderer,"ATI Radeon 9600", 15))
{
pr_ati_textureformat_one = 1; pr_ati_textureformat_one = 1;
initprintf("Enabling ATI Radeon 9600 texture format workaround.\n"); initprintf("Enabling ATI Radeon 9600 texture format workaround.\n");
} else }
else
pr_ati_textureformat_one = 0; pr_ati_textureformat_one = 0;
#endif #endif
} else }
else
pr_ati_fboworkaround = 0; pr_ati_fboworkaround = 0;
#endif #endif
glinfo.maxanisotropy = 1.0; glinfo.maxanisotropy = 1.0;
glinfo.bgra = 0; glinfo.bgra = 0;
glinfo.texcompr = 0; glinfo.texcompr = 0;
@ -1487,6 +1504,8 @@ int32_t setgamma(void)
double invgamma = 1 / gamma; double invgamma = 1 / gamma;
double norm = pow(255., invgamma - 1); double norm = pow(255., invgamma - 1);
if (novideo) return 0;
// This formula is taken from Doomsday // This formula is taken from Doomsday
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
@ -1857,19 +1876,23 @@ static int32_t SDL_WaitEventTimeout(SDL_Event * event, int32_t timeout)
if (timeout > 0) if (timeout > 0)
expiration = SDL_GetTicks() + timeout; expiration = SDL_GetTicks() + timeout;
for (;;) { for (;;)
{
SDL_PumpEvents(); SDL_PumpEvents();
switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, ~0)) { //SDL_FIRSTEVENT, SDL_LASTEVENT)) { switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, ~0)) //SDL_FIRSTEVENT, SDL_LASTEVENT)) {
{
case -1: case -1:
return 0; return 0;
case 1: case 1:
return 1; return 1;
case 0: case 0:
if (timeout == 0) { if (timeout == 0)
{
/* Polling and no events, just return */ /* Polling and no events, just return */
return 0; return 0;
} }
if (timeout > 0 && ((int32_t) (SDL_GetTicks() - expiration) >= 0)) { if (timeout > 0 && ((int32_t)(SDL_GetTicks() - expiration) >= 0))
{
/* Timeout expired and no events */ /* Timeout expired and no events */
return 0; return 0;
} }

View file

@ -9,7 +9,8 @@
#include "editor.h" #include "editor.h"
#include "baselayer.h" #include "baselayer.h"
enum { enum
{
TAB_CONFIG, TAB_CONFIG,
TAB_MESSAGES, TAB_MESSAGES,
}; };