2016-03-01 15:47:10 +00:00
|
|
|
/*
|
|
|
|
** p_acs.h
|
|
|
|
** ACS script stuff
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2012 Randy Heit
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __P_ACS_H__
|
|
|
|
#define __P_ACS_H__
|
|
|
|
|
|
|
|
#include "doomtype.h"
|
2019-01-06 09:24:27 +00:00
|
|
|
#include "dthinker.h"
|
2019-01-31 18:38:04 +00:00
|
|
|
#include "doomerrors.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
#define LOCAL_SIZE 20
|
|
|
|
#define NUM_MAPVARS 128
|
|
|
|
|
|
|
|
class FFont;
|
2018-03-11 17:32:00 +00:00
|
|
|
class FileReader;
|
2016-09-21 10:19:13 +00:00
|
|
|
struct line_t;
|
2018-11-24 12:06:01 +00:00
|
|
|
class FSerializer;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NUM_WORLDVARS = 256,
|
|
|
|
NUM_GLOBALVARS = 64
|
|
|
|
};
|
|
|
|
|
|
|
|
struct InitIntToZero
|
|
|
|
{
|
|
|
|
void Init(int &v)
|
|
|
|
{
|
|
|
|
v = 0;
|
|
|
|
}
|
|
|
|
};
|
2017-03-03 18:35:08 +00:00
|
|
|
typedef TMap<int32_t, int32_t, THashTraits<int32_t>, InitIntToZero> FWorldGlobalArray;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-02-03 12:39:01 +00:00
|
|
|
// Type of elements count is unsigned int instead of size_t to match ACSStringPool interface
|
|
|
|
template <typename T, unsigned int N>
|
|
|
|
struct BoundsCheckingArray
|
|
|
|
{
|
|
|
|
T &operator[](const unsigned int index)
|
|
|
|
{
|
|
|
|
if (index >= N)
|
|
|
|
{
|
|
|
|
I_Error("Out of bounds memory access in ACS VM");
|
|
|
|
}
|
|
|
|
|
|
|
|
return buffer[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
T *Pointer() { return buffer; }
|
|
|
|
unsigned int Size() const { return N; }
|
|
|
|
|
|
|
|
void Fill(const T &value) { std::fill(std::begin(buffer), std::end(buffer), value); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
T buffer[N];
|
|
|
|
};
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// ACS variables with global scope
|
2018-02-03 12:39:01 +00:00
|
|
|
extern BoundsCheckingArray<int32_t, NUM_GLOBALVARS> ACS_GlobalVars;
|
|
|
|
extern BoundsCheckingArray<FWorldGlobalArray, NUM_GLOBALVARS> ACS_GlobalArrays;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
#define LIBRARYID_MASK 0xFFF00000
|
|
|
|
#define LIBRARYID_SHIFT 20
|
|
|
|
|
|
|
|
// Global ACS string table
|
|
|
|
#define STRPOOL_LIBRARYID (INT_MAX >> LIBRARYID_SHIFT)
|
|
|
|
#define STRPOOL_LIBRARYID_OR (STRPOOL_LIBRARYID << LIBRARYID_SHIFT)
|
|
|
|
|
|
|
|
class ACSStringPool
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ACSStringPool();
|
|
|
|
int AddString(const char *str);
|
|
|
|
int AddString(FString &str);
|
|
|
|
const char *GetString(int strnum);
|
2019-01-06 08:37:11 +00:00
|
|
|
void LockString(int levelnum, int strnum);
|
2016-03-01 15:47:10 +00:00
|
|
|
void UnlockAll();
|
|
|
|
void MarkString(int strnum);
|
2019-01-06 08:37:11 +00:00
|
|
|
void LockStringArray(int levelnum, const int *strnum, unsigned int count);
|
2016-03-01 15:47:10 +00:00
|
|
|
void MarkStringArray(const int *strnum, unsigned int count);
|
|
|
|
void MarkStringMap(const FWorldGlobalArray &array);
|
|
|
|
void PurgeStrings();
|
|
|
|
void Clear();
|
|
|
|
void Dump() const;
|
2016-12-27 17:53:30 +00:00
|
|
|
void UnlockForLevel(int level) ;
|
2016-09-21 22:18:31 +00:00
|
|
|
void ReadStrings(FSerializer &file, const char *key);
|
2016-09-21 10:19:13 +00:00
|
|
|
void WriteStrings(FSerializer &file, const char *key) const;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int FindString(const char *str, size_t len, unsigned int h, unsigned int bucketnum);
|
|
|
|
int InsertString(FString &str, unsigned int h, unsigned int bucketnum);
|
|
|
|
void FindFirstFreeEntry(unsigned int base);
|
|
|
|
|
|
|
|
enum { NUM_BUCKETS = 251 };
|
|
|
|
enum { FREE_ENTRY = 0xFFFFFFFE }; // Stored in PoolEntry's Next field
|
|
|
|
enum { NO_ENTRY = 0xFFFFFFFF };
|
|
|
|
enum { MIN_GC_SIZE = 100 }; // Don't auto-collect until there are this many strings
|
|
|
|
struct PoolEntry
|
|
|
|
{
|
|
|
|
FString Str;
|
|
|
|
unsigned int Hash;
|
2018-04-01 11:35:49 +00:00
|
|
|
unsigned int Next = FREE_ENTRY;
|
2016-12-27 17:53:30 +00:00
|
|
|
bool Mark;
|
|
|
|
TArray<int> Locks;
|
|
|
|
|
2019-01-06 08:37:11 +00:00
|
|
|
void Lock(int levelnum);
|
|
|
|
void Unlock(int levelnum);
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
TArray<PoolEntry> Pool;
|
|
|
|
unsigned int PoolBuckets[NUM_BUCKETS];
|
|
|
|
unsigned int FirstFreeEntry;
|
|
|
|
};
|
|
|
|
extern ACSStringPool GlobalACSStrings;
|
|
|
|
|
|
|
|
void P_CollectACSGlobalStrings();
|
2016-09-21 22:18:31 +00:00
|
|
|
void P_ReadACSVars(FSerializer &);
|
2016-09-21 10:19:13 +00:00
|
|
|
void P_WriteACSVars(FSerializer &);
|
2016-03-01 15:47:10 +00:00
|
|
|
void P_ClearACSVars(bool);
|
|
|
|
|
|
|
|
struct ACSProfileInfo
|
|
|
|
{
|
|
|
|
unsigned long long TotalInstr;
|
|
|
|
unsigned int NumRuns;
|
|
|
|
unsigned int MinInstrPerRun;
|
|
|
|
unsigned int MaxInstrPerRun;
|
|
|
|
|
|
|
|
ACSProfileInfo();
|
|
|
|
void AddRun(unsigned int num_instr);
|
|
|
|
void Reset();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ProfileCollector
|
|
|
|
{
|
|
|
|
ACSProfileInfo *ProfileData;
|
|
|
|
class FBehavior *Module;
|
|
|
|
int Index;
|
|
|
|
};
|
|
|
|
|
2018-01-06 10:13:15 +00:00
|
|
|
class ACSLocalVariables
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ACSLocalVariables(TArray<int32_t> &variables)
|
|
|
|
: memory(&variables[0])
|
|
|
|
, count(variables.Size())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset(int32_t *const memory, const size_t count)
|
|
|
|
{
|
|
|
|
// TODO: pointer sanity check?
|
|
|
|
// TODO: constraints on count?
|
|
|
|
|
|
|
|
this->memory = memory;
|
|
|
|
this->count = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t& operator[](const size_t index)
|
|
|
|
{
|
|
|
|
if (index >= count)
|
|
|
|
{
|
|
|
|
I_Error("Out of bounds access to local variables in ACS VM");
|
|
|
|
}
|
|
|
|
|
|
|
|
return memory[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
const int32_t *GetPointer() const
|
|
|
|
{
|
|
|
|
return memory;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int32_t *memory;
|
|
|
|
size_t count;
|
|
|
|
};
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
struct ACSLocalArrayInfo
|
|
|
|
{
|
|
|
|
unsigned int Size;
|
|
|
|
int Offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ACSLocalArrays
|
|
|
|
{
|
|
|
|
unsigned int Count;
|
|
|
|
ACSLocalArrayInfo *Info;
|
|
|
|
|
|
|
|
ACSLocalArrays()
|
|
|
|
{
|
|
|
|
Count = 0;
|
|
|
|
Info = NULL;
|
|
|
|
}
|
|
|
|
~ACSLocalArrays()
|
|
|
|
{
|
|
|
|
if (Info != NULL)
|
|
|
|
{
|
|
|
|
delete[] Info;
|
|
|
|
Info = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bounds-checking Set and Get for local arrays
|
2018-01-06 10:13:15 +00:00
|
|
|
void Set(ACSLocalVariables &locals, int arraynum, int arrayentry, int value)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if ((unsigned int)arraynum < Count &&
|
|
|
|
(unsigned int)arrayentry < Info[arraynum].Size)
|
|
|
|
{
|
|
|
|
locals[Info[arraynum].Offset + arrayentry] = value;
|
|
|
|
}
|
|
|
|
}
|
2018-01-06 10:13:15 +00:00
|
|
|
int Get(ACSLocalVariables &locals, int arraynum, int arrayentry)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if ((unsigned int)arraynum < Count &&
|
|
|
|
(unsigned int)arrayentry < Info[arraynum].Size)
|
|
|
|
{
|
|
|
|
return locals[Info[arraynum].Offset + arrayentry];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// The in-memory version
|
|
|
|
struct ScriptPtr
|
|
|
|
{
|
|
|
|
int Number;
|
2017-03-08 14:20:00 +00:00
|
|
|
uint32_t Address;
|
|
|
|
uint8_t Type;
|
|
|
|
uint8_t ArgCount;
|
|
|
|
uint16_t VarCount;
|
|
|
|
uint16_t Flags;
|
2016-03-01 15:47:10 +00:00
|
|
|
ACSLocalArrays LocalArrays;
|
|
|
|
|
|
|
|
ACSProfileInfo ProfileData;
|
|
|
|
};
|
|
|
|
|
|
|
|
// The present ZDoom version
|
|
|
|
struct ScriptPtr3
|
|
|
|
{
|
2017-03-08 14:20:00 +00:00
|
|
|
int16_t Number;
|
|
|
|
uint8_t Type;
|
|
|
|
uint8_t ArgCount;
|
|
|
|
uint32_t Address;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// The intermediate ZDoom version
|
|
|
|
struct ScriptPtr1
|
|
|
|
{
|
2017-03-08 14:20:00 +00:00
|
|
|
int16_t Number;
|
|
|
|
uint16_t Type;
|
|
|
|
uint32_t Address;
|
|
|
|
uint32_t ArgCount;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// The old Hexen version
|
|
|
|
struct ScriptPtr2
|
|
|
|
{
|
2017-03-08 14:20:00 +00:00
|
|
|
uint32_t Number; // Type is Number / 1000
|
|
|
|
uint32_t Address;
|
|
|
|
uint32_t ArgCount;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ScriptFlagsPtr
|
|
|
|
{
|
2017-03-08 14:20:00 +00:00
|
|
|
uint16_t Number;
|
|
|
|
uint16_t Flags;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ScriptFunctionInFile
|
|
|
|
{
|
2017-03-08 14:20:00 +00:00
|
|
|
uint8_t ArgCount;
|
|
|
|
uint8_t LocalCount;
|
|
|
|
uint8_t HasReturnValue;
|
|
|
|
uint8_t ImportNum;
|
|
|
|
uint32_t Address;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ScriptFunction
|
|
|
|
{
|
2017-03-08 14:20:00 +00:00
|
|
|
uint8_t ArgCount;
|
|
|
|
uint8_t HasReturnValue;
|
|
|
|
uint8_t ImportNum;
|
2016-03-01 15:47:10 +00:00
|
|
|
int LocalCount;
|
2017-03-08 14:20:00 +00:00
|
|
|
uint32_t Address;
|
2016-03-01 15:47:10 +00:00
|
|
|
ACSLocalArrays LocalArrays;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Script types
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SCRIPT_Closed = 0,
|
|
|
|
SCRIPT_Open = 1,
|
|
|
|
SCRIPT_Respawn = 2,
|
|
|
|
SCRIPT_Death = 3,
|
|
|
|
SCRIPT_Enter = 4,
|
|
|
|
SCRIPT_Pickup = 5,
|
|
|
|
SCRIPT_BlueReturn = 6,
|
|
|
|
SCRIPT_RedReturn = 7,
|
|
|
|
SCRIPT_WhiteReturn = 8,
|
|
|
|
SCRIPT_Lightning = 12,
|
|
|
|
SCRIPT_Unloading = 13,
|
|
|
|
SCRIPT_Disconnect = 14,
|
|
|
|
SCRIPT_Return = 15,
|
2016-07-23 08:21:04 +00:00
|
|
|
SCRIPT_Event = 16, // [BB]
|
|
|
|
SCRIPT_Kill = 17, // [JM]
|
2016-08-29 14:45:28 +00:00
|
|
|
SCRIPT_Reopen = 18, // [Nash]
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Script flags
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SCRIPTF_Net = 0x0001 // Safe to "puke" in multiplayer
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ACSFormat { ACS_Old, ACS_Enhanced, ACS_LittleEnhanced, ACS_Unknown };
|
|
|
|
|
2019-01-05 17:19:35 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
class FBehavior
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FBehavior ();
|
|
|
|
~FBehavior ();
|
2019-01-28 21:04:33 +00:00
|
|
|
bool Init(FLevelLocals *l, int lumpnum, FileReader * fr = NULL, int len = 0);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
bool IsGood ();
|
2017-03-08 14:20:00 +00:00
|
|
|
uint8_t *FindChunk (uint32_t id) const;
|
|
|
|
uint8_t *NextChunk (uint8_t *chunk) const;
|
2016-03-01 15:47:10 +00:00
|
|
|
const ScriptPtr *FindScript (int number) const;
|
2017-03-08 14:20:00 +00:00
|
|
|
void StartTypedScripts (uint16_t type, AActor *activator, bool always, int arg1, bool runNow);
|
|
|
|
uint32_t PC2Ofs (int *pc) const { return (uint32_t)((uint8_t *)pc - Data); }
|
|
|
|
int *Ofs2PC (uint32_t ofs) const { return (int *)(Data + ofs); }
|
|
|
|
int *Jump2PC (uint32_t jumpPoint) const { return Ofs2PC(JumpPoints[jumpPoint]); }
|
2016-03-01 15:47:10 +00:00
|
|
|
ACSFormat GetFormat() const { return Format; }
|
|
|
|
ScriptFunction *GetFunction (int funcnum, FBehavior *&module) const;
|
|
|
|
int GetArrayVal (int arraynum, int index) const;
|
|
|
|
void SetArrayVal (int arraynum, int index, int value);
|
|
|
|
inline bool CopyStringToArray(int arraynum, int index, int maxLength, const char * string);
|
|
|
|
|
|
|
|
int FindFunctionName (const char *funcname) const;
|
|
|
|
int FindMapVarName (const char *varname) const;
|
|
|
|
int FindMapArray (const char *arrayname) const;
|
|
|
|
int GetLibraryID () const { return LibraryID; }
|
|
|
|
int *GetScriptAddress (const ScriptPtr *ptr) const { return (int *)(ptr->Address + Data); }
|
|
|
|
int GetScriptIndex (const ScriptPtr *ptr) const { ptrdiff_t index = ptr - Scripts; return index >= NumScripts ? -1 : (int)index; }
|
|
|
|
ScriptPtr *GetScriptPtr(int index) const { return index >= 0 && index < NumScripts ? &Scripts[index] : NULL; }
|
|
|
|
int GetLumpNum() const { return LumpNum; }
|
|
|
|
int GetDataSize() const { return DataSize; }
|
|
|
|
const char *GetModuleName() const { return ModuleName; }
|
|
|
|
ACSProfileInfo *GetFunctionProfileData(int index) { return index >= 0 && index < NumFunctions ? &FunctionProfileData[index] : NULL; }
|
|
|
|
ACSProfileInfo *GetFunctionProfileData(ScriptFunction *func) { return GetFunctionProfileData((int)(func - (ScriptFunction *)Functions)); }
|
2017-03-08 14:20:00 +00:00
|
|
|
const char *LookupString (uint32_t index) const;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-02-03 12:39:01 +00:00
|
|
|
BoundsCheckingArray<int32_t *, NUM_MAPVARS> MapVars;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct ArrayInfo;
|
|
|
|
|
|
|
|
ACSFormat Format;
|
|
|
|
|
2019-01-29 23:27:05 +00:00
|
|
|
FLevelLocals *Level;
|
2016-03-01 15:47:10 +00:00
|
|
|
int LumpNum;
|
2017-03-08 14:20:00 +00:00
|
|
|
uint8_t *Data;
|
2016-03-01 15:47:10 +00:00
|
|
|
int DataSize;
|
2017-03-08 14:20:00 +00:00
|
|
|
uint8_t *Chunks;
|
2016-03-01 15:47:10 +00:00
|
|
|
ScriptPtr *Scripts;
|
|
|
|
int NumScripts;
|
|
|
|
ScriptFunction *Functions;
|
|
|
|
ACSProfileInfo *FunctionProfileData;
|
|
|
|
int NumFunctions;
|
|
|
|
ArrayInfo *ArrayStore;
|
|
|
|
int NumArrays;
|
|
|
|
ArrayInfo **Arrays;
|
|
|
|
int NumTotalArrays;
|
2017-03-08 14:20:00 +00:00
|
|
|
uint32_t StringTable;
|
2017-03-03 18:35:08 +00:00
|
|
|
int32_t MapVarStore[NUM_MAPVARS];
|
2016-03-01 15:47:10 +00:00
|
|
|
TArray<FBehavior *> Imports;
|
2017-03-08 14:20:00 +00:00
|
|
|
uint32_t LibraryID;
|
2016-03-01 15:47:10 +00:00
|
|
|
char ModuleName[9];
|
|
|
|
TArray<int> JumpPoints;
|
|
|
|
|
|
|
|
void LoadScriptsDirectory ();
|
|
|
|
|
2016-04-11 08:46:30 +00:00
|
|
|
static int SortScripts (const void *a, const void *b);
|
2016-03-01 15:47:10 +00:00
|
|
|
void UnencryptStrings ();
|
2017-03-08 14:20:00 +00:00
|
|
|
void UnescapeStringTable(uint8_t *chunkstart, uint8_t *datastart, bool haspadding);
|
|
|
|
int FindStringInChunk (uint32_t *chunk, const char *varname) const;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-20 09:35:25 +00:00
|
|
|
void SerializeVars (FSerializer &arc);
|
2017-03-03 18:35:08 +00:00
|
|
|
void SerializeVarSet (FSerializer &arc, int32_t *vars, int max);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void MarkMapVarStrings() const;
|
2019-01-06 08:37:11 +00:00
|
|
|
void LockMapVarStrings(int levelnum) const;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2019-01-05 17:19:35 +00:00
|
|
|
friend struct FBehaviorContainer;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FBehaviorContainer
|
|
|
|
{
|
2019-01-28 21:04:33 +00:00
|
|
|
FLevelLocals *Level;
|
2019-01-05 17:19:35 +00:00
|
|
|
TArray<FBehavior *> StaticModules;
|
|
|
|
|
2019-01-28 21:04:33 +00:00
|
|
|
FBehaviorContainer(FLevelLocals *l) : Level(l) {}
|
|
|
|
|
2019-01-05 17:19:35 +00:00
|
|
|
FBehavior *LoadModule(int lumpnum, FileReader *fr = nullptr, int len = 0);
|
|
|
|
void LoadDefaultModules();
|
|
|
|
void UnloadModules();
|
|
|
|
bool CheckAllGood();
|
|
|
|
FBehavior *GetModule(int lib);
|
|
|
|
void SerializeModuleStates(FSerializer &arc);
|
|
|
|
void MarkLevelVarStrings();
|
2019-01-06 08:37:11 +00:00
|
|
|
void LockLevelVarStrings(int levelnum);
|
|
|
|
void UnlockLevelVarStrings(int levelnum);
|
2019-01-05 17:19:35 +00:00
|
|
|
|
|
|
|
const ScriptPtr *FindScript(int script, FBehavior *&module);
|
|
|
|
const char *LookupString(uint32_t index);
|
|
|
|
void StartTypedScripts(uint16_t type, AActor *activator, bool always, int arg1 = 0, bool runNow = false);
|
|
|
|
void StopMyScripts(AActor *actor);
|
2019-01-26 20:23:19 +00:00
|
|
|
void ArrangeScriptProfiles(TArray<ProfileCollector> &profiles);
|
|
|
|
void ArrangeFunctionProfiles(TArray<ProfileCollector> &profiles);
|
2019-01-05 17:19:35 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
2019-01-06 09:24:27 +00:00
|
|
|
class DLevelScript;
|
|
|
|
|
|
|
|
class DACSThinker : public DThinker
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(DACSThinker, DThinker)
|
|
|
|
HAS_OBJECT_POINTERS
|
|
|
|
public:
|
2019-01-27 00:49:20 +00:00
|
|
|
static const int DEFAULT_STAT = STAT_SCRIPTS;
|
2019-01-27 12:08:54 +00:00
|
|
|
void Construct() {}
|
2019-01-06 09:24:27 +00:00
|
|
|
~DACSThinker();
|
|
|
|
|
|
|
|
void Serialize(FSerializer &arc);
|
|
|
|
void Tick();
|
|
|
|
|
|
|
|
typedef TMap<int, DLevelScript *> ScriptMap;
|
|
|
|
ScriptMap RunningScripts; // Array of all synchronous scripts
|
|
|
|
|
|
|
|
void DumpScriptStatus();
|
|
|
|
void StopScriptsFor(AActor *actor);
|
|
|
|
|
|
|
|
private:
|
2019-01-27 12:08:54 +00:00
|
|
|
DLevelScript *LastScript = nullptr;
|
|
|
|
DLevelScript *Scripts = nullptr; // List of all running scripts
|
2019-01-06 09:24:27 +00:00
|
|
|
|
|
|
|
friend class DLevelScript;
|
|
|
|
friend class FBehavior;
|
|
|
|
friend struct FBehaviorContainer;
|
|
|
|
};
|
|
|
|
|
2019-01-05 17:19:35 +00:00
|
|
|
|
|
|
|
|
2019-01-06 08:37:11 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
#endif //__P_ACS_H__
|