2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** info.h
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2007-03-07 17:31:40 +00:00
|
|
|
** Copyright 1998-2007 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** 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 __INFO_H__
|
|
|
|
#define __INFO_H__
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2006-04-12 03:03:58 +00:00
|
|
|
#if !defined(_WIN32)
|
2006-02-24 04:48:15 +00:00
|
|
|
#include <inttypes.h> // for intptr_t
|
2006-04-12 03:03:58 +00:00
|
|
|
#elif !defined(_MSC_VER)
|
|
|
|
#include <stdint.h> // for mingw
|
2006-02-24 04:48:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dobject.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
|
|
|
|
const BYTE SF_FULLBRIGHT = 0x40;
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
struct Baggage;
|
|
|
|
class FScanner;
|
|
|
|
struct FActorInfo;
|
2008-09-15 00:47:31 +00:00
|
|
|
class FArchive;
|
2008-08-12 14:30:07 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
struct FState
|
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
WORD sprite;
|
|
|
|
SWORD Tics;
|
2006-02-24 04:48:15 +00:00
|
|
|
SBYTE Misc1;
|
|
|
|
BYTE Misc2;
|
|
|
|
BYTE Frame;
|
2008-09-22 18:55:29 +00:00
|
|
|
BYTE DefineFlags; // Unused byte so let's use it during state creation.
|
2006-02-24 04:48:15 +00:00
|
|
|
FState *NextState;
|
2008-08-12 14:30:07 +00:00
|
|
|
actionf_p ActionFunc;
|
2006-10-29 11:01:00 +00:00
|
|
|
int ParameterIndex;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
inline int GetFrame() const
|
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
return Frame & ~(SF_FULLBRIGHT);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
inline int GetFullbright() const
|
|
|
|
{
|
|
|
|
return Frame & SF_FULLBRIGHT ? 0x10 /*RF_FULLBRIGHT*/ : 0;
|
|
|
|
}
|
|
|
|
inline int GetTics() const
|
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
return Tics;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
inline int GetMisc1() const
|
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
return Misc1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
inline int GetMisc2() const
|
|
|
|
{
|
|
|
|
return Misc2;
|
|
|
|
}
|
|
|
|
inline FState *GetNextState() const
|
|
|
|
{
|
|
|
|
return NextState;
|
|
|
|
}
|
|
|
|
inline void SetFrame(BYTE frame)
|
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
Frame = (Frame & SF_FULLBRIGHT) | (frame-'A');
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-12 14:30:07 +00:00
|
|
|
void SetAction(PSymbolActionFunction *func, bool setdefaultparams = true)
|
|
|
|
{
|
|
|
|
if (func != NULL)
|
|
|
|
{
|
|
|
|
ActionFunc = func->Function;
|
|
|
|
if (setdefaultparams) ParameterIndex = func->defaultparameterindex+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ActionFunc = NULL;
|
|
|
|
if (setdefaultparams) ParameterIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
2009-01-06 00:03:18 +00:00
|
|
|
inline bool CallAction(AActor *self, AActor *stateowner, StateCallData *statecall = NULL)
|
2008-08-12 14:30:07 +00:00
|
|
|
{
|
|
|
|
if (ActionFunc != NULL)
|
|
|
|
{
|
2009-01-06 00:03:18 +00:00
|
|
|
ActionFunc(self, stateowner, this, ParameterIndex-1, statecall);
|
2008-08-12 14:30:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2006-05-10 02:40:43 +00:00
|
|
|
static const PClass *StaticFindStateOwner (const FState *state);
|
|
|
|
static const PClass *StaticFindStateOwner (const FState *state, const FActorInfo *info);
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
struct FStateLabels;
|
|
|
|
struct FStateLabel
|
|
|
|
{
|
|
|
|
FName Label;
|
|
|
|
FState *State;
|
|
|
|
FStateLabels *Children;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FStateLabels
|
|
|
|
{
|
|
|
|
int NumLabels;
|
|
|
|
FStateLabel Labels[1];
|
|
|
|
|
|
|
|
FStateLabel *FindLabel (FName label);
|
|
|
|
|
|
|
|
void Destroy(); // intentionally not a destructor!
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
FArchive &operator<< (FArchive &arc, FState *&state);
|
|
|
|
|
2009-03-22 11:37:56 +00:00
|
|
|
#include "gametype.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-04-28 09:06:32 +00:00
|
|
|
typedef TMap<FName, fixed_t> DmgFactors;
|
2007-05-26 10:50:32 +00:00
|
|
|
typedef TMap<FName, BYTE> PainChanceList;
|
2007-04-28 09:06:32 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
struct FActorInfo
|
|
|
|
{
|
|
|
|
static void StaticInit ();
|
|
|
|
static void StaticSetActorNums ();
|
|
|
|
|
|
|
|
void BuildDefaults ();
|
|
|
|
void ApplyDefaults (BYTE *defaults);
|
|
|
|
void RegisterIDs ();
|
2008-08-23 08:48:19 +00:00
|
|
|
void SetDamageFactor(FName type, fixed_t factor);
|
|
|
|
void SetPainChance(FName type, int chance);
|
2006-10-31 14:53:21 +00:00
|
|
|
|
2006-12-16 14:06:21 +00:00
|
|
|
FState *FindState (int numnames, FName *names, bool exact=false) const;
|
2008-09-22 18:55:29 +00:00
|
|
|
FState *FindStateByString(const char *name, bool exact=false);
|
|
|
|
FState *FindState (FName name) const
|
|
|
|
{
|
|
|
|
return FindState(1, &name);
|
|
|
|
}
|
2006-12-16 14:06:21 +00:00
|
|
|
|
2009-06-26 17:17:52 +00:00
|
|
|
FActorInfo *GetReplacement (bool lookskill=true);
|
|
|
|
FActorInfo *GetReplacee (bool lookskill=true);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
PClass *Class;
|
2006-02-24 04:48:15 +00:00
|
|
|
FState *OwnedStates;
|
2006-07-08 02:17:35 +00:00
|
|
|
FActorInfo *Replacement;
|
2006-07-16 15:00:10 +00:00
|
|
|
FActorInfo *Replacee;
|
2006-02-24 04:48:15 +00:00
|
|
|
int NumOwnedStates;
|
|
|
|
BYTE GameFilter;
|
|
|
|
BYTE SpawnID;
|
|
|
|
SWORD DoomEdNum;
|
2006-10-31 14:53:21 +00:00
|
|
|
FStateLabels * StateList;
|
2007-04-28 09:06:32 +00:00
|
|
|
DmgFactors *DamageFactors;
|
2007-05-26 10:50:32 +00:00
|
|
|
PainChanceList * PainChances;
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class FDoomEdMap
|
|
|
|
{
|
|
|
|
public:
|
2006-05-09 03:40:15 +00:00
|
|
|
~FDoomEdMap();
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
const PClass *FindType (int doomednum) const;
|
2008-09-01 19:56:32 +00:00
|
|
|
void AddType (int doomednum, const PClass *type, bool temporary = false);
|
2006-02-24 04:48:15 +00:00
|
|
|
void DelType (int doomednum);
|
|
|
|
void Empty ();
|
|
|
|
|
|
|
|
static void DumpMapThings ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum { DOOMED_HASHSIZE = 256 };
|
|
|
|
|
|
|
|
struct FDoomEdEntry
|
|
|
|
{
|
|
|
|
FDoomEdEntry *HashNext;
|
2006-05-10 02:40:43 +00:00
|
|
|
const PClass *Type;
|
2006-02-24 04:48:15 +00:00
|
|
|
int DoomEdNum;
|
2008-09-01 19:56:32 +00:00
|
|
|
bool temp;
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static FDoomEdEntry *DoomEdHash[DOOMED_HASHSIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
extern FDoomEdMap DoomEdMap;
|
|
|
|
|
2006-07-13 10:17:56 +00:00
|
|
|
int GetSpriteIndex(const char * spritename);
|
2008-09-22 18:55:29 +00:00
|
|
|
TArray<FName> &MakeStateNameList(const char * fname);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#endif // __INFO_H__
|