Fix CG_WaterLevel() checks for waterlevel 2 and 3
CG_WaterLevel() added lerpOrigin to itself instead of adding view height when checking for waterlevel 2 and 3. This did not cause issues because ioq3 only compared the calculated waterlevel to more or equal to 1.
This commit is contained in:
parent
6a03817a9c
commit
08ac364cd6
1 changed files with 12 additions and 7 deletions
|
@ -428,23 +428,28 @@ Returns waterlevel for entity origin
|
||||||
int CG_WaterLevel(centity_t *cent) {
|
int CG_WaterLevel(centity_t *cent) {
|
||||||
vec3_t point;
|
vec3_t point;
|
||||||
int contents, sample1, sample2, anim, waterlevel;
|
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;
|
anim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT;
|
||||||
|
|
||||||
if (anim == LEGS_WALKCR || anim == LEGS_IDLECR) {
|
if (anim == LEGS_WALKCR || anim == LEGS_IDLECR) {
|
||||||
point[2] += CROUCH_VIEWHEIGHT;
|
viewheight = CROUCH_VIEWHEIGHT;
|
||||||
} else {
|
} 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);
|
contents = CG_PointContents(point, -1);
|
||||||
|
|
||||||
if (contents & MASK_WATER) {
|
if (contents & MASK_WATER) {
|
||||||
sample2 = point[2] - MINS_Z;
|
sample2 = viewheight - MINS_Z;
|
||||||
sample1 = sample2 / 2;
|
sample1 = sample2 / 2;
|
||||||
waterlevel = 1;
|
waterlevel = 1;
|
||||||
point[2] = cent->lerpOrigin[2] + MINS_Z + sample1;
|
point[2] = cent->lerpOrigin[2] + MINS_Z + sample1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue