mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- moved the global spot state into FLevelLocals.
This way it doesn't even have to be a thinker.
This commit is contained in:
parent
7b16433e97
commit
dab68184f5
14 changed files with 39 additions and 44 deletions
|
@ -1968,6 +1968,7 @@ void FLevelLocals::Tick ()
|
||||||
|
|
||||||
void FLevelLocals::Mark()
|
void FLevelLocals::Mark()
|
||||||
{
|
{
|
||||||
|
GC::Mark(SpotState);
|
||||||
GC::Mark(FraggleScriptThinker);
|
GC::Mark(FraggleScriptThinker);
|
||||||
canvasTextureInfo.Mark();
|
canvasTextureInfo.Mark();
|
||||||
for (auto &s : sectorPortals)
|
for (auto &s : sectorPortals)
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "r_data/r_canvastexture.h"
|
#include "r_data/r_canvastexture.h"
|
||||||
|
|
||||||
class DFraggleThinker;
|
class DFraggleThinker;
|
||||||
|
class DSpotState;
|
||||||
|
|
||||||
struct FLevelData
|
struct FLevelData
|
||||||
{
|
{
|
||||||
|
@ -202,7 +203,9 @@ struct FLevelLocals : public FLevelData
|
||||||
FDynamicLight *lights;
|
FDynamicLight *lights;
|
||||||
|
|
||||||
// links to global game objects
|
// links to global game objects
|
||||||
TObjPtr<DFraggleThinker *> FraggleScriptThinker;
|
TArray<TObjPtr<AActor *>> CorpseQueue;
|
||||||
|
TObjPtr<DFraggleThinker *> FraggleScriptThinker = nullptr;
|
||||||
|
TObjPtr<DSpotState *> SpotState = nullptr;
|
||||||
|
|
||||||
bool IsJumpingAllowed() const;
|
bool IsJumpingAllowed() const;
|
||||||
bool IsCrouchingAllowed() const;
|
bool IsCrouchingAllowed() const;
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
static FRandom pr_spot ("SpecialSpot");
|
static FRandom pr_spot ("SpecialSpot");
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DSpotState, false, false)
|
IMPLEMENT_CLASS(DSpotState, false, false)
|
||||||
TObjPtr<DSpotState*> DSpotState::SpotState;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -198,16 +197,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FSpotList &list, FSpot
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
DSpotState::DSpotState ()
|
DSpotState::DSpotState ()
|
||||||
: DThinker (STAT_INFO)
|
|
||||||
{
|
{
|
||||||
if (SpotState)
|
|
||||||
{
|
|
||||||
I_Error ("Only one SpotState is allowed to exist at a time.\nCheck your code.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SpotState = this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -219,8 +209,6 @@ DSpotState::DSpotState ()
|
||||||
void DSpotState::OnDestroy ()
|
void DSpotState::OnDestroy ()
|
||||||
{
|
{
|
||||||
SpotLists.Reset();
|
SpotLists.Reset();
|
||||||
|
|
||||||
SpotState = NULL;
|
|
||||||
Super::OnDestroy();
|
Super::OnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,18 +228,6 @@ void DSpotState::Tick ()
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
DSpotState *DSpotState::GetSpotState(bool create)
|
|
||||||
{
|
|
||||||
if (SpotState == NULL && create) SpotState = Create<DSpotState>();
|
|
||||||
return SpotState;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
FSpotList *DSpotState::FindSpotList(PClassActor *type)
|
FSpotList *DSpotState::FindSpotList(PClassActor *type)
|
||||||
{
|
{
|
||||||
if (type == nullptr) return nullptr;
|
if (type == nullptr) return nullptr;
|
||||||
|
|
|
@ -7,10 +7,9 @@
|
||||||
struct FSpotList;
|
struct FSpotList;
|
||||||
|
|
||||||
|
|
||||||
class DSpotState : public DThinker
|
class DSpotState : public DObject
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(DSpotState, DThinker)
|
DECLARE_CLASS(DSpotState, DObject)
|
||||||
static TObjPtr<DSpotState*> SpotState;
|
|
||||||
TArray<FSpotList> SpotLists;
|
TArray<FSpotList> SpotLists;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -2981,6 +2981,8 @@ enum T_Flags
|
||||||
TF_SENSITIVEZ = 0x00000800, // Fail if the actor wouldn't fit in the position (for Z).
|
TF_SENSITIVEZ = 0x00000800, // Fail if the actor wouldn't fit in the position (for Z).
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DSpotState *GetSpotState(FLevelLocals *self, int create);
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(AActor, A_Teleport)
|
DEFINE_ACTION_FUNCTION(AActor, A_Teleport)
|
||||||
{
|
{
|
||||||
PARAM_ACTION_PROLOGUE(AActor);
|
PARAM_ACTION_PROLOGUE(AActor);
|
||||||
|
@ -3037,7 +3039,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Teleport)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DSpotState *state = DSpotState::GetSpotState();
|
DSpotState *state = GetSpotState(&level, false);
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
{
|
{
|
||||||
return numret;
|
return numret;
|
||||||
|
|
|
@ -976,6 +976,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
||||||
("level.bodyqueslot", level.bodyqueslot)
|
("level.bodyqueslot", level.bodyqueslot)
|
||||||
("level.spawnindex", level.spawnindex)
|
("level.spawnindex", level.spawnindex)
|
||||||
.Array("level.bodyque", level.bodyque, level.BODYQUESIZE)
|
.Array("level.bodyque", level.bodyque, level.BODYQUESIZE)
|
||||||
|
("level.spotstate", level.SpotState)
|
||||||
("level.fragglethinker", level.FraggleScriptThinker);
|
("level.fragglethinker", level.FraggleScriptThinker);
|
||||||
|
|
||||||
// Hub transitions must keep the current total time
|
// Hub transitions must keep the current total time
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
#include "scripting/vm/vm.h"
|
#include "scripting/vm/vm.h"
|
||||||
#include "fragglescript/t_fs.h"
|
#include "fragglescript/t_fs.h"
|
||||||
|
#include "a_specialspot.h"
|
||||||
#include "maploader/maploader.h"
|
#include "maploader/maploader.h"
|
||||||
|
|
||||||
void P_ClearUDMFKeys();
|
void P_ClearUDMFKeys();
|
||||||
|
@ -273,6 +274,7 @@ void FLevelLocals::ClearLevelData()
|
||||||
}
|
}
|
||||||
ClearPortals();
|
ClearPortals();
|
||||||
|
|
||||||
|
SpotState = nullptr;
|
||||||
canvasTextureInfo.EmptyList();
|
canvasTextureInfo.EmptyList();
|
||||||
sections.Clear();
|
sections.Clear();
|
||||||
segs.Clear();
|
segs.Clear();
|
||||||
|
|
|
@ -1957,13 +1957,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(FWeaponSlots, SetupWeaponSlots, FWeaponSlots::Setu
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_NATIVE(DSpotState, GetSpotState, DSpotState::GetSpotState)
|
|
||||||
{
|
|
||||||
PARAM_PROLOGUE;
|
|
||||||
PARAM_BOOL(create);
|
|
||||||
ACTION_RETURN_OBJECT(DSpotState::GetSpotState(create));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void AddSpot(DSpotState *state, AActor *spot)
|
static void AddSpot(DSpotState *state, AActor *spot)
|
||||||
{
|
{
|
||||||
state->AddSpot(spot);
|
state->AddSpot(spot);
|
||||||
|
@ -2506,6 +2499,20 @@ DEFINE_ACTION_FUNCTION_NATIVE(DHUDFont, Create, CreateHudFont)
|
||||||
//
|
//
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
|
|
||||||
|
DSpotState *GetSpotState(FLevelLocals *self, int create)
|
||||||
|
{
|
||||||
|
if (create && self->SpotState == nullptr) self->SpotState = Create<DSpotState>();
|
||||||
|
GC::WriteBarrier(self->SpotState);
|
||||||
|
return self->SpotState;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetSpotState, GetSpotState)
|
||||||
|
{
|
||||||
|
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
||||||
|
PARAM_INT(create);
|
||||||
|
ACTION_RETURN_POINTER(GetSpotState(self, create));
|
||||||
|
}
|
||||||
|
|
||||||
static void FormatMapName(FLevelLocals *self, int cr, FString *result)
|
static void FormatMapName(FLevelLocals *self, int cr, FString *result)
|
||||||
{
|
{
|
||||||
char mapnamecolor[3] = { '\34', char(cr + 'A'), 0 };
|
char mapnamecolor[3] = { '\34', char(cr + 'A'), 0 };
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version "3.7"
|
version "3.8"
|
||||||
#include "zscript/base.txt"
|
#include "zscript/base.txt"
|
||||||
#include "zscript/sounddata.txt"
|
#include "zscript/sounddata.txt"
|
||||||
#include "zscript/mapdata.txt"
|
#include "zscript/mapdata.txt"
|
||||||
|
|
|
@ -687,6 +687,7 @@ struct LevelLocals native
|
||||||
native bool IsCrouchingAllowed() const;
|
native bool IsCrouchingAllowed() const;
|
||||||
native bool IsFreelookAllowed() const;
|
native bool IsFreelookAllowed() const;
|
||||||
native void StartIntermission(Name type, int state) const;
|
native void StartIntermission(Name type, int state) const;
|
||||||
|
native SpotState GetSpotState(bool create = true);
|
||||||
|
|
||||||
native static clearscope bool IsPointInMap(vector3 p);
|
native static clearscope bool IsPointInMap(vector3 p);
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ extend class Actor
|
||||||
|
|
||||||
void A_BrainSpit(class<Actor> spawntype = null)
|
void A_BrainSpit(class<Actor> spawntype = null)
|
||||||
{
|
{
|
||||||
SpotState spstate = SpotState.GetSpotState();
|
SpotState spstate = Level.GetSpotState();
|
||||||
Actor targ;
|
Actor targ;
|
||||||
Actor spit;
|
Actor spit;
|
||||||
bool isdefault = false;
|
bool isdefault = false;
|
||||||
|
|
|
@ -293,7 +293,7 @@ class Sorcerer2 : Actor
|
||||||
|
|
||||||
void DSparilTeleport ()
|
void DSparilTeleport ()
|
||||||
{
|
{
|
||||||
SpotState state = SpotState.GetSpotState();
|
SpotState state = Level.GetSpotState();
|
||||||
if (state == null) return;
|
if (state == null) return;
|
||||||
|
|
||||||
Actor spot = state.GetSpotWithMinMaxDistance("BossSpot", pos.x, pos.y, 128, 0);
|
Actor spot = state.GetSpotWithMinMaxDistance("BossSpot", pos.x, pos.y, 128, 0);
|
||||||
|
|
|
@ -265,7 +265,7 @@ class Inventory : Actor
|
||||||
if (SpawnPointClass != NULL)
|
if (SpawnPointClass != NULL)
|
||||||
{
|
{
|
||||||
Actor spot = NULL;
|
Actor spot = NULL;
|
||||||
let state = SpotState.GetSpotState();
|
let state = Level.GetSpotState();
|
||||||
|
|
||||||
if (state != NULL) spot = state.GetRandomSpot(SpawnPointClass, false);
|
if (state != NULL) spot = state.GetRandomSpot(SpawnPointClass, false);
|
||||||
if (spot != NULL)
|
if (spot != NULL)
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
class SpotState : Object native
|
class SpotState : Object native
|
||||||
{
|
{
|
||||||
native static SpotState GetSpotState(bool create = true);
|
deprecated ("3.8") static SpotState GetSpotState(bool create = true)
|
||||||
|
{
|
||||||
|
return level.GetSpotState(create);
|
||||||
|
}
|
||||||
native SpecialSpot GetNextInList(class<Actor> type, int skipcounter);
|
native SpecialSpot GetNextInList(class<Actor> type, int skipcounter);
|
||||||
native SpecialSpot GetSpotWithMinMaxDistance(Class<Actor> type, double x, double y, double mindist, double maxdist);
|
native SpecialSpot GetSpotWithMinMaxDistance(Class<Actor> type, double x, double y, double mindist, double maxdist);
|
||||||
native SpecialSpot GetRandomSpot(class<Actor> type, bool onlyonce);
|
native SpecialSpot GetRandomSpot(class<Actor> type, bool onlyonce);
|
||||||
|
@ -13,7 +16,7 @@ class SpecialSpot : Actor
|
||||||
{
|
{
|
||||||
override void BeginPlay()
|
override void BeginPlay()
|
||||||
{
|
{
|
||||||
let sstate = SpotState.GetSpotState();
|
let sstate = Level.GetSpotState();
|
||||||
if (sstate != NULL) sstate.AddSpot(self);
|
if (sstate != NULL) sstate.AddSpot(self);
|
||||||
Super.BeginPlay();
|
Super.BeginPlay();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +29,7 @@ class SpecialSpot : Actor
|
||||||
|
|
||||||
override void OnDestroy()
|
override void OnDestroy()
|
||||||
{
|
{
|
||||||
let sstate = SpotState.GetSpotState(false);
|
let sstate = Level.GetSpotState(false);
|
||||||
if (sstate != NULL) sstate.RemoveSpot(self);
|
if (sstate != NULL) sstate.RemoveSpot(self);
|
||||||
Super.OnDestroy();
|
Super.OnDestroy();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +43,7 @@ class SpecialSpot : Actor
|
||||||
void A_SpawnSingleItem(class<Actor> cls, int fail_sp = 0, int fail_co = 0, int fail_dm = 0)
|
void A_SpawnSingleItem(class<Actor> cls, int fail_sp = 0, int fail_co = 0, int fail_dm = 0)
|
||||||
{
|
{
|
||||||
Actor spot = NULL;
|
Actor spot = NULL;
|
||||||
let state = SpotState.GetSpotState();
|
let state = Level.GetSpotState();
|
||||||
|
|
||||||
if (state != NULL) spot = state.GetRandomSpot(GetClass(), true);
|
if (state != NULL) spot = state.GetRandomSpot(GetClass(), true);
|
||||||
if (spot == NULL) return;
|
if (spot == NULL) return;
|
||||||
|
|
Loading…
Reference in a new issue