From 27a16fb1fa69d458fb10e6437eb07b85496b46b8 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Mon, 9 Sep 2013 00:42:43 +0200 Subject: 0.1.2 and code cleanup --- src/cgame/cg_buildable.c | 206 ++++++++++++++++++++++++----------------------- src/cgame/cg_event.c | 16 +++- src/cgame/cg_local.h | 12 ++- src/cgame/cg_main.c | 12 ++- src/cgame/cg_weapons.c | 3 +- 5 files changed, 136 insertions(+), 113 deletions(-) (limited to 'src/cgame') diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 7b5b85d..b1d40b0 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -2127,83 +2127,85 @@ Server responded to our cb with either cb2 or cb3. */ void CG_Cuboid_Response(void) { - // cb2 : server sets client-side cuboid - // cb3 : server agrees on player's cuboid - // cb3 : server doesnt agree on player's cuboid and corrects it - static qboolean init=qfalse; - if(!BG_Buildable(cg.predictedPlayerState.stats[STAT_BUILDABLE]&~SB_VALID_TOGGLEBIT,NULL)->cuboid) - return; - if(!Q_stricmp(CG_Argv(0),"cb2")&&trap_Argc()==4) - { - cg.cuboidSelection[0]=atof(CG_Argv(1)); - cg.cuboidSelection[1]=atof(CG_Argv(2)); - cg.cuboidSelection[2]=atof(CG_Argv(3)); - return; - } - else if(!Q_stricmp(CG_Argv(0),"cb3")) - { - if(trap_Argc()==2) + // cb2 : server sets client-side cuboid + // cb3 : server agrees on player's cuboid + // cb3 : server doesnt agree on player's cuboid and corrects it + static qboolean init = qfalse; + + if( !BG_Buildable( cg.predictedPlayerState.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, NULL )->cuboid ) + return; + + if( !Q_stricmp( CG_Argv( 0 ), "cb2" ) && trap_Argc( ) == 4 ) { - if(atoi(CG_Argv(1))==cg.latestCBNumber) - cg.forbidCuboids=qfalse; - return; + cg.cuboidSelection[ 0 ] = atof( CG_Argv( 1 ) ); + cg.cuboidSelection[ 1 ] = atof( CG_Argv( 2 ) ); + cg.cuboidSelection[ 2 ] = atof( CG_Argv( 3 ) ); + return; } - else if(trap_Argc()==5) + else if( !Q_stricmp( CG_Argv( 0 ), "cb3" ) ) { - cg.cuboidSelection[0]=atof(CG_Argv(2)); - cg.cuboidSelection[1]=atof(CG_Argv(3)); - cg.cuboidSelection[2]=atof(CG_Argv(4)); - if(atoi(CG_Argv(1))==cg.latestCBNumber) - { - cg.forbidCuboids=qfalse; - if(cg.lastCuboidError+250cuboid) - return; - VectorCopy(cg.cuboidSelection,dims); - switch(cg_cuboidResizeAxis.integer) - { - case 0: - dims[0]+=rate; - break; - case 1: - dims[1]+=rate; - break; - default: - dims[2]+=rate; - break; - } - if(dims[0]<1||dims[1]<1||dims[2]<1|| - dims[0]*dims[1]*dims[2]cuboid ) + return; + + VectorCopy( cg.cuboidSelection, dims ); + switch( cg_cuboidResizeAxis.integer ) + { + case 0: + dims[ 0 ] += rate; + break; + case 1: + dims[ 1 ] += rate; + break; + default: + dims[ 2 ] += rate; + break; + } + + if( dims[ 0 ] * dims[ 1 ] * dims[ 2 ] < CUBOID_MINVOLUME ) + return; + + if( enlarge ) + trap_S_StartLocalSound( cgs.media.cuboidResizeSoundA, CHAN_LOCAL_SOUND ); + else + trap_S_StartLocalSound( cgs.media.cuboidResizeSoundB, CHAN_LOCAL_SOUND ); + + VectorCopy( dims, cg.cuboidSelection ); } /* @@ -2218,25 +2220,24 @@ Syntax: #define SWAPFLOATS(a,b) {float __t;__t=a,a=b,b=__t;} void CG_CuboidRotate_f(void) { - int axis; + int axis; - if(!BG_Buildable(cg.predictedPlayerState.stats[STAT_BUILDABLE]&~SB_VALID_TOGGLEBIT,NULL)->cuboid) - return; - axis=cg_cuboidResizeAxis.integer; - switch(axis) - { - case 0: - SWAPFLOATS(cg.cuboidSelection[1],cg.cuboidSelection[2]); - break; - case 1: - SWAPFLOATS(cg.cuboidSelection[2],cg.cuboidSelection[0]); - break; - case 2: - SWAPFLOATS(cg.cuboidSelection[0],cg.cuboidSelection[1]); - break; - } - trap_S_StartLocalSound(cgs.media.cuboidRotateSound,CHAN_LOCAL_SOUND); - CG_Cuboid_Send(); + if( !BG_Buildable( cg.predictedPlayerState.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, NULL )->cuboid ) + return; + switch( cg_cuboidResizeAxis.integer ) + { + case 0: + SWAPFLOATS( cg.cuboidSelection[ 1 ], cg.cuboidSelection[ 2 ] ); + break; + case 1: + SWAPFLOATS( cg.cuboidSelection[ 2 ], cg.cuboidSelection[ 0 ] ); + break; + case 2: + SWAPFLOATS( cg.cuboidSelection[ 0 ], cg.cuboidSelection[ 1 ] ); + break; + } + trap_S_StartLocalSound( cgs.media.cuboidRotateSound, CHAN_LOCAL_SOUND ); + CG_Cuboid_Send( ); } /* @@ -2251,22 +2252,22 @@ Syntax: */ void CG_CuboidAxis_f(void) { - int axis; + int axis; - axis=cg_cuboidResizeAxis.integer; - if(!BG_Buildable(cg.predictedPlayerState.stats[STAT_BUILDABLE]&~SB_VALID_TOGGLEBIT,NULL)->cuboid) - return; - if(!CG_Argv(1)) - { - Com_Printf("cuboidAxis next|0|1|2 : set axis on which you want to resize your cuboid selection (0 - X, 1 - Y, 2 - Z)\n"); - return; - } - if(!Q_stricmp(CG_Argv(1),"next")) - axis++; - else - axis=atoi(CG_Argv(1)); - trap_Cvar_Set("cg_cuboidResizeAxis",va("%i",(axis+3)%3)); - trap_S_StartLocalSound(cgs.media.cuboidAxisChangeSound,CHAN_LOCAL_SOUND); + axis = cg_cuboidResizeAxis.integer; + if( !BG_Buildable( cg.predictedPlayerState.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, NULL )->cuboid) + return; + if( !CG_Argv( 1 ) ) + { + Com_Printf( "cuboidAxis next|0|1|2 : set axis on which you want to resize your cuboid selection (0 - X, 1 - Y, 2 - Z)\n" ); + return; + } + if( !Q_stricmp( CG_Argv( 1 ), "next" ) ) + axis++; + else + axis = atoi( CG_Argv( 1 ) ); + trap_Cvar_Set( "cg_cuboidResizeAxis", va( "%i" , ( axis + 3 ) % 3 ) ); + trap_S_StartLocalSound( cgs.media.cuboidAxisChangeSound, CHAN_LOCAL_SOUND ); } /* @@ -2280,11 +2281,12 @@ Otherwise send the normal +attack / -attack; */ void CG_CuboidAttack_f(void) { - if(BG_Buildable(cg.predictedPlayerState.stats[STAT_BUILDABLE]&~SB_VALID_TOGGLEBIT,NULL)->cuboid&&cg.forbidCuboids) - { - trap_S_StartLocalSound(cgs.media.cuboidErrorSound,CHAN_LOCAL_SOUND); - return; - } - trap_SendClientCommand(va("%s",CG_Argv(0))); + if( BG_Buildable( cg.predictedPlayerState.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, NULL )->cuboid && + cg.forbidCuboids ) + { + trap_S_StartLocalSound( cgs.media.cuboidErrorSound, CHAN_LOCAL_SOUND ); + return; + } + trap_SendClientCommand( va( "%s", CG_Argv(0) ) ); } diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index ec7b9a6..40df8b9 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -322,6 +322,12 @@ static void CG_Obituary( entityState_t *ent ) message = "was crushed under"; message2 = "'s weight"; break; + case MOD_LEVEL4_BOMB: + message = "was bombed by"; + Com_sprintf( className, 64, "'s %s", + BG_ClassConfig( PCL_ALIEN_LEVEL4 )->humanName ); + message2 = className; + break; case MOD_POISON: message = "should have used a medkit against"; @@ -966,7 +972,15 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) break; case EV_MGTURRET_SPINUP: - trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.turretSpinupSound ); + if( random() >= 0.5f ) + trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.turretSpinupSoundA ); + else + trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.turretSpinupSoundB ); + break; + + + case EV_MGTURRET_KILL: + trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.turretKillSound ); break; case EV_OVERMIND_SPAWNS: diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 95a6569..11133bf 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1240,8 +1240,10 @@ typedef struct sfxHandle_t humanTalkSound; sfxHandle_t landSound; sfxHandle_t fallSound; - sfxHandle_t turretSpinupSound; - + sfxHandle_t turretSpinupSoundA; + sfxHandle_t turretSpinupSoundB; + sfxHandle_t turretKillSound; + sfxHandle_t hardBounceSound1; sfxHandle_t hardBounceSound2; @@ -1606,6 +1608,7 @@ extern vmCvar_t cg_emoticons; extern vmCvar_t cg_chatTeamPrefix; extern vmCvar_t cg_cuboidResizeAxis; +extern vmCvar_t cg_cuboidResizeRate; extern vmCvar_t cg_cuboidPSQuality; extern vmCvar_t cg_cuboidInfoX; extern vmCvar_t cg_cuboidInfoY; @@ -2168,10 +2171,11 @@ typedef enum // mod version data -#define MODVER_CURRENT 2 +#define MODVER_CURRENT 3 +#define MODVER_C2_0_1_2 3 #define MODVER_C2_0_1_1 2 #define MODVER_C2_0_1_0 1 -#define MODVER_TITLE "0.1.1 (Sep 07)" +#define MODVER_TITLE "0.1.2 (Sep 09)" diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 48df981..4191cc7 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -228,6 +228,7 @@ vmCvar_t cg_emoticons; vmCvar_t cg_chatTeamPrefix; vmCvar_t cg_cuboidResizeAxis; +vmCvar_t cg_cuboidResizeRate; vmCvar_t cg_cuboidPSQuality; vmCvar_t cg_cuboidInfoX; vmCvar_t cg_cuboidInfoY; @@ -370,10 +371,11 @@ static cvarTable_t cvarTable[ ] = { &cg_emoticons, "cg_emoticons", "1", CVAR_LATCH|CVAR_ARCHIVE}, - { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE}, + { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE }, - { &cg_cuboidResizeAxis, "cg_cuboidResizeAxis", "2", 0}, - { &cg_cuboidPSQuality, "cg_cuboidPSQuality", "3", CVAR_ARCHIVE}, + { &cg_cuboidResizeAxis, "cg_cuboidResizeAxis", "2", 0 }, + { &cg_cuboidResizeRate, "cg_cuboidResizeRate", "5", CVAR_ARCHIVE }, + { &cg_cuboidPSQuality, "cg_cuboidPSQuality", "3", CVAR_ARCHIVE }, { &cg_cuboidInfoX, "cg_cuboidInfoX" ,"0", CVAR_ARCHIVE }, { &cg_cuboidInfoY, "cg_cuboidInfoY" ,"150", CVAR_ARCHIVE }, @@ -655,7 +657,9 @@ static void CG_RegisterSounds( void ) cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/tracer.wav", qfalse ); cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.wav", qfalse ); - cgs.media.turretSpinupSound = trap_S_RegisterSound( "sound/buildables/mgturret/spinup.wav", qfalse ); + cgs.media.turretSpinupSoundA = trap_S_RegisterSound( "sound/buildables/mgturret/spinup_a.wav", qfalse ); + cgs.media.turretSpinupSoundB = trap_S_RegisterSound( "sound/buildables/mgturret/spinup_b.wav", qfalse ); + cgs.media.turretKillSound = trap_S_RegisterSound( "sound/buildables/mgturret/turretkill_a.wav", qfalse ); cgs.media.weaponEmptyClick = trap_S_RegisterSound( "sound/weapons/click.wav", qfalse ); cgs.media.talkSound = trap_S_RegisterSound( "sound/misc/talk.wav", qfalse ); diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index 2bb23ff..f844f81 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -1765,8 +1765,7 @@ void CG_MissileHitEntity( weapon_t weaponNum, weaponMode_t weaponMode, if( weaponMode <= WPM_NONE || weaponMode >= WPM_NUM_WEAPONMODES ) weaponMode = WPM_PRIMARY; - // always impact! - //if( weapon->wim[ weaponMode ].alwaysImpact ) + if( weapon->wim[ weaponMode ].alwaysImpact ) { int sound; -- cgit