diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-05-20 14:05:34 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-05-21 15:47:12 +0200 |
commit | a77f4c3465d90b774a30c5ef2db3f57ff21c4e01 (patch) | |
tree | edf22059f78e7670ef003dce27ef538242022c75 /src/game/bg_misc.c | |
parent | d05bee2ac2ae858dbf690c8e6e84d9e7ea3db48f (diff) |
Remove all override code.
Overrides allowed changing some attributes of buildings and classes using configs (and without having to change the code itself). This commit removes this nonsensical system.
Diffstat (limited to 'src/game/bg_misc.c')
-rw-r--r-- | src/game/bg_misc.c | 492 |
1 files changed, 0 insertions, 492 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index db23c25..90c2254 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -634,9 +634,6 @@ buildableAttributes_t bg_buildableList[ ] = int bg_numBuildables = sizeof( bg_buildableList ) / sizeof( bg_buildableList[ 0 ] ); -//separate from bg_buildableList to work around char struct init bug -buildableAttributeOverrides_t bg_buildableOverrideList[ BA_NUM_BUILDABLES ]; - /* ============== BG_FindBuildNumForName @@ -741,9 +738,6 @@ char *BG_FindModelsForBuildable( int bclass, int modelNum ) { int i; - if( bg_buildableOverrideList[ bclass ].models[ modelNum ][ 0 ] != 0 ) - return bg_buildableOverrideList[ bclass ].models[ modelNum ]; - for( i = 0; i < bg_numBuildables; i++ ) { if( bg_buildableList[ i ].buildNum == bclass ) @@ -763,9 +757,6 @@ float BG_FindModelScaleForBuildable( int bclass ) { int i; - if( bg_buildableOverrideList[ bclass ].modelScale != 0.0f ) - return bg_buildableOverrideList[ bclass ].modelScale; - for( i = 0; i < bg_numBuildables; i++ ) { if( bg_buildableList[ i ].buildNum == bclass ) @@ -790,21 +781,11 @@ void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ) if( bg_buildableList[ i ].buildNum == bclass ) { if( mins != NULL ) - { VectorCopy( bg_buildableList[ i ].mins, mins ); - if( VectorLength( bg_buildableOverrideList[ bclass ].mins ) ) - VectorCopy( bg_buildableOverrideList[ bclass ].mins, mins ); - } - if( maxs != NULL ) - { VectorCopy( bg_buildableList[ i ].maxs, maxs ); - if( VectorLength( bg_buildableOverrideList[ bclass ].maxs ) ) - VectorCopy( bg_buildableOverrideList[ bclass ].maxs, maxs ); - } - return; } } @@ -825,9 +806,6 @@ float BG_FindZOffsetForBuildable( int bclass ) { int i; - if( bg_buildableOverrideList[ bclass ].zOffset != 0.0f ) - return bg_buildableOverrideList[ bclass ].zOffset; - for( i = 0; i < bg_numBuildables; i++ ) { if( bg_buildableList[ i ].buildNum == bclass ) @@ -1343,16 +1321,6 @@ qboolean BG_FindReplaceableTestForBuildable( int bclass ) /* ============== -BG_FindOverrideForBuildable -============== -*/ -static buildableAttributeOverrides_t *BG_FindOverrideForBuildable( int bclass ) -{ - return &bg_buildableOverrideList[ bclass ]; -} - -/* -============== BG_FindTransparentTestForBuildable ============== */ @@ -1370,162 +1338,6 @@ qboolean BG_FindTransparentTestForBuildable( int bclass ) return qfalse; } -/* -====================== -BG_ParseBuildableFile - -Parses a configuration file describing a builable -====================== -*/ -static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeOverrides_t *bao ) -{ - char *text_p; - int i; - int len; - char *token; - char text[ 20000 ]; - fileHandle_t f; - float scale; - - - // load the file - len = trap_FS_FOpenFile( filename, &f, FS_READ ); - if( len < 0 ) - return qfalse; - - if( len == 0 || len >= sizeof( text ) - 1 ) - { - trap_FS_FCloseFile( f ); - Com_Printf( S_COLOR_RED "ERROR: Buildable file %s is %s\n", filename, - len == 0 ? "empty" : "too long" ); - return qfalse; - } - - trap_FS_Read( text, len, f ); - text[ len ] = 0; - trap_FS_FCloseFile( f ); - - // parse the text - text_p = text; - - // read optional parameters - while( 1 ) - { - token = COM_Parse( &text_p ); - - if( !token ) - break; - - if( !Q_stricmp( token, "" ) ) - break; - - if( !Q_stricmp( token, "model" ) ) - { - int index = 0; - - token = COM_Parse( &text_p ); - if( !token ) - break; - - index = atoi( token ); - - if( index < 0 ) - index = 0; - else if( index > 3 ) - index = 3; - - token = COM_Parse( &text_p ); - if( !token ) - break; - - Q_strncpyz( bao->models[ index ], token, sizeof( bao->models[ 0 ] ) ); - - continue; - } - else if( !Q_stricmp( token, "modelScale" ) ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - scale = atof( token ); - - if( scale < 0.0f ) - scale = 0.0f; - - bao->modelScale = scale; - - continue; - } - else if( !Q_stricmp( token, "mins" ) ) - { - for( i = 0; i <= 2; i++ ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - bao->mins[ i ] = atof( token ); - } - - continue; - } - else if( !Q_stricmp( token, "maxs" ) ) - { - for( i = 0; i <= 2; i++ ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - bao->maxs[ i ] = atof( token ); - } - - continue; - } - else if( !Q_stricmp( token, "zOffset" ) ) - { - float offset; - - token = COM_Parse( &text_p ); - if( !token ) - break; - - offset = atof( token ); - - bao->zOffset = offset; - - continue; - } - - - Com_Printf( S_COLOR_RED "ERROR: unknown token '%s'\n", token ); - return qfalse; - } - - return qtrue; -} - -/* -=============== -BG_InitBuildableOverrides - -Set any overrides specfied by file -=============== -*/ -void BG_InitBuildableOverrides( void ) -{ - int i; - buildableAttributeOverrides_t *bao; - - for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ ) - { - bao = BG_FindOverrideForBuildable( i ); - - BG_ParseBuildableFile( va( "overrides/buildables/%s.cfg", BG_FindNameForBuildable( i ) ), bao ); - } -} - //////////////////////////////////////////////////////////////////////////////// classAttributes_t bg_classList[ ] = @@ -2038,9 +1850,6 @@ classAttributes_t bg_classList[ ] = int bg_numPclasses = sizeof( bg_classList ) / sizeof( bg_classList[ 0 ] ); -//separate from bg_classList to work around char struct init bug -classAttributeOverrides_t bg_classOverrideList[ PCL_NUM_CLASSES ]; - /* ============== BG_FindClassNumForName @@ -2089,9 +1898,6 @@ char *BG_FindHumanNameForClassNum( int pclass ) { int i; - if( bg_classOverrideList[ pclass ].humanName[ 0 ] != 0 ) - return bg_classOverrideList[ pclass ].humanName; - for( i = 0; i < bg_numPclasses; i++ ) { if( bg_classList[ i ].classNum == pclass ) @@ -2112,9 +1918,6 @@ char *BG_FindModelNameForClass( int pclass ) { int i; - if( bg_classOverrideList[ pclass ].modelName[ 0 ] != 0 ) - return bg_classOverrideList[ pclass ].modelName; - for( i = 0; i < bg_numPclasses; i++ ) { if( bg_classList[ i ].classNum == pclass ) @@ -2135,9 +1938,6 @@ float BG_FindModelScaleForClass( int pclass ) { int i; - if( bg_classOverrideList[ pclass ].modelScale != 0.0f ) - return bg_classOverrideList[ pclass ].modelScale; - for( i = 0; i < bg_numPclasses; i++ ) { if( bg_classList[ i ].classNum == pclass ) @@ -2159,9 +1959,6 @@ char *BG_FindSkinNameForClass( int pclass ) { int i; - if( bg_classOverrideList[ pclass ].skinName[ 0 ] != 0 ) - return bg_classOverrideList[ pclass ].skinName; - for( i = 0; i < bg_numPclasses; i++ ) { if( bg_classList[ i ].classNum == pclass ) @@ -2182,9 +1979,6 @@ float BG_FindShadowScaleForClass( int pclass ) { int i; - if( bg_classOverrideList[ pclass ].shadowScale != 0.0f ) - return bg_classOverrideList[ pclass ].shadowScale; - for( i = 0; i < bg_numPclasses; i++ ) { if( bg_classList[ i ].classNum == pclass ) @@ -2206,9 +2000,6 @@ char *BG_FindHudNameForClass( int pclass ) { int i; - if( bg_classOverrideList[ pclass ].hudName[ 0 ] != 0 ) - return bg_classOverrideList[ pclass ].hudName; - for( i = 0; i < bg_numPclasses; i++ ) { if( bg_classList[ i ].classNum == pclass ) @@ -2258,45 +2049,20 @@ void BG_FindBBoxForClass( int pclass, vec3_t mins, vec3_t maxs, vec3_t cmaxs, ve if( bg_classList[ i ].classNum == pclass ) { if( mins != NULL ) - { VectorCopy( bg_classList[ i ].mins, mins ); - if( VectorLength( bg_classOverrideList[ pclass ].mins ) ) - VectorCopy( bg_classOverrideList[ pclass ].mins, mins ); - } - if( maxs != NULL ) - { VectorCopy( bg_classList[ i ].maxs, maxs ); - if( VectorLength( bg_classOverrideList[ pclass ].maxs ) ) - VectorCopy( bg_classOverrideList[ pclass ].maxs, maxs ); - } - if( cmaxs != NULL ) - { VectorCopy( bg_classList[ i ].crouchMaxs, cmaxs ); - if( VectorLength( bg_classOverrideList[ pclass ].crouchMaxs ) ) - VectorCopy( bg_classOverrideList[ pclass ].crouchMaxs, cmaxs ); - } - if( dmins != NULL ) - { VectorCopy( bg_classList[ i ].deadMins, dmins ); - if( VectorLength( bg_classOverrideList[ pclass ].deadMins ) ) - VectorCopy( bg_classOverrideList[ pclass ].deadMins, dmins ); - } - if( dmaxs != NULL ) - { VectorCopy( bg_classList[ i ].deadMaxs, dmaxs ); - if( VectorLength( bg_classOverrideList[ pclass ].deadMaxs ) ) - VectorCopy( bg_classOverrideList[ pclass ].deadMaxs, dmaxs ); - } - return; } } @@ -2326,9 +2092,6 @@ float BG_FindZOffsetForClass( int pclass ) { int i; - if( bg_classOverrideList[ pclass ].zOffset != 0.0f ) - return bg_classOverrideList[ pclass ].zOffset; - for( i = 0; i < bg_numPclasses; i++ ) { if( bg_classList[ i ].classNum == pclass ) @@ -2361,12 +2124,6 @@ void BG_FindViewheightForClass( int pclass, int *viewheight, int *cViewheight ) break; } } - - if( bg_classOverrideList[ pclass ].viewheight != 0 ) - vh = bg_classOverrideList[ pclass ].viewheight; - if( bg_classOverrideList[ pclass ].crouchViewheight != 0 ) - cvh = bg_classOverrideList[ pclass ].crouchViewheight; - if( vh == 0 ) vh = bg_classList[ 0 ].viewheight; @@ -2821,255 +2578,6 @@ int BG_FindCostOfClass( int pclass ) return 0; } -/* -============== -BG_FindOverrideForClass -============== -*/ -static classAttributeOverrides_t *BG_FindOverrideForClass( int pclass ) -{ - return &bg_classOverrideList[ pclass ]; -} - -/* -====================== -BG_ParseClassFile - -Parses a configuration file describing a class -====================== -*/ -static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides_t *cao ) -{ - char *text_p; - int i; - int len; - char *token; - char text[ 20000 ]; - fileHandle_t f; - float scale = 0.0f; - - - // load the file - len = trap_FS_FOpenFile( filename, &f, FS_READ ); - if( len < 0 ) - return qfalse; - - if( len == 0 || len >= sizeof( text ) - 1 ) - { - trap_FS_FCloseFile( f ); - Com_Printf( S_COLOR_RED "ERROR: Class file %s is %s\n", filename, - len == 0 ? "empty" : "too long" ); - return qfalse; - } - - trap_FS_Read( text, len, f ); - text[ len ] = 0; - trap_FS_FCloseFile( f ); - - // parse the text - text_p = text; - - // read optional parameters - while( 1 ) - { - token = COM_Parse( &text_p ); - - if( !token ) - break; - - if( !Q_stricmp( token, "" ) ) - break; - - if( !Q_stricmp( token, "model" ) ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - Q_strncpyz( cao->modelName, token, sizeof( cao->modelName ) ); - - continue; - } - else if( !Q_stricmp( token, "skin" ) ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - Q_strncpyz( cao->skinName, token, sizeof( cao->skinName ) ); - - continue; - } - else if( !Q_stricmp( token, "hud" ) ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - Q_strncpyz( cao->hudName, token, sizeof( cao->hudName ) ); - - continue; - } - else if( !Q_stricmp( token, "modelScale" ) ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - scale = atof( token ); - - if( scale < 0.0f ) - scale = 0.0f; - - cao->modelScale = scale; - - continue; - } - else if( !Q_stricmp( token, "shadowScale" ) ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - scale = atof( token ); - - if( scale < 0.0f ) - scale = 0.0f; - - cao->shadowScale = scale; - - continue; - } - else if( !Q_stricmp( token, "mins" ) ) - { - for( i = 0; i <= 2; i++ ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - cao->mins[ i ] = atof( token ); - } - - continue; - } - else if( !Q_stricmp( token, "maxs" ) ) - { - for( i = 0; i <= 2; i++ ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - cao->maxs[ i ] = atof( token ); - } - - continue; - } - else if( !Q_stricmp( token, "deadMins" ) ) - { - for( i = 0; i <= 2; i++ ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - cao->deadMins[ i ] = atof( token ); - } - - continue; - } - else if( !Q_stricmp( token, "deadMaxs" ) ) - { - for( i = 0; i <= 2; i++ ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - cao->deadMaxs[ i ] = atof( token ); - } - - continue; - } - else if( !Q_stricmp( token, "crouchMaxs" ) ) - { - for( i = 0; i <= 2; i++ ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - cao->crouchMaxs[ i ] = atof( token ); - } - - continue; - } - else if( !Q_stricmp( token, "viewheight" ) ) - { - token = COM_Parse( &text_p ); - cao->viewheight = atoi( token ); - continue; - } - else if( !Q_stricmp( token, "crouchViewheight" ) ) - { - token = COM_Parse( &text_p ); - cao->crouchViewheight = atoi( token ); - continue; - } - else if( !Q_stricmp( token, "zOffset" ) ) - { - float offset; - - token = COM_Parse( &text_p ); - if( !token ) - break; - - offset = atof( token ); - - cao->zOffset = offset; - - continue; - } - else if( !Q_stricmp( token, "name" ) ) - { - token = COM_Parse( &text_p ); - if( !token ) - break; - - Q_strncpyz( cao->humanName, token, sizeof( cao->humanName ) ); - - continue; - } - - - Com_Printf( S_COLOR_RED "ERROR: unknown token '%s'\n", token ); - return qfalse; - } - - return qtrue; -} - -/* -=============== -BG_InitClassOverrides - -Set any overrides specfied by file -=============== -*/ -void BG_InitClassOverrides( void ) -{ - int i; - classAttributeOverrides_t *cao; - - for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) - { - cao = BG_FindOverrideForClass( i ); - - BG_ParseClassFile( va( "overrides/classes/%s.cfg", BG_FindNameForClassNum( i ) ), cao ); - } -} - //////////////////////////////////////////////////////////////////////////////// weaponAttributes_t bg_weapons[ ] = |