- some sanitizing of sector tag/line id management:

* make setting the line ID with P_TranslateLineDef explicit because there's one FraggleScript function that needs to work around the changes caused by this. There's also some functions setting only a temporary linedef. These would inevitably cause problems if the underlying data gets changed.
* remove FS function 'ChangeTag'. Fortunately this was just some long forgotten test stuff that can be removed without affecting any maps, but the feature would cause some serious problems in a more complex system.

With these changes it is guaranteed that after map setup the tag/ids won't change anymore.
This commit is contained in:
Christoph Oelckers 2015-04-15 20:10:27 +02:00
parent 5d819036b3
commit 203f88ce6e
6 changed files with 23 additions and 46 deletions

View file

@ -67,6 +67,7 @@
#include "v_font.h" #include "v_font.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "farchive.h" #include "farchive.h"
#include "p_setup.h"
static FRandom pr_script("FScript"); static FRandom pr_script("FScript");
@ -2226,9 +2227,6 @@ void FParser::SF_RunCommand(void)
// //
//========================================================================== //==========================================================================
// any linedef type
extern void P_TranslateLineDef (line_t *ld, maplinedef_t *mld);
void FParser::SF_LineTrigger() void FParser::SF_LineTrigger()
{ {
if (CheckArgs(1)) if (CheckArgs(1))
@ -2237,7 +2235,7 @@ void FParser::SF_LineTrigger()
maplinedef_t mld; maplinedef_t mld;
mld.special=intvalue(t_argv[0]); mld.special=intvalue(t_argv[0]);
mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0; mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0;
P_TranslateLineDef(&line, &mld); P_TranslateLineDef(&line, &mld, false);
P_ExecuteSpecial(line.special, NULL, Script->trigger, false, P_ExecuteSpecial(line.special, NULL, Script->trigger, false,
line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]); line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]);
} }
@ -4382,15 +4380,12 @@ void FParser::SF_SetLineTrigger()
FLineIdIterator itr(id); FLineIdIterator itr(id);
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)
{ {
if (t_argc == 2) tag = lines[i].GetMainId();
maplinedef_t mld; maplinedef_t mld;
mld.special = spec; mld.special = spec;
mld.tag = tag; mld.tag = tag;
mld.flags = 0; mld.flags = 0;
int f = lines[i].flags; int f = lines[i].flags;
P_TranslateLineDef(&lines[i], &mld); P_TranslateLineDef(&lines[i], &mld, false);
lines[i].ClearIds();
lines[i].SetMainId(tag);
lines[i].flags = (lines[i].flags & (ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)) | lines[i].flags = (lines[i].flags & (ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)) |
(f & ~(ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)); (f & ~(ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY));
@ -4401,26 +4396,13 @@ void FParser::SF_SetLineTrigger()
//========================================================================== //==========================================================================
// //
// new for GZDoom: Changes a sector's tag //
// (I only need this because MAP02 in RTC-3057 has some issues with the GL
// renderer that I can't fix without the scripts. But loading a FS on top on
// ACS still works so I can hack around it with this.)
// //
//========================================================================== //==========================================================================
void FParser::SF_ChangeTag() void FParser::SF_ChangeTag()
{ {
if (CheckArgs(2)) // Development garbage!
{
FSectorTagIterator it(t_argv[0].value.i);
int secnum;
while ((secnum = it.Next()) >= 0)
{
sectors[secnum].ClearTags();
sectors[secnum].SetMainTag(t_argv[1].value.i);
}
sector_t::HashTags();
}
} }

View file

@ -96,7 +96,6 @@ CVAR (Bool, gennodes, false, CVAR_SERVERINFO|CVAR_GLOBALCONFIG);
CVAR (Bool, genglnodes, false, CVAR_SERVERINFO); CVAR (Bool, genglnodes, false, CVAR_SERVERINFO);
CVAR (Bool, showloadtimes, false, 0); CVAR (Bool, showloadtimes, false, 0);
static void P_InitTagLists ();
static void P_Shutdown (); static void P_Shutdown ();
bool P_IsBuildMap(MapData *map); bool P_IsBuildMap(MapData *map);
@ -2146,11 +2145,10 @@ void P_LoadLineDefs (MapData * map)
// [RH] Translate old linedef special and flags to be // [RH] Translate old linedef special and flags to be
// compatible with the new format. // compatible with the new format.
P_TranslateLineDef (ld, mld); P_TranslateLineDef (ld, mld, true);
ld->v1 = &vertexes[LittleShort(mld->v1)]; ld->v1 = &vertexes[LittleShort(mld->v1)];
ld->v2 = &vertexes[LittleShort(mld->v2)]; ld->v2 = &vertexes[LittleShort(mld->v2)];
//ld->id = -1; ID has been assigned in P_TranslateLineDef
P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0])); P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0]));
P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1])); P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1]));
@ -3209,7 +3207,9 @@ static void P_GroupLines (bool buildmap)
// [RH] Moved this here // [RH] Moved this here
times[4].Clock(); times[4].Clock();
P_InitTagLists(); // killough 1/30/98: Create xref tables for tags // killough 1/30/98: Create xref tables for tags
sector_t::HashTags();
line_t::HashIds();
times[4].Unclock(); times[4].Unclock();
times[5].Clock(); times[5].Clock();
@ -3306,13 +3306,6 @@ void P_LoadBehavior (MapData * map)
} }
} }
// Hash the sector tags across the sectors and linedefs.
static void P_InitTagLists ()
{
sector_t::HashTags();
line_t::HashIds();
}
void P_GetPolySpots (MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors) void P_GetPolySpots (MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors)
{ {
if (map->HasBehavior) if (map->HasBehavior)

View file

@ -115,7 +115,7 @@ struct line_t;
struct maplinedef_t; struct maplinedef_t;
void P_LoadTranslator(const char *lumpname); void P_LoadTranslator(const char *lumpname);
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld); void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, bool setlineid);
int P_TranslateSectorSpecial (int); int P_TranslateSectorSpecial (int);
int GetUDMFInt(int type, int index, const char *key); int GetUDMFInt(int type, int index, const char *key);

View file

@ -754,7 +754,7 @@ public:
mld.flags = 0; mld.flags = 0;
mld.special = th->special; mld.special = th->special;
mld.tag = th->args[0]; mld.tag = th->args[0];
P_TranslateLineDef(&ld, &mld); P_TranslateLineDef(&ld, &mld, true);
th->special = ld.special; th->special = ld.special;
memcpy(th->args, ld.args, sizeof (ld.args)); memcpy(th->args, ld.args, sizeof (ld.args));
} }
@ -1068,7 +1068,7 @@ public:
memset(&mld, 0, sizeof(mld)); memset(&mld, 0, sizeof(mld));
mld.special = ld->special; mld.special = ld->special;
mld.tag = ld->GetMainId(); mld.tag = ld->GetMainId();
P_TranslateLineDef(ld, &mld); P_TranslateLineDef(ld, &mld, false);
ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY)); ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY));
} }
if (passuse && (ld->activation & SPAC_Use)) if (passuse && (ld->activation & SPAC_Use))

View file

@ -60,7 +60,7 @@ typedef enum
PushMany, PushMany,
} triggertype_e; } triggertype_e;
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, bool setid)
{ {
unsigned short special = (unsigned short) LittleShort(mld->special); unsigned short special = (unsigned short) LittleShort(mld->special);
short tag = LittleShort(mld->tag); short tag = LittleShort(mld->tag);
@ -100,12 +100,14 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
} }
flags = newflags; flags = newflags;
if (setid)
{
// For purposes of maintaining BOOM compatibility, each // For purposes of maintaining BOOM compatibility, each
// line also needs to have its ID set to the same as its tag. // line also needs to have its ID set to the same as its tag.
// An external conversion program would need to do this more // An external conversion program would need to do this more
// intelligently. // intelligently.
ld->ClearIds();
ld->SetMainId(tag); ld->SetMainId(tag);
}
// 0 specials are never translated. // 0 specials are never translated.
if (special == 0) if (special == 0)

View file

@ -70,6 +70,7 @@
#include "m_bbox.h" #include "m_bbox.h"
#include "r_data/r_translate.h" #include "r_data/r_translate.h"
#include "p_trace.h" #include "p_trace.h"
#include "p_setup.h"
#include "gstrings.h" #include "gstrings.h"
@ -4506,7 +4507,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Weave)
//=========================================================================== //===========================================================================
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld);
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect)
{ {
ACTION_PARAM_START(2); ACTION_PARAM_START(2);
@ -4520,7 +4520,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect)
if ((oldjunk.special = special)) // Linedef type if ((oldjunk.special = special)) // Linedef type
{ {
oldjunk.tag = tag; // Sector tag for linedef oldjunk.tag = tag; // Sector tag for linedef
P_TranslateLineDef(&junk, &oldjunk); // Turn into native type P_TranslateLineDef(&junk, &oldjunk, false); // Turn into native type
res = !!P_ExecuteSpecial(junk.special, NULL, self, false, junk.args[0], res = !!P_ExecuteSpecial(junk.special, NULL, self, false, junk.args[0],
junk.args[1], junk.args[2], junk.args[3], junk.args[4]); junk.args[1], junk.args[2], junk.args[3], junk.args[4]);
if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once, if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once,