From 987c878a9ac534e7804c8164b97249bf28eb76b9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 30 Dec 2008 23:27:27 +0000 Subject: [PATCH] - Fixed: FMOD calls for setting the water reverb must check the return code for errors. - Fixed: Hexen's dual attack weapons must check distance to targets in 3D, not 2D. SVN r1336 (trunk) --- docs/rh-log.txt | 4 +++ src/g_hexen/a_clericstaff.cpp | 4 +-- src/g_hexen/a_fighterhammer.cpp | 6 ++-- src/g_hexen/a_magecone.cpp | 2 +- src/p_local.h | 2 +- src/p_map.cpp | 27 +++++++++++++--- src/sound/fmodsound.cpp | 55 +++++++++++++++++++++------------ 7 files changed, 70 insertions(+), 30 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 49c06acbc..6c1ab6d57 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ December 30, 2008 (Changes by Graf Zahl) +- Fixed: FMOD calls for setting the water reverb must check the return code + for errors. +- Fixed: Hexen's dual attack weapons must check distance to targets in 3D, + not 2D. - Made several DECORATE errors which do not involve parsing non-fatal. - Added a static error counter to FScriptPosition class. - Changed initialization of actor class type properties: fuglyname is gone as diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp index 781578c0c..09f6513f8 100644 --- a/src/g_hexen/a_clericstaff.cpp +++ b/src/g_hexen/a_clericstaff.cpp @@ -66,7 +66,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck) for (i = 0; i < 3; i++) { angle = pmo->angle+i*(ANG45/16); - slope = P_AimLineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), &linetarget); + slope = P_AimLineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, false, true); if (linetarget) { P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff")); @@ -90,7 +90,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck) break; } angle = pmo->angle-i*(ANG45/16); - slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget); + slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, false, true); if (linetarget) { P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff")); diff --git a/src/g_hexen/a_fighterhammer.cpp b/src/g_hexen/a_fighterhammer.cpp index 2de5e6189..edb618bea 100644 --- a/src/g_hexen/a_fighterhammer.cpp +++ b/src/g_hexen/a_fighterhammer.cpp @@ -46,7 +46,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) for (i = 0; i < 16; i++) { angle = pmo->angle + i*(ANG45/32); - slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget); + slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, false, true); if (linetarget) { P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true); @@ -59,7 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) goto hammerdone; } angle = pmo->angle-i*(ANG45/32); - slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &linetarget); + slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &linetarget, 0, false, true); if(linetarget) { P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true); @@ -74,7 +74,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) } // didn't find any targets in meleerange, so set to throw out a hammer angle = pmo->angle; - slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget); + slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, false, true); if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true) != NULL) { pmo->special1 = false; diff --git a/src/g_hexen/a_magecone.cpp b/src/g_hexen/a_magecone.cpp index 97bee7302..ebf94f29a 100644 --- a/src/g_hexen/a_magecone.cpp +++ b/src/g_hexen/a_magecone.cpp @@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1) for (i = 0; i < 16; i++) { angle = self->angle+i*(ANG45/16); - slope = P_AimLineAttack (self, angle, MELEERANGE, &linetarget); + slope = P_AimLineAttack (self, angle, MELEERANGE, &linetarget, 0, false, true); if (linetarget) { P_DamageMobj (linetarget, self, self, damage, NAME_Ice); diff --git a/src/p_local.h b/src/p_local.h index 2ff6ff4b3..a20db63fc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -380,7 +380,7 @@ void P_FindFloorCeiling (AActor *actor, bool onlymidtex = false); bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); -fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget = NULL, fixed_t vrange=0, bool forcenosmart=false); +fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget = NULL, fixed_t vrange=0, bool forcenosmart=false, bool check3d = false); AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, const PClass *pufftype, bool ismelee = false); AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, bool ismelee = false); void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch); diff --git a/src/p_map.cpp b/src/p_map.cpp index 457661604..d716b38ff 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2359,6 +2359,7 @@ struct aim_t AActor * thing_friend, * thing_other; angle_t pitch_friend, pitch_other; bool notsmart; + bool check3d; void AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); @@ -2385,7 +2386,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e fixed_t thingbottompitch; fixed_t dist; int thingpitch; - + if (in->isaline) { li = in->d.line; @@ -2396,8 +2397,8 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e // Crosses a two sided line. // A two sided line will restrict the possible target ranges. FLineOpening open; - P_LineOpening (open, NULL, li, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); + P_LineOpening (open, NULL, li, it.Trace().x + FixedMul (it.Trace().dx, in->frac), + it.Trace().y + FixedMul (it.Trace().dy, in->frac)); if (open.bottom >= open.top) return; // stop @@ -2456,6 +2457,23 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e thingbottompitch = bottompitch; thingpitch = thingtoppitch/2 + thingbottompitch/2; + + if (check3d) + { + // We need to do a 3D distance check here because this is nearly always used in + // combination with P_LineAttack. P_LineAttack uses 3D distance but FPathTraverse + // only 2D. This causes some problems with Hexen's weapons that use different + // attack modes based on distance to target + fixed_t cosine = finecosine[thingpitch >> ANGLETOFINESHIFT]; + if (cosine != 0) + { + fixed_t d3 = FixedDiv( FixedMul( P_AproxDistance(it.Trace().dx, it.Trace().dy), in->frac), cosine); + if (d3 > attackrange) + { + return; + } + } + } if (sv_smartaim && !notsmart) { @@ -2500,7 +2518,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e // P_AimLineAttack // //============================================================================ -fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, bool forcenosmart) +fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, bool forcenosmart, bool check3d) { fixed_t x2; fixed_t y2; @@ -2508,6 +2526,7 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p angle >>= ANGLETOFINESHIFT; aim.shootthing = t1; + aim.check3d = check3d; x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 5c339b114..3bcc37144 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -903,26 +903,43 @@ bool FMODSoundRenderer::Init() FMOD::DSP *sfx_head, *pausable_head; result = SfxGroup->getDSPHead(&sfx_head); - result = sfx_head->getInput(0, &pausable_head, &SfxConnection); - - result = WaterLP->addInput(pausable_head, NULL); - WaterLP->setActive(false); - WaterLP->setParameter(FMOD_DSP_LOWPASS_CUTOFF, snd_waterlp); - WaterLP->setParameter(FMOD_DSP_LOWPASS_RESONANCE, 2); - if (WaterReverb != NULL) + if (result == FMOD_OK) { - FMOD::DSPConnection *dry; - result = WaterReverb->addInput(pausable_head, &dry); - result = dry->setMix(0.1f); - result = WaterReverb->addInput(WaterLP, NULL); - result = sfx_head->addInput(WaterReverb, NULL); - WaterReverb->setParameter(FMOD_DSP_REVERB_ROOMSIZE, 0.001f); - WaterReverb->setParameter(FMOD_DSP_REVERB_DAMP, 0.2f); - WaterReverb->setActive(false); - } - else - { - result = sfx_head->addInput(WaterLP, NULL); + result = sfx_head->getInput(0, &pausable_head, &SfxConnection); + if (result == FMOD_OK) + { + result = WaterLP->addInput(pausable_head, NULL); + WaterLP->setActive(false); + WaterLP->setParameter(FMOD_DSP_LOWPASS_CUTOFF, snd_waterlp); + WaterLP->setParameter(FMOD_DSP_LOWPASS_RESONANCE, 2); + if (WaterReverb != NULL) + { + FMOD::DSPConnection *dry; + result = WaterReverb->addInput(pausable_head, &dry); + if (result == FMOD_OK) + { + result = dry->setMix(0.1f); + if (result == FMOD_OK) + { + result = WaterReverb->addInput(WaterLP, NULL); + if (result == FMOD_OK) + { + result = sfx_head->addInput(WaterReverb, NULL); + if (result == FMOD_OK) + { + WaterReverb->setParameter(FMOD_DSP_REVERB_ROOMSIZE, 0.001f); + WaterReverb->setParameter(FMOD_DSP_REVERB_DAMP, 0.2f); + WaterReverb->setActive(false); + } + } + } + } + } + else + { + result = sfx_head->addInput(WaterLP, NULL); + } + } } } LastWaterLP = snd_waterlp;