- moved a few parts from g_level.cpp to better fitting places.
This commit is contained in:
parent
6be073f528
commit
ef3e5ef01e
6 changed files with 309 additions and 274 deletions
223
src/g_level.cpp
223
src/g_level.cpp
|
|
@ -1634,68 +1634,6 @@ void FLevelLocals::Init()
|
|||
notexturefill = info->notexturefill < 0 ? gl_notexturefill : !!info->notexturefill;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FLevelLocals::IsJumpingAllowed() const
|
||||
{
|
||||
if (dmflags & DF_NO_JUMP)
|
||||
return false;
|
||||
if (dmflags & DF_YES_JUMP)
|
||||
return true;
|
||||
return !(flags & LEVEL_JUMP_NO);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(FLevelLocals, IsJumpingAllowed)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
||||
ACTION_RETURN_BOOL(self->IsJumpingAllowed());
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FLevelLocals::IsCrouchingAllowed() const
|
||||
{
|
||||
if (dmflags & DF_NO_CROUCH)
|
||||
return false;
|
||||
if (dmflags & DF_YES_CROUCH)
|
||||
return true;
|
||||
return !(flags & LEVEL_CROUCH_NO);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(FLevelLocals, IsCrouchingAllowed)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
||||
ACTION_RETURN_BOOL(self->IsCrouchingAllowed());
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FLevelLocals::IsFreelookAllowed() const
|
||||
{
|
||||
if (dmflags & DF_NO_FREELOOK)
|
||||
return false;
|
||||
if (dmflags & DF_YES_FREELOOK)
|
||||
return true;
|
||||
return !(flags & LEVEL_FREELOOK_NO);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(FLevelLocals, IsFreelookAllowed)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
||||
ACTION_RETURN_BOOL(self->IsFreelookAllowed());
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
@ -1735,89 +1673,6 @@ void FLevelLocals::AirControlChanged ()
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Archives the current level
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FLevelLocals::SnapshotLevel ()
|
||||
{
|
||||
info->Snapshot.Clean();
|
||||
|
||||
if (info->isValid())
|
||||
{
|
||||
FSerializer arc(this);
|
||||
|
||||
if (arc.OpenWriter(save_formatted))
|
||||
{
|
||||
SaveVersion = SAVEVER;
|
||||
Serialize(arc, false);
|
||||
info->Snapshot = arc.GetCompressedOutput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Unarchives the current level based on its snapshot
|
||||
// The level should have already been loaded and setup.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FLevelLocals::UnSnapshotLevel (bool hubLoad)
|
||||
{
|
||||
if (info->Snapshot.mBuffer == nullptr)
|
||||
return;
|
||||
|
||||
if (info->isValid())
|
||||
{
|
||||
FSerializer arc(this);
|
||||
if (!arc.OpenReader(&info->Snapshot))
|
||||
{
|
||||
I_Error("Failed to load savegame");
|
||||
return;
|
||||
}
|
||||
|
||||
Serialize (arc, hubLoad);
|
||||
FromSnapshot = true;
|
||||
|
||||
auto it = GetThinkerIterator<AActor>(NAME_PlayerPawn);
|
||||
AActor *pawn, *next;
|
||||
|
||||
next = it.Next();
|
||||
while ((pawn = next) != 0)
|
||||
{
|
||||
next = it.Next();
|
||||
if (pawn->player == nullptr || pawn->player->mo == nullptr || !PlayerInGame(pawn->player))
|
||||
{
|
||||
int i;
|
||||
|
||||
// If this isn't the unmorphed original copy of a player, destroy it, because it's extra.
|
||||
for (i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
if (PlayerInGame(i) && Players[i]->morphTics && Players[i]->mo->alternative == pawn)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == MAXPLAYERS)
|
||||
{
|
||||
pawn->Destroy ();
|
||||
}
|
||||
}
|
||||
}
|
||||
arc.Close();
|
||||
}
|
||||
// No reason to keep the snapshot around once the level's been entered.
|
||||
info->Snapshot.Clean();
|
||||
if (hubLoad)
|
||||
{
|
||||
// Unlock ACS global strings that were locked when the snapshot was made.
|
||||
Behaviors.UnlockLevelVarStrings(levelnum);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
@ -1968,23 +1823,6 @@ void G_ReadVisited(FSerializer &arc)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD(listsnapshots)
|
||||
{
|
||||
for (unsigned i = 0; i < wadlevelinfos.Size(); ++i)
|
||||
{
|
||||
FCompressedBuffer *snapshot = &wadlevelinfos[i].Snapshot;
|
||||
if (snapshot->mBuffer != nullptr)
|
||||
{
|
||||
Printf("%s (%u -> %u bytes)\n", wadlevelinfos[i].MapName.GetChars(), snapshot->mCompressedSize, snapshot->mSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void P_WriteACSDefereds (FSerializer &arc)
|
||||
{
|
||||
bool found = false;
|
||||
|
|
@ -2322,64 +2160,3 @@ int IsPointInMap(FLevelLocals *Level, double x, double y, double z)
|
|||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Lists all currently defined maps
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD(listmaps)
|
||||
{
|
||||
for(unsigned i = 0; i < wadlevelinfos.Size(); i++)
|
||||
{
|
||||
level_info_t *info = &wadlevelinfos[i];
|
||||
MapData *map = P_OpenMapData(info->MapName, true);
|
||||
|
||||
if (map != NULL)
|
||||
{
|
||||
Printf("%s: '%s' (%s)\n", info->MapName.GetChars(), info->LookupLevelName().GetChars(),
|
||||
Wads.GetWadName(Wads.GetLumpFile(map->lumpnum)));
|
||||
delete map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// For testing sky fog sheets
|
||||
//
|
||||
//==========================================================================
|
||||
CCMD(skyfog)
|
||||
{
|
||||
if (argv.argc()>1)
|
||||
{
|
||||
// Do this only on the primary level.
|
||||
primaryLevel->skyfog = MAX(0, (int)strtoull(argv[1], NULL, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// ZScript counterpart to ACS ChangeSky, uses TextureIDs
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_ACTION_FUNCTION(FLevelLocals, ChangeSky)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
||||
PARAM_INT(sky1);
|
||||
PARAM_INT(sky2);
|
||||
self->skytexture1 = FSetTextureID(sky1);
|
||||
self->skytexture2 = FSetTextureID(sky2);
|
||||
InitSkyMap(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(FLevelLocals, StartIntermission)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
||||
PARAM_NAME(seq);
|
||||
PARAM_INT(state);
|
||||
F_StartIntermission(seq, (uint8_t)state);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue