From 950c314974baf06ededb4cd71f3a65fa10882b1e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Jan 2009 15:46:14 +0000 Subject: [PATCH] - replaced a few occurences of ONFLOORZ to work with 3D floors and 3DMidtex textures. - fixed skyrotate option. - fixed: 3D floors need to be spawned before the things. This was the reason why checking for the floor height did not work and which required a hack in P_ZMovement to prevent actors from falling through 3D floors. Now that this is working I could also fix some other things, most importantly floor and ceiling huggers which until now ignored 3D floors. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@285 b0f79afe-0144-0410-b225-9a4edf0717df --- src/g_hexen/a_hexenspecialdecs.cpp | 2 +- src/g_raven/a_minotaur.cpp | 2 +- src/g_strife/a_programmer.cpp | 2 +- src/g_strife/a_rebels.cpp | 2 +- src/g_strife/a_strifeweapons.cpp | 2 +- src/gl/gl_data.cpp | 1 - src/gl/gl_skydome.cpp | 6 +-- src/p_3dfloors.cpp | 25 +---------- src/p_3dfloors.h | 2 +- src/p_map.cpp | 24 +++++++++- src/p_mobj.cpp | 72 +++++++++++------------------- src/p_setup.cpp | 25 ++++++++++- 12 files changed, 83 insertions(+), 82 deletions(-) diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index fca9bade..c8c64b20 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -132,7 +132,7 @@ IMPLEMENT_CLASS (AZCorpseLynchedNoHeart) void AZCorpseLynchedNoHeart::PostBeginPlay () { Super::PostBeginPlay (); - Spawn ("BloodPool", x, y, ONFLOORZ, ALLOW_REPLACE); + Spawn ("BloodPool", x, y, floorz, ALLOW_REPLACE); } //============================================================================ diff --git a/src/g_raven/a_minotaur.cpp b/src/g_raven/a_minotaur.cpp index 1ad98c25..c3d6463c 100644 --- a/src/g_raven/a_minotaur.cpp +++ b/src/g_raven/a_minotaur.cpp @@ -406,7 +406,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MntrFloorFire) self->z = self->floorz; x = self->x + (pr_fire.Random2 () << 10); y = self->y + (pr_fire.Random2 () << 10); - mo = Spawn("MinotaurFX3", x, y, ONFLOORZ, ALLOW_REPLACE); + mo = Spawn("MinotaurFX3", x, y, self->floorz, ALLOW_REPLACE); mo->target = self->target; mo->momx = 1; // Force block checking P_CheckMissileSpawn (mo); diff --git a/src/g_strife/a_programmer.cpp b/src/g_strife/a_programmer.cpp index a8bcf42e..d3f25930 100644 --- a/src/g_strife/a_programmer.cpp +++ b/src/g_strife/a_programmer.cpp @@ -105,7 +105,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning) if (self->target == NULL) return; - spot = Spawn("SpectralLightningSpot", self->target->x, self->target->y, ONFLOORZ, ALLOW_REPLACE); + spot = Spawn("SpectralLightningSpot", self->target->x, self->target->y, self->target->floorz, ALLOW_REPLACE); if (spot != NULL) { spot->threshold = 25; diff --git a/src/g_strife/a_rebels.cpp b/src/g_strife/a_rebels.cpp index 2625ca17..56feee19 100644 --- a/src/g_strife/a_rebels.cpp +++ b/src/g_strife/a_rebels.cpp @@ -75,7 +75,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon) AActor *rebel; angle_t an; - rebel = Spawn("Rebel1", self->x, self->y, ONFLOORZ, ALLOW_REPLACE); + rebel = Spawn("Rebel1", self->x, self->y, self->floorz, ALLOW_REPLACE); if (!P_TryMove (rebel, rebel->x, rebel->y, true)) { rebel->Destroy (); diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 757863fd..0dbab29c 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -904,7 +904,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) P_BulletSlope (self, &linetarget); if (linetarget != NULL) { - spot = Spawn("SpectralLightningSpot", linetarget->x, linetarget->y, ONFLOORZ, ALLOW_REPLACE); + spot = Spawn("SpectralLightningSpot", linetarget->x, linetarget->y, linetarget->floorz, ALLOW_REPLACE); if (spot != NULL) { spot->tracer = linetarget; diff --git a/src/gl/gl_data.cpp b/src/gl/gl_data.cpp index 656b2d2b..d1d7ec93 100644 --- a/src/gl/gl_data.cpp +++ b/src/gl/gl_data.cpp @@ -268,7 +268,6 @@ static void ParseFunc(FScanner &sc, level_info_t *info) opt->skyrotatevector.Y = (float)sc.Float; sc.MustGetFloat(); opt->skyrotatevector.Z = (float)sc.Float; - sc.MustGetFloat(); opt->skyrotatevector.MakeUnit(); } else diff --git a/src/gl/gl_skydome.cpp b/src/gl/gl_skydome.cpp index f0173060..85f8e227 100644 --- a/src/gl/gl_skydome.cpp +++ b/src/gl/gl_skydome.cpp @@ -382,7 +382,7 @@ static void RenderDome(FTextureID texno, FGLTexture * tex, float x_offset, float if (texh>190 && skystretch) texh=190; - gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); + gl.Rotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); yAdd = y_offset/texh; @@ -463,7 +463,7 @@ static void RenderDome(FTextureID texno, FGLTexture * tex, float x_offset, float if (tex) { - gl.Rotatef(180.0f-x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); + gl.Rotatef(180.0f-x_offset, 0, 1, 0); } } @@ -480,7 +480,7 @@ static void RenderBox(FTextureID texno, FGLTexture * gltex, float x_offset, int int faces; FGLTexture * tex; - gl.Rotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); + gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); gl.Color3f(R, G ,B); if (sb->faces[5]) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 3c514933..7c1a866c 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -627,10 +627,10 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li //========================================================================== // -// Spawns non-ZDoom specials +// Spawns 3D floors // //========================================================================== -void P_SpawnSpecials2 (void) +void P_Spawn3DFloors (void) { static int flagvals[] = {128+512, 2+512, 512}; int i; @@ -670,27 +670,6 @@ void P_SpawnSpecials2 (void) line->special=0; line->args[0] = line->args[1] = line->args[2] = line->args[3] = line->args[4] = 0; } - - // - // Also do some tweaks to the spawned actors - // - TThinkerIterator it; - AActor * mo; - - while ((mo=it.Next())) - { - // Don't count monsters in end-of-level sectors - // In 99.9% of all occurences they are part of a trap - // and not supposed to be killed. - if (mo->flags & MF_COUNTKILL) - { - if (mo->Sector->special == dDamage_End) - { - level.total_monsters--; - mo->flags&=~(MF_COUNTKILL); - } - } - } } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index eafae224..970493e6 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -90,7 +90,7 @@ bool P_CheckFor3DCeilingHit(AActor * mo); void P_Recalculate3DFloors(sector_t *); void P_RecalculateAttached3DFloors(sector_t * sec); lightlist_t * P_GetPlaneLight(sector_t * , secplane_t * plane, bool underside); -void P_SpawnSpecials2( void ); +void P_Spawn3DFloors( void ); struct FLineOpening; diff --git a/src/p_map.cpp b/src/p_map.cpp index 8fa7985e..6967480b 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -166,7 +166,7 @@ static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPos // //========================================================================== -void P_FindFloorCeiling (AActor *actor, bool onlymidtex) +void P_FindFloorCeiling (AActor *actor, bool onlyspawnpos) { sector_t *sec; FCheckPosition tmf; @@ -197,7 +197,7 @@ void P_FindFloorCeiling (AActor *actor, bool onlymidtex) if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; - if (!onlymidtex || (tmf.touchmidtex && (tmf.floorz <= actor->z))) + if (!onlyspawnpos || (tmf.touchmidtex && (tmf.floorz <= actor->z))) { actor->floorz = tmf.floorz; actor->dropoffz = tmf.dropoffz; @@ -207,6 +207,26 @@ void P_FindFloorCeiling (AActor *actor, bool onlymidtex) actor->ceilingpic = tmf.ceilingpic; actor->ceilingsector = tmf.ceilingsector; } + + // also check 3D floors at the spawn position if the result from the block lines iterator cannot be used. + if (onlyspawnpos) + { + for(unsigned int i=0;iSector->e->XFloor.ffloors.Size();i++) + { + F3DFloor* rover=actor->Sector->e->XFloor.ffloors[i]; + + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(actor->x, actor->y); + fixed_t ff_top=rover->top.plane->ZatPoint(actor->x, actor->y); + + fixed_t delta1 = actor->z - (ff_bottom + ((ff_top-ff_bottom)/2)); + fixed_t delta2 = actor->z + (actor->height? actor->height:1) - (ff_bottom + ((ff_top-ff_bottom)/2)); + + if (ff_top > actor->floorz && abs(delta1) < abs(delta2)) actor->floorz = ff_top; + if (ff_bottom < actor->ceilingz && abs(delta1) >= abs(delta2)) actor->ceilingz = ff_bottom; + } + } } // diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index baab9661..6341615a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1851,28 +1851,6 @@ void P_ZMovement (AActor *mo) fixed_t delta; fixed_t oldz = mo->z; - // Intercept the stupid 'fall through 3dfloors' bug SSNTails 06-13-2002 - - // [GrafZahl] This is a really ugly workaround... :( - // But unless the collision code is completely rewritten it is the - // only way to avoid problems caused by incorrect positioning info... - for(unsigned int i=0;iSector->e->XFloor.ffloors.Size();i++) - { - F3DFloor* rover=mo->Sector->e->XFloor.ffloors[i]; - - if (!(rover->flags&FF_EXISTS)) continue; - if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(mo->x, mo->y); - fixed_t ff_top=rover->top.plane->ZatPoint(mo->x, mo->y); - - fixed_t delta1 = mo->z - (ff_bottom + ((ff_top-ff_bottom)/2)); - fixed_t delta2 = mo->z + (mo->height? mo->height:1) - (ff_bottom + ((ff_top-ff_bottom)/2)); - - if(ff_top > mo->floorz && abs(delta1) < abs(delta2)) mo->floorz = ff_top; - if(ff_bottom < mo->ceilingz && abs(delta1) >= abs(delta2)) mo->ceilingz = ff_bottom; - } - // // check for smooth step up // @@ -4613,6 +4591,26 @@ void P_PlaySpawnSound(AActor *missile, AActor *spawner) } } +static AActor * SpawnMissile (const PClass *type, fixed_t x, fixed_t y, fixed_t z) +{ + AActor *th = Spawn (type, x, y, z, ALLOW_REPLACE); + + if (th != NULL) + { + // Force floor huggers to the floor and ceiling huggers to the ceiling + if (th->flags3 & MF3_FLOORHUGGER) + { + z = th->floorz; + } + else if (th->flags3 & MF3_CEILINGHUGGER) + { + z = th->ceilingz - th->height; + } + } + return th; +} + + //--------------------------------------------------------------------------- // // FUNC P_SpawnMissile @@ -4642,22 +4640,13 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, type->TypeName.GetChars(), source->GetClass()->TypeName.GetChars()); return NULL; } - int defflags3 = GetDefaultByType (type)->flags3; - if (defflags3 & MF3_FLOORHUGGER) - { - z = ONFLOORZ; - } - else if (defflags3 & MF3_CEILINGHUGGER) - { - z = ONCEILINGZ; - } - else if (z != ONFLOORZ) + if (z != ONFLOORZ && z != ONCEILINGZ) { z -= source->floorclip; } - AActor *th = Spawn (type, x, y, z, ALLOW_REPLACE); + AActor *th = SpawnMissile (type, x, y, z); P_PlaySpawnSound(th, source); th->target = source; // record missile's originator @@ -4672,7 +4661,7 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, FVector3 velocity(dest->x - source->x, dest->y - source->y, dest->z - source->z); // Floor and ceiling huggers should never have a vertical component to their velocity - if (defflags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)) + if (th->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)) { velocity.Z = 0; } @@ -4766,21 +4755,14 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t momz, fixed_t speed, AActor *owner, bool checkspawn) { AActor *mo; - int defflags3 = GetDefaultByType (type)->flags3; - if (defflags3 & MF3_FLOORHUGGER) - { - z = ONFLOORZ; - } - else if (defflags3 & MF3_CEILINGHUGGER) - { - z = ONCEILINGZ; - } - if (z != ONFLOORZ) + if (z != ONFLOORZ && z != ONCEILINGZ && source != NULL) { z -= source->floorclip; } - mo = Spawn (type, source->x, source->y, z, ALLOW_REPLACE); + + mo = SpawnMissile (type, source->x, source->y, z); + P_PlaySpawnSound(mo, source); mo->target = owner != NULL ? owner : source; // Originator mo->angle = angle; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 68ce4907..9315c139 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3555,6 +3555,9 @@ void P_SetupLevel (char *lumpname, int position) deathmatchstarts.Clear (); + // Spawn 3d floors - must be done before spawning things so it can't be done in P_SpawnSpecials + P_Spawn3DFloors(); + if (!buildmap) { times[14].Clock(); @@ -3585,8 +3588,6 @@ void P_SetupLevel (char *lumpname, int position) // set up world state P_SpawnSpecials (); - // Spawn extended specials - P_SpawnSpecials2(); P_InitTagLists(); // This must be done BEFORE the PolyObj Spawn!!! @@ -3609,6 +3610,26 @@ void P_SetupLevel (char *lumpname, int position) } } + // Don't count monsters in end-of-level sectors + // In 99.9% of all occurences they are part of a trap + // and not supposed to be killed. + { + TThinkerIterator it; + AActor * mo; + + while ((mo=it.Next())) + { + if (mo->flags & MF_COUNTKILL) + { + if (mo->Sector->special == dDamage_End) + { + level.total_monsters--; + mo->flags&=~(MF_COUNTKILL); + } + } + } + } + T_PreprocessScripts(); // preprocess FraggleScript scripts // build subsector connect matrix