diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cl_fx.c | 13 | ||||
-rw-r--r-- | src/cl_local.h | 3 | ||||
-rw-r--r-- | src/cl_parse.c | 38 | ||||
-rw-r--r-- | src/cl_precache.c | 71 |
4 files changed, 82 insertions, 43 deletions
diff --git a/src/cl_fx.c b/src/cl_fx.c index 86a0a72..a250ecd 100644 --- a/src/cl_fx.c +++ b/src/cl_fx.c @@ -73,22 +73,25 @@ void CL_RunLightStyles( void ) { } } -void CL_SetLightStyle( int index, const char *string, size_t length ) { +void CL_SetLightStyle( int index, const char *s ) { int i; clightstyle_t *dest; dest = &cl_lightstyles[index]; - dest->length = length; + dest->length = strlen( s ); + if( dest->length > MAX_QPATH ) { + Com_Error( ERR_DROP, "%s: oversize style", __func__ ); + } - for( i = 0; i < length; i++ ) { - dest->map[i] = ( float )( string[i] - 'a' ) / ( float )( 'm' - 'a' ); + for( i = 0; i < dest->length; i++ ) { + dest->map[i] = ( float )( s[i] - 'a' ) / ( float )( 'm' - 'a' ); } if( dest->entry.prev ) { List_Delete( &dest->entry ); } - if( length > 1 ) { + if( dest->length > 1 ) { List_Append( &cl_lightlist, &dest->entry ); return; } diff --git a/src/cl_local.h b/src/cl_local.h index b6088ce..c7d8889 100644 --- a/src/cl_local.h +++ b/src/cl_local.h @@ -501,6 +501,7 @@ void CL_RegisterSounds( void ); void CL_RegisterBspModels( void ); void CL_RegisterVWepModels( void ); void CL_PrepRefresh( void ); +void CL_UpdateConfigstring( int index ); // // cl_download @@ -692,7 +693,7 @@ void CL_RunDLights (void); void CL_AddDLights (void); #endif #if USE_LIGHTSTYLES -void CL_SetLightStyle( int index, const char *string, size_t length ); +void CL_SetLightStyle( int index, const char *s ); void CL_RunLightStyles (void); void CL_AddLightStyles (void); #endif diff --git a/src/cl_parse.c b/src/cl_parse.c index 6057b75..bd86739 100644 --- a/src/cl_parse.c +++ b/src/cl_parse.c @@ -470,43 +470,7 @@ static void CL_ParseConfigstring( int index ) { } // do something apropriate - if( index == CS_MAXCLIENTS ) { - cl.maxclients = atoi( string ); - return; - } - if( index == CS_MODELS + 1 ) { - if( len <= 9 ) { - Com_Error( ERR_DROP, "%s: bad world model: %s", __func__, string ); - } - memcpy( cl.mapname, string + 5, len - 9 ); // skip "maps/" - cl.mapname[len - 9] = 0; // cut off ".bsp" - return; - } -#if USE_LIGHTSTYLES - if (index >= CS_LIGHTS && index < CS_LIGHTS+MAX_LIGHTSTYLES) { - CL_SetLightStyle( index - CS_LIGHTS, string, len ); - return; - } -#endif - - if( cls.state < ca_precached ) { - return; - } - if (index >= CS_MODELS+2 && index < CS_MODELS+MAX_MODELS) { - cl.model_draw[index-CS_MODELS] = R_RegisterModel (string); - if (*string == '*') - cl.model_clip[index-CS_MODELS] = BSP_InlineModel (cl.bsp, string); - else - cl.model_clip[index-CS_MODELS] = NULL; - } else if (index >= CS_SOUNDS && index < CS_SOUNDS+MAX_MODELS) { - cl.sound_precache[index-CS_SOUNDS] = S_RegisterSound (string); - } else if (index >= CS_IMAGES && index < CS_IMAGES+MAX_MODELS) { - cl.image_precache[index-CS_IMAGES] = R_RegisterPic (string); - } else if (index >= CS_PLAYERSKINS && index < CS_PLAYERSKINS+MAX_CLIENTS) { - CL_LoadClientinfo( &cl.clientinfo[index - CS_PLAYERSKINS], string ); - } else if( index == CS_AIRACCEL && !cl.pmp.qwmode ) { - cl.pmp.airaccelerate = atoi( string ) ? qtrue : qfalse; - } + CL_UpdateConfigstring( index ); } static void CL_ParseBaseline( int index, int bits ) { diff --git a/src/cl_precache.c b/src/cl_precache.c index a646d58..a5bd1aa 100644 --- a/src/cl_precache.c +++ b/src/cl_precache.c @@ -402,3 +402,74 @@ void CL_PrepRefresh (void) { SCR_UpdateScreen(); } +/* +================= +CL_UpdateConfigstring + +A configstring update has been parsed. +================= +*/ +void CL_UpdateConfigstring( int index ) { + const char *s = cl.configstrings[index]; + + if( index == CS_MAXCLIENTS ) { + cl.maxclients = atoi( s ); + return; + } + + if( index == CS_AIRACCEL ) { + if( cl.pmp.qwmode ) + cl.pmp.airaccelerate = qtrue; + else + cl.pmp.airaccelerate = atoi( s ) ? qtrue : qfalse; + return; + } + + if( index == CS_MODELS + 1 ) { + size_t len = strlen( s ); + + if( len <= 9 ) { + Com_Error( ERR_DROP, "%s: bad world model: %s", __func__, s ); + } + memcpy( cl.mapname, s + 5, len - 9 ); // skip "maps/" + cl.mapname[len - 9] = 0; // cut off ".bsp" + return; + } + +#if USE_LIGHTSTYLES + if( index >= CS_LIGHTS && index < CS_LIGHTS + MAX_LIGHTSTYLES ) { + CL_SetLightStyle( index - CS_LIGHTS, s ); + return; + } +#endif + + if( cls.state < ca_precached ) { + return; + } + + if( index >= CS_MODELS + 2 && index < CS_MODELS + MAX_MODELS ) { + int i = index - CS_MODELS; + + cl.model_draw[i] = R_RegisterModel( s ); + if( *s == '*' ) + cl.model_clip[i] = BSP_InlineModel( cl.bsp, s ); + else + cl.model_clip[i] = NULL; + return; + } + + if( index >= CS_SOUNDS && index < CS_SOUNDS + MAX_MODELS ) { + cl.sound_precache[ index - CS_SOUNDS ] = S_RegisterSound( s ); + return; + } + + if( index >= CS_IMAGES && index < CS_IMAGES + MAX_MODELS ) { + cl.image_precache[ index - CS_IMAGES] = R_RegisterPic( s ); + return; + } + + if( index >= CS_PLAYERSKINS && index < CS_PLAYERSKINS + MAX_CLIENTS ) { + CL_LoadClientinfo( &cl.clientinfo[ index - CS_PLAYERSKINS ], s ); + return; + } +} |