From e263d46ff7ccc6860968532e68e90dacece1c43c Mon Sep 17 00:00:00 2001 From: gez Date: Sun, 8 Apr 2012 10:39:30 +0000 Subject: [PATCH] * Updated to ZDoom r3542: - Added another flag to P_FindFloorCeiling() to get it to do its standard processing but without resetting the actor's sector. The 3D floor checks in P_NightmareRespawn() and A_RestoreSpecialPosition now use this. - Fixed: P_NightmareRespawn() did its Z clamping before checking for 3D floors. - Fixed: Respawning actors were not clamped to the ceiling. - Fixed: Passing hexdd.wad with a path to the -iwad parameter would disable searching the standard paths for hexen.wad. - Fixed: Stereo sound volume reduction should only be done for stereo sounds played in 3D. Head-relative ones should remain full volume. - Fixed: RunScript() ignored the always parameter. - Don't call secfriction() twice in the normal part of P_GetFriction(). - Fixed: The 3D floors part of P_GetFriction() did not check for friction still being set to ORIG_FRICTION, so it only worked with lower frictions. - Clamp maximum particle count to 65535. - Fixed: The inner railgun trail ignored the RGF_FULLBRIGHT flag. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1351 b0f79afe-0144-0410-b225-9a4edf0717df --- src/d_iwad.cpp | 2 +- src/d_net.cpp | 2 +- src/g_shared/a_pickups.cpp | 8 +++-- src/p_effect.cpp | 8 ++--- src/p_effect.h | 4 +-- src/p_local.h | 8 ++++- src/p_map.cpp | 53 +++++++++++++++++-------------- src/p_maputl.cpp | 2 +- src/p_mobj.cpp | 29 ++++++++++++++--- src/p_user.cpp | 2 +- src/sound/fmodsound.cpp | 24 +++++++------- src/svnrevision.h | 4 +-- src/thingdef/thingdef_codeptr.cpp | 2 +- 13 files changed, 92 insertions(+), 56 deletions(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 705ff2f7..0bad0c3e 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -413,7 +413,7 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, } } - if (iwadparm == NULL || wads[0].Path.IsEmpty()) + if (iwadparm == NULL || wads[0].Path.IsEmpty() || mIWads[wads[0].Type].Required.IsNotEmpty()) { if (GameConfig->SetSection ("IWADSearch.Directories")) { diff --git a/src/d_net.cpp b/src/d_net.cpp index 03b2ea2a..dbe07ccf 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2497,7 +2497,7 @@ static void RunScript(BYTE **stream, APlayerPawn *pawn, int snum, int argn, int arg[i] = argval; } } - P_StartScript(pawn, NULL, snum, level.mapname, arg, MIN(countof(arg), argn), ACS_NET); + P_StartScript(pawn, NULL, snum, level.mapname, arg, MIN(countof(arg), argn), ACS_NET | always); } void Net_SkipCommand (int type, BYTE **stream) diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index acf18350..bef479d5 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -357,7 +357,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) self->dropoffz = self->floorz = sec->floorplane.ZatPoint(_x, _y); self->ceilingz = sec->ceilingplane.ZatPoint(_x, _y); - P_FindFloorCeiling(self, true); + P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS); if (self->flags & MF_SPAWNCEILING) { @@ -385,12 +385,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) } } // Redo floor/ceiling check, in case of 3D floors - P_FindFloorCeiling(self, true); + P_FindFloorCeiling(self, FFCF_SAMESECTOR); if (self->z < self->floorz) { // Do not reappear under the floor, even if that's where we were for the // initial spawn. self->z = self->floorz; } + if (self->z + self->height > self->ceilingz) + { // Do the same for the ceiling. + self->z = self->ceilingz - self->height; + } } int AInventory::StaticLastMessageTic; diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 5e6189d6..7edaf812 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -151,8 +151,7 @@ void P_InitParticles () NumParticles = r_maxparticles; // This should be good, but eh... - if ( NumParticles < 100 ) - NumParticles = 100; + NumParticles = clamp(NumParticles, 100, 65535); P_DeinitParticles(); Particles = new particle_t[NumParticles]; @@ -688,8 +687,7 @@ void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end p->ttl = duration; p->fade = FADEFROMTTL(duration); p->size = 3; - if(fullbright) - p->bright = true; + p->bright = fullbright; tempvec = FMatrix3x3(dir, deg) * extend; p->velx = FLOAT2FIXED(tempvec.X * drift)>>4; @@ -760,6 +758,8 @@ void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end p->accz -= FRACUNIT/4096; pos += trail_step; + p->bright = fullbright; + if (color2 == -1) { int rand = M_Random(); diff --git a/src/p_effect.h b/src/p_effect.h index bd0aae60..66621573 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -59,13 +59,13 @@ struct particle_t fixed_t accx,accy,accz; BYTE ttl; BYTE trans; - BYTE size; + BYTE size:7; + BYTE bright:1; BYTE fade; int color; WORD tnext; WORD snext; subsector_t * subsector; - bool bright; }; extern particle_t *Particles; diff --git a/src/p_local.h b/src/p_local.h index 7575371e..9586651c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -432,7 +432,13 @@ void P_ResetSightCounters (bool full); bool P_TalkFacing (AActor *player); void P_UseLines (player_t* player); bool P_UsePuzzleItem (AActor *actor, int itemType); -void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos = false); + +enum +{ + FFCF_ONLYSPAWNPOS = 1, + FFCF_SAMESECTOR = 2 +}; +void P_FindFloorCeiling (AActor *actor, int flags=0); bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); diff --git a/src/p_map.cpp b/src/p_map.cpp index 1e04cab5..8273e763 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -170,12 +170,12 @@ static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPos // //========================================================================== -void P_GetFloorCeilingZ(FCheckPosition &tmf, bool get) +void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) { sector_t *sec; - if (get) + if (!(flags & FFCF_ONLYSPAWNPOS)) { - sec = P_PointInSector (tmf.x, tmf.y); + sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector (tmf.x, tmf.y) : sec = tmf.thing->Sector; tmf.floorsector = sec; tmf.ceilingsector = sec; @@ -184,7 +184,10 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, bool get) tmf.floorpic = sec->GetTexture(sector_t::floor); tmf.ceilingpic = sec->GetTexture(sector_t::ceiling); } - else sec = tmf.thing->Sector; + else + { + sec = tmf.thing->Sector; + } #ifdef _3DFLOORS for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) @@ -219,7 +222,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, bool get) // //========================================================================== -void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos) +void P_FindFloorCeiling (AActor *actor, int flags) { FCheckPosition tmf; @@ -228,9 +231,9 @@ void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos) tmf.y = actor->y; tmf.z = actor->z; - if (!onlyspawnpos) + if (!(flags & FFCF_ONLYSPAWNPOS)) { - P_GetFloorCeilingZ(tmf, true); + P_GetFloorCeilingZ(tmf, flags); } else { @@ -240,7 +243,7 @@ void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos) tmf.ceilingz = actor->ceilingz; tmf.floorpic = actor->floorpic; tmf.ceilingpic = actor->ceilingpic; - P_GetFloorCeilingZ(tmf, false); + P_GetFloorCeilingZ(tmf, flags); } actor->floorz = tmf.floorz; actor->dropoffz = tmf.dropoffz; @@ -266,7 +269,7 @@ void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos) if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; - if (!onlyspawnpos || (tmf.abovemidtex && (tmf.floorz <= actor->z))) + if (!(flags & FFCF_ONLYSPAWNPOS) || (tmf.abovemidtex && (tmf.floorz <= actor->z))) { actor->floorz = tmf.floorz; actor->dropoffz = tmf.dropoffz; @@ -321,7 +324,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr tmf.z = z; tmf.touchmidtex = false; tmf.abovemidtex = false; - P_GetFloorCeilingZ(tmf, true); + P_GetFloorCeilingZ(tmf, FFCF_ONLYSPAWNPOS); spechit.Clear (); @@ -488,6 +491,7 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) { int friction = ORIG_FRICTION; int movefactor = ORIG_FRICTION_FACTOR; + fixed_t newfriction; const msecnode_t *m; const sector_t *sec; @@ -498,8 +502,8 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) else if ((!(mo->flags & MF_NOGRAVITY) && mo->waterlevel > 1) || (mo->waterlevel == 1 && mo->z > mo->floorz + 6*FRACUNIT)) { - friction = secfriction (mo->Sector); - movefactor = secmovefac (mo->Sector) >> 1; + friction = secfriction(mo->Sector); + movefactor = secmovefac(mo->Sector) >> 1; } else if (var_friction && !(mo->flags & (MF_NOCLIP|MF_NOGRAVITY))) { // When the object is straddling sectors with the same @@ -512,16 +516,16 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) #ifdef _3DFLOORS // 3D floors must be checked, too - for(unsigned i=0;ie->XFloor.ffloors.Size();i++) + for (unsigned i = 0; i < sec->e->XFloor.ffloors.Size(); i++) { - F3DFloor * rover=sec->e->XFloor.ffloors[i]; - if (!(rover->flags&FF_EXISTS)) continue; - if(!(rover->flags & FF_SOLID)) continue; + F3DFloor *rover = sec->e->XFloor.ffloors[i]; + if (!(rover->flags & FF_EXISTS)) continue; + if (!(rover->flags & FF_SOLID)) continue; // Player must be on top of the floor to be affected... - if(mo->z != rover->top.plane->ZatPoint(mo->x,mo->y)) continue; - fixed_t newfriction=secfriction(rover->model); - if (newfrictionz != rover->top.plane->ZatPoint(mo->x,mo->y)) continue; + newfriction = secfriction(rover->model); + if (newfriction < friction || friction == ORIG_FRICTION) { friction = newfriction; movefactor = secmovefac(rover->model); @@ -534,13 +538,14 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) { continue; } - if ((secfriction(sec) < friction || friction == ORIG_FRICTION) && - (mo->z <= sec->floorplane.ZatPoint (mo->x, mo->y) || + newfriction = secfriction(sec); + if ((newfriction < friction || friction == ORIG_FRICTION) && + (mo->z <= sec->floorplane.ZatPoint(mo->x, mo->y) || (sec->GetHeightSec() != NULL && - mo->z <= sec->heightsec->floorplane.ZatPoint (mo->x, mo->y)))) + mo->z <= sec->heightsec->floorplane.ZatPoint(mo->x, mo->y)))) { - friction = secfriction (sec); - movefactor = secmovefac (sec); + friction = newfriction; + movefactor = secmovefac(sec); } } } diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 05c24869..477ed350 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -578,7 +578,7 @@ void AActor::SetOrigin (fixed_t ix, fixed_t iy, fixed_t iz) LinkToWorld (); floorz = Sector->floorplane.ZatPoint (ix, iy); ceilingz = Sector->ceilingplane.ZatPoint (ix, iy); - P_FindFloorCeiling(this, true); + P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS); } FBlockNode *FBlockNode::FreeBlocks = NULL; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 1829fe4c..49421828 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2476,12 +2476,34 @@ void P_NightmareRespawn (AActor *mobj) // can use P_CheckPosition() properly. mo->z = mo->floorz; } + if (mo->z + mo->height > mo->ceilingz) + { + mo->z = mo->ceilingz - mo->height; + } } else if (z == ONCEILINGZ) { mo->z -= mobj->SpawnPoint[2]; } + // If there are 3D floors, we need to find floor/ceiling again. + P_FindFloorCeiling(mo, FFCF_SAMESECTOR); + + if (z == ONFLOORZ) + { + if (mo->z < mo->floorz) + { // Do not respawn monsters in the floor, even if that's where they + // started. The initial P_ZMovement() call would have put them on + // the floor right away, but we need them on the floor now so we + // can use P_CheckPosition() properly. + mo->z = mo->floorz; + } + if (mo->z + mo->height > mo->ceilingz) + { // Do the same for the ceiling. + mo->z = mo->ceilingz - mo->height; + } + } + // something is occupying its position? if (!P_CheckPosition(mo, mo->x, mo->y, true)) { @@ -2491,9 +2513,6 @@ void P_NightmareRespawn (AActor *mobj) return; // no respawn } - // If there are 3D floors, we need to find floor/ceiling again. - P_FindFloorCeiling(mo, true); - z = mo->z; // inherit attributes from deceased one @@ -3629,7 +3648,7 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t // z-coordinate. if (!SpawningMapThing) { - P_FindFloorCeiling(actor, true); + P_FindFloorCeiling(actor, FFCF_ONLYSPAWNPOS); } else { @@ -4495,7 +4514,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) mobj->SpawnPoint[2] = mthing->z; mobj->SpawnAngle = mthing->angle; mobj->SpawnFlags = mthing->flags; - P_FindFloorCeiling(mobj, true); + P_FindFloorCeiling(mobj, FFCF_ONLYSPAWNPOS); if (!(mobj->flags2 & MF2_ARGSDEFINED)) { diff --git a/src/p_user.cpp b/src/p_user.cpp index 8b87a980..207df7e2 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -542,7 +542,7 @@ void APlayerPawn::PostBeginPlay() { dropoffz = floorz = Sector->floorplane.ZatPoint(x, y); ceilingz = Sector->ceilingplane.ZatPoint(x, y); - P_FindFloorCeiling(this, true); + P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS); z = floorz; } else diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 8236ca9a..21ba53b5 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -1772,17 +1772,6 @@ FISoundChannel *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener * ((FMOD::Sound *)sfx.data)->setDefaults(def_freq, def_vol, def_pan, def_priority); } - // Reduce volume of stereo sounds, because each channel will be summed together - // and is likely to be very similar, resulting in an amplitude twice what it - // would have been had it been mixed to mono. - if (FMOD_OK == ((FMOD::Sound *)sfx.data)->getFormat(NULL, NULL, &numchans, NULL)) - { - if (numchans > 1) - { - vol *= 0.5f; - } - } - if (FMOD_OK == result) { result = chan->getMode(&mode); @@ -1807,6 +1796,19 @@ FISoundChannel *FMODSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener * chan->setMode(mode); chan->setChannelGroup((flags & SNDF_NOPAUSE) ? SfxGroup : PausableSfx); + if (mode & FMOD_3D) + { + // Reduce volume of stereo sounds, because each channel will be summed together + // and is likely to be very similar, resulting in an amplitude twice what it + // would have been had it been mixed to mono. + if (FMOD_OK == ((FMOD::Sound *)sfx.data)->getFormat(NULL, NULL, &numchans, NULL)) + { + if (numchans > 1) + { + vol *= 0.5f; + } + } + } if (freq != 0) { chan->setFrequency(freq); diff --git a/src/svnrevision.h b/src/svnrevision.h index 84b78080..d1cd94dd 100644 --- a/src/svnrevision.h +++ b/src/svnrevision.h @@ -3,5 +3,5 @@ // This file was automatically generated by the // updaterevision tool. Do not edit by hand. -#define ZD_SVN_REVISION_STRING "3535" -#define ZD_SVN_REVISION_NUMBER 3535 +#define ZD_SVN_REVISION_STRING "3542" +#define ZD_SVN_REVISION_NUMBER 3542 diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 451f3650..5b070c00 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -2697,7 +2697,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) self->dropoffz = self->floorz = sec->floorplane.ZatPoint(self->x, self->y); self->ceilingz = sec->ceilingplane.ZatPoint(self->x, self->y); - P_FindFloorCeiling(self, true); + P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS); } } else