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 dfbbf3d63b5cd9a6b5d8c3b6fb25dadb0ca616de
Author: Donny <m4n4t4...@gmail.com>
Date:   Wed Jul 8 11:39:44 2015 -0400

    All: Fix CG_WaterLevel() checks
---
 MP/code/cgame/cg_event.c | 23 ++++++++++++++---------
 SP/code/cgame/cg_event.c | 22 +++++++++++++---------
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/MP/code/cgame/cg_event.c b/MP/code/cgame/cg_event.c
index eb3b459..b8b8af4 100644
--- a/MP/code/cgame/cg_event.c
+++ b/MP/code/cgame/cg_event.c
@@ -588,23 +588,28 @@ Returns waterlevel for entity origin
 int CG_WaterLevel(centity_t *cent) {
        vec3_t point;
        int contents, sample1, sample2, anim, waterlevel;
+       int viewheight;
 
-       // get waterlevel, accounting for ducking
-       waterlevel = 0;
-       VectorCopy(cent->lerpOrigin, point);
-       point[2] += MINS_Z + 1;
        anim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT;
 
        if (anim == LEGS_WALKCR || anim == LEGS_IDLECR) {
-               point[2] += CROUCH_VIEWHEIGHT;
+               viewheight = CROUCH_VIEWHEIGHT;
        } else {
-               point[2] += DEFAULT_VIEWHEIGHT;
+               viewheight = DEFAULT_VIEWHEIGHT;
        }
 
+       //
+       // get waterlevel, accounting for ducking
+       //
+       waterlevel = 0;
+
+       point[0] = cent->lerpOrigin[0];
+       point[1] = cent->lerpOrigin[1];
+       point[2] = cent->lerpOrigin[2] + MINS_Z + 1;
        contents = CG_PointContents(point, -1);
 
        if (contents & MASK_WATER) {
-               sample2 = point[2] - MINS_Z;
+               sample2 = viewheight - MINS_Z;
                sample1 = sample2 / 2;
                waterlevel = 1;
                point[2] = cent->lerpOrigin[2] + MINS_Z + sample1;
@@ -744,7 +749,7 @@ void CG_PainEvent( centity_t *cent, int health, qboolean 
crouching ) {
        }
 
        // play a gurp sound instead of a normal pain sound
-       if (CG_WaterLevel(cent) >= 1) {
+       if (CG_WaterLevel(cent) == 3) {
                if (rand()&1) {
                        trap_S_StartSound(NULL, cent->currentState.number, 
CHAN_VOICE, CG_CustomSound(cent->currentState.number, 
"sound/player/gurp1.wav"));
                } else {
@@ -2302,7 +2307,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
        case EV_DEATH3:
                DEBUGNAME( "EV_DEATHx" );
 
-               if (CG_WaterLevel(cent) >= 1) {
+               if (CG_WaterLevel(cent) == 3) {
                        trap_S_StartSound(NULL, es->number, CHAN_VOICE, 
CG_CustomSound(es->number, "*drown.wav"));
                } else {
                        trap_S_StartSound(NULL, es->number, CHAN_VOICE, 
CG_CustomSound(es->number, va("*death%i.wav", event - EV_DEATH1 + 1)));
diff --git a/SP/code/cgame/cg_event.c b/SP/code/cgame/cg_event.c
index 9b9873d..f1973f8 100644
--- a/SP/code/cgame/cg_event.c
+++ b/SP/code/cgame/cg_event.c
@@ -546,23 +546,27 @@ Returns waterlevel for entity origin
 int CG_WaterLevel(centity_t *cent) {
        vec3_t point;
        int contents, sample1, sample2, anim, waterlevel;
+       int viewheight;
 
-       // get waterlevel, accounting for ducking
-       waterlevel = 0;
-       VectorCopy(cent->lerpOrigin, point);
-       point[2] += MINS_Z + 1;
        anim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT;
 
        if (anim == LEGS_WALKCR || anim == LEGS_IDLECR) {
-               point[2] += CROUCH_VIEWHEIGHT;
+               viewheight = CROUCH_VIEWHEIGHT;
        } else {
-               point[2] += DEFAULT_VIEWHEIGHT;
+               viewheight = DEFAULT_VIEWHEIGHT;
        }
 
+       // get waterlevel, accounting for ducking
+       //
+       waterlevel = 0;
+
+       point[0] = cent->lerpOrigin[0];
+       point[1] = cent->lerpOrigin[1];
+       point[2] = cent->lerpOrigin[2] + MINS_Z + 1;
        contents = CG_PointContents(point, -1);
 
        if (contents & MASK_WATER) {
-               sample2 = point[2] - MINS_Z;
+               sample2 = viewheight - MINS_Z;
                sample1 = sample2 / 2;
                waterlevel = 1;
                point[2] = cent->lerpOrigin[2] + MINS_Z + sample1;
@@ -702,7 +706,7 @@ void CG_PainEvent( centity_t *cent, int health, qboolean 
crouching ) {
        }
        
        // play a gurp sound instead of a normal pain sound
-       if (CG_WaterLevel(cent) >= 1) {
+       if (CG_WaterLevel(cent) == 3) {
                if (rand()&1) {
                        trap_S_StartSound(NULL, cent->currentState.number, 
CHAN_VOICE, CG_CustomSound(cent->currentState.number, 
"sound/player/gurp1.wav"));
                } else {
@@ -2364,7 +2368,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
        case EV_DEATH3:
                DEBUGNAME( "EV_DEATHx" );
 
-               if (CG_WaterLevel(cent) >= 1) {
+               if (CG_WaterLevel(cent) == 3) {
                        trap_S_StartSound(NULL, es->number, CHAN_VOICE, 
CG_CustomSound(es->number, "sound/player/gurp1.wav"));
                } else {
                        trap_S_StartSound(NULL, es->number, CHAN_VOICE, 
CG_CustomSound(es->number, va("*death%i.wav", event - EV_DEATH1 + 1)));

-- 
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

Reply via email to