mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
thinker_era
A first pass in attempts to fix crashes when ACS causes map changes. Frustratingly still got a crash, but I think this is definitely the right foundation to work with.
This commit is contained in:
parent
6e6c0cd71f
commit
dce2c73df1
5 changed files with 31 additions and 4 deletions
|
|
@ -350,10 +350,13 @@ ACSVM::Word Environment::callSpecImpl
|
||||||
|
|
||||||
activator_t *activator = static_cast<activator_t *>(Z_Calloc(sizeof(activator_t), PU_LEVEL, nullptr));
|
activator_t *activator = static_cast<activator_t *>(Z_Calloc(sizeof(activator_t), PU_LEVEL, nullptr));
|
||||||
auto __ = srb2::finally(
|
auto __ = srb2::finally(
|
||||||
[activator]()
|
[info, activator]()
|
||||||
{
|
{
|
||||||
P_SetTarget(&activator->mo, NULL);
|
if (info->thread_era == thinker_era)
|
||||||
Z_Free(activator);
|
{
|
||||||
|
P_SetTarget(&activator->mo, NULL);
|
||||||
|
Z_Free(activator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ enum acs_tagType_e
|
||||||
class ThreadInfo : public ACSVM::ThreadInfo
|
class ThreadInfo : public ACSVM::ThreadInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
UINT32 thread_era; // If equal to thinker_era, mobj pointers are safe.
|
||||||
mobj_t *mo; // Object that activated this thread.
|
mobj_t *mo; // Object that activated this thread.
|
||||||
line_t *line; // Linedef that activated this thread.
|
line_t *line; // Linedef that activated this thread.
|
||||||
UINT8 side; // Front / back side of said linedef.
|
UINT8 side; // Front / back side of said linedef.
|
||||||
|
|
@ -67,6 +68,7 @@ public:
|
||||||
bool fromLineSpecial; // Called from P_ProcessLineSpecial.
|
bool fromLineSpecial; // Called from P_ProcessLineSpecial.
|
||||||
|
|
||||||
ThreadInfo() :
|
ThreadInfo() :
|
||||||
|
thread_era { thinker_era },
|
||||||
mo{ nullptr },
|
mo{ nullptr },
|
||||||
line{ nullptr },
|
line{ nullptr },
|
||||||
side{ 0 },
|
side{ 0 },
|
||||||
|
|
@ -77,6 +79,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadInfo(const ThreadInfo &info) :
|
ThreadInfo(const ThreadInfo &info) :
|
||||||
|
thread_era { thinker_era },
|
||||||
mo{ nullptr },
|
mo{ nullptr },
|
||||||
line{ info.line },
|
line{ info.line },
|
||||||
side{ info.side },
|
side{ info.side },
|
||||||
|
|
@ -88,6 +91,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadInfo(const activator_t *activator) :
|
ThreadInfo(const activator_t *activator) :
|
||||||
|
thread_era { thinker_era },
|
||||||
mo{ nullptr },
|
mo{ nullptr },
|
||||||
line{ activator->line },
|
line{ activator->line },
|
||||||
side{ activator->side },
|
side{ activator->side },
|
||||||
|
|
@ -100,11 +104,15 @@ public:
|
||||||
|
|
||||||
~ThreadInfo()
|
~ThreadInfo()
|
||||||
{
|
{
|
||||||
P_SetTarget(&mo, nullptr);
|
if (thread_era == thinker_era)
|
||||||
|
{
|
||||||
|
P_SetTarget(&mo, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadInfo &operator = (const ThreadInfo &info)
|
ThreadInfo &operator = (const ThreadInfo &info)
|
||||||
{
|
{
|
||||||
|
thread_era = thinker_era;
|
||||||
P_SetTarget(&mo, info.mo);
|
P_SetTarget(&mo, info.mo);
|
||||||
line = info.line;
|
line = info.line;
|
||||||
side = info.side;
|
side = info.side;
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ typedef enum
|
||||||
extern thinker_t thlist[];
|
extern thinker_t thlist[];
|
||||||
|
|
||||||
void P_InitThinkers(void);
|
void P_InitThinkers(void);
|
||||||
|
void P_InvalidateThinkersWithoutInit(void);
|
||||||
void P_AddThinker(const thinklistnum_t n, thinker_t *thinker);
|
void P_AddThinker(const thinklistnum_t n, thinker_t *thinker);
|
||||||
void P_RemoveThinker(thinker_t *thinker);
|
void P_RemoveThinker(thinker_t *thinker);
|
||||||
void P_UnlinkThinker(thinker_t *thinker);
|
void P_UnlinkThinker(thinker_t *thinker);
|
||||||
|
|
|
||||||
13
src/p_tick.c
13
src/p_tick.c
|
|
@ -53,6 +53,8 @@
|
||||||
tic_t leveltime;
|
tic_t leveltime;
|
||||||
boolean thinkersCompleted;
|
boolean thinkersCompleted;
|
||||||
|
|
||||||
|
UINT32 thinker_era = 0;
|
||||||
|
|
||||||
static boolean g_freezeCheat;
|
static boolean g_freezeCheat;
|
||||||
static boolean g_freezeLevel;
|
static boolean g_freezeLevel;
|
||||||
|
|
||||||
|
|
@ -276,6 +278,8 @@ void P_InitThinkers(void)
|
||||||
{
|
{
|
||||||
UINT8 i;
|
UINT8 i;
|
||||||
|
|
||||||
|
P_InvalidateThinkersWithoutInit();
|
||||||
|
|
||||||
for (i = 0; i < NUM_THINKERLISTS; i++)
|
for (i = 0; i < NUM_THINKERLISTS; i++)
|
||||||
{
|
{
|
||||||
thlist[i].prev = thlist[i].next = &thlist[i];
|
thlist[i].prev = thlist[i].next = &thlist[i];
|
||||||
|
|
@ -297,6 +301,15 @@ void P_InitThinkers(void)
|
||||||
Obj_ResetCheckpoints();
|
Obj_ResetCheckpoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// P_InvalidateThinkersWithoutInit
|
||||||
|
//
|
||||||
|
|
||||||
|
void P_InvalidateThinkersWithoutInit(void)
|
||||||
|
{
|
||||||
|
thinker_era++;
|
||||||
|
}
|
||||||
|
|
||||||
// Adds a new thinker at the end of the list.
|
// Adds a new thinker at the end of the list.
|
||||||
void P_AddThinker(const thinklistnum_t n, thinker_t *thinker)
|
void P_AddThinker(const thinklistnum_t n, thinker_t *thinker)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ void P_PreTicker(INT32 frames);
|
||||||
void P_DoTeamscrambling(void);
|
void P_DoTeamscrambling(void);
|
||||||
void P_RemoveThinkerDelayed(thinker_t *thinker); //killed
|
void P_RemoveThinkerDelayed(thinker_t *thinker); //killed
|
||||||
|
|
||||||
|
extern UINT32 thinker_era;
|
||||||
|
|
||||||
mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target
|
mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
, const char *source_file, int source_line
|
, const char *source_file, int source_line
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue