diff options
author | Tim Angus <tim@ngus.net> | 2007-09-25 19:52:36 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2007-09-25 19:52:36 +0000 |
commit | 899c8bb46cd255f821b1ffd09c668d730f5da8c9 (patch) | |
tree | 24cbe8d8b8c04391cc52b7e6faca0ec171777341 /src/cgame | |
parent | b440cc296c43290906d9ab2d556377fd1d1fbfed (diff) |
* Remove B_REMOVED_TOGGLEBIT, use ps->misc per player instead
* Fix last spawn and uniqueness tests for marked deconstruction
* Fix buildable collision tests for non-marked deconstruction
* New g_markDeconstruct settings to guard against abuse
+ 0 off
+ 1 on, no replacements allowed
+ 2 on, replacements allowed of same type
+ 3 on, any replacements allowed
* Unlink then relink all buildables when doing build tests
* Fixes to tutorial text for marked deconstruction
* Remove unused "weaponswitch" client command
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_buildable.c | 55 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 12 | ||||
-rw-r--r-- | src/cgame/cg_tutorial.c | 26 |
3 files changed, 61 insertions, 32 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index d34a8e1f..7f2b2edf 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -1169,7 +1169,7 @@ static int CG_SortDistance( const void *a, const void *b ) CG_PlayerIsBuilder ================== */ -static qboolean CG_PlayerIsBuilder( void ) +static qboolean CG_PlayerIsBuilder( buildable_t buildable ) { switch( cg.predictedPlayerState.weapon ) { @@ -1177,7 +1177,8 @@ static qboolean CG_PlayerIsBuilder( void ) case WP_ABUILD2: case WP_HBUILD: case WP_HBUILD2: - return qtrue; + return BG_FindTeamForBuildable( buildable ) == + BG_FindTeamForWeapon( cg.predictedPlayerState.weapon ); default: return qfalse; @@ -1186,6 +1187,28 @@ static qboolean CG_PlayerIsBuilder( void ) /* ================== +CG_BuildableRemovalPending +================== +*/ +static qboolean CG_BuildableRemovalPending( int entityNum ) +{ + int i; + playerState_t *ps = &cg.snap->ps; + + if( !( ps->stats[ STAT_BUILDABLE ] & SB_VALID_TOGGLEBIT ) ) + return qfalse; + + for( i = 0; i < MAX_MISC; i++ ) + { + if( ps->misc[ i ] == entityNum ) + return qtrue; + } + + return qfalse; +} + +/* +================== CG_DrawBuildableStatus ================== */ @@ -1197,22 +1220,18 @@ void CG_DrawBuildableStatus( void ) int buildableList[ MAX_ENTITIES_IN_SNAPSHOT ]; int buildables = 0; - if( CG_PlayerIsBuilder( ) ) + for( i = 0; i < cg.snap->numEntities; i++ ) { - for( i = 0; i < cg.snap->numEntities; i++ ) - { - cent = &cg_entities[ cg.snap->entities[ i ].number ]; - es = ¢->currentState; + cent = &cg_entities[ cg.snap->entities[ i ].number ]; + es = ¢->currentState; - if( es->eType == ET_BUILDABLE && - BG_FindTeamForBuildable( es->modelindex ) == - BG_FindTeamForWeapon( cg.predictedPlayerState.weapon ) ) - buildableList[ buildables++ ] = cg.snap->entities[ i ].number; - } - qsort( buildableList, buildables, sizeof( int ), CG_SortDistance ); - for( i = 0; i < buildables; i++ ) - CG_BuildableStatusDisplay( &cg_entities[ buildableList[ i ] ] ); + if( es->eType == ET_BUILDABLE && CG_PlayerIsBuilder( es->modelindex ) ) + buildableList[ buildables++ ] = cg.snap->entities[ i ].number; } + + qsort( buildableList, buildables, sizeof( int ), CG_SortDistance ); + for( i = 0; i < buildables; i++ ) + CG_BuildableStatusDisplay( &cg_entities[ buildableList[ i ] ] ); } #define BUILDABLE_SOUND_PERIOD 500 @@ -1302,7 +1321,7 @@ void CG_Buildable( centity_t *cent ) else ent.nonNormalizedAxes = qfalse; - if( CG_PlayerIsBuilder( ) && ( es->generic1 & B_REMOVED_TOGGLEBIT ) ) + if( CG_PlayerIsBuilder( es->modelindex ) && CG_BuildableRemovalPending( es->number ) ) ent.customShader = cgs.media.redBuildShader; //add to refresh list @@ -1347,7 +1366,7 @@ void CG_Buildable( centity_t *cent ) else turretBarrel.nonNormalizedAxes = qfalse; - if( CG_PlayerIsBuilder( ) && ( es->generic1 & B_REMOVED_TOGGLEBIT ) ) + if( CG_PlayerIsBuilder( es->modelindex ) && CG_BuildableRemovalPending( es->number ) ) turretBarrel.customShader = cgs.media.redBuildShader; trap_R_AddRefEntityToScene( &turretBarrel ); @@ -1392,7 +1411,7 @@ void CG_Buildable( centity_t *cent ) else turretTop.nonNormalizedAxes = qfalse; - if( CG_PlayerIsBuilder( ) && ( es->generic1 & B_REMOVED_TOGGLEBIT ) ) + if( CG_PlayerIsBuilder( es->modelindex ) && CG_BuildableRemovalPending( es->number ) ) turretTop.customShader = cgs.media.redBuildShader; trap_R_AddRefEntityToScene( &turretTop ); diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 811733e7..f9822241 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -950,18 +950,6 @@ static void CG_ServerCommand( void ) return; } - if( !strcmp( cmd, "weaponswitch" ) ) - { - CG_Printf( "client weaponswitch\n" ); - if( trap_Argc( ) == 2 ) - { - cg.weaponSelect = atoi( CG_Argv( 1 ) ); - cg.weaponSelectTime = cg.time; - } - - return; - } - // server requests a ptrc if( !strcmp( cmd, "ptrcrequest" ) ) { diff --git a/src/cgame/cg_tutorial.c b/src/cgame/cg_tutorial.c index 888e9e1a..9997abcd 100644 --- a/src/cgame/cg_tutorial.c +++ b/src/cgame/cg_tutorial.c @@ -351,8 +351,9 @@ CG_HumanCkitText */ static void CG_HumanCkitText( char *text, playerState_t *ps ) { - buildable_t buildable = ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT; - float health; + buildable_t buildable = ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT; + entityState_t *es; + float health; if( buildable > BA_NONE ) { @@ -380,7 +381,28 @@ static void CG_HumanCkitText( char *text, playerState_t *ps ) va( "Hold %s to repair this structure\n", CG_KeyNameForCommand( "+button5" ) ) ); } + } + } + if( ( es = CG_BuildableInRange( ps, NULL ) ) ) + { + if( cgs.markDeconstruct ) + { + if( es->generic1 & B_MARKED_TOGGLEBIT ) + { + Q_strcat( text, MAX_TUTORIAL_TEXT, + va( "Press %s to unmark this structure\n", + CG_KeyNameForCommand( "deconstruct" ) ) ); + } + else + { + Q_strcat( text, MAX_TUTORIAL_TEXT, + va( "Press %s to mark this structure\n", + CG_KeyNameForCommand( "deconstruct" ) ) ); + } + } + else + { Q_strcat( text, MAX_TUTORIAL_TEXT, va( "Press %s to destroy this structure\n", CG_KeyNameForCommand( "deconstruct" ) ) ); |