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.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** Important restrictions because of the way FState is structured:
|
|
|
|
**
|
|
|
|
** The range of Frame is [0,63]. Since sprite naming conventions
|
|
|
|
** are even more restrictive than this, this isn't something to
|
|
|
|
** really worry about.
|
|
|
|
**
|
|
|
|
** The range of Tics is [-1,65534]. If Misc1 is important, then
|
|
|
|
** the range of Tics is reduced to [-1,254], because Misc1 also
|
|
|
|
** doubles as the high byte of the tic.
|
|
|
|
**
|
|
|
|
** The range of Misc1 is [-128,127] and Misc2's range is [0,255].
|
|
|
|
**
|
|
|
|
** When compiled with Visual C++, this struct is 16 bytes. With
|
|
|
|
** any other compiler (assuming a 32-bit architecture), it is 20 bytes.
|
|
|
|
** This is because with VC++, I can use the charizing operator to
|
|
|
|
** initialize the name array to exactly 4 chars. If GCC would
|
|
|
|
** compile something like char t = "PLYR"[0]; as char t = 'P'; then GCC
|
|
|
|
** could also use the 16-byte version. Unfortunately, GCC compiles it
|
|
|
|
** more like:
|
|
|
|
**
|
|
|
|
** char t;
|
|
|
|
** void initializer () {
|
|
|
|
** static const char str[]="PLYR";
|
|
|
|
** t = str[0];
|
|
|
|
** }
|
|
|
|
**
|
|
|
|
** While this does allow the use of a 16-byte FState, the additional
|
|
|
|
** code amounts to more than 4 bytes.
|
|
|
|
**
|
|
|
|
** If C++ would allow char name[4] = "PLYR"; without an error (as C does),
|
|
|
|
** I could just initialize the name as a regular string and be done with it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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 "dthinker.h"
|
|
|
|
#include "farchive.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "name.h"
|
2007-04-22 09:06:29 +00:00
|
|
|
#include "tarray.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
const BYTE SF_FULLBRIGHT = 0x40;
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
struct Baggage;
|
|
|
|
class FScanner;
|
|
|
|
struct FActorInfo;
|
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
inline bool CallAction(AActor *self, StateCallData *statecall = NULL)
|
2008-08-12 14:30:07 +00:00
|
|
|
{
|
|
|
|
if (ActionFunc != NULL)
|
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
ActionFunc(self, 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);
|
|
|
|
|
|
|
|
#ifndef EGAMETYPE
|
|
|
|
#define EGAMETYPE
|
|
|
|
enum EGameType
|
|
|
|
{
|
|
|
|
GAME_Any = 0,
|
|
|
|
GAME_Doom = 1,
|
|
|
|
GAME_Heretic = 2,
|
|
|
|
GAME_Hexen = 4,
|
|
|
|
GAME_Strife = 8,
|
2008-08-30 19:44:19 +00:00
|
|
|
GAME_Chex = 16,
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-30 19:44:19 +00:00
|
|
|
GAME_Raven = GAME_Heretic|GAME_Hexen,
|
|
|
|
GAME_DoomStrife = GAME_Doom|GAME_Strife,
|
|
|
|
GAME_DoomChex = GAME_Doom|GAME_Chex,
|
|
|
|
GAME_DoomStrifeChex = GAME_Doom|GAME_Strife|GAME_Chex
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
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 (FName name) const;
|
|
|
|
FState *FindState (int numnames, FName *names, bool exact=false) const;
|
|
|
|
|
2006-07-08 02:17:35 +00:00
|
|
|
FActorInfo *GetReplacement ();
|
2006-07-16 15:00:10 +00:00
|
|
|
FActorInfo *GetReplacee ();
|
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;
|
|
|
|
void AddType (int doomednum, const PClass *type);
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
static FDoomEdEntry *DoomEdHash[DOOMED_HASHSIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
extern FDoomEdMap DoomEdMap;
|
|
|
|
|
2006-07-13 10:17:56 +00:00
|
|
|
int GetSpriteIndex(const char * spritename);
|
2007-04-22 09:06:29 +00:00
|
|
|
void MakeStateNameList(const char * fname, TArray<FName> * out);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#endif // __INFO_H__
|