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"
|
|
|
|
|
2012-04-07 12:11:17 +00:00
|
|
|
#include "m_fixed.h"
|
|
|
|
|
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
|
|
|
|
2010-04-19 02:46:50 +00:00
|
|
|
// Sprites that are fixed in position because they can have special meanings.
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SPR_TNT1, // The empty sprite
|
|
|
|
SPR_FIXED, // Do not change sprite or frame
|
|
|
|
SPR_NOCHANGE, // Do not change sprite (frame change is okay)
|
|
|
|
};
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
struct FState
|
|
|
|
{
|
2008-08-10 14:19:47 +00:00
|
|
|
WORD sprite;
|
|
|
|
SWORD Tics;
|
2010-04-19 02:46:50 +00:00
|
|
|
int Misc1; // Was changed to SBYTE, reverted to long for MBF compat
|
|
|
|
int Misc2; // Was changed to BYTE, reverted to long for MBF compat
|
|
|
|
BYTE Frame:6;
|
|
|
|
BYTE Fullbright:1; // State is fullbright
|
|
|
|
BYTE SameFrame:1; // Ignore Frame (except when spawning actor)
|
2008-09-22 18:55:29 +00:00
|
|
|
BYTE DefineFlags; // Unused byte so let's use it during state creation.
|
2009-10-25 15:26:19 +00:00
|
|
|
short Light;
|
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
|
|
|
|
{
|
2010-04-19 02:46:50 +00:00
|
|
|
return Frame;
|
|
|
|
}
|
|
|
|
inline bool GetSameFrame() const
|
|
|
|
{
|
|
|
|
return SameFrame;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
inline int GetFullbright() const
|
|
|
|
{
|
2010-04-19 02:46:50 +00:00
|
|
|
return Fullbright ? 0x10 /*RF_FULLBRIGHT*/ : 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2010-04-19 02:46:50 +00:00
|
|
|
Frame = 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
|
|
|
|
2010-03-07 09:13:41 +00:00
|
|
|
// Standard pre-defined skin colors
|
|
|
|
struct FPlayerColorSet
|
|
|
|
{
|
2012-03-16 02:23:31 +00:00
|
|
|
struct ExtraRange
|
|
|
|
{
|
|
|
|
BYTE RangeStart, RangeEnd; // colors to remap
|
|
|
|
BYTE FirstColor, LastColor; // colors to map to
|
|
|
|
};
|
|
|
|
|
2010-03-07 09:13:41 +00:00
|
|
|
FName Name; // Name of this color
|
|
|
|
|
|
|
|
int Lump; // Lump to read the translation from, otherwise use next 2 fields
|
|
|
|
BYTE FirstColor, LastColor; // Describes the range of colors to use for the translation
|
|
|
|
|
|
|
|
BYTE RepresentativeColor; // A palette entry representative of this translation,
|
|
|
|
// for map arrows and status bar backgrounds and such
|
2012-03-16 02:23:31 +00:00
|
|
|
BYTE NumExtraRanges;
|
|
|
|
ExtraRange Extra[6];
|
2010-03-07 09:13:41 +00:00
|
|
|
};
|
|
|
|
|
2012-03-23 01:20:45 +00:00
|
|
|
struct DmgFactors : public TMap<FName, fixed_t>
|
|
|
|
{
|
|
|
|
fixed_t *CheckFactor(FName type);
|
|
|
|
};
|
2010-03-22 21:18:54 +00:00
|
|
|
typedef TMap<FName, int> PainChanceList;
|
2011-06-06 22:23:43 +00:00
|
|
|
typedef TMap<FName, PalEntry> PainFlashList;
|
2010-03-07 09:13:41 +00:00
|
|
|
typedef TMap<int, FPlayerColorSet> FPlayerColorSetMap;
|
2007-04-28 09:06:32 +00:00
|
|
|
|
2012-04-07 12:11:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct DamageTypeDefinition
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DamageTypeDefinition() { Clear(); }
|
|
|
|
|
|
|
|
fixed_t DefaultFactor;
|
|
|
|
bool ReplaceFactor;
|
|
|
|
bool NoArmor;
|
|
|
|
|
|
|
|
void Apply(FName const type);
|
|
|
|
void Clear()
|
|
|
|
{
|
2012-04-07 15:29:47 +00:00
|
|
|
DefaultFactor = FRACUNIT;
|
2012-04-07 12:11:17 +00:00
|
|
|
ReplaceFactor = false;
|
|
|
|
NoArmor = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DamageTypeDefinition *Get(FName const type);
|
|
|
|
static bool IgnoreArmor(FName const type);
|
|
|
|
static int ApplyMobjDamageFactor(int damage, FName const type, DmgFactors const * const factors);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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);
|
2011-06-06 22:23:43 +00:00
|
|
|
void SetPainFlash(FName type, PalEntry color);
|
2010-03-07 09:13:41 +00:00
|
|
|
void SetColorSet(int index, const FPlayerColorSet *set);
|
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
|
|
|
|
2012-04-22 07:23:59 +00:00
|
|
|
bool OwnsState(const FState *state)
|
|
|
|
{
|
|
|
|
return state >= OwnedStates && state < OwnedStates + NumOwnedStates;
|
|
|
|
}
|
|
|
|
|
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;
|
2010-03-07 09:13:41 +00:00
|
|
|
FStateLabels *StateList;
|
2007-04-28 09:06:32 +00:00
|
|
|
DmgFactors *DamageFactors;
|
2010-03-07 09:13:41 +00:00
|
|
|
PainChanceList *PainChances;
|
2011-06-06 22:23:43 +00:00
|
|
|
PainFlashList *PainFlashes;
|
2010-03-07 09:13:41 +00:00
|
|
|
FPlayerColorSetMap *ColorSets;
|
2011-09-10 04:24:40 +00:00
|
|
|
TArray<const PClass *> VisibleToPlayerClass;
|
2011-09-23 08:23:51 +00:00
|
|
|
TArray<const PClass *> RestrictedToPlayerClass;
|
|
|
|
TArray<const PClass *> ForbiddenToPlayerClass;
|
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;
|
|
|
|
|
2011-07-04 20:22:55 +00:00
|
|
|
int GetSpriteIndex(const char * spritename, bool add = true);
|
2008-09-22 18:55:29 +00:00
|
|
|
TArray<FName> &MakeStateNameList(const char * fname);
|
2009-10-25 15:26:19 +00:00
|
|
|
void AddStateLight(FState *state, const char *lname);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#endif // __INFO_H__
|