diff options
-rw-r--r-- | source/cl_draw.c | 28 | ||||
-rw-r--r-- | source/com_local.h | 4 | ||||
-rw-r--r-- | source/com_public.h | 12 | ||||
-rw-r--r-- | source/cvar.c | 3 | ||||
-rw-r--r-- | source/gl_main.c | 21 | ||||
-rw-r--r-- | source/gl_models.c | 18 | ||||
-rw-r--r-- | source/mvd_game.c | 1 | ||||
-rw-r--r-- | source/q_files.h | 15 | ||||
-rw-r--r-- | source/sys_unix.c | 52 | ||||
-rw-r--r-- | source/sys_win.c | 14 |
10 files changed, 93 insertions, 75 deletions
diff --git a/source/cl_draw.c b/source/cl_draw.c index 6dfc1ba..3c2c675 100644 --- a/source/cl_draw.c +++ b/source/cl_draw.c @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. cvar_t *scr_draw2d; cvar_t *scr_showturtle; cvar_t *scr_showfollowing; +cvar_t *scr_showstats; cvar_t *scr_lag_x; cvar_t *scr_lag_y; cvar_t *scr_lag_draw; @@ -818,6 +819,28 @@ static void draw_turtle( void ) { #undef DF } +static void SCR_DrawStats( void ) { + char buffer[MAX_QPATH]; + int i, j; + int x, y; + + j = scr_showstats->integer; + if( j > MAX_STATS ) { + j = MAX_STATS; + } + x = 8; + y = ( scr_hudHeight - j * CHAR_HEIGHT ) / 2; + for( i = 0; i < j; i++ ) { + Com_sprintf( buffer, sizeof( buffer ), "%2d: %d", i, cl.frame.ps.stats[i] ); + if( cl.oldframe.ps.stats[i] != cl.frame.ps.stats[i] ) { + ref.SetColor( DRAW_COLOR_RGBA, colorRed ); + } + ref.DrawString( x, y, 0, MAX_STRING_CHARS, buffer, scr_font ); + ref.SetColor( DRAW_COLOR_CLEAR, NULL ); + y += CHAR_HEIGHT; + } +} + /* ================= SCR_Draw2D @@ -903,6 +926,10 @@ void SCR_Draw2D( void ) { draw_turtle(); } + if( scr_showstats->integer ) { + SCR_DrawStats(); + } + SCR_DrawPause(); if( scr_glconfig.renderer == GL_RENDERER_SOFTWARE ) { @@ -935,6 +962,7 @@ void SCR_InitDraw( void ) { scr_lag_y = Cvar_Get( "scr_lag_y", "-1", 0 ); scr_lag_draw = Cvar_Get( "scr_lag_draw", "0", 0 ); scr_alpha = Cvar_Get( "scr_alpha", "1", 0 ); + scr_showstats = Cvar_Get( "scr_showstats", "0", 0 ); Cmd_Register( scr_drawcmds ); } diff --git a/source/com_local.h b/source/com_local.h index d7b0a2c..9e8be04 100644 --- a/source/com_local.h +++ b/source/com_local.h @@ -1036,8 +1036,8 @@ void Sys_SetClipboardData( const char *data ); void Sys_Sleep( int msec ); void Sys_Setenv( const char *name, const char *value ); -void Hunk_Begin( mempool_t *pool, int maxsize ); -void *Hunk_Alloc( mempool_t *pool, int size ); +void Hunk_Begin( mempool_t *pool, size_t maxsize ); +void *Hunk_Alloc( mempool_t *pool, size_t size ); void Hunk_Free( mempool_t *pool ); void Sys_Init( void ); diff --git a/source/com_public.h b/source/com_public.h index b446baf..84fa8c8 100644 --- a/source/com_public.h +++ b/source/com_public.h @@ -239,18 +239,18 @@ SYSTEM */ typedef struct { - byte *base; - int maxsize; - int cursize; - int mapped; + void *base; + size_t maxsize; + size_t cursize; + size_t mapped; } mempool_t; typedef struct sysAPI_s { unsigned (*Milliseconds)( void ); char *(*GetClipboardData)( void ); void (*SetClipboardData)( const char *data ); - void (*HunkBegin)( mempool_t *pool, int maxsize ); - void *(*HunkAlloc)( mempool_t *pool, int size ); + void (*HunkBegin)( mempool_t *pool, size_t maxsize ); + void *(*HunkAlloc)( mempool_t *pool, size_t size ); void (*HunkEnd)( mempool_t *pool ); void (*HunkFree)( mempool_t *pool ); } sysAPI_t; diff --git a/source/cvar.c b/source/cvar.c index e27ae16..cf09eca 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -229,7 +229,8 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { // update default string if cvar was set from command line Z_Free( var->default_string ); var->default_string = Cvar_CopyString( var_value ); - if( ( flags & ( CVAR_NOSET | CVAR_ROM ) || + if( ( ( flags & CVAR_ROM ) || + ( ( flags & CVAR_NOSET ) && com_initialized ) || ( ( flags & CVAR_CHEAT ) && !CL_CheatsOK() ) ) && strcmp( var_value, var->string ) ) { diff --git a/source/gl_main.c b/source/gl_main.c index 76e78fd..02b9b74 100644 --- a/source/gl_main.c +++ b/source/gl_main.c @@ -274,22 +274,25 @@ static void GL_DrawSpriteModel( model_t *model ) { entity_t *e = glr.ent; spriteFrame_t *frame; image_t *image; - int idx, bits; + int bits; float alpha; - idx = e->frame % model->numFrames; - frame = &model->sframes[idx]; + frame = &model->sframes[e->frame % model->numFrames]; image = frame->image; GL_TexEnv( GL_MODULATE ); - alpha = 1; - bits = GLS_DEFAULT; - if( e->flags & RF_TRANSLUCENT ) { - alpha = e->alpha; - bits = GLS_BLEND_BLEND; - } + alpha = ( e->flags & RF_TRANSLUCENT ) ? e->alpha : 1.0f; + if( alpha == 1.0f ) { + if( image->flags & if_transparent ) { + bits = GLS_ALPHATEST_ENABLE; + } else { + bits = GLS_DEFAULT; + } + } else { + bits = GLS_BLEND_BLEND; + } GL_Bits( bits ); qglColor4f( 1, 1, 1, alpha ); diff --git a/source/gl_models.c b/source/gl_models.c index 5defe24..e1a6848 100644 --- a/source/gl_models.c +++ b/source/gl_models.c @@ -760,10 +760,10 @@ static qboolean Model_LoadSp2( model_t *model, const byte *rawdata, int length ) dsprite_t *header; dsprframe_t *src_frame; spriteFrame_t *dst_frame; - int ident, version, numframes; - int i, width, height; + unsigned ident, version, numframes, width, height; char buffer[MAX_SKINNAME]; image_t *image; + int i; if( length < sizeof( *header ) ) { Com_EPrintf( "%s has length < header length\n", model->name ); @@ -784,25 +784,17 @@ static qboolean Model_LoadSp2( model_t *model, const byte *rawdata, int length ) Com_EPrintf( "%s is not an sp2 file\n", model->name ); return qfalse; } - if( version != SPRITE_VERSION ) { Com_EPrintf( "%s has bad version: %d != %d\n", model->name, version, ALIAS_VERSION ); return qfalse; } - - if( numframes < 1 ) { + if( numframes < 1 || numframes > MAX_MD2SKINS ) { Com_EPrintf( "%s has bad number of frames: %d\n", model->name, numframes ); return qfalse; } - if( numframes > MAX_MD2SKINS ) { - Com_EPrintf( "%s has too many frames: %d > %d\n", - model->name, numframes, MAX_MD2SKINS ); - return qfalse; - } - model->type = MODEL_SPRITE; sys.HunkBegin( &model->pool, 0x10000 ); @@ -814,8 +806,8 @@ static qboolean Model_LoadSp2( model_t *model, const byte *rawdata, int length ) for( i = 0; i < numframes; i++ ) { width = LittleLong( src_frame->width ); height = LittleLong( src_frame->height ); - if( width <= 0 || height <= 0 ) { - Com_WPrintf( "%s has bad image dimensions for frame #%d: %d x %d\n", + if( width < 1 || height < 1 || width > MAX_TEXTURE_SIZE || height > MAX_TEXTURE_SIZE ) { + Com_WPrintf( "%s has bad image dimensions for frame #%d: %ux%u\n", model->name, width, height, i ); width = 1; height = 1; diff --git a/source/mvd_game.c b/source/mvd_game.c index a6f7f6a..cbaacfe 100644 --- a/source/mvd_game.c +++ b/source/mvd_game.c @@ -31,6 +31,7 @@ static cvar_t *mvd_flood_msgs; static cvar_t *mvd_flood_persecond; static cvar_t *mvd_flood_waitdelay; static cvar_t *mvd_flood_mute; +static cvar_t *mvd_stats_hack; udpClient_t *mvd_clients; diff --git a/source/q_files.h b/source/q_files.h index 0f08bcb..38f2e42 100644 --- a/source/q_files.h +++ b/source/q_files.h @@ -264,17 +264,16 @@ typedef struct { // little-endian "IDS2" #define SPRITE_VERSION 2 -typedef struct -{ - int width, height; - int origin_x, origin_y; // raster coordinates inside pic - char name[MAX_SKINNAME]; // name of pcx file +typedef struct { + uint32_t width, height; + uint32_t origin_x, origin_y; // raster coordinates inside pic + char name[MAX_SKINNAME]; // name of pcx file } dsprframe_t; typedef struct { - int ident; - int version; - int numframes; + uint32_t ident; + uint32_t version; + uint32_t numframes; dsprframe_t frames[1]; // variable sized } dsprite_t; diff --git a/source/sys_unix.c b/source/sys_unix.c index b05993f..2f48063 100644 --- a/source/sys_unix.c +++ b/source/sys_unix.c @@ -405,15 +405,15 @@ HUNK =============================================================================== */ -void Hunk_Begin( mempool_t *pool, int maxsize ) { - byte *buf; +void Hunk_Begin( mempool_t *pool, size_t maxsize ) { + void *buf; // reserve a huge chunk of memory, but don't commit any yet pool->maxsize = ( maxsize + 4095 ) & ~4095; pool->cursize = 0; buf = mmap( NULL, pool->maxsize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0 ); - if( buf == NULL || buf == ( byte * )-1 ) { + if( buf == NULL || buf == ( void * )-1 ) { Com_Error( ERR_FATAL, "%s: unable to virtual allocate %d bytes", __func__, pool->maxsize ); } @@ -421,47 +421,41 @@ void Hunk_Begin( mempool_t *pool, int maxsize ) { pool->mapped = pool->maxsize; } -void *Hunk_Alloc( mempool_t *pool, int size ) { - byte *buf; +void *Hunk_Alloc( mempool_t *pool, size_t size ) { + void *buf; // round to cacheline size = ( size + 31 ) & ~31; if( pool->cursize + size > pool->maxsize ) { - Com_Error( ERR_FATAL, "%s: unable to allocate %d bytes out of %d", + Com_Error( ERR_FATAL, "%s: unable to allocate %"PRIz" bytes out of %"PRIz, __func__, size, pool->maxsize ); } - buf = pool->base + pool->cursize; + buf = ( byte * )pool->base + pool->cursize; pool->cursize += size; return buf; } void Hunk_End( mempool_t *pool ) { - byte *n; + size_t newsize = ( pool->cursize + 4095 ) & ~4095; -#ifndef __linux__ - size_t old_size = pool->maxsize; - size_t new_size = pool->cursize; - void * unmap_base; - size_t unmap_len; - - new_size = round_page(new_size); - old_size = round_page(old_size); - if (new_size > old_size) { - Com_Error( ERR_FATAL, "Hunk_End: new_size > old_size" ); + if( newsize > pool->maxsize ) { + Com_Error( ERR_FATAL, "%s: newsize > maxsize", __func__ ); } - if (new_size < old_size) { - unmap_base = (caddr_t)(pool->base + new_size); - unmap_len = old_size - new_size; - n = munmap(unmap_base, unmap_len) + pool->base; - } + + if( newsize < pool->maxsize ) { +#ifdef __linux__ + void *buf = mremap( pool->base, pool->maxsize, newsize, 0 ); #else - n = mremap( pool->base, pool->maxsize, pool->cursize, 0 ); + void *unmap_base = ( byte * )pool->base + newsize; + size_t unmap_len = pool->maxsize - newsize; + void *buf = munmap( unmap_base, unmap_len ) + pool->base; #endif - if( n != pool->base ) { - Com_Error( ERR_FATAL, "%s: could not remap virtual block: %s", - __func__, strerror( errno ) ); - } - pool->mapped = pool->cursize; + if( buf != pool->base ) { + Com_Error( ERR_FATAL, "%s: could not remap virtual block: %s", + __func__, strerror( errno ) ); + } + } + pool->mapped = newsize; } void Hunk_Free( mempool_t *pool ) { diff --git a/source/sys_win.c b/source/sys_win.c index e5764f2..06d6ebd 100644 --- a/source/sys_win.c +++ b/source/sys_win.c @@ -574,19 +574,19 @@ HUNK =============================================================================== */ -void Hunk_Begin( mempool_t *pool, int maxsize ) { +void Hunk_Begin( mempool_t *pool, size_t maxsize ) { // reserve a huge chunk of memory, but don't commit any yet pool->cursize = 0; pool->maxsize = ( maxsize + 4095 ) & ~4095; pool->base = VirtualAlloc( NULL, pool->maxsize, MEM_RESERVE, PAGE_NOACCESS ); if( !pool->base ) { Com_Error( ERR_FATAL, - "VirtualAlloc reserve %d bytes failed. GetLastError() = %lu", + "VirtualAlloc reserve %"PRIz" bytes failed. GetLastError() = %lu", pool->maxsize, GetLastError() ); } } -void *Hunk_Alloc( mempool_t *pool, int size ) { +void *Hunk_Alloc( mempool_t *pool, size_t size ) { void *buf; // round to cacheline @@ -594,17 +594,17 @@ void *Hunk_Alloc( mempool_t *pool, int size ) { pool->cursize += size; if( pool->cursize > pool->maxsize ) - Com_Error( ERR_FATAL, "Hunk_Alloc: couldn't allocate %d bytes", size ); + Com_Error( ERR_FATAL, "%s: couldn't allocate %"PRIz" bytes", __func__, size ); // commit pages as needed buf = VirtualAlloc( pool->base, pool->cursize, MEM_COMMIT, PAGE_READWRITE ); if( !buf ) { Com_Error( ERR_FATAL, - "VirtualAlloc commit %d bytes failed. GetLastError() = %lu", + "VirtualAlloc commit %"PRIz" bytes failed. GetLastError() = %lu", pool->cursize, GetLastError() ); } - return ( void * )( pool->base + pool->cursize - size ); + return ( byte * )pool->base + pool->cursize - size; } void Hunk_End( mempool_t *pool ) { @@ -618,7 +618,7 @@ void Hunk_Free( mempool_t *pool ) { } } - memset( pool, 0, sizeof( pool ) ); + memset( pool, 0, sizeof( *pool ) ); } /* |