From 87b23d160bcbfe8ed35d6ff0921b72f54109ae41 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sun, 25 Dec 2016 13:09:32 +0200 Subject: [PATCH 01/14] Ported RenderRadius and related code from gzdoom branch --- game-music-emu/gme/gme_types.h | 10 +-- src/actor.h | 4 ++ src/p_local.h | 2 + src/p_map.cpp | 91 +++++++++++++++++++++++++++ src/p_maputl.cpp | 4 ++ src/p_mobj.cpp | 4 ++ src/p_setup.cpp | 1 + src/p_udmf.cpp | 1 + src/r_defs.h | 2 + src/r_things.cpp | 9 ++- src/scripting/thingdef_properties.cpp | 9 +++ wadsrc/static/zscript/actor.txt | 2 + 12 files changed, 133 insertions(+), 6 deletions(-) mode change 100644 => 100755 game-music-emu/gme/gme_types.h diff --git a/game-music-emu/gme/gme_types.h b/game-music-emu/gme/gme_types.h old mode 100644 new mode 100755 index 06226f4aa..bd3670e64 --- a/game-music-emu/gme/gme_types.h +++ b/game-music-emu/gme/gme_types.h @@ -1,11 +1,13 @@ #ifndef GME_TYPES_H #define GME_TYPES_H -/* - * This is a default gme_types.h for use when *not* using - * CMake. If CMake is in use gme_types.h.in will be - * processed instead. +/* CMake will either define the following to 1, or #undef it, + * depending on the options passed to CMake. This is used to + * conditionally compile in the various emulator types. + * + * See gme_type_list() in gme.cpp */ + #define USE_GME_AY #define USE_GME_GBS #define USE_GME_GYM diff --git a/src/actor.h b/src/actor.h index 12bb4dc28..18c3ecb17 100644 --- a/src/actor.h +++ b/src/actor.h @@ -33,6 +33,7 @@ // States are tied to finite states are tied to animation frames. #include "info.h" +#include #include "doomdef.h" #include "textures/textures.h" #include "r_data/renderstyle.h" @@ -1035,6 +1036,7 @@ public: struct sector_t *ceilingsector; FTextureID ceilingpic; // contacted sec ceilingpic double radius, Height; // for movement checking + double renderradius; double projectilepassheight; // height for clipping projectile movement against this actor @@ -1141,6 +1143,8 @@ public: struct msecnode_t *touching_sectorlist; // phares 3/14/98 struct msecnode_t *render_sectorlist; // same for cross-sectorportal rendering struct portnode_t *render_portallist; // and for cross-lineportal + std::forward_list* touching_render_sectors; // this is the list of sectors that this thing interesects with it's max(radius, renderradius). + int validcount; TObjPtr Inventory; // [RH] This actor's inventory diff --git a/src/p_local.h b/src/p_local.h index ef702e018..4244005c3 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -400,6 +400,8 @@ void P_DelSeclist(msecnode_t *); // phares 3/16/98 msecnode_t *P_AddSecnode(sector_t *s, AActor *thing, msecnode_t *nextnode, msecnode_t *&sec_thinglist); msecnode_t* P_DelSecnode(msecnode_t *, msecnode_t *sector_t::*head); void P_CreateSecNodeList(AActor*); // phares 3/14/98 +void P_LinkRenderSectors(AActor*); +void P_UnlinkRenderSectors(AActor*); double P_GetMoveFactor(const AActor *mo, double *frictionp); // phares 3/6/98 double P_GetFriction(const AActor *mo, double *frictionfactor); diff --git a/src/p_map.cpp b/src/p_map.cpp index 81934ceb7..e1e42db60 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6640,6 +6640,97 @@ void P_CreateSecNodeList(AActor *thing) } +//============================================================================= +// +// P_LinkRenderSectors +// +// Alters/creates the list of touched sectors for thing's render radius. +// +//============================================================================= + +void P_LinkRenderSectors(AActor* thing) +{ + FBoundingBox box(thing->X(), thing->Y(), std::max(thing->renderradius, thing->radius)); + FBlockLinesIterator it(box); + line_t *ld; + + // add to surrounding sectors + while ((ld = it.Next())) + { + if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) + continue; + + // + // create necessary lists. + if (!thing->touching_render_sectors) thing->touching_render_sectors = new std::forward_list(); + + // + if (ld->frontsector != thing->Sector) + { + if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->frontsector) == thing->touching_render_sectors->end()) + thing->touching_render_sectors->push_front(ld->frontsector); + if (!ld->frontsector->touching_render_things) ld->frontsector->touching_render_things = new std::forward_list(); + ld->frontsector->touching_render_things->push_front(thing); + } + + if (ld->backsector && ld->backsector != thing->Sector) + { + if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->backsector) == thing->touching_render_sectors->end()) + thing->touching_render_sectors->push_front(ld->backsector); + if (!ld->backsector->touching_render_things) ld->backsector->touching_render_things = new std::forward_list(); + ld->backsector->touching_render_things->push_front(thing); + } + } + + // add to own sector + if (!thing->Sector->touching_render_things) thing->Sector->touching_render_things = new std::forward_list(); + thing->Sector->touching_render_things->push_front(thing); +} + + +//============================================================================= +// +// P_UnlinkRenderSectors +// +// Reverses P_LinkRenderSectors. +// +//============================================================================= + +void P_UnlinkRenderSectors(AActor* thing) +{ + if (thing->touching_render_sectors) + { + for (std::forward_list::iterator it = thing->touching_render_sectors->begin(); + it != thing->touching_render_sectors->end(); it++) + { + sector_t* sec = (*it); + if (sec->touching_render_things) + { + sec->touching_render_things->remove(thing); + if (sec->touching_render_things->empty()) + { + delete sec->touching_render_things; + sec->touching_render_things = NULL; + } + } + } + + delete thing->touching_render_sectors; + thing->touching_render_sectors = NULL; + } + + if (thing->Sector->touching_render_things) + { + thing->Sector->touching_render_things->remove(thing); + if (thing->Sector->touching_render_things->empty()) + { + delete thing->Sector->touching_render_things; + thing->Sector->touching_render_things = NULL; + } + } +} + + //============================================================================= // // P_DelPortalnode diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index d676e966c..57c86587d 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -277,6 +277,8 @@ void AActor::UnlinkFromWorld () sector_list = touching_sectorlist; touching_sectorlist = NULL; //to be restored by P_SetThingPosition + + P_UnlinkRenderSectors(this); } } @@ -456,6 +458,8 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) P_CreateSecNodeList(this); touching_sectorlist = sector_list; // Attach to thing sector_list = NULL; // clear for next time + + P_LinkRenderSectors(this); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 72ddd9395..6f54b59ff 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -204,6 +204,7 @@ DEFINE_FIELD(AActor, ceilingsector) DEFINE_FIELD(AActor, ceilingpic) DEFINE_FIELD(AActor, Height) DEFINE_FIELD(AActor, radius) +DEFINE_FIELD(AActor, renderradius) DEFINE_FIELD(AActor, projectilepassheight) DEFINE_FIELD(AActor, tics) DEFINE_FIELD_NAMED(AActor, state, curstate) // clashes with type 'state'. @@ -510,6 +511,8 @@ void AActor::Serialize(FSerializer &arc) void AActor::PostSerialize() { touching_sectorlist = NULL; + if (touching_render_sectors) delete touching_render_sectors; + touching_render_sectors = NULL; LinkToWorld(false, Sector); AddToHash(); @@ -4544,6 +4547,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a actor->frame = st->GetFrame(); actor->renderflags = (actor->renderflags & ~RF_FULLBRIGHT) | ActorRenderFlags::FromInt (st->GetFullbright()); actor->touching_sectorlist = NULL; // NULL head of sector list // phares 3/13/98 + actor->touching_render_sectors = NULL; if (G_SkillProperty(SKILLP_FastMonsters) && actor->GetClass()->FastSpeed >= 0) actor->Speed = actor->GetClass()->FastSpeed; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 11aef9d8d..7c663508b 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1512,6 +1512,7 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex) ss->thinglist = NULL; ss->touching_thinglist = NULL; // phares 3/14/98 ss->render_thinglist = NULL; + ss->touching_render_things = NULL; ss->seqType = defSeqType; ss->SeqName = NAME_None; ss->nextsec = -1; //jff 2/26/98 add fields to support locking out diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index c1a64f84b..2e335f4f0 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1297,6 +1297,7 @@ public: sec->thinglist = NULL; sec->touching_thinglist = NULL; // phares 3/14/98 sec->render_thinglist = NULL; + sec->touching_render_things = NULL; sec->seqType = (level.flags & LEVEL_SNDSEQTOTALCTRL) ? 0 : -1; sec->nextsec = -1; //jff 2/26/98 add fields to support locking out sec->prevsec = -1; // stair retriggering until build completes diff --git a/src/r_defs.h b/src/r_defs.h index 6f3b925c7..c63e5b46c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -23,6 +23,7 @@ #ifndef __R_DEFS_H__ #define __R_DEFS_H__ +#include #include "doomdef.h" #include "templates.h" #include "memarena.h" @@ -1001,6 +1002,7 @@ public: // thinglist is a subset of touching_thinglist struct msecnode_t *touching_thinglist; // phares 3/14/98 struct msecnode_t *render_thinglist; // for cross-portal rendering. + std::forward_list* touching_render_things; // this is used to allow wide things to be rendered not only from their main sector. double gravity; // [RH] Sector gravity (1.0 is normal) FNameNoInit damagetype; // [RH] Means-of-death for applied damage diff --git a/src/r_things.cpp b/src/r_things.cpp index a1ace0d49..77f45188c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1225,7 +1225,7 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) // A sector might have been split into several // subsectors during BSP building. // Thus we check whether it was already added. - if (sec->thinglist == NULL || sec->validcount == validcount) + if (sec->touching_render_things == NULL || sec->validcount == validcount) return; // Well, now it will be done. @@ -1234,8 +1234,13 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) spriteshade = LIGHT2SHADE(lightlevel + r_actualextralight); // Handle all things in sector. - for (thing = sec->thinglist; thing; thing = thing->snext) + for (std::forward_list::iterator it = sec->touching_render_things->begin(); + it != sec->touching_render_things->end(); it++) { + thing = (*it); + if (thing->validcount == validcount) continue; + thing->validcount = validcount; + FIntCVar *cvar = thing->GetClass()->distancecheck; if (cvar != NULL && *cvar >= 0) { diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index e318a9806..08dd62dfb 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -713,6 +713,15 @@ DEFINE_PROPERTY(radius, F, Actor) defaults->radius = id; } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(renderradius, F, Actor) +{ + PROP_DOUBLE_PARM(id, 0); + defaults->renderradius = id; +} + //========================================================================== // //========================================================================== diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 4324f162a..2ced709ae 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -45,6 +45,7 @@ class Actor : Thinker native native TextureID ceilingpic; native double Height; native readonly double Radius; + native readonly double RenderRadius; native double projectilepassheight; native int tics; native readonly State CurState; @@ -201,6 +202,7 @@ class Actor : Thinker native Health DEFAULT_HEALTH; Reactiontime 8; Radius 20; + RenderRadius 0; Height 16; Mass 100; RenderStyle 'Normal'; From 98657f6844aff32747a2cdef79424323bc864bc5 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sun, 25 Dec 2016 13:19:45 +0200 Subject: [PATCH 02/14] STYLE_None actors are no more subject to P_LinkRenderSectors --- src/p_map.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_map.cpp b/src/p_map.cpp index e1e42db60..a194f2de3 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6650,6 +6650,10 @@ void P_CreateSecNodeList(AActor *thing) void P_LinkRenderSectors(AActor* thing) { + // if this thing has RenderStyle None, don't link it anywhere. + if (thing->RenderStyle == LegacyRenderStyles[STYLE_None]) + return; + FBoundingBox box(thing->X(), thing->Y(), std::max(thing->renderradius, thing->radius)); FBlockLinesIterator it(box); line_t *ld; From fcd8a0ce9259f1bf22daca836067a525b786cdfc Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sun, 25 Dec 2016 13:35:03 +0200 Subject: [PATCH 03/14] Reverted STYLE_None change to P_LinkRenderSectors, implemented zero RenderRadius that effectively disables rendering of an actor entirely --- src/p_map.cpp | 4 ++-- wadsrc/static/zscript/actor.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index a194f2de3..54aec251f 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6651,10 +6651,10 @@ void P_CreateSecNodeList(AActor *thing) void P_LinkRenderSectors(AActor* thing) { // if this thing has RenderStyle None, don't link it anywhere. - if (thing->RenderStyle == LegacyRenderStyles[STYLE_None]) + if (thing->renderradius == 0) return; - FBoundingBox box(thing->X(), thing->Y(), std::max(thing->renderradius, thing->radius)); + FBoundingBox box(thing->X(), thing->Y(), thing->renderradius > 0 ? thing->renderradius : thing->renderradius); FBlockLinesIterator it(box); line_t *ld; diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 2ced709ae..34bc9d359 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -202,7 +202,7 @@ class Actor : Thinker native Health DEFAULT_HEALTH; Reactiontime 8; Radius 20; - RenderRadius 0; + RenderRadius -1; Height 16; Mass 100; RenderStyle 'Normal'; From 40a180c15f0282ee20d41b6e473b9c7454b60937 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sun, 25 Dec 2016 13:37:45 +0200 Subject: [PATCH 04/14] Changed zero RenderRadius logic - thing should still link to own sector --- src/p_map.cpp | 83 ++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 54aec251f..367e8d3c3 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6651,38 +6651,38 @@ void P_CreateSecNodeList(AActor *thing) void P_LinkRenderSectors(AActor* thing) { // if this thing has RenderStyle None, don't link it anywhere. - if (thing->renderradius == 0) - return; - - FBoundingBox box(thing->X(), thing->Y(), thing->renderradius > 0 ? thing->renderradius : thing->renderradius); - FBlockLinesIterator it(box); - line_t *ld; - - // add to surrounding sectors - while ((ld = it.Next())) + if (thing->renderradius != 0) { - if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) - continue; + FBoundingBox box(thing->X(), thing->Y(), thing->renderradius > 0 ? thing->renderradius : thing->renderradius); + FBlockLinesIterator it(box); + line_t *ld; - // - // create necessary lists. - if (!thing->touching_render_sectors) thing->touching_render_sectors = new std::forward_list(); - - // - if (ld->frontsector != thing->Sector) + // add to surrounding sectors + while ((ld = it.Next())) { - if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->frontsector) == thing->touching_render_sectors->end()) - thing->touching_render_sectors->push_front(ld->frontsector); - if (!ld->frontsector->touching_render_things) ld->frontsector->touching_render_things = new std::forward_list(); - ld->frontsector->touching_render_things->push_front(thing); - } + if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) + continue; - if (ld->backsector && ld->backsector != thing->Sector) - { - if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->backsector) == thing->touching_render_sectors->end()) - thing->touching_render_sectors->push_front(ld->backsector); - if (!ld->backsector->touching_render_things) ld->backsector->touching_render_things = new std::forward_list(); - ld->backsector->touching_render_things->push_front(thing); + // + // create necessary lists. + if (!thing->touching_render_sectors) thing->touching_render_sectors = new std::forward_list(); + + // + if (ld->frontsector != thing->Sector) + { + if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->frontsector) == thing->touching_render_sectors->end()) + thing->touching_render_sectors->push_front(ld->frontsector); + if (!ld->frontsector->touching_render_things) ld->frontsector->touching_render_things = new std::forward_list(); + ld->frontsector->touching_render_things->push_front(thing); + } + + if (ld->backsector && ld->backsector != thing->Sector) + { + if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->backsector) == thing->touching_render_sectors->end()) + thing->touching_render_sectors->push_front(ld->backsector); + if (!ld->backsector->touching_render_things) ld->backsector->touching_render_things = new std::forward_list(); + ld->backsector->touching_render_things->push_front(thing); + } } } @@ -6702,25 +6702,28 @@ void P_LinkRenderSectors(AActor* thing) void P_UnlinkRenderSectors(AActor* thing) { - if (thing->touching_render_sectors) + if (thing->renderradius != 0) { - for (std::forward_list::iterator it = thing->touching_render_sectors->begin(); - it != thing->touching_render_sectors->end(); it++) + if (thing->touching_render_sectors) { - sector_t* sec = (*it); - if (sec->touching_render_things) + for (std::forward_list::iterator it = thing->touching_render_sectors->begin(); + it != thing->touching_render_sectors->end(); it++) { - sec->touching_render_things->remove(thing); - if (sec->touching_render_things->empty()) + sector_t* sec = (*it); + if (sec->touching_render_things) { - delete sec->touching_render_things; - sec->touching_render_things = NULL; + sec->touching_render_things->remove(thing); + if (sec->touching_render_things->empty()) + { + delete sec->touching_render_things; + sec->touching_render_things = NULL; + } } } - } - delete thing->touching_render_sectors; - thing->touching_render_sectors = NULL; + delete thing->touching_render_sectors; + thing->touching_render_sectors = NULL; + } } if (thing->Sector->touching_render_things) From 44c19b5ad9936902770f0bb0d348c5dfdfe90396 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sun, 25 Dec 2016 13:40:21 +0200 Subject: [PATCH 05/14] Changed zero RenderRadius logic - negative values now used for 'no rendering', restored old logic with max(radius, renderradius) --- src/p_map.cpp | 6 +++--- wadsrc/static/zscript/actor.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 367e8d3c3..ca83d342d 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6651,9 +6651,9 @@ void P_CreateSecNodeList(AActor *thing) void P_LinkRenderSectors(AActor* thing) { // if this thing has RenderStyle None, don't link it anywhere. - if (thing->renderradius != 0) + if (thing->renderradius >= 0) { - FBoundingBox box(thing->X(), thing->Y(), thing->renderradius > 0 ? thing->renderradius : thing->renderradius); + FBoundingBox box(thing->X(), thing->Y(), std::max(thing->radius, thing->renderradius)); FBlockLinesIterator it(box); line_t *ld; @@ -6702,7 +6702,7 @@ void P_LinkRenderSectors(AActor* thing) void P_UnlinkRenderSectors(AActor* thing) { - if (thing->renderradius != 0) + if (thing->renderradius >= 0) { if (thing->touching_render_sectors) { diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 34bc9d359..2ced709ae 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -202,7 +202,7 @@ class Actor : Thinker native Health DEFAULT_HEALTH; Reactiontime 8; Radius 20; - RenderRadius -1; + RenderRadius 0; Height 16; Mass 100; RenderStyle 'Normal'; From 38cb7aeaaa2001c2039e73a671a2ba679792a374 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sun, 25 Dec 2016 13:43:24 +0200 Subject: [PATCH 06/14] Invisible and Custom bridges now have RenderRadius -1 to prevent excessive linking --- wadsrc/static/zscript/shared/bridge.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wadsrc/static/zscript/shared/bridge.txt b/wadsrc/static/zscript/shared/bridge.txt index ea38796a7..251055426 100644 --- a/wadsrc/static/zscript/shared/bridge.txt +++ b/wadsrc/static/zscript/shared/bridge.txt @@ -32,6 +32,7 @@ class CustomBridge : Actor native +NOLIFTDROP +ACTLIKEBRIDGE Radius 32; + RenderRadius -1; Height 2; RenderStyle "None"; } @@ -85,6 +86,7 @@ class InvisibleBridge : Actor native { RenderStyle "None"; Radius 32; + RenderRadius -1; Height 4; +SOLID +NOGRAVITY From 89b7cf4262d5e3c9ac22b2a742acc5169e552627 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 14:35:35 +0100 Subject: [PATCH 07/14] - fixed: RenderRadius needs to be serialized. - fixed: CustomBridge can be visible so it shouldn't be completely excluded from the render lists. --- src/p_mobj.cpp | 1 + wadsrc/static/zscript/shared/bridge.txt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 6f54b59ff..aa0ce7096 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -374,6 +374,7 @@ void AActor::Serialize(FSerializer &arc) A("floorsector", floorsector) A("ceilingsector", ceilingsector) A("radius", radius) + A("renderradius", renderradius) A("height", Height) A("ppassheight", projectilepassheight) A("vel", Vel) diff --git a/wadsrc/static/zscript/shared/bridge.txt b/wadsrc/static/zscript/shared/bridge.txt index 251055426..6fb0a99d5 100644 --- a/wadsrc/static/zscript/shared/bridge.txt +++ b/wadsrc/static/zscript/shared/bridge.txt @@ -32,7 +32,6 @@ class CustomBridge : Actor native +NOLIFTDROP +ACTLIKEBRIDGE Radius 32; - RenderRadius -1; Height 2; RenderStyle "None"; } From 2ce55e54164eec6de759de3ca93bcb04a727f906 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 19:19:49 +0100 Subject: [PATCH 08/14] - fixed: non-damaging attacks should not cause infighting, unless some relevant pain flags are being set. --- src/c_console.cpp | 2 +- src/p_interaction.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index 0a324eb8f..faeec0a68 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1573,7 +1573,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) static TArray command; const size_t length = buffer.Text.Len(); - command.Resize(length + 1); + command.Resize(unsigned(length + 1)); memcpy(&command[0], buffer.Text.GetChars(), length); command[length] = '\0'; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 9aa178e64..102142d38 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1545,7 +1545,7 @@ dopain: target->SetState (target->SeeState); } } - else if (source != target->target && target->OkayToSwitchTarget (source)) + else if ((damage > 0 || fakedPain) && source != target->target && target->OkayToSwitchTarget (source)) { // Target actor is not intent on another actor, // so make him chase after source From 663b305eec40b86fd916ff2e63039cd3d23f49fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 19:25:19 +0100 Subject: [PATCH 09/14] - include proper headers for std::find. --- src/g_pch.h | 1 + src/p_map.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/g_pch.h b/src/g_pch.h index a22649815..2c3676f5a 100644 --- a/src/g_pch.h +++ b/src/g_pch.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/src/p_map.cpp b/src/p_map.cpp index ca83d342d..517327843 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -24,6 +24,7 @@ #include #include +#include #include "templates.h" From 5723f10cc35c2832257c24eb5db3a7ca7937fe24 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 19:37:07 +0100 Subject: [PATCH 10/14] - use 'for' iterator syntax to check touching_renderlists. --- src/p_map.cpp | 4 +--- src/r_things.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 517327843..e90d24bed 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6707,10 +6707,8 @@ void P_UnlinkRenderSectors(AActor* thing) { if (thing->touching_render_sectors) { - for (std::forward_list::iterator it = thing->touching_render_sectors->begin(); - it != thing->touching_render_sectors->end(); it++) + for (auto sec : *thing->touching_render_sectors) { - sector_t* sec = (*it); if (sec->touching_render_things) { sec->touching_render_things->remove(thing); diff --git a/src/r_things.cpp b/src/r_things.cpp index 77f45188c..4cf056aed 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1234,10 +1234,8 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) spriteshade = LIGHT2SHADE(lightlevel + r_actualextralight); // Handle all things in sector. - for (std::forward_list::iterator it = sec->touching_render_things->begin(); - it != sec->touching_render_things->end(); it++) + for (auto thing : *sec->touching_render_things) { - thing = (*it); if (thing->validcount == validcount) continue; thing->validcount = validcount; From 04ff4282ef0e07f3c4844068304f13f26df69a7f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 22:40:26 +0100 Subject: [PATCH 11/14] - removed the global 'sector_list' variable. If the calling code wants to recycle this it will have to pass a container variable to AActor::UnlinkFromWorld and AActor::LinkToWorld. This was changed because keeping such data in a global variable is dangerous for a set of functions that can be called from a script. Note that the scripted versions do not yet support saving of the touching_sectorlist. --- src/actor.h | 10 +++++-- src/b_game.cpp | 9 +++--- src/g_inventory/a_pickups.cpp | 13 +++----- src/g_level.cpp | 10 +++---- src/g_shared/a_movingcamera.cpp | 15 ++++++---- src/p_actionfunctions.cpp | 14 +++++---- src/p_local.h | 7 +---- src/p_map.cpp | 43 +++++++++------------------ src/p_maputl.cpp | 22 +++++++------- src/p_mobj.cpp | 26 ++++++++-------- src/p_user.cpp | 22 +++++++------- src/portal.cpp | 5 ++-- src/r_things.cpp | 1 - src/scripting/thingdef_properties.cpp | 5 ++-- 14 files changed, 95 insertions(+), 107 deletions(-) diff --git a/src/actor.h b/src/actor.h index 18c3ecb17..e896e205b 100644 --- a/src/actor.h +++ b/src/actor.h @@ -562,8 +562,14 @@ inline T *GetDefault () struct line_t; struct secplane_t; +struct msecnode_t; struct FStrifeDialogueNode; +struct FLinkContext +{ + msecnode_t *sector_list = nullptr; +}; + class DDropItem : public DObject { DECLARE_CLASS(DDropItem, DObject) @@ -1220,8 +1226,8 @@ private: bool FixMapthingPos(); public: - void LinkToWorld (bool spawningmapthing=false, sector_t *sector = NULL); - void UnlinkFromWorld (); + void LinkToWorld (FLinkContext *ctx, bool spawningmapthing=false, sector_t *sector = NULL); + void UnlinkFromWorld(FLinkContext *ctx); void AdjustFloorClip (); bool InStateSequence(FState * newstate, FState * basestate); int GetTics(FState * newstate); diff --git a/src/b_game.cpp b/src/b_game.cpp index 9d6419787..b99b97a60 100644 --- a/src/b_game.cpp +++ b/src/b_game.cpp @@ -118,23 +118,24 @@ void FCajunMaster::Main () } //Check if player should go observer. Or un observe + FLinkContext ctx; if (bot_observer && !observer && !netgame) { Printf ("%s is now observer\n", players[consoleplayer].userinfo.GetName()); observer = true; - players[consoleplayer].mo->UnlinkFromWorld (); + players[consoleplayer].mo->UnlinkFromWorld (&ctx); players[consoleplayer].mo->flags = MF_DROPOFF|MF_NOBLOCKMAP|MF_NOCLIP|MF_NOTDMATCH|MF_NOGRAVITY|MF_FRIENDLY; players[consoleplayer].mo->flags2 |= MF2_FLY; - players[consoleplayer].mo->LinkToWorld (); + players[consoleplayer].mo->LinkToWorld (&ctx); } else if (!bot_observer && observer && !netgame) //Go back { Printf ("%s returned to the fray\n", players[consoleplayer].userinfo.GetName()); observer = false; - players[consoleplayer].mo->UnlinkFromWorld (); + players[consoleplayer].mo->UnlinkFromWorld (&ctx); players[consoleplayer].mo->flags = MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH|MF_FRIENDLY; players[consoleplayer].mo->flags2 &= ~MF2_FLY; - players[consoleplayer].mo->LinkToWorld (); + players[consoleplayer].mo->LinkToWorld (&ctx); } } diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index 42af5e87f..f019a8053 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -636,14 +636,9 @@ void AInventory::BecomeItem () { if (!(flags & (MF_NOBLOCKMAP|MF_NOSECTOR))) { - UnlinkFromWorld (); - if (sector_list) - { - P_DelSeclist (sector_list); - sector_list = NULL; - } + UnlinkFromWorld (nullptr); flags |= MF_NOBLOCKMAP|MF_NOSECTOR; - LinkToWorld (); + LinkToWorld (nullptr); } RemoveFromHash (); flags &= ~MF_SPECIAL; @@ -674,9 +669,9 @@ void AInventory::BecomePickup () } if (flags & (MF_NOBLOCKMAP|MF_NOSECTOR)) { - UnlinkFromWorld (); + UnlinkFromWorld (nullptr); flags &= ~(MF_NOBLOCKMAP|MF_NOSECTOR); - LinkToWorld (); + LinkToWorld (nullptr); P_FindFloorCeiling (this); } flags = (GetDefault()->flags | MF_DROPPED) & ~MF_COUNTITEM; diff --git a/src/g_level.cpp b/src/g_level.cpp index 4bb78461a..321810589 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1196,8 +1196,7 @@ void G_StartTravel () // Only living players travel. Dead ones get a new body on the new level. if (players[i].health > 0) { - pawn->UnlinkFromWorld (); - P_DelSector_List (); + pawn->UnlinkFromWorld (nullptr); int tid = pawn->tid; // Save TID pawn->RemoveFromHash (); pawn->tid = tid; // Restore TID (but no longer linked into the hash chain) @@ -1206,8 +1205,7 @@ void G_StartTravel () for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory) { inv->ChangeStatNum (STAT_TRAVELLING); - inv->UnlinkFromWorld (); - P_DelSector_List (); + inv->UnlinkFromWorld (nullptr); } } } @@ -1304,7 +1302,7 @@ void G_FinishTravel () { pawndup->Destroy(); } - pawn->LinkToWorld (); + pawn->LinkToWorld (nullptr); pawn->ClearInterpolation(); pawn->AddToHash (); pawn->SetState(pawn->SpawnState); @@ -1313,7 +1311,7 @@ void G_FinishTravel () for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory) { inv->ChangeStatNum (STAT_INVENTORY); - inv->LinkToWorld (); + inv->LinkToWorld (nullptr); inv->Travelled (); } if (ib_compatflags & BCOMPATF_RESETPLAYERSPEED) diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index a1ffe5dc6..c09d93fd5 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -364,6 +364,7 @@ void APathFollower::NewNode () bool APathFollower::Interpolate () { DVector3 dpos(0, 0, 0); + FLinkContext ctx; if ((args[2] & 8) && Time > 0.f) { @@ -372,7 +373,7 @@ bool APathFollower::Interpolate () if (CurrNode->Next==NULL) return false; - UnlinkFromWorld (); + UnlinkFromWorld (&ctx); DVector3 newpos; if (args[2] & 1) { // linear @@ -389,7 +390,7 @@ bool APathFollower::Interpolate () newpos.Z = Splerp(PrevNode->Z(), CurrNode->Z(), CurrNode->Next->Z(), CurrNode->Next->Next->Z()); } SetXYZ(newpos); - LinkToWorld (); + LinkToWorld (&ctx); if (args[2] & 6) { @@ -541,10 +542,11 @@ void AActorMover::Activate (AActor *activator) tracer->flags |= MF_NOGRAVITY; if (args[2] & 128) { - tracer->UnlinkFromWorld (); + FLinkContext ctx; + tracer->UnlinkFromWorld (&ctx); tracer->flags |= MF_NOBLOCKMAP; tracer->flags &= ~MF_SOLID; - tracer->LinkToWorld (); + tracer->LinkToWorld (&ctx); } if (tracer->flags3 & MF3_ISMONSTER) { @@ -563,9 +565,10 @@ void AActorMover::Deactivate (AActor *activator) Super::Deactivate (activator); if (tracer != NULL) { - tracer->UnlinkFromWorld (); + FLinkContext ctx; + tracer->UnlinkFromWorld (&ctx); tracer->flags = ActorFlags::FromInt (special1); - tracer->LinkToWorld (); + tracer->LinkToWorld (&ctx); tracer->flags2 = ActorFlags2::FromInt (special2); } } diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index e292447bf..4136ec331 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -5229,12 +5229,13 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, double xydist, double zdist) } else { - self->UnlinkFromWorld (); + FLinkContext ctx; + self->UnlinkFromWorld (&ctx); self->flags |= MF_NOBLOCKMAP; // We need to do portal offsetting here explicitly, because SetXY cannot do that. newpos -= self->Pos().XY(); self->SetXY(self->Vec2Offset(newpos.X, newpos.Y)); - self->LinkToWorld (); + self->LinkToWorld (&ctx); } self->WeaveIndexXY = weaveXY; } @@ -6862,17 +6863,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetSize) double oldradius = self->radius; double oldheight = self->Height; - self->UnlinkFromWorld(); + FLinkContext ctx; + self->UnlinkFromWorld(&ctx); self->radius = newradius; self->Height = newheight; - self->LinkToWorld(); + self->LinkToWorld(&ctx); if (testpos && !P_TestMobjLocation(self)) { - self->UnlinkFromWorld(); + self->UnlinkFromWorld(&ctx); self->radius = oldradius; self->Height = oldheight; - self->LinkToWorld(); + self->LinkToWorld(&ctx); ACTION_RETURN_BOOL(false); } diff --git a/src/p_local.h b/src/p_local.h index 4244005c3..25b465d26 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -245,10 +245,6 @@ AActor *P_RoughMonsterSearch (AActor *mo, int distance, bool onlyseekable=false, // -// If "floatok" true, move would be ok -// if within "tmfloorz - tmceilingz". -extern msecnode_t *sector_list; // phares 3/16/98 - struct spechit_t { line_t *line; @@ -395,11 +391,10 @@ enum int P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance, FName damageType, int flags, int fulldamagedistance=0); -void P_DelSector_List(); void P_DelSeclist(msecnode_t *); // phares 3/16/98 msecnode_t *P_AddSecnode(sector_t *s, AActor *thing, msecnode_t *nextnode, msecnode_t *&sec_thinglist); msecnode_t* P_DelSecnode(msecnode_t *, msecnode_t *sector_t::*head); -void P_CreateSecNodeList(AActor*); // phares 3/14/98 +msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list); void P_LinkRenderSectors(AActor*); void P_UnlinkRenderSectors(AActor*); double P_GetMoveFactor(const AActor *mo, double *frictionp); // phares 3/6/98 diff --git a/src/p_map.cpp b/src/p_map.cpp index e90d24bed..9dcd165c2 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -82,9 +82,6 @@ static FRandom pr_crunch("DoCrunch"); TArray spechit; TArray portalhit; -// Temporary holder for thing_sectorlist threads -msecnode_t* sector_list = NULL; // phares 3/16/98 - //========================================================================== // // FindRefPoint @@ -2390,10 +2387,11 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, FLinePortal *port = ld->getPortal(); if (port->mType == PORTT_LINKED) { - thing->UnlinkFromWorld(); + FLinkContext ctx; + thing->UnlinkFromWorld(&ctx); thing->SetXY(tm.pos + port->mDisplacement); thing->Prev += port->mDisplacement; - thing->LinkToWorld(); + thing->LinkToWorld(&ctx); P_FindFloorCeiling(thing); portalcrossed = true; tm.portalstep = false; @@ -2414,11 +2412,12 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, thing->flags6 &= ~MF6_INTRYMOVE; return false; } - thing->UnlinkFromWorld(); + FLinkContext ctx; + thing->UnlinkFromWorld(&ctx); thing->SetXYZ(pos); P_TranslatePortalVXVY(ld, thing->Vel.X, thing->Vel.Y); P_TranslatePortalAngle(ld, thing->Angles.Yaw); - thing->LinkToWorld(); + thing->LinkToWorld(&ctx); P_FindFloorCeiling(thing); thing->ClearInterpolation(); portalcrossed = true; @@ -2459,7 +2458,8 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, if (!portalcrossed) { // the move is ok, so link the thing into its new position - thing->UnlinkFromWorld(); + FLinkContext ctx; + thing->UnlinkFromWorld(&ctx); oldsector = thing->Sector; thing->floorz = tm.floorz; @@ -2472,7 +2472,7 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, thing->ceilingsector = tm.ceilingsector; thing->SetXY(pos); - thing->LinkToWorld(); + thing->LinkToWorld(&ctx); } if (thing->flags2 & MF2_FLOORCLIP) @@ -2565,13 +2565,14 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, // If the actor stepped through a ceiling portal we need to reacquire the actual position info after the transition if (tm.portalstep) { + FLinkContext ctx; DVector3 oldpos = thing->Pos(); - thing->UnlinkFromWorld(); + thing->UnlinkFromWorld(&ctx); thing->SetXYZ(thing->PosRelative(thing->Sector->GetOppositePortalGroup(sector_t::ceiling))); thing->Prev = thing->Pos() - oldpos; thing->Sector = P_PointInSector(thing->Pos()); thing->PrevPortalGroup = thing->Sector->PortalGroup; - thing->LinkToWorld(); + thing->LinkToWorld(&ctx); P_FindFloorCeiling(thing); } @@ -6532,23 +6533,6 @@ msecnode_t *P_DelSecnode(msecnode_t *node, msecnode_t *sector_t::*listhead) return NULL; } // phares 3/13/98 -//============================================================================= -// -// P_DelSector_List -// -// Deletes the sector_list and NULLs it. -// -//============================================================================= - -void P_DelSector_List() -{ - if (sector_list != NULL) - { - P_DelSeclist(sector_list); - sector_list = NULL; - } -} - //============================================================================= // // P_DelSeclist @@ -6572,7 +6556,7 @@ void P_DelSeclist(msecnode_t *node) // //============================================================================= -void P_CreateSecNodeList(AActor *thing) +msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list) { msecnode_t *node; @@ -6638,6 +6622,7 @@ void P_CreateSecNodeList(AActor *thing) node = node->m_tnext; } } + return sector_list; } diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 57c86587d..d7d5fd658 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -242,9 +242,9 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, co // //========================================================================== -void AActor::UnlinkFromWorld () +void AActor::UnlinkFromWorld (FLinkContext *ctx) { - sector_list = NULL; + if (ctx != nullptr) ctx->sector_list = nullptr; if (!(flags & MF_NOSECTOR)) { // invisible things don't need to be in sector list @@ -275,7 +275,8 @@ void AActor::UnlinkFromWorld () // If this Thing is being removed entirely, then the calling // routine will clear out the nodes in sector_list. - sector_list = touching_sectorlist; + if (ctx != nullptr) ctx->sector_list = touching_sectorlist; + else P_DelSeclist(touching_sectorlist); touching_sectorlist = NULL; //to be restored by P_SetThingPosition P_UnlinkRenderSectors(this); @@ -390,7 +391,7 @@ bool AActor::FixMapthingPos() DEFINE_ACTION_FUNCTION(AActor, UnlinkFromWorld) { PARAM_SELF_PROLOGUE(AActor); - self->UnlinkFromWorld(); + self->UnlinkFromWorld(nullptr); // fixme return 0; } @@ -403,7 +404,7 @@ DEFINE_ACTION_FUNCTION(AActor, UnlinkFromWorld) // //========================================================================== -void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) +void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sector) { bool spawning = spawningmapthing; @@ -455,9 +456,7 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) // When a node is deleted, its sector links (the links starting // at sector_t->touching_thinglist) are broken. When a node is // added, new sector links are created. - P_CreateSecNodeList(this); - touching_sectorlist = sector_list; // Attach to thing - sector_list = NULL; // clear for next time + touching_sectorlist = P_CreateSecNodeList(this, ctx != nullptr? ctx->sector_list : nullptr); // Attach to thing P_LinkRenderSectors(this); } @@ -522,15 +521,16 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) DEFINE_ACTION_FUNCTION(AActor, LinkToWorld) { PARAM_SELF_PROLOGUE(AActor); - self->LinkToWorld(); + self->LinkToWorld(nullptr); // fixme return 0; } void AActor::SetOrigin(double x, double y, double z, bool moving) { - UnlinkFromWorld (); + FLinkContext ctx; + UnlinkFromWorld (&ctx); SetXYZ(x, y, z); - LinkToWorld (); + LinkToWorld (&ctx); P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS); if (!moving) ClearInterpolation(); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index aa0ce7096..1955f6b4e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -514,7 +514,7 @@ void AActor::PostSerialize() touching_sectorlist = NULL; if (touching_render_sectors) delete touching_render_sectors; touching_render_sectors = NULL; - LinkToWorld(false, Sector); + LinkToWorld(nullptr, false, Sector); AddToHash(); if (player) @@ -3690,12 +3690,13 @@ DVector3 AActor::GetPortalTransition(double byoffset, sector_t **pSec) void AActor::CheckPortalTransition(bool islinked) { bool moved = false; + FLinkContext ctx; while (!Sector->PortalBlocksMovement(sector_t::ceiling)) { if (Z() >= Sector->GetPortalPlaneZ(sector_t::ceiling)) { DVector3 oldpos = Pos(); - if (islinked && !moved) UnlinkFromWorld(); + if (islinked && !moved) UnlinkFromWorld(&ctx); SetXYZ(PosRelative(Sector->GetOppositePortalGroup(sector_t::ceiling))); Prev = Pos() - oldpos; Sector = P_PointInSector(Pos()); @@ -3712,7 +3713,7 @@ void AActor::CheckPortalTransition(bool islinked) if (Z() < portalz && floorz < portalz) { DVector3 oldpos = Pos(); - if (islinked && !moved) UnlinkFromWorld(); + if (islinked && !moved) UnlinkFromWorld(&ctx); SetXYZ(PosRelative(Sector->GetOppositePortalGroup(sector_t::floor))); Prev = Pos() - oldpos; Sector = P_PointInSector(Pos()); @@ -3722,7 +3723,7 @@ void AActor::CheckPortalTransition(bool islinked) else break; } } - if (islinked && moved) LinkToWorld(); + if (islinked && moved) LinkToWorld(&ctx); } // @@ -3785,11 +3786,12 @@ void AActor::Tick () if (!Vel.isZero() || !(flags & MF_NOBLOCKMAP)) { - UnlinkFromWorld(); + FLinkContext ctx; + UnlinkFromWorld(&ctx); flags |= MF_NOBLOCKMAP; SetXYZ(Vec3Offset(Vel)); CheckPortalTransition(false); - LinkToWorld(); + LinkToWorld(&ctx); } } else @@ -4553,7 +4555,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a actor->Speed = actor->GetClass()->FastSpeed; // set subsector and/or block links - actor->LinkToWorld (SpawningMapThing); + actor->LinkToWorld (nullptr, SpawningMapThing); actor->ClearInterpolation(); actor->dropoffz = actor->floorz = actor->Sector->floorplane.ZatPoint(pos); @@ -4930,12 +4932,9 @@ void AActor::Destroy () RemoveFromHash (); // unlink from sector and block lists - UnlinkFromWorld (); + UnlinkFromWorld (nullptr); flags |= MF_NOSECTOR|MF_NOBLOCKMAP; - // Delete all nodes on the current sector_list phares 3/16/98 - P_DelSector_List(); - // Transform any playing sound into positioned, non-actor sounds. S_RelinkSound (this, NULL); @@ -7486,9 +7485,10 @@ void AActor::RestoreSpecialPosition() // Move item back to its original location DVector2 sp = SpawnPoint; - UnlinkFromWorld(); + FLinkContext ctx; + UnlinkFromWorld(&ctx); SetXY(sp); - LinkToWorld(true); + LinkToWorld(&ctx, true); SetZ(Sector->floorplane.ZatPoint(sp)); P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS | FFCF_NOPORTALS); // no portal checks here so that things get spawned in this sector. diff --git a/src/p_user.cpp b/src/p_user.cpp index 47c64d063..40a3cb2f6 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2939,7 +2939,8 @@ void P_UnPredictPlayer () // could cause it to change during prediction. player->camera = savedcamera; - act->UnlinkFromWorld(); + FLinkContext ctx; + act->UnlinkFromWorld(&ctx); memcpy(&act->snext, PredictionActorBackup, sizeof(APlayerPawn) - ((BYTE *)&act->snext - (BYTE *)act)); // The blockmap ordering needs to remain unchanged, too. @@ -2968,7 +2969,7 @@ void P_UnPredictPlayer () } // Destroy old refrences - msecnode_t *node = sector_list; + msecnode_t *node = ctx.sector_list; while (node) { node->m_thing = NULL; @@ -2976,22 +2977,23 @@ void P_UnPredictPlayer () } // Make the sector_list match the player's touching_sectorlist before it got predicted. - P_DelSeclist(sector_list); - sector_list = NULL; + P_DelSeclist(ctx.sector_list); + ctx.sector_list = NULL; for (i = PredictionTouchingSectorsBackup.Size(); i-- > 0;) { - sector_list = P_AddSecnode(PredictionTouchingSectorsBackup[i], act, sector_list, PredictionTouchingSectorsBackup[i]->touching_thinglist); + ctx.sector_list = P_AddSecnode(PredictionTouchingSectorsBackup[i], act, ctx.sector_list, PredictionTouchingSectorsBackup[i]->touching_thinglist); } - act->touching_sectorlist = sector_list; // Attach to thing - sector_list = NULL; // clear for next time + act->touching_sectorlist = ctx.sector_list; // Attach to thing + ctx.sector_list = NULL; // clear for next time - node = sector_list; + // Huh??? + node = ctx.sector_list; while (node) { if (node->m_thing == NULL) { - if (node == sector_list) - sector_list = node->m_tnext; + if (node == ctx.sector_list) + ctx.sector_list = node->m_tnext; node = P_DelSecnode(node, §or_t::touching_thinglist); } else diff --git a/src/portal.cpp b/src/portal.cpp index f1454cdc6..4b8a81dc1 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -1140,8 +1140,9 @@ void P_CreateLinkedPortals() P_CollectConnectedGroups(actor->Sector->PortalGroup, actor->Pos(), actor->Top(), actor->radius, check); if (check.Size() > 0) { - actor->UnlinkFromWorld(); - actor->LinkToWorld(); + FLinkContext ctx; + actor->UnlinkFromWorld(&ctx); + actor->LinkToWorld(&ctx); } } } diff --git a/src/r_things.cpp b/src/r_things.cpp index 4cf056aed..8d326b319 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1217,7 +1217,6 @@ static void R_ProjectWallSprite(AActor *thing, const DVector3 &pos, FTextureID p // [RH] Save which side of heightsec sprite is on here. void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) { - AActor *thing; F3DFloor *fakeceiling = NULL; F3DFloor *fakefloor = NULL; diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 08dd62dfb..27b7ab2d3 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -216,9 +216,10 @@ bool ModActorFlag(AActor *actor, FString &flagname, bool set, bool printerror) // If these 2 flags get changed we need to update the blockmap and sector links. bool linkchange = flagp == &actor->flags && (fd->flagbit == MF_NOBLOCKMAP || fd->flagbit == MF_NOSECTOR); - if (linkchange) actor->UnlinkFromWorld(); + FLinkContext ctx; + if (linkchange) actor->UnlinkFromWorld(&ctx); ModActorFlag(actor, fd, set); - if (linkchange) actor->LinkToWorld(); + if (linkchange) actor->LinkToWorld(&ctx); } if (actor->CountsAsKill() && actor->health > 0) ++level.total_monsters; From 7f72de6b7188bf62ecca0f5db6c98237e4e6211a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Dec 2016 11:58:08 +0100 Subject: [PATCH 12/14] - use msecnode_t's for the touching_renderlists instead of std::forward_list. - preparations for checking the proper sector to get a sprite's lighting info. --- src/actor.h | 3 +- src/p_local.h | 6 +-- src/p_map.cpp | 113 ++++------------------------------------------- src/p_maputl.cpp | 30 ++++++++----- src/p_mobj.cpp | 9 ++-- src/p_setup.cpp | 8 ++-- src/p_udmf.cpp | 8 ++-- src/p_user.cpp | 2 +- src/r_defs.h | 2 +- src/r_things.cpp | 15 ++++--- 10 files changed, 55 insertions(+), 141 deletions(-) diff --git a/src/actor.h b/src/actor.h index e896e205b..364bb7098 100644 --- a/src/actor.h +++ b/src/actor.h @@ -568,6 +568,7 @@ struct FStrifeDialogueNode; struct FLinkContext { msecnode_t *sector_list = nullptr; + msecnode_t *render_list = nullptr; }; class DDropItem : public DObject @@ -1149,7 +1150,7 @@ public: struct msecnode_t *touching_sectorlist; // phares 3/14/98 struct msecnode_t *render_sectorlist; // same for cross-sectorportal rendering struct portnode_t *render_portallist; // and for cross-lineportal - std::forward_list* touching_render_sectors; // this is the list of sectors that this thing interesects with it's max(radius, renderradius). + struct msecnode_t *touching_rendersectors; // this is the list of sectors that this thing interesects with it's max(radius, renderradius). int validcount; diff --git a/src/p_local.h b/src/p_local.h index 25b465d26..93bbbbf11 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -391,12 +391,10 @@ enum int P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance, FName damageType, int flags, int fulldamagedistance=0); -void P_DelSeclist(msecnode_t *); // phares 3/16/98 +void P_DelSeclist(msecnode_t *, msecnode_t *sector_t::*seclisthead); msecnode_t *P_AddSecnode(sector_t *s, AActor *thing, msecnode_t *nextnode, msecnode_t *&sec_thinglist); msecnode_t* P_DelSecnode(msecnode_t *, msecnode_t *sector_t::*head); -msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list); -void P_LinkRenderSectors(AActor*); -void P_UnlinkRenderSectors(AActor*); +msecnode_t *P_CreateSecNodeList(AActor *thing, double radius, msecnode_t *sector_list, msecnode_t *sector_t::*seclisthead); double P_GetMoveFactor(const AActor *mo, double *frictionp); // phares 3/6/98 double P_GetFriction(const AActor *mo, double *frictionfactor); diff --git a/src/p_map.cpp b/src/p_map.cpp index 9dcd165c2..20796ed23 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6541,10 +6541,10 @@ msecnode_t *P_DelSecnode(msecnode_t *node, msecnode_t *sector_t::*listhead) // //============================================================================= -void P_DelSeclist(msecnode_t *node) +void P_DelSeclist(msecnode_t *node, msecnode_t *sector_t::*sechead) { while (node) - node = P_DelSecnode(node, §or_t::touching_thinglist); + node = P_DelSecnode(node, sechead); } //============================================================================= @@ -6556,7 +6556,7 @@ void P_DelSeclist(msecnode_t *node) // //============================================================================= -msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list) +msecnode_t *P_CreateSecNodeList(AActor *thing, double radius, msecnode_t *sector_list, msecnode_t *sector_t::*seclisthead) { msecnode_t *node; @@ -6572,7 +6572,7 @@ msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list) node = node->m_tnext; } - FBoundingBox box(thing->X(), thing->Y(), thing->radius); + FBoundingBox box(thing->X(), thing->Y(), radius); FBlockLinesIterator it(box); line_t *ld; @@ -6588,7 +6588,7 @@ msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list) // allowed to move to this position, then the sector_list // will be attached to the Thing's AActor at touching_sectorlist. - sector_list = P_AddSecnode(ld->frontsector, thing, sector_list, ld->frontsector->touching_thinglist); + sector_list = P_AddSecnode(ld->frontsector, thing, sector_list, ld->frontsector->*seclisthead); // Don't assume all lines are 2-sided, since some Things // like MT_TFOG are allowed regardless of whether their radius takes @@ -6598,12 +6598,12 @@ msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list) // Use sidedefs instead of 2s flag to determine two-sidedness. if (ld->backsector) - sector_list = P_AddSecnode(ld->backsector, thing, sector_list, ld->backsector->touching_thinglist); + sector_list = P_AddSecnode(ld->backsector, thing, sector_list, ld->backsector->*seclisthead); } // Add the sector of the (x,y) point to sector_list. - sector_list = P_AddSecnode(thing->Sector, thing, sector_list, thing->Sector->touching_thinglist); + sector_list = P_AddSecnode(thing->Sector, thing, sector_list, thing->Sector->*seclisthead); // Now delete any nodes that won't be used. These are the ones where // m_thing is still NULL. @@ -6615,7 +6615,7 @@ msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list) { if (node == sector_list) sector_list = node->m_tnext; - node = P_DelSecnode(node, §or_t::touching_thinglist); + node = P_DelSecnode(node, seclisthead); } else { @@ -6625,103 +6625,6 @@ msecnode_t *P_CreateSecNodeList(AActor *thing, msecnode_t *sector_list) return sector_list; } - -//============================================================================= -// -// P_LinkRenderSectors -// -// Alters/creates the list of touched sectors for thing's render radius. -// -//============================================================================= - -void P_LinkRenderSectors(AActor* thing) -{ - // if this thing has RenderStyle None, don't link it anywhere. - if (thing->renderradius >= 0) - { - FBoundingBox box(thing->X(), thing->Y(), std::max(thing->radius, thing->renderradius)); - FBlockLinesIterator it(box); - line_t *ld; - - // add to surrounding sectors - while ((ld = it.Next())) - { - if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) - continue; - - // - // create necessary lists. - if (!thing->touching_render_sectors) thing->touching_render_sectors = new std::forward_list(); - - // - if (ld->frontsector != thing->Sector) - { - if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->frontsector) == thing->touching_render_sectors->end()) - thing->touching_render_sectors->push_front(ld->frontsector); - if (!ld->frontsector->touching_render_things) ld->frontsector->touching_render_things = new std::forward_list(); - ld->frontsector->touching_render_things->push_front(thing); - } - - if (ld->backsector && ld->backsector != thing->Sector) - { - if (std::find(thing->touching_render_sectors->begin(), thing->touching_render_sectors->end(), ld->backsector) == thing->touching_render_sectors->end()) - thing->touching_render_sectors->push_front(ld->backsector); - if (!ld->backsector->touching_render_things) ld->backsector->touching_render_things = new std::forward_list(); - ld->backsector->touching_render_things->push_front(thing); - } - } - } - - // add to own sector - if (!thing->Sector->touching_render_things) thing->Sector->touching_render_things = new std::forward_list(); - thing->Sector->touching_render_things->push_front(thing); -} - - -//============================================================================= -// -// P_UnlinkRenderSectors -// -// Reverses P_LinkRenderSectors. -// -//============================================================================= - -void P_UnlinkRenderSectors(AActor* thing) -{ - if (thing->renderradius >= 0) - { - if (thing->touching_render_sectors) - { - for (auto sec : *thing->touching_render_sectors) - { - if (sec->touching_render_things) - { - sec->touching_render_things->remove(thing); - if (sec->touching_render_things->empty()) - { - delete sec->touching_render_things; - sec->touching_render_things = NULL; - } - } - } - - delete thing->touching_render_sectors; - thing->touching_render_sectors = NULL; - } - } - - if (thing->Sector->touching_render_things) - { - thing->Sector->touching_render_things->remove(thing); - if (thing->Sector->touching_render_things->empty()) - { - delete thing->Sector->touching_render_things; - thing->Sector->touching_render_things = NULL; - } - } -} - - //============================================================================= // // P_DelPortalnode diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index d7d5fd658..d4ac79ce7 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -271,15 +271,19 @@ void AActor::UnlinkFromWorld (FLinkContext *ctx) // put it back into touching_sectorlist. It's done this way to // avoid a lot of deleting/creating for nodes, when most of the // time you just get back what you deleted anyway. - // - // If this Thing is being removed entirely, then the calling - // routine will clear out the nodes in sector_list. - if (ctx != nullptr) ctx->sector_list = touching_sectorlist; - else P_DelSeclist(touching_sectorlist); - touching_sectorlist = NULL; //to be restored by P_SetThingPosition - - P_UnlinkRenderSectors(this); + if (ctx != nullptr) + { + ctx->sector_list = touching_sectorlist; + ctx->render_list = touching_rendersectors; + } + else + { + P_DelSeclist(touching_sectorlist, §or_t::touching_thinglist); + P_DelSeclist(touching_rendersectors, §or_t::touching_renderthings); + } + touching_sectorlist = nullptr; //to be restored by P_SetThingPosition + touching_rendersectors = nullptr; } } @@ -456,9 +460,13 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec // When a node is deleted, its sector links (the links starting // at sector_t->touching_thinglist) are broken. When a node is // added, new sector links are created. - touching_sectorlist = P_CreateSecNodeList(this, ctx != nullptr? ctx->sector_list : nullptr); // Attach to thing - - P_LinkRenderSectors(this); + touching_sectorlist = P_CreateSecNodeList(this, radius, ctx != nullptr? ctx->sector_list : nullptr, §or_t::touching_thinglist); // Attach to thing + if (renderradius >= 0) touching_rendersectors = P_CreateSecNodeList(this, MAX(radius, renderradius), ctx != nullptr ? ctx->render_list : nullptr, §or_t::touching_renderthings); + else + { + touching_rendersectors = nullptr; + if (ctx != nullptr) P_DelSeclist(ctx->render_list, §or_t::touching_renderthings); + } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 1955f6b4e..7e5dbc88e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -511,9 +511,8 @@ void AActor::Serialize(FSerializer &arc) void AActor::PostSerialize() { - touching_sectorlist = NULL; - if (touching_render_sectors) delete touching_render_sectors; - touching_render_sectors = NULL; + touching_sectorlist = nullptr; + touching_rendersectors = nullptr; LinkToWorld(nullptr, false, Sector); AddToHash(); @@ -4549,8 +4548,8 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a actor->sprite = st->sprite; actor->frame = st->GetFrame(); actor->renderflags = (actor->renderflags & ~RF_FULLBRIGHT) | ActorRenderFlags::FromInt (st->GetFullbright()); - actor->touching_sectorlist = NULL; // NULL head of sector list // phares 3/13/98 - actor->touching_render_sectors = NULL; + actor->touching_sectorlist = nullptr; // NULL head of sector list // phares 3/13/98 + actor->touching_rendersectors = nullptr; if (G_SkillProperty(SKILLP_FastMonsters) && actor->GetClass()->FastSpeed >= 0) actor->Speed = actor->GetClass()->FastSpeed; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 7c663508b..d3bcc742d 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1509,10 +1509,10 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex) else // [RH] Translate to new sector special ss->special = P_TranslateSectorSpecial (LittleShort(ms->special)); tagManager.AddSectorTag(i, LittleShort(ms->tag)); - ss->thinglist = NULL; - ss->touching_thinglist = NULL; // phares 3/14/98 - ss->render_thinglist = NULL; - ss->touching_render_things = NULL; + ss->thinglist = nullptr; + ss->touching_thinglist = nullptr; // phares 3/14/98 + ss->render_thinglist = nullptr; + ss->touching_renderthings = nullptr; ss->seqType = defSeqType; ss->SeqName = NAME_None; ss->nextsec = -1; //jff 2/26/98 add fields to support locking out diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 2e335f4f0..2ef8a9ced 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1294,10 +1294,10 @@ public: sec->SetYScale(sector_t::ceiling, 1.); sec->SetAlpha(sector_t::floor, 1.); sec->SetAlpha(sector_t::ceiling, 1.); - sec->thinglist = NULL; - sec->touching_thinglist = NULL; // phares 3/14/98 - sec->render_thinglist = NULL; - sec->touching_render_things = NULL; + sec->thinglist = nullptr; + sec->touching_thinglist = nullptr; // phares 3/14/98 + sec->render_thinglist = nullptr; + sec->touching_renderthings = nullptr; sec->seqType = (level.flags & LEVEL_SNDSEQTOTALCTRL) ? 0 : -1; sec->nextsec = -1; //jff 2/26/98 add fields to support locking out sec->prevsec = -1; // stair retriggering until build completes diff --git a/src/p_user.cpp b/src/p_user.cpp index 40a3cb2f6..6db4a57f5 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2977,7 +2977,7 @@ void P_UnPredictPlayer () } // Make the sector_list match the player's touching_sectorlist before it got predicted. - P_DelSeclist(ctx.sector_list); + P_DelSeclist(ctx.sector_list, §or_t::touching_thinglist); ctx.sector_list = NULL; for (i = PredictionTouchingSectorsBackup.Size(); i-- > 0;) { diff --git a/src/r_defs.h b/src/r_defs.h index c63e5b46c..f48a07ba3 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1002,7 +1002,7 @@ public: // thinglist is a subset of touching_thinglist struct msecnode_t *touching_thinglist; // phares 3/14/98 struct msecnode_t *render_thinglist; // for cross-portal rendering. - std::forward_list* touching_render_things; // this is used to allow wide things to be rendered not only from their main sector. + struct msecnode_t *touching_renderthings; // this is used to allow wide things to be rendered not only from their main sector. double gravity; // [RH] Sector gravity (1.0 is normal) FNameNoInit damagetype; // [RH] Means-of-death for applied damage diff --git a/src/r_things.cpp b/src/r_things.cpp index 8d326b319..ce356808e 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -714,7 +714,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // R_ProjectSprite // Generates a vissprite for a thing if it might be visible. // -void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling) +void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector) { double tr_x; double tr_y; @@ -1086,6 +1086,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } FDynamicColormap *mybasecolormap = basecolormap; + if (current_sector->sectornum != thing->Sector->sectornum) // compare sectornums to account for R_FakeFlat copies. + { + // Todo: The actor is from a different sector so we have to retrieve the proper basecolormap for that sector. + } // Sprites that are added to the scene must fade to black. if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) @@ -1224,7 +1228,7 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) // A sector might have been split into several // subsectors during BSP building. // Thus we check whether it was already added. - if (sec->touching_render_things == NULL || sec->validcount == validcount) + if (sec->touching_renderthings == nullptr || sec->validcount == validcount) return; // Well, now it will be done. @@ -1233,8 +1237,9 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) spriteshade = LIGHT2SHADE(lightlevel + r_actualextralight); // Handle all things in sector. - for (auto thing : *sec->touching_render_things) + for(auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext) { + auto thing = p->m_thing; if (thing->validcount == validcount) continue; thing->validcount = validcount; @@ -1250,7 +1255,7 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) } // find fake level - for(auto rover : frontsector->e->XFloor.ffloors) + for(auto rover : thing->Sector->e->XFloor.ffloors) { if(!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue; if(!(rover->flags & FF_SOLID) || rover->alpha != 255) continue; @@ -1266,7 +1271,7 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) if(rover->bottom.plane->ZatPoint(0., 0.) >= thing->Top()) fakeceiling = rover; } } - R_ProjectSprite (thing, fakeside, fakefloor, fakeceiling); + R_ProjectSprite (thing, fakeside, fakefloor, fakeceiling, sec); fakeceiling = NULL; fakefloor = NULL; } From aeee80c8fa4d3e7e04f8da6579bfa50cc69392f9 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 26 Dec 2016 15:59:44 +0200 Subject: [PATCH 13/14] Fixed endianness issue in script VM See https://forum.zdoom.org/viewtopic.php?t=54549 --- src/scripting/vm/vm.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 1869c410b..fdf5f3c9f 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -21,27 +21,35 @@ typedef VM_UBYTE VM_ATAG; #define VM_EPSILON (1/65536.0) +#ifdef __BIG_ENDIAN__ +#define VM_DEFINE_OP2(TYPE, ARG1, ARG2) TYPE ARG2, ARG1 +#define VM_DEFINE_OP4(TYPE, ARG1, ARG2, ARG3, ARG4) TYPE ARG4, ARG3, ARG2, ARG1 +#else // little endian +#define VM_DEFINE_OP2(TYPE, ARG1, ARG2) TYPE ARG1, ARG2 +#define VM_DEFINE_OP4(TYPE, ARG1, ARG2, ARG3, ARG4) TYPE ARG1, ARG2, ARG3, ARG4 +#endif // __BIG_ENDIAN__ + union VMOP { struct { - VM_UBYTE op, a, b, c; + VM_DEFINE_OP4(VM_UBYTE, op, a, b, c); }; struct { - VM_SBYTE pad0, as, bs, cs; + VM_DEFINE_OP4(VM_SBYTE, pad0, as, bs, cs); }; struct { - VM_SWORD pad1:8, i24:24; + VM_DEFINE_OP2(VM_SWORD, pad1:8, i24:24); }; struct { - VM_SWORD pad2:16, i16:16; + VM_DEFINE_OP2(VM_SWORD, pad2:16, i16:16); }; struct { - VM_UHALF pad3, i16u; + VM_DEFINE_OP2(VM_UHALF, pad3, i16u); }; VM_UWORD word; @@ -56,6 +64,9 @@ union VMOP // sar eax,10h }; +#undef VM_DEFINE_OP4 +#undef VM_DEFINE_OP2 + enum { #include "vmops.h" From 625e97dfd1708ccb3a02db74b8f0150c0f2a7b23 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Dec 2016 16:21:44 +0100 Subject: [PATCH 14/14] - fixed: UpdateRenderSectorList needs to reset the sector before traversing floor portals. --- src/p_map.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_map.cpp b/src/p_map.cpp index 20796ed23..85c3e3da8 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6755,6 +6755,7 @@ void AActor::UpdateRenderSectorList() sec = P_PointInSector(newpos); render_sectorlist = P_AddSecnode(sec, this, render_sectorlist, sec->render_thinglist); } + sec = Sector; lasth = FLT_MAX; while (!sec->PortalBlocksMovement(sector_t::floor)) {