This is an automated email from the git hooks/post-receive script. smcv pushed a commit to annotated tag 1.42d in repository iortcw.
commit 7ecb1b5d05ac729f3b2285be868a6c3b414cf323 Author: nate....@gmail.com <nate....@gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a> Date: Mon Apr 28 02:06:19 2014 +0000 Client enhancement, feature added: - cg_noAmmoAutoSwitch --- MP/code/cgame/cg_event.c | 10 ++++-- MP/code/cgame/cg_local.h | 4 ++- MP/code/cgame/cg_main.c | 4 ++- MP/code/cgame/cg_weapons.c | 90 ++++++++++++++++++++++++---------------------- 4 files changed, 60 insertions(+), 48 deletions(-) diff --git a/MP/code/cgame/cg_event.c b/MP/code/cgame/cg_event.c index 7560683..3fedcbd 100644 --- a/MP/code/cgame/cg_event.c +++ b/MP/code/cgame/cg_event.c @@ -1924,9 +1924,13 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { if ( ( es->weapon != WP_GRENADE_LAUNCHER ) && ( es->weapon != WP_GRENADE_PINEAPPLE ) && ( es->weapon != WP_DYNAMITE ) && ( es->weapon != WP_DYNAMITE2 ) ) { trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound ); } - if ( es->number == cg.snap->ps.clientNum ) { - CG_OutOfAmmoChange(); - } + // L0 - noAmmoAutoSwitch (patched) + if (es->number == cg.snap->ps.clientNum + && (cg_noAmmoAutoSwitch.integer > 0 + && !CG_WeaponSelectable(cg.weaponSelect))) + { + CG_OutOfAmmoChange(event == EV_NOAMMO ? qfalse : qtrue); + } // ~ break; case EV_CHANGE_WEAPON: { diff --git a/MP/code/cgame/cg_local.h b/MP/code/cgame/cg_local.h index 1208f4b..fc1cb87 100644 --- a/MP/code/cgame/cg_local.h +++ b/MP/code/cgame/cg_local.h @@ -1777,6 +1777,7 @@ extern vmCvar_t cg_drawWeaponIconFlash; extern vmCvar_t cg_bloodFlash; extern vmCvar_t cg_muzzleFlash; extern vmCvar_t cg_complaintPopUp; +extern vmCvar_t cg_noAmmoAutoSwitch; // // cg_main.c @@ -1991,6 +1992,7 @@ void CG_NextWeapon_f( void ); void CG_PrevWeapon_f( void ); void CG_Weapon_f( void ); void CG_WeaponBank_f( void ); +qboolean CG_WeaponSelectable(int i); void CG_FinishWeaponChange( int lastweap, int newweap ); @@ -2031,7 +2033,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent void CG_DrawWeaponSelect( void ); void CG_DrawHoldableSelect( void ); -void CG_OutOfAmmoChange( void ); +void CG_OutOfAmmoChange( qboolean allowForceSwitch ); void CG_HoldableUsedupChange( void ); //----(SA) added //----(SA) added to header to access from outside cg_weapons.c diff --git a/MP/code/cgame/cg_main.c b/MP/code/cgame/cg_main.c index e4f6294..0457ab0 100644 --- a/MP/code/cgame/cg_main.c +++ b/MP/code/cgame/cg_main.c @@ -286,6 +286,7 @@ vmCvar_t cg_bloodDamageBlend; vmCvar_t cg_bloodFlash; vmCvar_t cg_muzzleFlash; vmCvar_t cg_complaintPopUp; +vmCvar_t cg_noAmmoAutoSwitch; // ~L0 typedef struct { @@ -495,7 +496,8 @@ cvarTable_t cvarTable[] = { { &cg_bloodDamageBlend, "cg_bloodDamageBlend", "1.0", CVAR_ARCHIVE }, { &cg_bloodFlash, "cg_bloodFlash", "1.0", CVAR_ARCHIVE }, { &cg_muzzleFlash, "cg_muzzleFlash", "1", CVAR_ARCHIVE }, - { &cg_complaintPopUp, "cg_complaintPopUp", "1", CVAR_ARCHIVE } + { &cg_complaintPopUp, "cg_complaintPopUp", "1", CVAR_ARCHIVE }, + { &cg_noAmmoAutoSwitch, "cg_noAmmoAutoSwitch", "1", CVAR_ARCHIVE } // ~L0 }; diff --git a/MP/code/cgame/cg_weapons.c b/MP/code/cgame/cg_weapons.c index 6337c21..b286bed 100644 --- a/MP/code/cgame/cg_weapons.c +++ b/MP/code/cgame/cg_weapons.c @@ -3110,7 +3110,7 @@ static qboolean CG_WeaponHasAmmo( int i ) { CG_WeaponSelectable =============== */ -static qboolean CG_WeaponSelectable( int i ) { +qboolean CG_WeaponSelectable( int i ) { // allow the player to unselect all weapons // if(i == WP_NONE) @@ -4156,7 +4156,7 @@ CG_OutOfAmmoChange The current weapon has just run out of ammo =================== */ -void CG_OutOfAmmoChange( void ) { +void CG_OutOfAmmoChange( qboolean allowForceSwitch ) { int i; int bank = 0, cycle = 0; int equiv = WP_NONE; @@ -4175,47 +4175,51 @@ void CG_OutOfAmmoChange( void ) { } // jpw -// JPW NERVE -- early out if we just fired Panzerfaust, go to pistola, then grenades - if ( cg.weaponSelect == WP_PANZERFAUST ) { - for ( i = 0; i < MAX_WEAPS_IN_BANK_MP; i++ ) - if ( CG_WeaponSelectable( weapBanksMultiPlayer[2][i] ) ) { // find a pistol - cg.weaponSelect = weapBanksMultiPlayer[2][i]; - CG_FinishWeaponChange( cg.predictedPlayerState.weapon, cg.weaponSelect ); - return; - } - for ( i = 0; i < MAX_WEAPS_IN_BANK_MP; i++ ) - if ( CG_WeaponSelectable( weapBanksMultiPlayer[4][i] ) ) { // find a grenade - cg.weaponSelect = weapBanksMultiPlayer[4][i]; - CG_FinishWeaponChange( cg.predictedPlayerState.weapon, cg.weaponSelect ); - return; - } - } -// jpw - - // never switch weapon if auto-reload is disabled - if ( !cg.pmext.bAutoReload && IS_AUTORELOAD_WEAPON( cg.weaponSelect ) ) { - return; - } - - // if you're using an alt mode weapon, try switching back to the parent - // otherwise, switch to the equivalent if you've got it - if ( cg.weaponSelect >= WP_BEGINSECONDARY && cg.weaponSelect <= WP_LASTSECONDARY ) { - cg.weaponSelect = equiv = getAltWeapon( cg.weaponSelect ); // base any further changes on the parent - if ( CG_WeaponSelectable( equiv ) ) { // the parent was selectable, drop back to that - CG_FinishWeaponChange( cg.predictedPlayerState.weapon, cg.weaponSelect ); //----(SA) - return; - } - } - - - // now try the opposite team's equivalent weap - equiv = getEquivWeapon( cg.weaponSelect ); - - if ( equiv != cg.weaponSelect && CG_WeaponSelectable( equiv ) ) { - cg.weaponSelect = equiv; - CG_FinishWeaponChange( cg.predictedPlayerState.weapon, cg.weaponSelect ); //----(SA) - return; - } + // L0 - wrapped for noAmmoAutoSwitch + if ( allowForceSwitch ) + { + // JPW NERVE -- early out if we just fired Panzerfaust, go to pistola, then grenades + if (cg.weaponSelect == WP_PANZERFAUST) { + for (i = 0; i < MAX_WEAPS_IN_BANK_MP; i++) + if (CG_WeaponSelectable(weapBanksMultiPlayer[2][i])) { // find a pistol + cg.weaponSelect = weapBanksMultiPlayer[2][i]; + CG_FinishWeaponChange(cg.predictedPlayerState.weapon, cg.weaponSelect); + return; + } + for (i = 0; i < MAX_WEAPS_IN_BANK_MP; i++) + if (CG_WeaponSelectable(weapBanksMultiPlayer[4][i])) { // find a grenade + cg.weaponSelect = weapBanksMultiPlayer[4][i]; + CG_FinishWeaponChange(cg.predictedPlayerState.weapon, cg.weaponSelect); + return; + } + } + // jpw + + // never switch weapon if auto-reload is disabled + if (!cg.pmext.bAutoReload && IS_AUTORELOAD_WEAPON(cg.weaponSelect)) { + return; + } + + // if you're using an alt mode weapon, try switching back to the parent + // otherwise, switch to the equivalent if you've got it + if (cg.weaponSelect >= WP_BEGINSECONDARY && cg.weaponSelect <= WP_LASTSECONDARY) { + cg.weaponSelect = equiv = getAltWeapon(cg.weaponSelect); // base any further changes on the parent + if (CG_WeaponSelectable(equiv)) { // the parent was selectable, drop back to that + CG_FinishWeaponChange(cg.predictedPlayerState.weapon, cg.weaponSelect); //----(SA) + return; + } + } + + + // now try the opposite team's equivalent weap + equiv = getEquivWeapon(cg.weaponSelect); + + if (equiv != cg.weaponSelect && CG_WeaponSelectable(equiv)) { + cg.weaponSelect = equiv; + CG_FinishWeaponChange(cg.predictedPlayerState.weapon, cg.weaponSelect); //----(SA) + return; + } + } // ~L0 - Wrapper ends here.. // // more complicated selection -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git _______________________________________________ Pkg-games-commits mailing list Pkg-games-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits