diff options
-rw-r--r-- | source/cl_draw.c | 44 | ||||
-rw-r--r-- | source/cvar.c | 58 | ||||
-rw-r--r-- | source/g_public.h | 6 | ||||
-rw-r--r-- | source/gl_draw.c | 14 | ||||
-rw-r--r-- | source/gl_mesh.c | 4 | ||||
-rw-r--r-- | source/mvd_game.c | 3 | ||||
-rw-r--r-- | source/q_msg.h | 3 | ||||
-rw-r--r-- | source/q_shared.c | 11 | ||||
-rw-r--r-- | source/q_shared.h | 4 | ||||
-rw-r--r-- | source/sv_ents.c | 6 | ||||
-rw-r--r-- | source/sv_game.c | 65 | ||||
-rw-r--r-- | source/sv_local.h | 3 | ||||
-rw-r--r-- | source/sv_main.c | 6 | ||||
-rw-r--r-- | source/sv_user.c | 2 | ||||
-rw-r--r-- | source/sv_world.c | 10 | ||||
-rw-r--r-- | source/sw_alias.c | 3 |
16 files changed, 119 insertions, 123 deletions
diff --git a/source/cl_draw.c b/source/cl_draw.c index eddb357..6dfc1ba 100644 --- a/source/cl_draw.c +++ b/source/cl_draw.c @@ -471,24 +471,38 @@ typedef struct { cmd_macro_t *macro; // int stat; //}; + unsigned color; } drawobj_t; static list_t scr_objects; +static void SCR_Color_g( genctx_t *ctx ) { + int color; + + for( color = 0; color < 10; color++ ) { + if( !Prompt_AddMatch( ctx, colorNames[color] ) ) { + break; + } + } +} + static void SCR_Draw_c( genctx_t *ctx, int argnum ) { if( argnum == 1 ) { Cvar_Variable_g( ctx ); Cmd_Macro_g( ctx ); + } else if( argnum == 4 ) { + SCR_Color_g( ctx ); } } // draw cl_fps -1 80 static void SCR_Draw_f( void ) { int x, y; - const char *s; + const char *s, *c; drawobj_t *obj; cmd_macro_t *macro; // int stat; + int color = COLOR_RESET; int argc = Cmd_Argc(); if( argc == 1 ) { @@ -506,7 +520,7 @@ static void SCR_Draw_f( void ) { } if( argc < 4 ) { - Com_Printf( "Usage: %s <name> <x> <y>\n", Cmd_Argv( 0 ) ); + Com_Printf( "Usage: %s <name> <x> <y> [color]\n", Cmd_Argv( 0 ) ); return; } @@ -514,9 +528,23 @@ static void SCR_Draw_f( void ) { x = atoi( Cmd_Argv( 2 ) ); y = atoi( Cmd_Argv( 3 ) ); + if( argc > 4 ) { + c = Cmd_Argv( 4 ); + for( color = 0; color < 10; color++ ) { + if( !strcmp( colorNames[color], c ) ) { + break; + } + } + if( color == 10 ) { + Com_Printf( "Unknown color '%s'\n", c ); + return; + } + } + obj = Z_Malloc( sizeof( *obj ) ); obj->x = x; obj->y = y; + obj->color = color; #if 0 if( *s == '!' || *s == '#' ) { @@ -547,6 +575,10 @@ static void SCR_Draw_g( genctx_t *ctx ) { drawobj_t *obj; const char *s; + if( LIST_EMPTY( &scr_objects ) ) { + return; + } + Prompt_AddMatch( ctx, "all" ); LIST_FOR_EACH( drawobj_t, obj, &scr_objects, entry ) { @@ -624,7 +656,12 @@ static void draw_objects( void ) { flags |= UI_RIGHT; } if( y < 0 ) { - y += scr_hudHeight - 8 + 1; + y += scr_hudHeight - CHAR_HEIGHT + 1; + } + if( obj->color == 8 ) { + flags |= UI_ALTCOLOR; + } else if( obj->color < 8 ) { + ref.SetColor( DRAW_COLOR_RGB, colorTable[obj->color] ); } if( obj->macro ) { obj->macro->function( buffer, sizeof( buffer ) ); @@ -632,6 +669,7 @@ static void draw_objects( void ) { } else { SCR_DrawString( x, y, flags, obj->cvar->string ); } + ref.SetColor( DRAW_COLOR_CLEAR, NULL ); } } diff --git a/source/cvar.c b/source/cvar.c index 79df3f0..e27ae16 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -162,6 +162,25 @@ static void Cvar_ParseString( cvar_t *var ) { } } +static void Cvar_UpdateString( cvar_t *var, const char *value, cvarSetSource_t source ) { + Z_Free( var->string ); // free the old value string + + var->string = Cvar_CopyString( value ); + Cvar_ParseString( var ); + + if( var->flags & CVAR_INFOMASK ) { + cvar_infoModified |= var->flags & CVAR_INFOMASK; + if( var->flags & CVAR_USERINFO ) { + CL_UpdateUserinfo( var, source ); + } + } + + var->modified = qtrue; + if( source != CVAR_SET_DIRECT && var->changed ) { + var->changed( var ); + } +} + /* ============ @@ -199,17 +218,8 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { if( ( var->flags & CVAR_LATCHED ) && var->latched_string ) { if( strcmp( var->latched_string, var->string ) ) { // update latched cvar - Z_Free( var->string ); - var->string = Cvar_CopyString( var->latched_string ); - Cvar_ParseString( var ); - - if( var->flags & CVAR_USERINFO ) { - CL_UpdateUserinfo( var, CVAR_SET_DIRECT ); - } - - var->modified = qtrue; + Cvar_UpdateString( var, var->latched_string, CVAR_SET_DIRECT ); } - Z_Free( var->latched_string ); var->latched_string = NULL; } @@ -219,6 +229,13 @@ 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 ) || + ( ( flags & CVAR_CHEAT ) && !CL_CheatsOK() ) ) + && strcmp( var_value, var->string ) ) + { + // reset cvar back to default value + Cvar_UpdateString( var, var_value, CVAR_SET_DIRECT ); + } var->flags &= ~CVAR_USER_CREATED; } else if( !( var->flags & CVAR_DEFAULTS_MIXED ) ) { if( strcmp( var->default_string, var_value ) ) { @@ -229,6 +246,7 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { } #if 1 if( ( var->flags & CVAR_LATCHED ) && !( flags & CVAR_LATCHED ) ) { + // cvar is no longer latched if( var->latched_string ) { Z_Free( var->latched_string ); var->latched_string = NULL; @@ -281,6 +299,9 @@ Cvar_SetByVar ============ */ void Cvar_SetByVar( cvar_t *var, const char *value, cvarSetSource_t source ) { + if( !value ) { + value = ""; + } if( !strcmp( value, var->string ) && !( var->flags & (CVAR_LATCHED|CVAR_LATCH) ) ) { @@ -395,23 +416,8 @@ void Cvar_SetByVar( cvar_t *var, const char *value, cvarSetSource_t source ) { Z_Free( var->latched_string ); var->latched_string = NULL; } - - Z_Free( var->string ); // free the old value string - - var->string = Cvar_CopyString( value ); - Cvar_ParseString( var ); - if( var->flags & CVAR_INFOMASK ) { - cvar_infoModified |= var->flags & CVAR_INFOMASK; - if( var->flags & CVAR_USERINFO ) { - CL_UpdateUserinfo( var, source ); - } - } - - var->modified = qtrue; - if( source != CVAR_SET_DIRECT && var->changed ) { - var->changed( var ); - } + Cvar_UpdateString( var, value, source ); } /* diff --git a/source/g_public.h b/source/g_public.h index 703e23c..fac43a4 100644 --- a/source/g_public.h +++ b/source/g_public.h @@ -40,9 +40,9 @@ SOLID_BSP // bsp clip, touch on edge // extended features -#define GAME_FEATURE_CLIENTNUM 1 -#define GAME_FEATURE_PROPERINUSE 2 -#define GAME_FEATURE_MVDSPEC 4 +#define GMF_CLIENTNUM 1 +#define GMF_PROPERINUSE 2 +#define GMF_MVDSPEC 4 //=============================================================== diff --git a/source/gl_draw.c b/source/gl_draw.c index 9387a9e..f95f1f9 100644 --- a/source/gl_draw.c +++ b/source/gl_draw.c @@ -277,14 +277,14 @@ int Draw_String( int x, int y, int flags, size_t maxChars, float s, t; image_t *image; color_t colors[2]; - int mask; + int mask, altmask = 0; image = R_ImageForHandle( hFont ); - mask = 0; if( flags & UI_ALTCOLOR ) { - mask |= 128; + altmask |= 128; } + mask = altmask; *( uint32_t * )colors[0] = *( uint32_t * )draw.color; *( uint32_t * )colors[1] = MakeColor( 255, 255, 255, draw.color[3] ); @@ -295,10 +295,7 @@ int Draw_String( int x, int y, int flags, size_t maxChars, mask |= 128; } else if( c == COLOR_RESET ) { *( uint32_t * )colors[0] = *( uint32_t * )draw.color; - mask = 0; - if( flags & UI_ALTCOLOR ) { - mask |= 128; - } + mask = altmask; } else { VectorCopy( colorTable[ ColorIndex( c ) ], colors[0] ); mask = 0; @@ -308,13 +305,12 @@ int Draw_String( int x, int y, int flags, size_t maxChars, } c = *string++; - c |= mask; - if( ( c & 127 ) == 32 ) { x += 8; continue; } + c |= mask; s = ( c & 15 ) * 0.0625f; t = ( c >> 4 ) * 0.0625f; diff --git a/source/gl_mesh.c b/source/gl_mesh.c index 2b1104f..2fbb7e5 100644 --- a/source/gl_mesh.c +++ b/source/gl_mesh.c @@ -49,7 +49,7 @@ static void Tess_Mesh( aliasMesh_t *mesh, int oldframe, int newframe ) { aliasVert_t *src_vert; vec_t *dst_vert; int i, count; - vec_t *normal; + const vec_t *normal; #if USE_SHADING byte *dst_color; vec_t d; @@ -103,7 +103,7 @@ static void Tess_LerpedMesh( aliasMesh_t *mesh, int oldframe, int newframe ) { aliasVert_t *src_newvert; vec_t *dst_vert; int i, count; - vec_t *normal; + const vec_t *normal; #if USE_SHADING byte *dst_color; vec_t d; diff --git a/source/mvd_game.c b/source/mvd_game.c index 33b871b..a6f7f6a 100644 --- a/source/mvd_game.c +++ b/source/mvd_game.c @@ -986,6 +986,7 @@ static void MVD_GameInit( void ) { mvd_flood_waitdelay = Cvar_Get( "flood_waitdelay", "10", 0 ); mvd_flood_mute = Cvar_Get( "flood_mute", "0", 0 ); mvd_default_map = Cvar_Get( "mvd_default_map", "q2dm1", CVAR_LATCH ); + Cvar_Get( "g_features", va( "%d", GMF_CLIENTNUM|GMF_PROPERINUSE ), CVAR_ROM ); Z_TagReserve( ( sizeof( edict_t ) + sizeof( udpClient_t ) ) * sv_maxclients->integer + @@ -1042,8 +1043,6 @@ static void MVD_GameInit( void ) { // SV_InfoSet( "gamedir", "gtv" ); SV_InfoSet( "gamename", "gtv" ); SV_InfoSet( "gamedate", __DATE__ ); - - gameFeatures = GAME_FEATURE_CLIENTNUM|GAME_FEATURE_PROPERINUSE; } static void MVD_GameShutdown( void ) { diff --git a/source/q_msg.h b/source/q_msg.h index e9a9900..622d5f5 100644 --- a/source/q_msg.h +++ b/source/q_msg.h @@ -54,9 +54,6 @@ void SZ_WriteString( sizebuf_t *sb, const char *string ); //============================================================================ -#define NUMVERTEXNORMALS 162 -extern vec3_t bytedirs[NUMVERTEXNORMALS]; - typedef enum { MSG_PS_IGNORE_GUNINDEX = ( 1 << 0 ), MSG_PS_IGNORE_GUNFRAMES = ( 1 << 1 ), diff --git a/source/q_shared.c b/source/q_shared.c index 5368564..4d830f7 100644 --- a/source/q_shared.c +++ b/source/q_shared.c @@ -21,11 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "config.h" #include "q_shared.h" -static const char *const hexchars = "0123456789ABCDEF"; +static const char hexchars[] = "0123456789ABCDEF"; vec3_t vec3_origin = { 0, 0, 0 }; - const color_t colorBlack = { 0, 0, 0, 255 }; const color_t colorRed = { 255, 0, 0, 255 }; const color_t colorGreen = { 0, 255, 0, 255 }; @@ -46,7 +45,13 @@ const color_t colorTable[8] = { { 255, 255, 255, 255 } }; -vec3_t bytedirs[NUMVERTEXNORMALS] = { +const char colorNames[10][8] = { + "black", "red", "green", "yellow", + "blue", "cyan", "magenta", "white", + "alt", "none" +}; + +const vec3_t bytedirs[NUMVERTEXNORMALS] = { {-0.525731, 0.000000, 0.850651}, {-0.442863, 0.238856, 0.864188}, {-0.295242, 0.000000, 0.955423}, diff --git a/source/q_shared.h b/source/q_shared.h index de1e8f2..197ef8f 100644 --- a/source/q_shared.h +++ b/source/q_shared.h @@ -169,7 +169,7 @@ extern vec3_t vec3_origin; #define NUMVERTEXNORMALS 162 -extern vec3_t bytedirs[NUMVERTEXNORMALS]; +extern const vec3_t bytedirs[NUMVERTEXNORMALS]; extern const color_t colorBlack; extern const color_t colorRed; @@ -182,6 +182,8 @@ extern const color_t colorWhite; extern const color_t colorTable[8]; +extern const char colorNames[10][8]; + typedef struct vrect_s { int x, y, width, height; } vrect_t; diff --git a/source/sv_ents.c b/source/sv_ents.c index 327dae2..a01ac40 100644 --- a/source/sv_ents.c +++ b/source/sv_ents.c @@ -375,7 +375,7 @@ void SV_BuildClientFrame( client_t *client ) { frame->ps = *ps; // grab the current clientNum - if( gameFeatures & GAME_FEATURE_CLIENTNUM ) { + if( g_features->integer & GMF_CLIENTNUM ) { frame->clientNum = clent->client->clientNum; } else { frame->clientNum = client->number; @@ -392,7 +392,7 @@ void SV_BuildClientFrame( client_t *client ) { ent = EDICT_POOL( client, e ); // ignore entities not in use - if( ( gameFeatures & GAME_FEATURE_PROPERINUSE ) && !ent->inuse ) { + if( ( g_features->integer & GMF_PROPERINUSE ) && !ent->inuse ) { continue; } @@ -467,7 +467,7 @@ void SV_BuildClientFrame( client_t *client ) { // XXX: hide this enitity from renderer if( ( client->protocol != PROTOCOL_VERSION_Q2PRO || client->settings[CLS_RECORDING] ) && - ( gameFeatures & GAME_FEATURE_CLIENTNUM ) && + ( g_features->integer & GMF_CLIENTNUM ) && e == frame->clientNum + 1 && ent != clent ) { state->modelindex = 0; diff --git a/source/sv_game.c b/source/sv_game.c index 21aeceb..a0e854a 100644 --- a/source/sv_game.c +++ b/source/sv_game.c @@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sv_local.h" game_export_t *ge; -int gameFeatures; /* ================ @@ -733,14 +732,14 @@ static void PF_AddCommandString( const char *string ) { static void PF_SetAreaPortalState( int portalnum, qboolean open ) { if( !sv.cm.cache ) { - Com_Error( ERR_DROP, "PF_SetAreaPortalState: no map loaded" ); + Com_Error( ERR_DROP, "%s: no map loaded", __func__ ); } CM_SetAreaPortalState( &sv.cm, portalnum, open ); } static qboolean PF_AreasConnected( int area1, int area2 ) { if( !sv.cm.cache ) { - Com_Error( ERR_DROP, "PF_AreasConnected: no map loaded" ); + Com_Error( ERR_DROP, "%s: no map loaded", __func__ ); } return CM_AreasConnected( &sv.cm, area1, area2 ); } @@ -757,45 +756,21 @@ Called when either the entire server is being killed, or it is changing to a different game directory. =============== */ -void SV_ShutdownGameProgs (void) -{ - if (!ge) - return; - ge->Shutdown (); - ge = NULL; - gameFeatures = 0; +void SV_ShutdownGameProgs (void) { + if( ge ) { + ge->Shutdown(); + ge = NULL; + } if( game_library ) { Sys_FreeLibrary( game_library ); game_library = NULL; } + if( g_features ) { + Cvar_SetByVar( g_features, NULL, CVAR_SET_DIRECT ); + g_features->flags = CVAR_USER_CREATED; + } } -#if 0 -static qboolean SV_GameSetupCallback( api_type_t type, void *api ) { - switch( type ) { - case API_CMD: - Cmd_FillAPI( ( cmdAPI_t * )api ); - break; - case API_CVAR: - Cvar_FillAPI( ( cvarAPI_t * )api ); - break; - case API_FS: - FS_FillAPI( ( fsAPI_t * )api ); - break; - case API_COMMON: - Com_FillAPI( ( commonAPI_t * )api ); - break; - case API_SYSTEM: - Sys_FillAPI( ( sysAPI_t * )api ); - break; - default: - Com_Error( ERR_FATAL, "SV_GameSetupCallback: bad api type" ); - } - - return qtrue; -} -#endif - /* =============== SV_InitGameProgs @@ -803,18 +778,10 @@ SV_InitGameProgs Init the game subsystem for a new map =============== */ -void SCR_DebugGraph (float value, int color); - -void SV_InitGameProgs ( void ) -{ +void SV_InitGameProgs ( void ) { game_import_t import; char path[MAX_OSPATH]; game_export_t *(*entry)( game_import_t * ) = NULL; - int (*ggf)( int ); - /*moduleEntry_t moduleEntry; - moduleInfo_t info; - moduleCapability_t caps; - APISetupCallback_t callback;*/ // unload anything we have now SV_ShutdownGameProgs (); @@ -927,14 +894,6 @@ void SV_InitGameProgs ( void ) ge->apiversion, GAME_API_VERSION); } - // get features - ggf = Sys_GetProcAddress( game_library, "GetGameFeatures" ); - if( ggf ) { - gameFeatures = ggf( GAME_FEATURE_CLIENTNUM|GAME_FEATURE_MVDSPEC ); - } else { - gameFeatures = 0; - } - // initialize ge->Init (); diff --git a/source/sv_local.h b/source/sv_local.h index 0a14cb4..2d3cc03 100644 --- a/source/sv_local.h +++ b/source/sv_local.h @@ -400,7 +400,7 @@ extern cvar_t *sv_status_show; extern cvar_t *sv_badauth_time; extern cvar_t *sv_uptime; -extern cvar_t *sv_nextserver; +extern cvar_t *g_features; extern cvar_t *sv_timeout; extern cvar_t *sv_zombietime; @@ -580,7 +580,6 @@ qboolean SV_EdictPV( cm_t *cm, edict_t *ent, byte *mask ); // sv_game.c // extern game_export_t *ge; -extern int gameFeatures; void SV_InitGameProgs( void ); void SV_ShutdownGameProgs (void); diff --git a/source/sv_main.c b/source/sv_main.c index b27e75d..7b4802d 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -84,7 +84,7 @@ cvar_t *sv_status_show; cvar_t *sv_uptime; cvar_t *sv_badauth_time; -cvar_t *sv_nextserver; +cvar_t *g_features; //============================================================================ @@ -1780,7 +1780,6 @@ void SV_Init( void ) { #endif sv_iplimit = Cvar_Get( "sv_iplimit", "3", 0 ); - sv_nextserver = Cvar_Get( "nextserver", "", 0 ); sv_status_show = Cvar_Get( "sv_status_show", "2", 0 ); @@ -1792,6 +1791,9 @@ void SV_Init( void ) { sv_badauth_time = Cvar_Get( "sv_badauth_time", "1", 0 ); sv_badauth_time->changed = sv_badauth_time_changed; + Cvar_Get( "sv_features", va( "%d", GMF_CLIENTNUM|GMF_MVDSPEC ), CVAR_ROM ); + g_features = Cvar_Get( "g_features", NULL, CVAR_USER_CREATED ); + // // set up default pmove parameters // diff --git a/source/sv_user.c b/source/sv_user.c index ead7e3f..83f3cb8 100644 --- a/source/sv_user.c +++ b/source/sv_user.c @@ -59,7 +59,7 @@ static void create_baselines( void ) { for( i = 1; i < sv_client->pool->num_edicts; i++ ) { ent = EDICT_POOL( sv_client, i ); - if( ( gameFeatures & GAME_FEATURE_PROPERINUSE ) && !ent->inuse ) { + if( ( g_features->integer & GMF_PROPERINUSE ) && !ent->inuse ) { continue; } diff --git a/source/sv_world.c b/source/sv_world.c index cffc332..ca0a039 100644 --- a/source/sv_world.c +++ b/source/sv_world.c @@ -432,7 +432,6 @@ int SV_PointContents (vec3_t p) int i, num; int contents, c2; cnode_t *headnode; - float *angles; if( !sv.cm.cache ) { Com_Error( ERR_DROP, "SV_PointContents: no map loaded" ); @@ -450,9 +449,6 @@ int SV_PointContents (vec3_t p) // might intersect, so do an exact clip headnode = SV_HullForEntity (hit); - angles = hit->s.angles; - if (hit->solid != SOLID_BSP) - angles = vec3_origin; // boxes don't rotate c2 = CM_TransformedPointContents (p, headnode, hit->s.origin, hit->s.angles); @@ -485,7 +481,6 @@ void SV_ClipMoveToEntities ( moveclip_t *clip ) edict_t *touchlist[MAX_EDICTS], *touch; trace_t trace; cnode_t *headnode; - float *angles; num = SV_AreaEdicts (clip->boxmins, clip->boxmaxs, touchlist , MAX_EDICTS, AREA_SOLID); @@ -515,13 +510,10 @@ void SV_ClipMoveToEntities ( moveclip_t *clip ) // might intersect, so do an exact clip headnode = SV_HullForEntity (touch); - angles = touch->s.angles; - if (touch->solid != SOLID_BSP) - angles = vec3_origin; // boxes don't rotate CM_TransformedBoxTrace (&trace, clip->start, clip->end, clip->mins, clip->maxs, headnode, clip->contentmask, - touch->s.origin, angles); + touch->s.origin, touch->s.angles); clip->trace->allsolid |= trace.allsolid; clip->trace->startsolid |= trace.startsolid; diff --git a/source/sw_alias.c b/source/sw_alias.c index 660c320..be24ad2 100644 --- a/source/sw_alias.c +++ b/source/sw_alias.c @@ -417,7 +417,8 @@ void R_AliasTransformFinalVerts( int numpoints, finalvert_t *fv, dtrivertx_t *ol for ( i = 0; i < numpoints; i++, fv++, oldv++, newv++ ) { int temp; - float lightcos, *plightnormal; + float lightcos; + const float *plightnormal; vec3_t lerped_vert; lerped_vert[0] = r_lerp_move[0] + oldv->v[0]*r_lerp_backv[0] + newv->v[0]*r_lerp_frontv[0]; |