2006-05-10 02:40:43 +00:00
|
|
|
#ifndef DOBJTYPE_H
|
|
|
|
#define DOBJTYPE_H
|
|
|
|
|
|
|
|
#ifndef __DOBJECT_H__
|
|
|
|
#error You must #include "dobject.h" to get dobjtype.h
|
|
|
|
#endif
|
|
|
|
|
2008-10-19 21:43:36 +00:00
|
|
|
#include "thingdef/thingdef_type.h"
|
|
|
|
|
2006-11-29 04:51:16 +00:00
|
|
|
// Symbol information -------------------------------------------------------
|
|
|
|
|
|
|
|
enum ESymbolType
|
|
|
|
{
|
|
|
|
SYM_Const,
|
2008-10-19 21:43:36 +00:00
|
|
|
SYM_Variable,
|
2009-09-23 00:24:47 +00:00
|
|
|
SYM_ActionFunction,
|
|
|
|
SYM_VMFunction
|
2006-11-29 04:51:16 +00:00
|
|
|
};
|
|
|
|
|
2009-09-16 01:39:44 +00:00
|
|
|
class PSymbol : public DObject
|
2006-11-29 04:51:16 +00:00
|
|
|
{
|
2009-09-16 01:39:44 +00:00
|
|
|
DECLARE_ABSTRACT_CLASS(PSymbol, DObject);
|
|
|
|
public:
|
2008-06-06 02:17:28 +00:00
|
|
|
virtual ~PSymbol();
|
|
|
|
|
2006-11-29 04:51:16 +00:00
|
|
|
ESymbolType SymbolType;
|
|
|
|
FName SymbolName;
|
2008-10-19 21:43:36 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
PSymbol(FName name, ESymbolType type) { SymbolType = type; SymbolName = name; }
|
2006-11-29 04:51:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A constant value ---------------------------------------------------------
|
|
|
|
|
2009-09-16 01:39:44 +00:00
|
|
|
class PSymbolConst : public PSymbol
|
2006-11-29 04:51:16 +00:00
|
|
|
{
|
2009-09-16 01:39:44 +00:00
|
|
|
DECLARE_CLASS(PSymbolConst, PSymbol);
|
|
|
|
public:
|
2008-10-19 21:43:36 +00:00
|
|
|
int ValueType;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
int Value;
|
|
|
|
double Float;
|
|
|
|
};
|
|
|
|
|
|
|
|
PSymbolConst(FName name) : PSymbol(name, SYM_Const) {}
|
2009-09-16 01:39:44 +00:00
|
|
|
PSymbolConst() : PSymbol(NAME_None, SYM_Const) {}
|
2008-10-19 21:43:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A variable ---------------------------------------------------------
|
|
|
|
|
2009-09-16 01:39:44 +00:00
|
|
|
class PSymbolVariable : public PSymbol
|
2008-10-19 21:43:36 +00:00
|
|
|
{
|
2009-09-16 01:39:44 +00:00
|
|
|
DECLARE_CLASS(PSymbolVariable, PSymbol);
|
|
|
|
public:
|
2008-10-19 21:43:36 +00:00
|
|
|
FExpressionType ValueType;
|
|
|
|
int size;
|
|
|
|
intptr_t offset;
|
|
|
|
|
|
|
|
PSymbolVariable(FName name) : PSymbol(name, SYM_Variable) {}
|
2009-09-16 01:39:44 +00:00
|
|
|
PSymbolVariable() : PSymbol(NAME_None, SYM_Variable) {}
|
2006-11-29 04:51:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// An action function -------------------------------------------------------
|
|
|
|
//
|
|
|
|
// The Arguments string is a string of characters as understood by
|
|
|
|
// the DECORATE parser:
|
|
|
|
//
|
|
|
|
// If the letter is uppercase, it is required. Lowercase letters are optional.
|
|
|
|
// i = integer
|
|
|
|
// f = fixed point
|
|
|
|
// s = sound name
|
|
|
|
// m = actor name
|
|
|
|
// t = string
|
|
|
|
// l = jump label
|
|
|
|
// c = color
|
|
|
|
// x = expression
|
|
|
|
// y = expression
|
|
|
|
// If the final character is a +, the previous parameter is repeated indefinitely,
|
|
|
|
// and an "imaginary" first parameter is inserted containing the total number of
|
|
|
|
// parameters passed.
|
2008-08-12 14:30:07 +00:00
|
|
|
struct FState;
|
2008-08-14 08:52:55 +00:00
|
|
|
struct StateCallData;
|
2009-01-06 00:03:18 +00:00
|
|
|
typedef void (*actionf_p)(AActor *self, AActor *stateowner, FState *state, int parameters, StateCallData *statecall);
|
2006-11-29 04:51:16 +00:00
|
|
|
|
2009-09-16 01:39:44 +00:00
|
|
|
class PSymbolActionFunction : public PSymbol
|
2006-11-29 04:51:16 +00:00
|
|
|
{
|
2009-09-16 01:39:44 +00:00
|
|
|
DECLARE_CLASS(PSymbolActionFunction, PSymbol);
|
|
|
|
public:
|
2006-11-29 04:51:16 +00:00
|
|
|
FString Arguments;
|
2008-08-12 14:30:07 +00:00
|
|
|
actionf_p Function;
|
|
|
|
int defaultparameterindex;
|
2008-10-19 21:43:36 +00:00
|
|
|
|
|
|
|
PSymbolActionFunction(FName name) : PSymbol(name, SYM_ActionFunction) {}
|
2009-09-16 01:39:44 +00:00
|
|
|
PSymbolActionFunction() : PSymbol(NAME_None, SYM_ActionFunction) {}
|
2006-11-29 04:51:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A symbol table -----------------------------------------------------------
|
|
|
|
|
2009-09-23 00:24:47 +00:00
|
|
|
class VMFunction;
|
|
|
|
class PSymbolVMFunction : public PSymbol
|
2006-11-29 04:51:16 +00:00
|
|
|
{
|
2009-09-23 00:24:47 +00:00
|
|
|
DECLARE_CLASS(PSymbolVMFunction, PSymbol);
|
|
|
|
HAS_OBJECT_POINTERS;
|
2006-11-29 04:51:16 +00:00
|
|
|
public:
|
2009-09-23 00:24:47 +00:00
|
|
|
VMFunction *Function;
|
2006-11-29 11:14:40 +00:00
|
|
|
|
2009-09-23 00:24:47 +00:00
|
|
|
PSymbolVMFunction(FName name) : PSymbol(name, SYM_VMFunction) {}
|
|
|
|
PSymbolVMFunction() : PSymbol(NAME_None, SYM_VMFunction) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// A symbol table -----------------------------------------------------------
|
|
|
|
|
2009-09-16 01:39:44 +00:00
|
|
|
struct PSymbolTable
|
2006-11-29 04:51:16 +00:00
|
|
|
{
|
2009-09-16 01:39:44 +00:00
|
|
|
PSymbolTable();
|
2006-11-29 04:51:16 +00:00
|
|
|
~PSymbolTable();
|
|
|
|
|
2009-09-17 01:36:14 +00:00
|
|
|
size_t MarkSymbols();
|
2009-09-16 01:39:44 +00:00
|
|
|
|
2006-11-29 04:51:16 +00:00
|
|
|
// Sets the table to use for searches if this one doesn't contain the
|
|
|
|
// requested symbol.
|
|
|
|
void SetParentTable (PSymbolTable *parent);
|
|
|
|
|
|
|
|
// Finds a symbol in the table, optionally searching parent tables
|
|
|
|
// as well.
|
|
|
|
PSymbol *FindSymbol (FName symname, bool searchparents) const;
|
|
|
|
|
|
|
|
// Places the symbol in the table and returns a pointer to it or NULL if
|
|
|
|
// a symbol with the same name is already in the table. This symbol is
|
|
|
|
// not copied and will be freed when the symbol table is destroyed.
|
|
|
|
PSymbol *AddSymbol (PSymbol *sym);
|
|
|
|
|
2008-06-06 02:17:28 +00:00
|
|
|
// Frees all symbols from this table.
|
|
|
|
void ReleaseSymbols();
|
|
|
|
|
2006-11-29 04:51:16 +00:00
|
|
|
private:
|
|
|
|
PSymbolTable *ParentSymbolTable;
|
|
|
|
TArray<PSymbol *> Symbols;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Meta-info for every class derived from DObject ---------------------------
|
|
|
|
|
2009-09-17 01:36:14 +00:00
|
|
|
class PClass : public DObject
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
2009-09-17 01:36:14 +00:00
|
|
|
DECLARE_CLASS(PClass, DObject);
|
|
|
|
HAS_OBJECT_POINTERS;
|
|
|
|
public:
|
2006-05-10 02:40:43 +00:00
|
|
|
static void StaticInit ();
|
2006-05-12 03:14:40 +00:00
|
|
|
static void StaticShutdown ();
|
2006-05-10 02:40:43 +00:00
|
|
|
static void StaticFreeData (PClass *type);
|
|
|
|
|
|
|
|
// Per-class information -------------------------------------
|
|
|
|
FName TypeName; // this class's name
|
|
|
|
unsigned int Size; // this class's size
|
|
|
|
PClass *ParentClass; // the class this class derives from
|
|
|
|
const size_t *Pointers; // object pointers defined by this class *only*
|
|
|
|
const size_t *FlatPointers; // object pointers defined by this class and all its superclasses; not initialized by default
|
|
|
|
FActorInfo *ActorInfo;
|
|
|
|
PClass *HashNext;
|
|
|
|
FMetaTable Meta;
|
|
|
|
BYTE *Defaults;
|
2008-08-12 09:57:59 +00:00
|
|
|
bool bRuntimeClass; // class was defined at run-time, not compile-time
|
2006-05-10 02:40:43 +00:00
|
|
|
unsigned short ClassIndex;
|
2006-11-29 04:51:16 +00:00
|
|
|
PSymbolTable Symbols;
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
void (*ConstructNative)(void *);
|
|
|
|
|
|
|
|
// The rest are all functions and static data ----------------
|
2009-09-17 01:36:14 +00:00
|
|
|
PClass();
|
|
|
|
~PClass();
|
2006-05-10 02:40:43 +00:00
|
|
|
void InsertIntoHash ();
|
|
|
|
DObject *CreateNew () const;
|
|
|
|
PClass *CreateDerivedClass (FName name, unsigned int size);
|
2008-07-21 17:03:30 +00:00
|
|
|
void InitializeActorInfo ();
|
2006-05-10 02:40:43 +00:00
|
|
|
void BuildFlatPointers ();
|
2006-10-31 14:53:21 +00:00
|
|
|
void FreeStateList();
|
2008-08-06 22:59:24 +00:00
|
|
|
const PClass *NativeClass() const;
|
2009-09-17 01:36:14 +00:00
|
|
|
size_t PropagateMark();
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
// Returns true if this type is an ancestor of (or same as) the passed type.
|
|
|
|
bool IsAncestorOf (const PClass *ti) const
|
|
|
|
{
|
|
|
|
while (ti)
|
|
|
|
{
|
|
|
|
if (this == ti)
|
|
|
|
return true;
|
|
|
|
ti = ti->ParentClass;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
inline bool IsDescendantOf (const PClass *ti) const
|
|
|
|
{
|
|
|
|
return ti->IsAncestorOf (this);
|
|
|
|
}
|
|
|
|
|
2007-03-24 14:59:28 +00:00
|
|
|
// Find a type, given its name.
|
|
|
|
static const PClass *FindClass (const char *name) { return FindClass (FName (name, true)); }
|
|
|
|
static const PClass *FindClass (const FString &name) { return FindClass (FName (name, true)); }
|
|
|
|
static const PClass *FindClass (ENamedName name) { return FindClass (FName (name)); }
|
2006-05-10 02:40:43 +00:00
|
|
|
static const PClass *FindClass (FName name);
|
2008-12-29 23:03:38 +00:00
|
|
|
const PClass *FindClassTentative (FName name); // not static!
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
static TArray<PClass *> m_Types;
|
|
|
|
static TArray<PClass *> m_RuntimeActors;
|
|
|
|
|
|
|
|
enum { HASH_SIZE = 256 };
|
|
|
|
static PClass *TypeHash[HASH_SIZE];
|
- The garbage collector is now run one last time just before exiting the game.
- Removed movie volume from the sound menu and renamed some of the other
options to give the MIDI device name more room to display itself.
- Moved the midi device selection into the main sound menu.
- Added FMOD as MIDI device -1, to replace the MIDI mapper. This is still the
default device. By default, it uses exactly the same DLS instruments as the
Microsoft GS Wavetable Synth. If you have another set DLS level 1 patch set
you want to use, set the snd_midipatchfile cvar to specify where it should
load the instruments from.
- Changed the ProduceMIDI function to store its output into a TArray<BYTE>.
An overloaded version wraps around it to continue to supply file-writing
support for external Timidity++ usage.
- Added an FMOD credits banner to comply with their non-commercial license.
- Reimplemented the snd_buffersize cvar for the FMOD Ex sound system. Rather
than a time in ms, this is now the length in samples of the DSP buffer.
Also added the snd_buffercount cvar to offer complete control over the
call to FMOD::System::setDSPBufferSize(). Note that with any snd_samplerate
below about 44kHz, you will need to set snd_buffersize to avoid long
latencies.
- Reimplemented the snd_output cvar for the FMOD Ex sound system.
- Changed snd_samplerate default to 0. This now means to use the default
sample rate.
- Made snd_output, snd_output_format, snd_speakermode, snd_resampler, and
snd_hrtf available through the menu.
- Split the HRTF effect selection into its own cvar: snd_hrtf.
- Removed 96000 Hz option from the menu. It's still available through the
cvar, if desired.
- Fixed: If Windows sound init failed, retry with DirectSound. (Apparently,
WASAPI doesn't work with more than two speakers and PCM-Float output at the
same time.)
- Fixed: Area sounds only played from the front speakers once you got within
the 2D panning area.
SVN r854 (trunk)
2008-03-26 04:27:07 +00:00
|
|
|
|
|
|
|
static bool bShutdown;
|
2006-05-10 02:40:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|