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,
|
2006-11-29 04:51:16 +00:00
|
|
|
SYM_ActionFunction
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PSymbol
|
|
|
|
{
|
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:
|
2015-02-07 15:35:23 +00:00
|
|
|
PSymbol(FName name, ESymbolType type):SymbolName(name) { SymbolType = type; }
|
2006-11-29 04:51:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A constant value ---------------------------------------------------------
|
|
|
|
|
|
|
|
struct PSymbolConst : public PSymbol
|
|
|
|
{
|
2008-10-19 21:43:36 +00:00
|
|
|
int ValueType;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
int Value;
|
|
|
|
double Float;
|
|
|
|
};
|
|
|
|
|
|
|
|
PSymbolConst(FName name) : PSymbol(name, SYM_Const) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// A variable ---------------------------------------------------------
|
|
|
|
|
|
|
|
struct PSymbolVariable : public PSymbol
|
|
|
|
{
|
|
|
|
FExpressionType ValueType;
|
2009-10-25 02:19:51 +00:00
|
|
|
//int size;
|
2008-10-19 21:43:36 +00:00
|
|
|
intptr_t offset;
|
2009-10-25 02:19:51 +00:00
|
|
|
bool bUserVar;
|
2008-10-19 21:43:36 +00:00
|
|
|
|
|
|
|
PSymbolVariable(FName name) : PSymbol(name, 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
|
|
|
|
|
|
|
struct PSymbolActionFunction : public PSymbol
|
|
|
|
{
|
|
|
|
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) {}
|
2006-11-29 04:51:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A symbol table -----------------------------------------------------------
|
|
|
|
|
|
|
|
class PSymbolTable
|
|
|
|
{
|
|
|
|
public:
|
2006-11-29 11:14:40 +00:00
|
|
|
PSymbolTable() : ParentSymbolTable(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-11-29 04:51:16 +00:00
|
|
|
~PSymbolTable();
|
|
|
|
|
|
|
|
// 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;
|
2009-10-25 02:19:51 +00:00
|
|
|
|
|
|
|
friend class DObject;
|
2006-11-29 04:51:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Meta-info for every class derived from DObject ---------------------------
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
struct PClass
|
|
|
|
{
|
|
|
|
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);
|
2010-12-15 11:45:39 +00:00
|
|
|
static void ClearRuntimeData();
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
// 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 ----------------
|
|
|
|
void InsertIntoHash ();
|
|
|
|
DObject *CreateNew () const;
|
|
|
|
PClass *CreateDerivedClass (FName name, unsigned int size);
|
2009-10-25 02:19:51 +00:00
|
|
|
unsigned int Extend(unsigned int extension);
|
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;
|
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!
|
2010-08-26 20:59:15 +00:00
|
|
|
PClass *GetReplacement() const;
|
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
|