Permalink
Browse files

- moved the non-map timers out of LevelLocals into GameSession and mo…

…ved the composite compatibility flags into FLevelLocals, because they are level specific.
  • Loading branch information...
coelckers committed Jan 10, 2019
1 parent 3b59afa commit 229dde1e67222044abdea42b8ba01b0c5c1f3384
Showing with 248 additions and 196 deletions.
  1. +2 −2 src/bbannouncer.cpp
  2. +12 −9 src/d_main.cpp
  3. +5 −2 src/d_net.cpp
  4. +0 −1 src/doomstat.h
  5. +2 −2 src/dsectoreffect.cpp
  6. +7 −8 src/g_game.cpp
  7. +22 −18 src/g_level.cpp
  8. +12 −5 src/g_levellocals.h
  9. +1 −1 src/g_shared/a_lightning.cpp
  10. +7 −7 src/g_statusbar/sbarinfo_commands.cpp
  11. +1 −1 src/hu_scores.cpp
  12. +2 −1 src/hwrenderer/scene/hw_drawlist.cpp
  13. +1 −0 src/hwrenderer/scene/hw_drawlist.h
  14. +1 −1 src/hwrenderer/scene/hw_walls.cpp
  15. +14 −11 src/maploader/compatibility.cpp
  16. +2 −2 src/maploader/maploader.cpp
  17. +1 −1 src/maploader/slopes.cpp
  18. +4 −4 src/p_acs.cpp
  19. +1 −1 src/p_conversation.cpp
  20. +1 −1 src/p_doors.cpp
  21. +6 −6 src/p_enemy.cpp
  22. +4 −4 src/p_floor.cpp
  23. +4 −4 src/p_interaction.cpp
  24. +1 −1 src/p_lights.cpp
  25. +1 −1 src/p_lnspec.cpp
  26. +16 −16 src/p_map.cpp
  27. +1 −1 src/p_maputl.cpp
  28. +2 −1 src/p_maputl.h
  29. +18 −18 src/p_mobj.cpp
  30. +5 −9 src/p_saveg.cpp
  31. +6 −6 src/p_sectors.cpp
  32. +1 −1 src/p_setup.cpp
  33. +1 −1 src/p_sight.cpp
  34. +3 −3 src/p_spec.cpp
  35. +2 −2 src/p_teleport.cpp
  36. +2 −2 src/p_tick.cpp
  37. +1 −1 src/p_trace.cpp
  38. +1 −1 src/po_man.cpp
  39. +11 −11 src/s_sound.cpp
  40. +1 −3 src/scripting/backend/codegen.cpp
  41. +2 −2 src/scripting/vmthunks.cpp
  42. +26 −0 src/scripting/vmthunks_actors.cpp
  43. +1 −1 src/statistics.cpp
  44. +2 −2 src/swrenderer/line/r_line.cpp
  45. +3 −3 src/swrenderer/line/r_renderdrawsegment.cpp
  46. +1 −1 src/swrenderer/things/r_visiblespritelist.cpp
  47. +2 −2 wadsrc/static/zscript/actor.txt
  48. +11 −3 wadsrc/static/zscript/base.txt
  49. +2 −1 wadsrc/static/zscript/doom/fatso.txt
  50. +3 −1 wadsrc/static/zscript/doom/painelemental.txt
  51. +3 −3 wadsrc/static/zscript/shared/morph.txt
  52. +5 −5 wadsrc/static/zscript/statusbar/alt_hud.txt
  53. +1 −1 wadsrc/static/zscript/statusbar/heretic_sbar.txt
  54. +1 −1 wadsrc/static/zscript/statusbar/statusbar.txt
@@ -182,9 +182,9 @@ static FRandom pr_bbannounce ("BBAnnounce");
void DoVoiceAnnounce (const char *sound)
{
// Don't play announcements too close together
if (LastAnnounceTime == 0 || LastAnnounceTime <= level.time-5)
if (LastAnnounceTime == 0 || LastAnnounceTime <= currentSession->time-5)
{
LastAnnounceTime = level.time;
LastAnnounceTime = currentSession->time;
S_Sound (CHAN_VOICE, sound, 1, ATTN_NONE);
}
}
@@ -502,9 +502,6 @@ CVAR (Flag, sv_respawnsuper, dmflags2, DF2_RESPAWN_SUPER);
//
//==========================================================================

int i_compatflags, i_compatflags2; // internal compatflags composed from the compatflags CVAR and MAPINFO settings
int ii_compatflags, ii_compatflags2, ib_compatflags;

EXTERN_CVAR(Int, compatmode)

static int GetCompatibility(FLevelLocals *Level, int mask)
@@ -521,17 +518,23 @@ static int GetCompatibility2(FLevelLocals *Level, int mask)

CUSTOM_CVAR (Int, compatflags, 0, CVAR_ARCHIVE|CVAR_SERVERINFO)
{
int old = i_compatflags;
i_compatflags = GetCompatibility(&level, self) | ii_compatflags;
if ((old ^ i_compatflags) & COMPATF_POLYOBJ)
ForAllLevels([&](FLevelLocals *Level)
{
level.ClearAllSubsectorLinks();
}
int old = Level->i_compatflags;
Level->i_compatflags = GetCompatibility(Level, self) | Level->ii_compatflags;
if ((old ^ Level->i_compatflags) & COMPATF_POLYOBJ)
{
Level->ClearAllSubsectorLinks();
}
});
}

CUSTOM_CVAR (Int, compatflags2, 0, CVAR_ARCHIVE|CVAR_SERVERINFO)
{
i_compatflags2 = GetCompatibility2(&level, self) | ii_compatflags2;
ForAllLevels([&](FLevelLocals *Level)
{
Level->i_compatflags2 = GetCompatibility2(Level, self) | Level->ii_compatflags2;
});
}

CUSTOM_CVAR(Int, compatmode, 0, CVAR_ARCHIVE|CVAR_NOINITCALL)
@@ -2226,8 +2226,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
s = ReadString (stream);
// Using LEVEL_NOINTERMISSION tends to throw the game out of sync.
// That was a long time ago. Maybe it works now?
level.flags |= LEVEL_CHANGEMAPCHEAT;
G_ChangeLevel(s, pos, 0);
if (currentSession)
{
currentSession->Levelinfo[0]->flags |= LEVEL_CHANGEMAPCHEAT;
G_ChangeLevel(s, pos, 0);
}
break;

case DEM_SUICIDE:
@@ -248,7 +248,6 @@ EXTERN_CVAR (Int, dmflags2); // [BC]

EXTERN_CVAR (Int, compatflags);
EXTERN_CVAR (Int, compatflags2);
extern int i_compatflags, i_compatflags2, ii_compatflags, ii_compatflags2, ib_compatflags;

// Filters from AddAutoloadFiles(). Used to filter files from archives.
extern FString LumpFilterIWAD;
@@ -221,7 +221,7 @@ EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direct
//destheight = (dest < ceilingheight) ? dest : ceilingheight;
if (!ceilingplane.isSlope() && !floorplane.isSlope() &&
!PortalIsLinked(sector_t::ceiling) &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > ceilingplane.fD()))
(!(Level->i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > ceilingplane.fD()))
{
dest = -ceilingplane.fD();
}
@@ -311,7 +311,7 @@ EMoveResult sector_t::MoveCeiling(double speed, double dest, int crush, int dire
//destheight = (dest > floorheight) ? dest : floorheight;
if (!ceilingplane.isSlope() && !floorplane.isSlope() &&
!PortalIsLinked(sector_t::floor) &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -floorplane.fD()))
(!(Level->i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -floorplane.fD()))
{
dest = -floorplane.fD();
}
@@ -1685,11 +1685,11 @@ void G_DoPlayerPop(int playernum)
}

// [RH] Make the player disappear
level.Behaviors.StopMyScripts(players[playernum].mo);
players[playernum].mo->Level->Behaviors.StopMyScripts(players[playernum].mo);
// [ZZ] fire player disconnect hook
E_PlayerDisconnected(playernum);
// [RH] Let the scripts know the player left
level.Behaviors.StartTypedScripts(&level, SCRIPT_Disconnect, players[playernum].mo, true, playernum, true);
players[playernum].mo->Level->Behaviors.StartTypedScripts(&level, SCRIPT_Disconnect, players[playernum].mo, true, playernum, true);
if (players[playernum].mo != NULL)
{
P_DisconnectEffect(players[playernum].mo);
@@ -1902,7 +1902,7 @@ void G_DoLoadGame ()
arc("ticrate", time[0])
("leveltime", time[1]);
// dearchive all the modifications
level.time = Scale(time[1], TICRATE, time[0]);
currentSession->time = Scale(time[1], TICRATE, time[0]);

G_ReadSnapshots(resfile.get());
resfile.reset(nullptr); // we no longer need the resource file below this point
@@ -2081,9 +2081,8 @@ static void PutSaveComment (FSerializer &arc)
});

// Append elapsed time
levelTime = level.time / TICRATE;
comment.AppendFormat("time: %02d:%02d:%02d",
levelTime/3600, (levelTime%3600)/60, levelTime%60);
levelTime = currentSession->time / TICRATE;
comment.AppendFormat("time: %02d:%02d:%02d", levelTime/3600, (levelTime%3600)/60, levelTime%60);

// Write out the comment
arc.AddString("Comment", comment);
@@ -2196,11 +2195,11 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
savegameglobals.AddString("importantcvars", vars.GetChars());
}

if (level.time != 0 || level.maptime != 0)
if (currentSession->time != 0)
{
int tic = TICRATE;
savegameglobals("ticrate", tic);
savegameglobals("leveltime", level.time);
savegameglobals("leveltime", currentSession->time);
}

STAT_Serialize(savegameglobals);
@@ -540,9 +540,10 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
}
FRandom::StaticClearRandom ();
P_ClearACSVars(true);
level.time = 0;
currentSession->time = 0;
currentSession->totaltime = 0;

level.maptime = 0;
level.totaltime = 0;
level.spawnindex = 0;

if (!multiplayer || !deathmatch)
@@ -610,7 +611,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill
Printf (TEXTCOLOR_RED "Unloading scripts cannot exit the level again.\n");
return;
}
if (gameaction == ga_completed && !(i_compatflags2 & COMPATF2_MULTIEXIT)) // do not exit multiple times.
if (gameaction == ga_completed && !(currentSession->Levelinfo[0]->i_compatflags2 & COMPATF2_MULTIEXIT)) // do not exit multiple times.
{
return;
}
@@ -665,7 +666,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill

startpos = position;
gameaction = ga_completed;
level.SetMusicVolume(1.0);
currentSession->SetMusicVolume(1.0);

if (nextinfo != NULL)
{
@@ -738,37 +739,39 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill

const char *G_GetExitMap()
{
return level.NextMap;
return currentSession->Levelinfo[0]->NextMap;
}

const char *G_GetSecretExitMap()
{
const char *nextmap = level.NextMap;
auto Level = currentSession->Levelinfo[0];
const char *nextmap = Level->NextMap;

if (level.NextSecretMap.Len() > 0)
if (Level->NextSecretMap.Len() > 0)
{
if (P_CheckMapData(level.NextSecretMap))
if (P_CheckMapData(Level->NextSecretMap))
{
nextmap = level.NextSecretMap;
nextmap = Level->NextSecretMap;
}
}
return nextmap;
}

//==========================================================================
//
// The flags here must always be on the primary level.
//
//==========================================================================

void G_ExitLevel (int position, bool keepFacing)
{
level.flags3 |= LEVEL3_EXITNORMALUSED;
currentSession->Levelinfo[0]->flags3 |= LEVEL3_EXITNORMALUSED;
G_ChangeLevel(G_GetExitMap(), position, keepFacing ? CHANGELEVEL_KEEPFACING : 0);
}

void G_SecretExitLevel (int position)
{
level.flags3 |= LEVEL3_EXITSECRETUSED;
currentSession->Levelinfo[0]->flags3 |= LEVEL3_EXITSECRETUSED;
G_ChangeLevel(G_GetSecretExitMap(), position, 0);
}

@@ -847,14 +850,14 @@ void G_DoCompleted ()
wminfo.partime = TICRATE * Level->partime;
wminfo.sucktime = Level->sucktime;
wminfo.pnum = consoleplayer;
wminfo.totaltime = Level->totaltime;
wminfo.totaltime = currentSession->totaltime;

for (i=0 ; i<MAXPLAYERS ; i++)
{
wminfo.plyr[i].skills = players[i].killcount;
wminfo.plyr[i].sitems = players[i].itemcount;
wminfo.plyr[i].ssecret = players[i].secretcount;
wminfo.plyr[i].stime = level.time;
wminfo.plyr[i].stime = currentSession->time;
memcpy (wminfo.plyr[i].frags, players[i].frags
, sizeof(wminfo.plyr[i].frags));
wminfo.plyr[i].fragcount = players[i].fragcount;
@@ -922,7 +925,7 @@ void G_DoCompleted ()
{ // Reset world variables for the new hub.
P_ClearACSVars(false);
}
level.time = 0;
currentSession->time = 0;
level.maptime = 0;
level.spawnindex = 0;
}
@@ -1477,7 +1480,7 @@ int G_FinishTravel ()
VMCall(func, params, 1, nullptr, 0);
}
}
if (ib_compatflags & BCOMPATF_RESETPLAYERSPEED)
if (pawn->Level->ib_compatflags & BCOMPATF_RESETPLAYERSPEED)
{
pawn->Speed = pawn->GetDefault()->Speed;
}
@@ -1505,6 +1508,8 @@ void FLevelLocals::InitLevelLocals ()

// Session data should be moved out of here later!
currentSession->F1Pic = info->F1Pic;
currentSession->MusicVolume = 1.f;


P_InitParticles(this);
P_ClearParticles(this);
@@ -1560,7 +1565,6 @@ void FLevelLocals::InitLevelLocals ()
levelnum = info->levelnum;
Music = info->Music;
musicorder = info->musicorder;
MusicVolume = 1.f;
HasHeightSecs = false;

LevelName = info->LookupLevelName();
@@ -2198,9 +2202,9 @@ void FLevelLocals::SetMusic()
//
//==========================================================================

void FLevelLocals::SetMusicVolume(float f)
void FGameSession::SetMusicVolume(float f)
{
MusicVolume = f;
if (currentSession) currentSession->MusicVolume = f;
I_SetMusicVolume(f);
}

@@ -115,6 +115,11 @@ struct FLevelData
FDialogueIDMap DialogueRoots;
FDialogueMap ClassRoots;

int ii_compatflags = 0;
int ii_compatflags2 = 0;
int ib_compatflags = 0;
int i_compatflags = 0;
int i_compatflags2 = 0;

};

@@ -128,7 +133,6 @@ struct FLevelLocals : public FLevelData
void AddScroller(int secnum);
void SetInterMusic(const char *nextmap);
void SetMusic();
void SetMusicVolume(float v);
void ClearLevelData();
void ClearPortals();
bool CheckIfExitIsGood(AActor *self, level_info_t *newmap);
@@ -162,9 +166,7 @@ struct FLevelLocals : public FLevelData
DSectorMarker *SectorMarker;

uint8_t md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded.
int time; // time in the hub
int maptime; // time in the map
int totaltime; // time in the game
int maptime; // time in the map
int starttime;
int partime;
int sucktime;
@@ -257,7 +259,6 @@ struct FLevelLocals : public FLevelData

FName deathsequence;
float pixelstretch;
float MusicVolume;

// Hardware render stuff that can either be set via CVAR or MAPINFO
ELightMode lightMode;
@@ -302,6 +303,12 @@ class FGameSession
public:
TArray<FLevelLocals *> Levelinfo;
FString F1Pic;
float MusicVolume;
int time; // time in the hub
int totaltime; // time in the game


void SetMusicVolume(float vol);
};

extern FGameSession *currentSession;
@@ -168,7 +168,7 @@ void DLightningThinker::LightningFlash ()
}
else
{
if (pr_lightning() < 128 && !(Level->time&32))
if (pr_lightning() < 128 && !(currentSession->time&32))
{
NextLightningFlash = ((pr_lightning()&7)+2)*35;
}
Oops, something went wrong.

0 comments on commit 229dde1

Please sign in to comment.