Permalink
Browse files

- the final batch of level removal before refactoring the underlying …

…data.
  • Loading branch information...
coelckers committed Jan 10, 2019
1 parent ad17bce commit d6d66ca774bb12e115bd66c1c02fb3489b05d287
@@ -1093,10 +1093,11 @@ CCMD(nextmap)
TEXTCOLOR_NORMAL " is for single-player only.\n");
return;
}
auto Level = who->Level;

if (level.NextMap.Len() > 0 && level.NextMap.Compare("enDSeQ", 6))
if (Level->NextMap.Len() > 0 && Level->NextMap.Compare("enDSeQ", 6))
{
G_DeferedInitNew(level.NextMap);
G_DeferedInitNew(Level->NextMap);
}
else
{
@@ -1117,10 +1118,11 @@ CCMD(nextsecret)
TEXTCOLOR_NORMAL " is for single-player only.\n");
return;
}
auto Level = who->Level;

if (level.NextSecretMap.Len() > 0 && level.NextSecretMap.Compare("enDSeQ", 6))
if (Level->NextSecretMap.Len() > 0 && Level->NextSecretMap.Compare("enDSeQ", 6))
{
G_DeferedInitNew(level.NextSecretMap);
G_DeferedInitNew(Level->NextSecretMap);
}
else
{
@@ -1165,7 +1167,7 @@ static void PrintSecretString(const char *string, FLevelLocals *Level)
{
auto secnum = (unsigned)strtoull(string+2, (char**)&string, 10);
if (*string == ';') string++;
if (Level && secnum < level.sectors.Size())
if (Level && secnum < Level->sectors.Size())
{
if (Level->sectors[secnum].isSecret()) colstr = TEXTCOLOR_RED;
else if (Level->sectors[secnum].wasSecret()) colstr = TEXTCOLOR_GREEN;
@@ -68,7 +68,7 @@ void G_PlayDemo (char* name);
void G_TimeDemo (const char* name);
bool G_CheckDemoStatus (void);

void G_WorldDone (void);
void G_WorldDone (FLevelLocals *);

void G_Ticker (void);
bool G_Responder (event_t* ev);
@@ -214,7 +214,15 @@ CCMD (map)
if (argv.argc() > 1)
{
const char *mapname = argv[1];
if (!strcmp(mapname, "*")) mapname = level.MapName.GetChars();
if (!strcmp(mapname, "*"))
{
if (who == nullptr)
{
Printf("Player is not in a level that can be restarted.\n");
return;
}
mapname = who->Level->MapName.GetChars();
}

try
{
@@ -264,7 +272,16 @@ UNSAFE_CCMD(recordmap)
if (argv.argc() > 2)
{
const char *mapname = argv[2];
if (!strcmp(mapname, "*")) mapname = level.MapName.GetChars();

if (!strcmp(mapname, "*"))
{
if (who == nullptr)
{
Printf("Player is not in a level that can be restarted.\n");
return;
}
mapname = who->Level->MapName.GetChars();
}

try
{
@@ -745,9 +762,10 @@ void G_SecretExitLevel (int position)
//
//==========================================================================

void G_DoCompleted (void)
void G_DoCompleted ()
{
int i;
int i;
auto Level = &level;

gameaction = ga_nothing;

@@ -768,24 +786,24 @@ void G_DoCompleted (void)
}

// [RH] Mark this level as having been visited
if (!(level.flags & LEVEL_CHANGEMAPCHEAT))
FindLevelInfo (level.MapName)->flags |= LEVEL_VISITED;
if (!(Level->flags & LEVEL_CHANGEMAPCHEAT))
Level->info->flags |= LEVEL_VISITED;

if (automapactive)
AM_Stop ();

// Close the conversation menu if open.
P_FreeStrifeConversations ();

wminfo.finished_ep = level.cluster - 1;
wminfo.finished_ep = Level->cluster - 1;
wminfo.LName0 = TexMan.CheckForTexture(level.info->PName, ETextureType::MiscPatch);
wminfo.current = level.MapName;
wminfo.current = Level->MapName;

if (deathmatch &&
(dmflags & DF_SAME_LEVEL) &&
!(level.flags & LEVEL_CHANGEMAPCHEAT))
!(Level->flags & LEVEL_CHANGEMAPCHEAT))
{
wminfo.next = level.MapName;
wminfo.next = Level->MapName;
wminfo.LName1 = wminfo.LName0;
}
else
@@ -807,14 +825,14 @@ void G_DoCompleted (void)
nextlevel = wminfo.next;

wminfo.next_ep = FindLevelInfo (wminfo.next)->cluster - 1;
wminfo.maxkills = level.total_monsters;
wminfo.maxitems = level.total_items;
wminfo.maxsecret = level.total_secrets;
wminfo.maxkills = Level->total_monsters;
wminfo.maxitems = Level->total_items;
wminfo.maxsecret = Level->total_secrets;
wminfo.maxfrags = 0;
wminfo.partime = TICRATE * level.partime;
wminfo.sucktime = level.sucktime;
wminfo.partime = TICRATE * Level->partime;
wminfo.sucktime = Level->sucktime;
wminfo.pnum = consoleplayer;
wminfo.totaltime = level.totaltime;
wminfo.totaltime = Level->totaltime;

for (i=0 ; i<MAXPLAYERS ; i++)
{
@@ -832,7 +850,7 @@ void G_DoCompleted (void)
// the player and clear the world vars. If this is just an
// ordinary cluster (not a hub), take stuff from the player, but
// leave the world vars alone.
cluster_info_t *thiscluster = FindClusterInfo (level.cluster);
cluster_info_t *thiscluster = FindClusterInfo (Level->cluster);
cluster_info_t *nextcluster = FindClusterInfo (wminfo.next_ep+1); // next_ep is cluster-1
EFinishLevelType mode;

@@ -866,22 +884,19 @@ void G_DoCompleted (void)

if (mode == FINISH_SameHub)
{ // Remember the level's state for re-entry.
if (!(level.flags2 & LEVEL2_FORGETSTATE))
if (!(Level->flags2 & LEVEL2_FORGETSTATE))
{
G_SnapshotLevel ();
// Do not free any global strings this level might reference
// Do not free any global strings this level (or any sublevel) might reference
// while it's not loaded.
ForAllLevels([](FLevelLocals *Level)
{
Level->Behaviors.LockLevelVarStrings(Level);
});
}
else
{ // Make sure we don't have a snapshot lying around from before.
ForAllLevels([](FLevelLocals *Level)
{
Level->info->Snapshot.Clean();
});
{ // Make sure we don't have a snapshot lying around from before. (Snapshots are only attached to the primary level!)
Level->info->Snapshot.Clean();
}
}
else
@@ -900,10 +915,10 @@ void G_DoCompleted (void)
finishstate = mode;

if (!deathmatch &&
((level.flags & LEVEL_NOINTERMISSION) ||
((Level->flags & LEVEL_NOINTERMISSION) ||
((nextcluster == thiscluster) && (thiscluster->flags & CLUSTER_HUB) && !(thiscluster->flags & CLUSTER_ALLOWINTERMISSION))))
{
G_WorldDone ();
G_WorldDone (Level);
return;
}

@@ -1153,17 +1168,17 @@ void G_DoLoadLevel (int position, bool autosave, bool newGame)
//
//==========================================================================

void G_WorldDone (void)
void G_WorldDone (FLevelLocals *Level)
{
cluster_info_t *nextcluster;
cluster_info_t *thiscluster;

gameaction = ga_worlddone;

if (level.flags & LEVEL_CHANGEMAPCHEAT)
if (Level->flags & LEVEL_CHANGEMAPCHEAT)
return;

thiscluster = FindClusterInfo (level.cluster);
thiscluster = FindClusterInfo (Level->cluster);

if (strncmp (nextlevel, "enDSeQ", 6) == 0)
{
@@ -1182,7 +1197,7 @@ void G_WorldDone (void)
}
}

auto ext = level.info->ExitMapTexts.CheckKey(level.flags3 & LEVEL3_EXITSECRETUSED ? NAME_Secret : NAME_Normal);
auto ext = Level->info->ExitMapTexts.CheckKey(Level->flags3 & LEVEL3_EXITSECRETUSED ? NAME_Secret : NAME_Normal);
if (ext != nullptr && (ext->mDefined & FExitText::DEF_TEXT))
{
F_StartFinale(ext->mDefined & FExitText::DEF_MUSIC ? ext->mMusic : gameinfo.finaleMusic,
@@ -1210,9 +1225,9 @@ void G_WorldDone (void)
{
FExitText *ext = nullptr;

if (level.flags3 & LEVEL3_EXITSECRETUSED) ext = level.info->ExitMapTexts.CheckKey(NAME_Secret);
else if (level.flags3 & LEVEL3_EXITNORMALUSED) ext = level.info->ExitMapTexts.CheckKey(NAME_Normal);
if (ext == nullptr) ext = level.info->ExitMapTexts.CheckKey(nextlevel);
if (Level->flags3 & LEVEL3_EXITSECRETUSED) ext = Level->info->ExitMapTexts.CheckKey(NAME_Secret);
else if (Level->flags3 & LEVEL3_EXITNORMALUSED) ext = Level->info->ExitMapTexts.CheckKey(NAME_Normal);
if (ext == nullptr) ext = Level->info->ExitMapTexts.CheckKey(nextlevel);

if (ext != nullptr)
{
@@ -1233,7 +1248,7 @@ void G_WorldDone (void)

nextcluster = FindClusterInfo (FindLevelInfo (nextlevel)->cluster);

if (nextcluster->cluster != level.cluster && !deathmatch)
if (nextcluster->cluster != Level->cluster && !deathmatch)
{
// Only start the finale if the next level's cluster is different
// than the current one and we're not in deathmatch.
@@ -1263,7 +1278,8 @@ void G_WorldDone (void)

DEFINE_ACTION_FUNCTION(FLevelLocals, WorldDone)
{
G_WorldDone();
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
G_WorldDone(self);
return 0;
}

@@ -1314,7 +1330,7 @@ void G_StartTravel ()
AActor *inv;
players[i].camera = nullptr;

// Only living players travel. Dead ones get a new body on the new level.
// Only living players travel. Dead ones get a new body on the new map.
if (players[i].health > 0)
{
pawn->UnlinkFromWorld (nullptr);
@@ -1376,7 +1392,7 @@ int G_FinishTravel ()
if (pawndup != nullptr)
{
Printf(TEXTCOLOR_RED "No player %d start to travel to!\n", pnum + 1);
// Move to the coordinates this player had when they left the level.
// Move to the coordinates this player had when they left the map.
pawn->SetXYZ(pawndup->Pos());
}
else
@@ -2139,11 +2155,11 @@ void FLevelLocals::AddScroller (int secnum)

void FLevelLocals::SetInterMusic(const char *nextmap)
{
auto mus = level.info->MapInterMusic.CheckKey(nextmap);
auto mus = info->MapInterMusic.CheckKey(nextmap);
if (mus != nullptr)
S_ChangeMusic(mus->first, mus->second);
else if (level.info->InterMusic.IsNotEmpty())
S_ChangeMusic(level.info->InterMusic, level.info->intermusicorder);
else if (info->InterMusic.IsNotEmpty())
S_ChangeMusic(info->InterMusic, info->intermusicorder);
else
S_ChangeMusic(gameinfo.intermissionMusic.GetChars(), gameinfo.intermissionOrder);
}
@@ -2215,7 +2231,7 @@ inline T VecDiff(FLevelLocals *Level, const T& v1, const T& v2)
{
T result = v2 - v1;

if (level.subsectors.Size() > 0)
if (Level->subsectors.Size() > 0)
{
const sector_t *const sec1 = P_PointInSector(Level, v1);
const sector_t *const sec2 = P_PointInSector(Level, v2);
@@ -2307,7 +2323,9 @@ CCMD(skyfog)
{
if (argv.argc()>1)
{
level.skyfog = MAX(0, (int)strtoull(argv[1], NULL, 0));
ForAllLevels([&](FLevelLocals *Level) {
Level->skyfog = MAX(0, (int)strtoull(argv[1], NULL, 0));
});
}
}

@@ -142,6 +142,7 @@ struct FLevelLocals : public FLevelData
int GetConversation(FName classname);
void SetConversation(int convid, PClassActor *Class, int dlgindex);
int FindNode (const FStrifeDialogueNode *node);
bool GetInfighting();

//
// P_ClearTidHashes
@@ -393,9 +393,6 @@ int G_SkillProperty(ESkillProperty prop)
return AllSkills[gameskill].NoPain;

case SKILLP_Infight:
// This property also needs to consider the level flags for the same info.
if (level.flags2 & LEVEL2_TOTALINFIGHTING) return 1;
if (level.flags2 & LEVEL2_NOINFIGHTING) return -1;
if (AllSkills[gameskill].Infighting == LEVEL2_TOTALINFIGHTING) return 1;
if (AllSkills[gameskill].Infighting == LEVEL2_NOINFIGHTING) return -1;
return infighting;
@@ -52,11 +52,11 @@
#undef DD
#endif

void FNodeBuilder::Extract (FLevelLocals &level)
void FNodeBuilder::Extract (FLevelLocals &destination)
{
int i;

auto &outVerts = level.vertexes;
auto &outVerts = destination.vertexes;
int vertCount = Vertices.Size ();
outVerts.Alloc(vertCount);

@@ -65,12 +65,12 @@ void FNodeBuilder::Extract (FLevelLocals &level)
outVerts[i].set(Vertices[i].x, Vertices[i].y);
}

auto &outSubs = level.subsectors;
auto &outSubs = destination.subsectors;
auto subCount = Subsectors.Size();
outSubs.Alloc(subCount);
memset(&outSubs[0], 0, subCount * sizeof(subsector_t));

auto &outNodes = level.nodes;
auto &outNodes = destination.nodes;
auto nodeCount = Nodes.Size ();
outNodes.Alloc(nodeCount);

@@ -103,7 +103,7 @@ void FNodeBuilder::Extract (FLevelLocals &level)
}
}

auto &outSegs = level.segs;
auto &outSegs = destination.segs;
if (GLNodes)
{
TArray<glseg_t> segs (Segs.Size()*5/4);
@@ -584,6 +584,19 @@ int FLevelLocals::FindNode (const FStrifeDialogueNode *node)
return rootnode;
}

//============================================================================
//
//
//
//============================================================================

int FLevelLocals::GetInfighting()
{
if (flags2 & LEVEL2_TOTALINFIGHTING) return 1;
if (flags2 & LEVEL2_NOINFIGHTING) return -1;
return G_SkillProperty(SKILLP_Infight);
}

//============================================================================
//
// CheckStrifeItem
@@ -1625,7 +1625,7 @@ bool AActor::OkayToSwitchTarget(AActor *other)
int infight;
if (flags7 & MF7_FORCEINFIGHTING) infight = 1;
else if (flags5 & MF5_NOINFIGHTING) infight = -1;
else infight = G_SkillProperty(SKILLP_Infight);
else infight = Level->GetInfighting();

if (infight < 0 && other->player == NULL && !IsHostile (other))
{
Oops, something went wrong.

0 comments on commit d6d66ca

Please sign in to comment.