Merge branch 'scripting'

Conflicts:
	src/actor.h
	src/g_doom/a_doomweaps.cpp
	src/g_hexen/a_blastradius.cpp
	src/p_enemy.cpp
	src/p_enemy.h
	src/thingdef/thingdef.h
	src/thingdef/thingdef_codeptr.cpp
	wadsrc/static/actors/constants.txt
This commit is contained in:
Randy Heit 2016-02-04 15:15:29 -06:00
commit b3b0886b64
230 changed files with 24061 additions and 8641 deletions

View file

@ -82,7 +82,7 @@ void A_Unblock(AActor *self, bool drop)
// If the actor has attached metadata for items to drop, drop those.
if (drop && !self->IsKindOf (RUNTIME_CLASS (APlayerPawn))) // [GRB]
{
FDropItem *di = self->GetDropItems();
DDropItem *di = self->GetDropItems();
if (di != NULL)
{
@ -90,8 +90,11 @@ void A_Unblock(AActor *self, bool drop)
{
if (di->Name != NAME_None)
{
const PClass *ti = PClass::FindClass(di->Name);
if (ti) P_DropItem (self, ti, di->amount, di->probability);
PClassActor *ti = PClass::FindActor(di->Name);
if (ti != NULL)
{
P_DropItem (self, ti, di->Amount, di->Probability);
}
}
di = di->Next;
}
@ -101,12 +104,16 @@ void A_Unblock(AActor *self, bool drop)
DEFINE_ACTION_FUNCTION(AActor, A_NoBlocking)
{
PARAM_ACTION_PROLOGUE;
A_Unblock(self, true);
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_Fall)
{
PARAM_ACTION_PROLOGUE;
A_Unblock(self, true);
return 0;
}
//==========================================================================
@ -117,8 +124,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Fall)
DEFINE_ACTION_FUNCTION(AActor, A_SetFloorClip)
{
PARAM_ACTION_PROLOGUE;
self->flags2 |= MF2_FLOORCLIP;
self->AdjustFloorClip ();
return 0;
}
//==========================================================================
@ -129,8 +139,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetFloorClip)
DEFINE_ACTION_FUNCTION(AActor, A_UnSetFloorClip)
{
PARAM_ACTION_PROLOGUE;
self->flags2 &= ~MF2_FLOORCLIP;
self->floorclip = 0;
return 0;
}
//==========================================================================
@ -141,7 +154,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetFloorClip)
DEFINE_ACTION_FUNCTION(AActor, A_HideThing)
{
PARAM_ACTION_PROLOGUE;
self->renderflags |= RF_INVISIBLE;
return 0;
}
//==========================================================================
@ -152,7 +168,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_HideThing)
DEFINE_ACTION_FUNCTION(AActor, A_UnHideThing)
{
PARAM_ACTION_PROLOGUE;
self->renderflags &= ~RF_INVISIBLE;
return 0;
}
//============================================================================
@ -163,6 +182,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnHideThing)
DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath)
{
PARAM_ACTION_PROLOGUE;
int t = pr_freezedeath();
self->tics = 75+t+pr_freezedeath();
self->flags |= MF_SOLID|MF_SHOOTABLE|MF_NOBLOOD|MF_ICECORPSE;
@ -196,6 +217,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath)
self->args[1], self->args[2], self->args[3], self->args[4]);
self->special = 0;
}
return 0;
}
//==========================================================================
@ -206,8 +228,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath)
DEFINE_ACTION_FUNCTION(AActor, A_GenericFreezeDeath)
{
PARAM_ACTION_PROLOGUE;
self->Translation = TRANSLATION(TRANSLATION_Standard, 7);
CALL_ACTION(A_FreezeDeath, self);
return 0;
}
//============================================================================
@ -218,6 +243,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenericFreezeDeath)
DEFINE_ACTION_FUNCTION(AActor, A_IceSetTics)
{
PARAM_ACTION_PROLOGUE;
int floor;
self->tics = 70+(pr_icesettics()&63);
@ -230,6 +257,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceSetTics)
{
self->tics <<= 1;
}
return 0;
}
//============================================================================
@ -240,6 +268,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceSetTics)
DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
{
PARAM_ACTION_PROLOGUE;
int i;
int numChunks;
@ -248,7 +277,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
if ((self->velx || self->vely || self->velz) && !(self->flags6 & MF6_SHATTERING))
{
self->tics = 3*TICRATE;
return;
return 0;
}
self->velx = self->vely = self->velz = 0;
S_Sound (self, CHAN_BODY, "misc/icebreak", 1, ATTN_NORM);
@ -312,6 +341,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
A_Unblock(self, true);
self->SetState(self->FindState(NAME_Null));
return 0;
}
//----------------------------------------------------------------------------
@ -413,13 +443,20 @@ void DCorpsePointer::Serialize (FArchive &arc)
// throw another corpse on the queue
DEFINE_ACTION_FUNCTION(AActor, A_QueueCorpse)
{
PARAM_ACTION_PROLOGUE;
if (sv_corpsequeuesize > 0)
{
new DCorpsePointer (self);
}
return 0;
}
// Remove an self from the queue (for resurrection)
DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse)
{
PARAM_ACTION_PROLOGUE;
TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER);
DCorpsePointer *corpsePtr;
@ -429,9 +466,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse)
{
corpsePtr->Corpse = NULL;
corpsePtr->Destroy ();
return;
return 0;
}
}
return 0;
}
//============================================================================
@ -442,7 +480,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse)
DEFINE_ACTION_FUNCTION(AActor, A_SetInvulnerable)
{
PARAM_ACTION_PROLOGUE;
self->flags2 |= MF2_INVULNERABLE;
return 0;
}
//============================================================================
@ -453,7 +494,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetInvulnerable)
DEFINE_ACTION_FUNCTION(AActor, A_UnSetInvulnerable)
{
PARAM_ACTION_PROLOGUE;
self->flags2 &= ~MF2_INVULNERABLE;
return 0;
}
//============================================================================
@ -464,7 +508,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetInvulnerable)
DEFINE_ACTION_FUNCTION(AActor, A_SetReflective)
{
PARAM_ACTION_PROLOGUE;
self->flags2 |= MF2_REFLECTIVE;
return 0;
}
//============================================================================
@ -475,7 +522,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetReflective)
DEFINE_ACTION_FUNCTION(AActor, A_UnSetReflective)
{
PARAM_ACTION_PROLOGUE;
self->flags2 &= ~MF2_REFLECTIVE;
return 0;
}
//============================================================================
@ -486,7 +536,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetReflective)
DEFINE_ACTION_FUNCTION(AActor, A_SetReflectiveInvulnerable)
{
PARAM_ACTION_PROLOGUE;
self->flags2 |= MF2_REFLECTIVE|MF2_INVULNERABLE;
return 0;
}
//============================================================================
@ -497,7 +550,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetReflectiveInvulnerable)
DEFINE_ACTION_FUNCTION(AActor, A_UnSetReflectiveInvulnerable)
{
PARAM_ACTION_PROLOGUE;
self->flags2 &= ~(MF2_REFLECTIVE|MF2_INVULNERABLE);
return 0;
}
//==========================================================================
@ -508,8 +564,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetReflectiveInvulnerable)
DEFINE_ACTION_FUNCTION(AActor, A_SetShootable)
{
PARAM_ACTION_PROLOGUE;
self->flags2 &= ~MF2_NONSHOOTABLE;
self->flags |= MF_SHOOTABLE;
return 0;
}
//==========================================================================
@ -520,8 +579,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetShootable)
DEFINE_ACTION_FUNCTION(AActor, A_UnSetShootable)
{
PARAM_ACTION_PROLOGUE;
self->flags2 |= MF2_NONSHOOTABLE;
self->flags &= ~MF_SHOOTABLE;
return 0;
}
//===========================================================================
@ -532,7 +594,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetShootable)
DEFINE_ACTION_FUNCTION(AActor, A_NoGravity)
{
PARAM_ACTION_PROLOGUE;
self->flags |= MF_NOGRAVITY;
return 0;
}
//===========================================================================
@ -543,8 +608,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_NoGravity)
DEFINE_ACTION_FUNCTION(AActor, A_Gravity)
{
PARAM_ACTION_PROLOGUE;
self->flags &= ~MF_NOGRAVITY;
self->gravity = FRACUNIT;
return 0;
}
//===========================================================================
@ -555,8 +623,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Gravity)
DEFINE_ACTION_FUNCTION(AActor, A_LowGravity)
{
PARAM_ACTION_PROLOGUE;
self->flags &= ~MF_NOGRAVITY;
self->gravity = FRACUNIT/8;
return 0;
}
//===========================================================================

View file

@ -180,7 +180,7 @@ void ABasicArmor::AbsorbDamage (int damage, FName damageType, int &newdamage)
// The differences include not using a default value, and of course the way
// the damage factor info is obtained.
const fixed_t *pdf = NULL;
DmgFactors *df = PClass::FindClass(ArmorType)->ActorInfo->DamageFactors;
DmgFactors *df = PClass::FindActor(ArmorType)->DamageFactors;
if (df != NULL && df->CountUsed() != 0)
{
pdf = df->CheckFactor(damageType);

View file

@ -369,9 +369,9 @@ void APowerInvulnerable::InitEffect ()
Super::InitEffect();
Owner->effects &= ~FX_RESPAWNINVUL;
Owner->flags2 |= MF2_INVULNERABLE;
if (Mode == NAME_None)
if (Mode == NAME_None && Owner->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
{
Mode = (ENamedName)RUNTIME_TYPE(Owner)->Meta.GetMetaInt(APMETA_InvulMode);
Mode = static_cast<PClassPlayerPawn *>(Owner->GetClass())->InvulMode;
}
if (Mode == NAME_Reflective)
{
@ -1619,8 +1619,8 @@ void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bo
static const fixed_t def = 4*FRACUNIT;
if (!passive && damage > 0)
{
const fixed_t * pdf = NULL;
DmgFactors * df = GetClass()->ActorInfo->DamageFactors;
const fixed_t *pdf = NULL;
DmgFactors *df = GetClass()->DamageFactors;
if (df != NULL && df->CountUsed() != 0)
{
pdf = df->CheckFactor(damageType);
@ -1700,7 +1700,7 @@ void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage
if (passive && damage > 0)
{
const fixed_t *pdf = NULL;
DmgFactors *df = GetClass()->ActorInfo->DamageFactors;
DmgFactors *df = GetClass()->DamageFactors;
if (df != NULL && df->CountUsed() != 0)
{
pdf = df->CheckFactor(damageType);
@ -1887,9 +1887,9 @@ void APowerMorph::InitEffect( )
if (Owner != NULL && Owner->player != NULL && PlayerClass != NAME_None)
{
player_t *realplayer = Owner->player; // Remember the identity of the player
const PClass *morph_flash = PClass::FindClass (MorphFlash);
const PClass *unmorph_flash = PClass::FindClass (UnMorphFlash);
const PClass *player_class = PClass::FindClass (PlayerClass);
PClassActor *morph_flash = PClass::FindActor(MorphFlash);
PClassActor *unmorph_flash = PClass::FindActor(UnMorphFlash);
PClassPlayerPawn *player_class = dyn_cast<PClassPlayerPawn>(PClass::FindClass (PlayerClass));
if (P_MorphPlayer(realplayer, realplayer, player_class, -1/*INDEFINITELY*/, MorphStyle, morph_flash, unmorph_flash))
{
Owner = realplayer->mo; // Replace the new owner in our owner; safe because we are not attached to anything yet

View file

@ -44,7 +44,7 @@ public:
virtual bool Use (bool pickup);
virtual void Serialize (FArchive &arc);
const PClass *PowerupType;
PClassActor *PowerupType;
int EffectTics; // Non-0 to override the powerup's default tics
PalEntry BlendColor; // Non-0 to override the powerup's default blend
FNameNoInit Mode; // Meaning depends on powerup - used for Invulnerability and Invisibility

View file

@ -92,10 +92,12 @@ void ACustomBridge::Destroy()
DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
{
PARAM_ACTION_PROLOGUE;
if (self->target == NULL)
{ // Don't crash if somebody spawned this into the world
// independantly of a Bridge actor.
return;
return 0;
}
// Set default values
// Every five tics, Hexen moved the ball 3/256th of a revolution.
@ -113,18 +115,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
self->SetOrigin(self->target->Vec3Angle(rotationradius, self->angle, 0), true);
self->floorz = self->target->floorz;
self->ceilingz = self->target->ceilingz;
return 0;
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
{
PARAM_ACTION_PROLOGUE;
PARAM_CLASS_OPT(balltype, AActor) { balltype = NULL; }
angle_t startangle;
AActor *ball;
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(balltype, 0);
if (balltype == NULL) balltype = PClass::FindClass("BridgeBall");
if (balltype == NULL)
{
balltype = PClass::FindActor("BridgeBall");
}
startangle = pr_orbit() << 24;
@ -138,6 +144,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
ball->target = self;
CALL_ACTION(A_BridgeOrbit, ball);
}
return 0;
}

View file

@ -31,7 +31,7 @@ IMPLEMENT_CLASS(AGlassShard)
void P_SpawnDirt (AActor *actor, fixed_t radius)
{
const PClass *dtype = NULL;
PClassActor *dtype = NULL;
AActor *mo;
fixed_t zo = (pr_dirt() << 9) + FRACUNIT;
@ -39,7 +39,7 @@ void P_SpawnDirt (AActor *actor, fixed_t radius)
char fmt[8];
mysnprintf(fmt, countof(fmt), "Dirt%d", 1 + pr_dirt()%6);
dtype = PClass::FindClass(fmt);
dtype = PClass::FindActor(fmt);
if (dtype)
{
mo = Spawn (dtype, pos, ALLOW_REPLACE);

View file

@ -168,7 +168,7 @@ void AFastProjectile::Effect()
{
//if (pr_smoke() < 128) // [RH] I think it looks better if it's consistent
{
FName name = (ENamedName) this->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None);
FName name = GetClass()->MissileName;
if (name != NAME_None)
{
fixed_t hitz = Z()-8*FRACUNIT;
@ -178,9 +178,9 @@ void AFastProjectile::Effect()
hitz = floorz;
}
// Do not clip this offset to the floor.
hitz += GetClass()->Meta.GetMetaFixed (ACMETA_MissileHeight);
hitz += GetClass()->MissileHeight;
const PClass *trail = PClass::FindClass(name);
PClassActor *trail = PClass::FindActor(name);
if (trail != NULL)
{
AActor *act = Spawn (trail, X(), Y(), hitz, ALLOW_REPLACE);

View file

@ -14,10 +14,10 @@
struct OneKey
{
const PClass *key;
PClassActor *key;
int count;
bool check(AActor * owner)
bool check(AActor *owner)
{
if (owner->IsKindOf(RUNTIME_CLASS(AKey)))
{
@ -122,7 +122,7 @@ static const char * keywords_lock[]={
//
//===========================================================================
static void AddOneKey(Keygroup *keygroup, const PClass *mi, FScanner &sc)
static void AddOneKey(Keygroup *keygroup, PClassActor *mi, FScanner &sc)
{
if (mi)
{
@ -159,17 +159,17 @@ static void AddOneKey(Keygroup *keygroup, const PClass *mi, FScanner &sc)
//
//===========================================================================
static Keygroup * ParseKeygroup(FScanner &sc)
static Keygroup *ParseKeygroup(FScanner &sc)
{
Keygroup * keygroup;
const PClass * mi;
Keygroup *keygroup;
PClassActor *mi;
sc.MustGetStringName("{");
keygroup = new Keygroup;
while (!sc.CheckString("}"))
{
sc.MustGetString();
mi = PClass::FindClass(sc.String);
mi = PClass::FindActor(sc.String);
AddOneKey(keygroup, mi, sc);
}
if (keygroup->anykeylist.Size() == 0)
@ -208,9 +208,9 @@ static void ParseLock(FScanner &sc)
int i,r,g,b;
int keynum;
Lock sink;
Lock * lock=&sink;
Keygroup * keygroup;
const PClass * mi;
Lock *lock = &sink;
Keygroup *keygroup;
PClassActor *mi;
sc.MustGetNumber();
keynum = sc.Number;
@ -292,7 +292,7 @@ static void ParseLock(FScanner &sc)
break;
default:
mi = PClass::FindClass(sc.String);
mi = PClass::FindActor(sc.String);
if (mi)
{
keygroup = new Keygroup;
@ -328,27 +328,27 @@ static void ParseLock(FScanner &sc)
static void ClearLocks()
{
unsigned int i;
for(i=0;i<PClass::m_Types.Size();i++)
for(i = 0; i < PClassActor::AllActorClasses.Size(); i++)
{
if (PClass::m_Types[i]->IsDescendantOf(RUNTIME_CLASS(AKey)))
if (PClassActor::AllActorClasses[i]->IsDescendantOf(RUNTIME_CLASS(AKey)))
{
AKey *key = static_cast<AKey*>(GetDefaultByType(PClass::m_Types[i]));
AKey *key = static_cast<AKey*>(GetDefaultByType(PClassActor::AllActorClasses[i]));
if (key != NULL)
{
key->KeyNumber = 0;
}
}
}
for(i=0;i<256;i++)
for(i = 0; i < 256; i++)
{
if (locks[i]!=NULL)
if (locks[i] != NULL)
{
delete locks[i];
locks[i]=NULL;
locks[i] = NULL;
}
}
currentnumber=0;
keysdone=false;
currentnumber = 0;
keysdone = false;
}
//===========================================================================

View file

@ -30,7 +30,7 @@ void InitAllPowerupEffects(AInventory *item);
//
//---------------------------------------------------------------------------
bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, int duration, int style, const PClass *enter_flash, const PClass *exit_flash)
bool P_MorphPlayer (player_t *activator, player_t *p, PClassPlayerPawn *spawntype, int duration, int style, PClassActor *enter_flash, PClassActor *exit_flash)
{
AInventory *item;
APlayerPawn *morphed;
@ -135,7 +135,7 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i
hxarmor->Slots[1] = 0;
hxarmor->Slots[2] = 0;
hxarmor->Slots[3] = 0;
hxarmor->Slots[4] = spawntype->Meta.GetMetaFixed (APMETA_Hexenarmor0);
hxarmor->Slots[4] = spawntype->HexenArmor[0];
}
else
{
@ -241,7 +241,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
mo->Score = pmo->Score;
InitAllPowerupEffects(mo->Inventory);
const PClass *exit_flash = player->MorphExitFlash;
PClassActor *exit_flash = player->MorphExitFlash;
bool correctweapon = !!(player->MorphStyle & MORPH_LOSEACTUALWEAPON);
bool undobydeathsaves = !!(player->MorphStyle & MORPH_UNDOBYDEATHSAVES);
@ -278,8 +278,8 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
// and for the original DOOM status bar.
if (player == &players[consoleplayer])
{
const char *face = pmo->GetClass()->Meta.GetMetaString (APMETA_Face);
if (face != NULL && strcmp(face, "None") != 0)
FString face = pmo->GetClass()->Face;
if (face.IsNotEmpty() && strcmp(face, "None") != 0)
{
// Assume root-level base skin to begin with
size_t skinindex = 0;
@ -325,8 +325,8 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
}
if (correctweapon)
{ // Better "lose morphed weapon" semantics
const PClass *morphweapon = PClass::FindClass (pmo->MorphWeapon);
if (morphweapon != NULL && morphweapon->IsDescendantOf (RUNTIME_CLASS(AWeapon)))
PClassActor *morphweapon = PClass::FindActor(pmo->MorphWeapon);
if (morphweapon != NULL && morphweapon->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
AWeapon *OriginalMorphWeapon = static_cast<AWeapon *>(mo->FindInventory (morphweapon));
if ((OriginalMorphWeapon != NULL) && (OriginalMorphWeapon->GivenAsMorphWeapon))
@ -356,7 +356,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
AHexenArmor *hxarmor = mo->FindInventory<AHexenArmor>();
if (hxarmor != NULL)
{
hxarmor->Slots[4] = mo->GetClass()->Meta.GetMetaFixed (APMETA_Hexenarmor0);
hxarmor->Slots[4] = mo->GetClass()->HexenArmor[0];
}
return true;
}
@ -369,7 +369,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
//
//---------------------------------------------------------------------------
bool P_MorphMonster (AActor *actor, const PClass *spawntype, int duration, int style, const PClass *enter_flash, const PClass *exit_flash)
bool P_MorphMonster (AActor *actor, PClassActor *spawntype, int duration, int style, PClassActor *enter_flash, PClassActor *exit_flash)
{
AMorphedMonster *morphed;
@ -470,7 +470,7 @@ bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force)
actor->AddToHash ();
beast->UnmorphedMe = NULL;
DObject::StaticPointerSubstitution (beast, actor);
const PClass *exit_flash = beast->MorphExitFlash;
PClassActor *exit_flash = beast->MorphExitFlash;
beast->Destroy ();
AActor *eflash = Spawn(exit_flash, beast->PosPlusZ(TELEFOGHEIGHT), ALLOW_REPLACE);
if (eflash)
@ -550,7 +550,10 @@ bool P_MorphedDeath(AActor *actor, AActor **morphed, int *morphedstyle, int *mor
if (realme->flags4 & MF4_BOSSDEATH)
{
realme->health = 0; // make sure that A_BossDeath considers it dead.
CALL_ACTION(A_BossDeath, realme);
// FIXME: Use the caller's stack once the whole chain is scriptable.
VMFrameStack stack;
VMValue params[3] = { realme, realme, VMValue(NULL, ATAG_STATE) };
stack.Call(A_BossDeath_VMPtr, params, countof(params), NULL, 0, NULL);
}
}
fakeme->flags3 |= MF3_STAYMORPHED; // moved here from AMorphedMonster::Die()
@ -607,16 +610,16 @@ IMPLEMENT_CLASS(AMorphProjectile)
int AMorphProjectile::DoSpecialDamage (AActor *target, int damage, FName damagetype)
{
const PClass *morph_flash = PClass::FindClass (MorphFlash);
const PClass *unmorph_flash = PClass::FindClass (UnMorphFlash);
PClassActor *morph_flash = PClass::FindActor(MorphFlash);
PClassActor *unmorph_flash = PClass::FindActor(UnMorphFlash);
if (target->player)
{
const PClass *player_class = PClass::FindClass (PlayerClass);
PClassPlayerPawn *player_class = dyn_cast<PClassPlayerPawn>(PClass::FindClass(PlayerClass));
P_MorphPlayer (NULL, target->player, player_class, Duration, MorphStyle, morph_flash, unmorph_flash);
}
else
{
const PClass *monster_class = PClass::FindClass (MonsterClass);
PClassActor *monster_class = PClass::FindActor(MonsterClass);
P_MorphMonster (target, monster_class, Duration, MorphStyle, morph_flash, unmorph_flash);
}
return -1;

View file

@ -29,16 +29,16 @@ enum
MORPH_STANDARDUNDOING = MORPH_UNDOBYTOMEOFPOWER | MORPH_UNDOBYCHAOSDEVICE | MORPH_UNDOBYTIMEOUT,
};
struct PClass;
class PClass;
class AActor;
class player_t;
class AMorphedMonster;
bool P_MorphPlayer (player_t *activator, player_t *player, const PClass *morphclass, int duration = 0, int style = 0,
const PClass *enter_flash = NULL, const PClass *exit_flash = NULL);
bool P_MorphPlayer (player_t *activator, player_t *player, PClassPlayerPawn *morphclass, int duration = 0, int style = 0,
PClassActor *enter_flash = NULL, PClassActor *exit_flash = NULL);
bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag = 0, bool force = false);
bool P_MorphMonster (AActor *actor, const PClass *morphclass, int duration = 0, int style = 0,
const PClass *enter_flash = NULL, const PClass *exit_flash = NULL);
bool P_MorphMonster (AActor *actor, PClassActor *morphclass, int duration = 0, int style = 0,
PClassActor *enter_flash = NULL, PClassActor *exit_flash = NULL);
bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force = false);
bool P_UpdateMorphedMonster (AActor *actor);
bool P_MorphedDeath(AActor *actor, AActor **morphed, int *morphedstyle, int *morphedhealth);

View file

@ -22,6 +22,41 @@
static FRandom pr_restore ("RestorePos");
IMPLEMENT_CLASS(PClassInventory)
PClassInventory::PClassInventory()
{
GiveQuest = 0;
AltHUDIcon.SetNull();
}
void PClassInventory::Derive(PClass *newclass)
{
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassInventory)));
Super::Derive(newclass);
PClassInventory *newc = static_cast<PClassInventory *>(newclass);
newc->PickupMessage = PickupMessage;
newc->GiveQuest = GiveQuest;
newc->AltHUDIcon = AltHUDIcon;
}
IMPLEMENT_CLASS(PClassAmmo)
PClassAmmo::PClassAmmo()
{
DropAmount = 0;
}
void PClassAmmo::Derive(PClass *newclass)
{
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassAmmo)));
Super::Derive(newclass);
PClassAmmo *newc = static_cast<PClassAmmo *>(newclass);
newc->DropAmount = DropAmount;
}
IMPLEMENT_CLASS (AAmmo)
//===========================================================================
@ -53,15 +88,15 @@ void AAmmo::Serialize (FArchive &arc)
//
//===========================================================================
const PClass *AAmmo::GetParentAmmo () const
PClassActor *AAmmo::GetParentAmmo () const
{
const PClass *type = GetClass ();
PClass *type = GetClass();
while (type->ParentClass != RUNTIME_CLASS(AAmmo) && type->ParentClass != NULL)
{
type = type->ParentClass;
}
return type;
return static_cast<PClassActor *>(type);
}
//===========================================================================
@ -139,8 +174,7 @@ AInventory *AAmmo::CreateCopy (AActor *other)
if (GetClass()->ParentClass != RUNTIME_CLASS(AAmmo) && GetClass() != RUNTIME_CLASS(AAmmo))
{
const PClass *type = GetParentAmmo();
assert (type->ActorInfo != NULL);
PClassActor *type = GetParentAmmo();
if (!GoAway ())
{
Destroy ();
@ -289,11 +323,14 @@ bool P_GiveBody (AActor *actor, int num, int max)
DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialThing1)
{
PARAM_ACTION_PROLOGUE;
self->renderflags &= ~RF_INVISIBLE;
if (static_cast<AInventory *>(self)->DoRespawn ())
{
S_Sound (self, CHAN_VOICE, "misc/spawn", 1, ATTN_IDLE);
}
return 0;
}
//---------------------------------------------------------------------------
@ -304,12 +341,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialThing1)
DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialThing2)
{
PARAM_ACTION_PROLOGUE;
self->flags |= MF_SPECIAL;
if (!(self->GetDefault()->flags & MF_NOGRAVITY))
{
self->flags &= ~MF_NOGRAVITY;
}
self->SetState (self->SpawnState);
return 0;
}
@ -321,6 +361,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialThing2)
DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialDoomThing)
{
PARAM_ACTION_PROLOGUE;
self->renderflags &= ~RF_INVISIBLE;
self->flags |= MF_SPECIAL;
if (!(self->GetDefault()->flags & MF_NOGRAVITY))
@ -333,6 +375,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialDoomThing)
S_Sound (self, CHAN_VOICE, "misc/spawn", 1, ATTN_IDLE);
Spawn ("ItemFog", self->Pos(), ALLOW_REPLACE);
}
return 0;
}
//---------------------------------------------------------------------------
@ -343,6 +386,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialDoomThing)
DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
{
PARAM_ACTION_PROLOGUE;
// Move item back to its original location
fixed_t _x, _y;
sector_t *sec;
@ -397,6 +442,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
self->PrevX = self->X();
self->PrevY = self->Y();
self->PrevZ = self->Z();
return 0;
}
int AInventory::StaticLastMessageTic;
@ -1079,7 +1125,7 @@ void AInventory::DoPickupSpecial (AActor *toucher)
const char *AInventory::PickupMessage ()
{
return GetClass()->Meta.GetMetaString (AIMETA_PickupMessage);
return GetClass()->PickupMessage;
}
//===========================================================================
@ -1306,8 +1352,8 @@ bool AInventory::DoRespawn ()
void AInventory::GiveQuest (AActor *toucher)
{
int quest = GetClass()->Meta.GetMetaInt(AIMETA_GiveQuest);
if (quest>0 && quest<31)
int quest = GetClass()->GiveQuest;
if (quest > 0 && quest <= (int)countof(QuestItemClasses))
{
toucher->GiveInventoryType (QuestItemClasses[quest-1]);
}
@ -1478,7 +1524,7 @@ bool AInventory::CanPickup (AActor *toucher)
if (!toucher)
return false;
FActorInfo *ai = GetClass()->ActorInfo;
PClassActor *ai = GetClass();
// Is the item restricted to certain player classes?
if (ai->RestrictedToPlayerClass.Size() != 0)
{
@ -1607,6 +1653,35 @@ bool ACustomInventory::TryPickup (AActor *&toucher)
return useok;
}
IMPLEMENT_CLASS(PClassHealth)
//===========================================================================
//
// PClassHealth Constructor
//
//===========================================================================
PClassHealth::PClassHealth()
{
LowHealth = 0;
}
//===========================================================================
//
// PClassHealth :: Derive
//
//===========================================================================
void PClassHealth::Derive(PClass *newclass)
{
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassHealth)));
Super::Derive(newclass);
PClassHealth *newc = static_cast<PClassHealth *>(newclass);
newc->LowHealth = LowHealth;
newc->LowHealthMessage = LowHealthMessage;
}
IMPLEMENT_CLASS (AHealth)
//===========================================================================
@ -1616,13 +1691,13 @@ IMPLEMENT_CLASS (AHealth)
//===========================================================================
const char *AHealth::PickupMessage ()
{
int threshold = GetClass()->Meta.GetMetaInt(AIMETA_LowHealth, 0);
int threshold = GetClass()->LowHealth;
if (PrevHealth < threshold)
{
const char *message = GetClass()->Meta.GetMetaString (AIMETA_LowHealthMessage);
FString message = GetClass()->LowHealthMessage;
if (message != NULL)
if (message.IsNotEmpty())
{
return message;
}
@ -1752,13 +1827,14 @@ AInventory *ABackpackItem::CreateCopy (AActor *other)
{
// Find every unique type of ammo. Give it to the player if
// he doesn't have it already, and double its maximum capacity.
for (unsigned int i = 0; i < PClass::m_Types.Size(); ++i)
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
const PClass *type = PClass::m_Types[i];
PClass *type = PClassActor::AllActorClasses[i];
if (type->ParentClass == RUNTIME_CLASS(AAmmo))
{
AAmmo *ammo = static_cast<AAmmo *>(other->FindInventory (type));
PClassActor *atype = static_cast<PClassActor *>(type);
AAmmo *ammo = static_cast<AAmmo *>(other->FindInventory(atype));
int amount = static_cast<AAmmo *>(GetDefaultByType(type))->BackpackAmount;
// extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL))
@ -1768,7 +1844,7 @@ AInventory *ABackpackItem::CreateCopy (AActor *other)
if (amount < 0) amount = 0;
if (ammo == NULL)
{ // The player did not have the ammo. Add it.
ammo = static_cast<AAmmo *>(Spawn (type, 0, 0, 0, NO_REPLACE));
ammo = static_cast<AAmmo *>(Spawn(atype, 0, 0, 0, NO_REPLACE));
ammo->Amount = bDepleted ? 0 : amount;
if (ammo->BackpackMaxAmount > ammo->MaxAmount)
{

View file

@ -10,6 +10,8 @@
class player_t;
class FConfigFile;
class AWeapon;
class PClassWeapon;
class PClassPlayerPawn;
struct visstyle_t;
class FWeaponSlot
@ -20,13 +22,13 @@ public:
FWeaponSlot &operator= (const FWeaponSlot &other) { Weapons = other.Weapons; return *this; }
void Clear() { Weapons.Clear(); }
bool AddWeapon (const char *type);
bool AddWeapon (const PClass *type);
bool AddWeapon (PClassWeapon *type);
void AddWeaponList (const char *list, bool clear);
AWeapon *PickWeapon (player_t *player, bool checkammo = false);
int Size () const { return (int)Weapons.Size(); }
int LocateWeapon (const PClass *type);
int LocateWeapon (PClassWeapon *type);
inline const PClass *GetWeapon (int index) const
inline PClassWeapon *GetWeapon (int index) const
{
if ((unsigned)index < Weapons.Size())
{
@ -43,7 +45,7 @@ public:
private:
struct WeaponInfo
{
const PClass *Type;
PClassWeapon *Type;
fixed_t Position;
};
void SetInitialPositions();
@ -69,25 +71,25 @@ struct FWeaponSlots
AWeapon *PickPrevWeapon (player_t *player);
void Clear ();
bool LocateWeapon (const PClass *type, int *const slot, int *const index);
ESlotDef AddDefaultWeapon (int slot, const PClass *type);
bool LocateWeapon (PClassWeapon *type, int *const slot, int *const index);
ESlotDef AddDefaultWeapon (int slot, PClassWeapon *type);
void AddExtraWeapons();
void SetFromGameInfo();
void SetFromPlayer(const PClass *type);
void StandardSetup(const PClass *type);
void LocalSetup(const PClass *type);
void SetFromPlayer(PClassPlayerPawn *type);
void StandardSetup(PClassPlayerPawn *type);
void LocalSetup(PClassActor *type);
void SendDifferences(int playernum, const FWeaponSlots &other);
int RestoreSlots (FConfigFile *config, const char *section);
void PrintSettings();
void AddSlot(int slot, const PClass *type, bool feedback);
void AddSlotDefault(int slot, const PClass *type, bool feedback);
void AddSlot(int slot, PClassWeapon *type, bool feedback);
void AddSlotDefault(int slot, PClassWeapon *type, bool feedback);
};
void P_PlaybackKeyConfWeapons(FWeaponSlots *slots);
void Net_WriteWeapon(const PClass *type);
const PClass *Net_ReadWeapon(BYTE **stream);
void Net_WriteWeapon(PClassWeapon *type);
PClassWeapon *Net_ReadWeapon(BYTE **stream);
void P_SetupWeapons_ntohton();
void P_WriteDemoWeaponsChunk(BYTE **demo);
@ -99,17 +101,6 @@ void P_ReadDemoWeaponsChunk(BYTE **demo);
// A pickup is anything the player can pickup (i.e. weapons, ammo, powerups, etc)
enum
{
AIMETA_BASE = 0x71000,
AIMETA_PickupMessage, // string
AIMETA_GiveQuest, // optionally give one of the quest items.
AIMETA_DropAmount, // specifies the amount for a dropped ammo item
AIMETA_LowHealth,
AIMETA_LowHealthMessage,
AIMETA_PuzzFailMessage,
};
enum
{
IF_ACTIVATABLE = 1<<0, // can be activated
@ -141,9 +132,22 @@ enum
};
class PClassInventory : public PClassActor
{
DECLARE_CLASS(PClassInventory, PClassActor)
protected:
virtual void Derive(PClass *newclass);
public:
PClassInventory();
FString PickupMessage;
int GiveQuest; // Optionally give one of the quest items.
FTextureID AltHUDIcon;
};
class AInventory : public AActor
{
DECLARE_CLASS (AInventory, AActor)
DECLARE_CLASS_WITH_META(AInventory, AActor, PClassInventory)
HAS_OBJECT_POINTERS
public:
virtual void Touch (AActor *toucher);
@ -182,7 +186,7 @@ public:
const PClass *SpawnPointClass; // For respawning like Heretic's mace
DWORD ItemFlags;
const PClass *PickupFlash; // actor to spawn as pickup flash
PClassActor *PickupFlash; // actor to spawn as pickup flash
FSoundIDNoInit PickupSound;
@ -233,43 +237,59 @@ public:
};
// Ammo: Something a weapon needs to operate
class PClassAmmo : public PClassInventory
{
DECLARE_CLASS(PClassAmmo, PClassInventory)
protected:
virtual void Derive(PClass *newclass);
public:
PClassAmmo();
int DropAmount; // Specifies the amount for a dropped ammo item.
};
class AAmmo : public AInventory
{
DECLARE_CLASS (AAmmo, AInventory)
DECLARE_CLASS_WITH_META(AAmmo, AInventory, PClassAmmo)
public:
void Serialize (FArchive &arc);
AInventory *CreateCopy (AActor *other);
bool HandlePickup (AInventory *item);
const PClass *GetParentAmmo () const;
PClassActor *GetParentAmmo () const;
AInventory *CreateTossable ();
int BackpackAmount, BackpackMaxAmount;
};
// A weapon is just that.
enum
class PClassWeapon : public PClassInventory
{
AWMETA_BASE = 0x72000,
AWMETA_SlotNumber,
AWMETA_SlotPriority,
DECLARE_CLASS(PClassWeapon, PClassInventory);
protected:
virtual void Derive(PClass *newclass);
public:
PClassWeapon();
int SlotNumber;
fixed_t SlotPriority;
};
class AWeapon : public AInventory
{
DECLARE_CLASS (AWeapon, AInventory)
DECLARE_CLASS_WITH_META(AWeapon, AInventory, PClassWeapon)
HAS_OBJECT_POINTERS
public:
DWORD WeaponFlags;
const PClass *AmmoType1, *AmmoType2; // Types of ammo used by this weapon
PClassAmmo *AmmoType1, *AmmoType2; // Types of ammo used by this weapon
int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon
int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon
int AmmoUse1, AmmoUse2; // How much ammo to use with each shot
int Kickback;
fixed_t YAdjust; // For viewing the weapon fullscreen
FSoundIDNoInit UpSound, ReadySound; // Sounds when coming up and idle
const PClass *SisterWeaponType; // Another weapon to pick up with this one
const PClass *ProjectileType; // Projectile used by primary attack
const PClass *AltProjectileType; // Projectile used by alternate attack
PClassWeapon *SisterWeaponType; // Another weapon to pick up with this one
PClassActor *ProjectileType; // Projectile used by primary attack
PClassActor *AltProjectileType; // Projectile used by alternate attack
int SelectionOrder; // Lower-numbered weapons get picked first
int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo
fixed_t MoveCombatDist; // Used by bots, but do they *really* need it?
@ -330,9 +350,9 @@ public:
};
protected:
AAmmo *AddAmmo (AActor *other, const PClass *ammotype, int amount);
AAmmo *AddAmmo (AActor *other, PClassActor *ammotype, int amount);
bool AddExistingAmmo (AAmmo *ammo, int amount);
AWeapon *AddWeapon (const PClass *weapon);
AWeapon *AddWeapon (PClassWeapon *weapon);
};
enum
@ -377,9 +397,21 @@ public:
// Health is some item that gives the player health when picked up.
class PClassHealth : public PClassInventory
{
DECLARE_CLASS(PClassHealth, PClassInventory)
protected:
virtual void Derive(PClass *newclass);
public:
PClassHealth();
FString LowHealthMessage;
int LowHealth;
};
class AHealth : public AInventory
{
DECLARE_CLASS (AHealth, AInventory)
DECLARE_CLASS_WITH_META(AHealth, AInventory, PClassHealth)
int PrevHealth;
public:
@ -482,9 +514,18 @@ protected:
};
// PuzzleItems work in conjunction with the UsePuzzleItem special
class PClassPuzzleItem : public PClassInventory
{
DECLARE_CLASS(PClassPuzzleItem, PClassInventory);
protected:
virtual void Derive(PClass *newclass);
public:
FString PuzzFailMessage;
};
class APuzzleItem : public AInventory
{
DECLARE_CLASS (APuzzleItem, AInventory)
DECLARE_CLASS_WITH_META(APuzzleItem, AInventory, PClassPuzzleItem)
public:
void Serialize (FArchive &arc);
bool ShouldStay ();

View file

@ -9,7 +9,16 @@
#include "v_font.h"
#include "farchive.h"
IMPLEMENT_CLASS (APuzzleItem)
IMPLEMENT_CLASS(PClassPuzzleItem)
void PClassPuzzleItem::Derive(PClass *newclass)
{
Super::Derive(newclass);
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassPuzzleItem)));
static_cast<PClassPuzzleItem *>(newclass)->PuzzFailMessage = PuzzFailMessage;
}
IMPLEMENT_CLASS(APuzzleItem)
void APuzzleItem::Serialize (FArchive &arc)
{
@ -37,9 +46,9 @@ bool APuzzleItem::Use (bool pickup)
S_Sound (Owner, CHAN_VOICE, "*puzzfail", 1, ATTN_IDLE);
if (Owner != NULL && Owner->CheckLocalView (consoleplayer))
{
const char *message = GetClass()->Meta.GetMetaString (AIMETA_PuzzFailMessage);
if (message != NULL && *message=='$') message = GStrings[message + 1];
if (message == NULL) message = GStrings("TXT_USEPUZZLEFAILED");
FString message = GetClass()->PuzzFailMessage;
if (message.IsNotEmpty() && message[0] == '$') message = GStrings[&message[1]];
if (message.IsEmpty()) message = GStrings("TXT_USEPUZZLEFAILED");
C_MidPrintBold (SmallFont, message);
}
return false;

View file

@ -20,7 +20,7 @@
#define MAX_RANDOMSPAWNERS_RECURSION 32 // Should be largely more than enough, honestly.
static FRandom pr_randomspawn("RandomSpawn");
static bool IsMonster(const FDropItem *di)
static bool IsMonster(DDropItem *di)
{
const PClass *pclass = PClass::FindClass(di->Name);
@ -41,9 +41,9 @@ class ARandomSpawner : public AActor
// random spawner's velocity (0...) instead of their own.
void BeginPlay()
{
FDropItem *di; // di will be our drop item list iterator
FDropItem *drop; // while drop stays as the reference point.
int n=0;
DDropItem *di; // di will be our drop item list iterator
DDropItem *drop; // while drop stays as the reference point.
int n = 0;
bool nomonsters = (dmflags & DF_NO_MONSTERS) || (level.flags2 & LEVEL2_NOMONSTERS);
Super::BeginPlay();
@ -56,8 +56,8 @@ class ARandomSpawner : public AActor
{
if (!nomonsters || !IsMonster(di))
{
if (di->amount < 0) di->amount = 1; // default value is -1, we need a positive value.
n += di->amount; // this is how we can weight the list.
if (di->Amount < 0) di->Amount = 1; // default value is -1, we need a positive value.
n += di->Amount; // this is how we can weight the list.
}
di = di->Next;
}
@ -77,7 +77,7 @@ class ARandomSpawner : public AActor
if (di->Name != NAME_None &&
(!nomonsters || !IsMonster(di)))
{
n -= di->amount;
n -= di->Amount;
if ((di->Next != NULL) && (n > -1))
di = di->Next;
else
@ -95,14 +95,14 @@ class ARandomSpawner : public AActor
Destroy();
return;
}
else if (pr_randomspawn() <= di->probability) // prob 255 = always spawn, prob 0 = never spawn.
else if (pr_randomspawn() <= di->Probability) // prob 255 = always spawn, prob 0 = almost never spawn.
{
// Handle replacement here so as to get the proper speed and flags for missiles
const PClass *cls;
cls = PClass::FindClass(di->Name);
PClassActor *cls;
cls = PClass::FindActor(di->Name);
if (cls != NULL)
{
const PClass *rep = cls->GetReplacement();
PClassActor *rep = cls->GetReplacement();
if (rep != NULL)
{
cls = rep;
@ -132,21 +132,29 @@ class ARandomSpawner : public AActor
// necessary to them -- such as their source and destination.
void PostBeginPlay()
{
AActor * newmobj = NULL;
bool boss = false;
Super::PostBeginPlay();
if (Species == NAME_None)
{
Destroy();
return;
AActor *newmobj = NULL;
bool boss = false;
if (Species == NAME_None)
{
Destroy();
return;
}
const PClass * cls = PClass::FindClass(Species);
PClassActor *cls = PClass::FindActor(Species);
if (this->flags & MF_MISSILE && target && target->target) // Attempting to spawn a missile.
{
if ((tracer == NULL) && (flags2 & MF2_SEEKERMISSILE)) tracer = target->target;
if ((tracer == NULL) && (flags2 & MF2_SEEKERMISSILE))
{
tracer = target->target;
}
newmobj = P_SpawnMissileXYZ(Pos(), target, target->target, cls, false);
}
else newmobj = Spawn(cls, Pos(), NO_REPLACE);
else
{
newmobj = Spawn(cls, Pos(), NO_REPLACE);
}
if (newmobj != NULL)
{
// copy everything relevant
@ -200,7 +208,7 @@ class ARandomSpawner : public AActor
if ((newmobj->flags4 & MF4_BOSSDEATH) || (newmobj->flags2 & MF2_BOSS))
boss = true;
// If a replaced actor has either of those same flags, it's also a boss.
AActor * rep = GetDefaultByType(GetClass()->ActorInfo->GetReplacee()->Class);
AActor *rep = GetDefaultByType(GetClass()->GetReplacee());
if (rep && ((rep->flags4 & MF4_BOSSDEATH) || (rep->flags2 & MF2_BOSS)))
boss = true;
}
@ -215,7 +223,7 @@ class ARandomSpawner : public AActor
Super::Tick();
if (tracer == NULL || tracer->health <= 0)
{
CALL_ACTION(A_BossDeath, this);
A_BossDeath(this);
Destroy();
}
}
@ -223,4 +231,3 @@ class ARandomSpawner : public AActor
};
IMPLEMENT_CLASS (ARandomSpawner)

View file

@ -215,7 +215,7 @@ public:
TObjPtr<AActor> UnmorphedMe;
int UnmorphTime, MorphStyle;
const PClass *MorphExitFlash;
PClassActor *MorphExitFlash;
ActorFlags FlagsSave;
};

View file

@ -270,7 +270,7 @@ FSpotList *DSpotState::FindSpotList(const PClass *type)
bool DSpotState::AddSpot(ASpecialSpot *spot)
{
FSpotList *list = FindSpotList(RUNTIME_TYPE(spot));
FSpotList *list = FindSpotList(spot->GetClass());
if (list != NULL) return list->Add(spot);
return false;
}
@ -283,7 +283,7 @@ bool DSpotState::AddSpot(ASpecialSpot *spot)
bool DSpotState::RemoveSpot(ASpecialSpot *spot)
{
FSpotList *list = FindSpotList(RUNTIME_TYPE(spot));
FSpotList *list = FindSpotList(spot->GetClass());
if (list != NULL) return list->Remove(spot);
return false;
}
@ -391,36 +391,36 @@ void ASpecialSpot::Destroy()
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem)
{
PARAM_ACTION_PROLOGUE;
PARAM_CLASS (cls, AActor);
PARAM_INT_OPT (fail_sp) { fail_sp = 0; }
PARAM_INT_OPT (fail_co) { fail_co = 0; }
PARAM_INT_OPT (fail_dm) { fail_dm = 0; }
AActor *spot = NULL;
DSpotState *state = DSpotState::GetSpotState();
if (state != NULL) spot = state->GetRandomSpot(RUNTIME_TYPE(self), true);
if (spot == NULL) return;
ACTION_PARAM_START(4);
ACTION_PARAM_CLASS(cls, 0);
ACTION_PARAM_INT(fail_sp, 1);
ACTION_PARAM_INT(fail_co, 2);
ACTION_PARAM_INT(fail_dm, 3);
if (state != NULL) spot = state->GetRandomSpot(self->GetClass(), true);
if (spot == NULL) return 0;
if (!multiplayer && pr_spawnmace() < fail_sp)
{ // Sometimes doesn't show up if not in deathmatch
return;
return 0;
}
if (multiplayer && !deathmatch && pr_spawnmace() < fail_co)
{
return;
return 0;
}
if (deathmatch && pr_spawnmace() < fail_dm)
{
return;
return 0;
}
if (cls == NULL)
{
return;
return 0;
}
AActor *spawned = Spawn(cls, self->Pos(), ALLOW_REPLACE);
@ -436,8 +436,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem)
}
if (spawned->IsKindOf(RUNTIME_CLASS(AInventory)))
{
static_cast<AInventory*>(spawned)->SpawnPointClass = RUNTIME_TYPE(self);
static_cast<AInventory*>(spawned)->SpawnPointClass = self->GetClass();
}
}
return 0;
}

View file

@ -14,7 +14,7 @@ public:
virtual void PlayPickupSound (AActor *toucher);
int PieceValue;
const PClass * WeaponClass;
PClassWeapon *WeaponClass;
TObjPtr<AWeapon> FullWeapon;
};

View file

@ -31,11 +31,29 @@ FString WeaponSection;
TArray<FString> KeyConfWeapons;
FWeaponSlots *PlayingKeyConf;
TArray<const PClass *> Weapons_ntoh;
TMap<const PClass *, int> Weapons_hton;
TArray<PClassWeapon *> Weapons_ntoh;
TMap<PClassWeapon *, int> Weapons_hton;
static int STACK_ARGS ntoh_cmp(const void *a, const void *b);
IMPLEMENT_CLASS(PClassWeapon)
PClassWeapon::PClassWeapon()
{
SlotNumber = -1;
SlotPriority = FIXED_MAX;
}
void PClassWeapon::Derive(PClass *newclass)
{
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassWeapon)));
Super::Derive(newclass);
PClassWeapon *newc = static_cast<PClassWeapon *>(newclass);
newc->SlotNumber = SlotNumber;
newc->SlotPriority = SlotPriority;
}
//===========================================================================
//
// AWeapon :: Serialize
@ -334,7 +352,7 @@ void AWeapon::AttachToOwner (AActor *other)
//
//===========================================================================
AAmmo *AWeapon::AddAmmo (AActor *other, const PClass *ammotype, int amount)
AAmmo *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount)
{
AAmmo *ammo;
@ -407,7 +425,7 @@ bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount)
//
//===========================================================================
AWeapon *AWeapon::AddWeapon (const PClass *weapontype)
AWeapon *AWeapon::AddWeapon (PClassWeapon *weapontype)
{
AWeapon *weap;
@ -708,13 +726,13 @@ void AWeaponGiver::Serialize(FArchive &arc)
bool AWeaponGiver::TryPickup(AActor *&toucher)
{
FDropItem *di = GetDropItems();
DDropItem *di = GetDropItems();
AWeapon *weap;
if (di != NULL)
{
const PClass *ti = PClass::FindClass(di->Name);
if (ti->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
PClassWeapon *ti = dyn_cast<PClassWeapon>(PClass::FindClass(di->Name));
if (ti != NULL)
{
if (master == NULL)
{
@ -764,10 +782,10 @@ bool AWeaponGiver::TryPickup(AActor *&toucher)
bool FWeaponSlot::AddWeapon(const char *type)
{
return AddWeapon (PClass::FindClass (type));
return AddWeapon(static_cast<PClassWeapon *>(PClass::FindClass(type)));
}
bool FWeaponSlot::AddWeapon(const PClass *type)
bool FWeaponSlot::AddWeapon(PClassWeapon *type)
{
unsigned int i;
@ -828,7 +846,7 @@ void FWeaponSlot :: AddWeaponList(const char *list, bool clear)
//
//===========================================================================
int FWeaponSlot::LocateWeapon(const PClass *type)
int FWeaponSlot::LocateWeapon(PClassWeapon *type)
{
unsigned int i;
@ -954,7 +972,7 @@ void FWeaponSlot::Sort()
for (i = 1; i < (int)Weapons.Size(); ++i)
{
fixed_t pos = Weapons[i].Position;
const PClass *type = Weapons[i].Type;
PClassWeapon *type = Weapons[i].Type;
for (j = i - 1; j >= 0 && Weapons[j].Position > pos; --j)
{
Weapons[j + 1] = Weapons[j];
@ -1003,7 +1021,7 @@ void FWeaponSlots::Clear()
//
//===========================================================================
ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, const PClass *type)
ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, PClassWeapon *type)
{
int currSlot, index;
@ -1028,7 +1046,7 @@ ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, const PClass *type)
//
//===========================================================================
bool FWeaponSlots::LocateWeapon (const PClass *type, int *const slot, int *const index)
bool FWeaponSlots::LocateWeapon (PClassWeapon *type, int *const slot, int *const index)
{
int i, j;
@ -1126,7 +1144,7 @@ AWeapon *FWeaponSlots::PickNextWeapon(player_t *player)
slot = 0;
}
}
const PClass *type = Slots[slot].GetWeapon(index);
PClassWeapon *type = Slots[slot].GetWeapon(index);
AWeapon *weap = static_cast<AWeapon *>(player->mo->FindInventory(type));
if (weap != NULL && weap->CheckAmmo(AWeapon::EitherFire, false))
{
@ -1181,7 +1199,7 @@ AWeapon *FWeaponSlots::PickPrevWeapon (player_t *player)
}
index = Slots[slot].Size() - 1;
}
const PClass *type = Slots[slot].GetWeapon(index);
PClassWeapon *type = Slots[slot].GetWeapon(index);
AWeapon *weap = static_cast<AWeapon *>(player->mo->FindInventory(type));
if (weap != NULL && weap->CheckAmmo(AWeapon::EitherFire, false))
{
@ -1213,23 +1231,25 @@ void FWeaponSlots::AddExtraWeapons()
}
// Append extra weapons to the slots.
for (unsigned int i = 0; i < PClass::m_Types.Size(); ++i)
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
PClass *cls = PClass::m_Types[i];
PClass *cls = PClassActor::AllActorClasses[i];
if (cls->ActorInfo != NULL &&
(cls->ActorInfo->GameFilter == GAME_Any || (cls->ActorInfo->GameFilter & gameinfo.gametype)) &&
cls->ActorInfo->Replacement == NULL && // Replaced weapons don't get slotted.
cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)) &&
!(static_cast<AWeapon*>(GetDefaultByType(cls))->WeaponFlags & WIF_POWERED_UP) &&
!LocateWeapon(cls, NULL, NULL) // Don't duplicate it if it's already present.
if (!cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
continue;
}
PClassWeapon *acls = static_cast<PClassWeapon *>(cls);
if ((acls->GameFilter == GAME_Any || (acls->GameFilter & gameinfo.gametype)) &&
acls->Replacement == NULL && // Replaced weapons don't get slotted.
!(((AWeapon *)(acls->Defaults))->WeaponFlags & WIF_POWERED_UP) &&
!LocateWeapon(acls, NULL, NULL) // Don't duplicate it if it's already present.
)
{
int slot = cls->Meta.GetMetaInt(AWMETA_SlotNumber, -1);
int slot = acls->SlotNumber;
if ((unsigned)slot < NUM_WEAPON_SLOTS)
{
fixed_t position = cls->Meta.GetMetaFixed(AWMETA_SlotPriority, INT_MAX);
FWeaponSlot::WeaponInfo info = { cls, position };
FWeaponSlot::WeaponInfo info = { acls, acls->SlotPriority };
Slots[slot].Weapons.Push(info);
}
}
@ -1266,7 +1286,7 @@ void FWeaponSlots::SetFromGameInfo()
{
for (unsigned j = 0; j < gameinfo.DefaultWeaponSlots[i].Size(); i++)
{
const PClass *cls = PClass::FindClass(gameinfo.DefaultWeaponSlots[i][j]);
PClassWeapon *cls = dyn_cast<PClassWeapon>(PClass::FindClass(gameinfo.DefaultWeaponSlots[i][j]));
if (cls == NULL)
{
Printf("Unknown weapon class '%s' found in default weapon slot assignments\n",
@ -1291,7 +1311,7 @@ void FWeaponSlots::SetFromGameInfo()
//
//===========================================================================
void FWeaponSlots::StandardSetup(const PClass *type)
void FWeaponSlots::StandardSetup(PClassPlayerPawn *type)
{
SetFromPlayer(type);
AddExtraWeapons();
@ -1311,7 +1331,7 @@ void FWeaponSlots::StandardSetup(const PClass *type)
//
//===========================================================================
void FWeaponSlots::LocalSetup(const PClass *type)
void FWeaponSlots::LocalSetup(PClassActor *type)
{
P_PlaybackKeyConfWeapons(this);
if (WeaponSection.IsNotEmpty())
@ -1384,15 +1404,14 @@ void FWeaponSlots::SendDifferences(int playernum, const FWeaponSlots &other)
//
//===========================================================================
void FWeaponSlots::SetFromPlayer(const PClass *type)
void FWeaponSlots::SetFromPlayer(PClassPlayerPawn *type)
{
Clear();
for (int i = 0; i < NUM_WEAPON_SLOTS; ++i)
{
const char *str = type->Meta.GetMetaString(APMETA_Slot0 + i);
if (str != NULL)
if (!type->Slot[i].IsEmpty())
{
Slots[i].AddWeaponList(str, false);
Slots[i].AddWeaponList(type->Slot[i], false);
}
}
}
@ -1503,7 +1522,7 @@ CCMD (setslot)
Net_WriteByte(argv.argc()-2);
for (int i = 2; i < argv.argc(); i++)
{
Net_WriteWeapon(PClass::FindClass(argv[i]));
Net_WriteWeapon(dyn_cast<PClassWeapon>(PClass::FindClass(argv[i])));
}
}
}
@ -1514,7 +1533,7 @@ CCMD (setslot)
//
//===========================================================================
void FWeaponSlots::AddSlot(int slot, const PClass *type, bool feedback)
void FWeaponSlots::AddSlot(int slot, PClassWeapon *type, bool feedback)
{
if (type != NULL && !Slots[slot].AddWeapon(type) && feedback)
{
@ -1532,19 +1551,26 @@ CCMD (addslot)
return;
}
PClassWeapon *type= dyn_cast<PClassWeapon>(PClass::FindClass(argv[2]));
if (type == NULL)
{
Printf("%s is not a weapon\n", argv[2]);
return;
}
if (ParsingKeyConf)
{
KeyConfWeapons.Push(argv.args());
}
else if (PlayingKeyConf != NULL)
{
PlayingKeyConf->AddSlot(int(slot), PClass::FindClass(argv[2]), false);
PlayingKeyConf->AddSlot(int(slot), type, false);
}
else
{
Net_WriteByte(DEM_ADDSLOT);
Net_WriteByte(slot);
Net_WriteWeapon(PClass::FindClass(argv[2]));
Net_WriteWeapon(type);
}
}
@ -1567,7 +1593,7 @@ CCMD (weaponsection)
// CCMD addslotdefault
//
//===========================================================================
void FWeaponSlots::AddSlotDefault(int slot, const PClass *type, bool feedback)
void FWeaponSlots::AddSlotDefault(int slot, PClassWeapon *type, bool feedback)
{
if (type != NULL && type->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
@ -1592,7 +1618,7 @@ void FWeaponSlots::AddSlotDefault(int slot, const PClass *type, bool feedback)
CCMD (addslotdefault)
{
const PClass *type;
PClassWeapon *type;
unsigned int slot;
if (argv.argc() != 3 || (slot = atoi (argv[1])) >= NUM_WEAPON_SLOTS)
@ -1601,8 +1627,8 @@ CCMD (addslotdefault)
return;
}
type = PClass::FindClass (argv[2]);
if (type == NULL || !type->IsDescendantOf (RUNTIME_CLASS(AWeapon)))
type = dyn_cast<PClassWeapon>(PClass::FindClass(argv[2]));
if (type == NULL)
{
Printf ("%s is not a weapon\n", argv[2]);
return;
@ -1614,13 +1640,13 @@ CCMD (addslotdefault)
}
else if (PlayingKeyConf != NULL)
{
PlayingKeyConf->AddSlotDefault(int(slot), PClass::FindClass(argv[2]), false);
PlayingKeyConf->AddSlotDefault(int(slot), type, false);
}
else
{
Net_WriteByte(DEM_ADDSLOTDEFAULT);
Net_WriteByte(slot);
Net_WriteWeapon(PClass::FindClass(argv[2]));
Net_WriteWeapon(type);
}
}
@ -1657,20 +1683,20 @@ void P_PlaybackKeyConfWeapons(FWeaponSlots *slots)
void P_SetupWeapons_ntohton()
{
unsigned int i;
const PClass *cls;
PClassWeapon *cls;
Weapons_ntoh.Clear();
Weapons_hton.Clear();
cls = NULL;
Weapons_ntoh.Push(cls); // Index 0 is always NULL.
for (i = 0; i < PClass::m_Types.Size(); ++i)
for (i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
PClass *cls = PClass::m_Types[i];
PClassActor *cls = PClassActor::AllActorClasses[i];
if (cls->ActorInfo != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
if (cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
Weapons_ntoh.Push(cls);
Weapons_ntoh.Push(static_cast<PClassWeapon *>(cls));
}
}
qsort(&Weapons_ntoh[1], Weapons_ntoh.Size() - 1, sizeof(Weapons_ntoh[0]), ntoh_cmp);
@ -1696,10 +1722,10 @@ void P_SetupWeapons_ntohton()
static int STACK_ARGS ntoh_cmp(const void *a, const void *b)
{
const PClass *c1 = *(const PClass **)a;
const PClass *c2 = *(const PClass **)b;
int g1 = c1->ActorInfo->GameFilter == GAME_Any ? 1 : (c1->ActorInfo->GameFilter & gameinfo.gametype) ? 0 : 2;
int g2 = c2->ActorInfo->GameFilter == GAME_Any ? 1 : (c2->ActorInfo->GameFilter & gameinfo.gametype) ? 0 : 2;
PClassWeapon *c1 = *(PClassWeapon **)a;
PClassWeapon *c2 = *(PClassWeapon **)b;
int g1 = c1->GameFilter == GAME_Any ? 1 : (c1->GameFilter & gameinfo.gametype) ? 0 : 2;
int g2 = c2->GameFilter == GAME_Any ? 1 : (c2->GameFilter & gameinfo.gametype) ? 0 : 2;
if (g1 != g2)
{
return g1 - g2;
@ -1737,7 +1763,7 @@ void P_WriteDemoWeaponsChunk(BYTE **demo)
void P_ReadDemoWeaponsChunk(BYTE **demo)
{
int count, i;
const PClass *type;
PClassWeapon *type;
const char *s;
count = ReadWord(demo);
@ -1750,7 +1776,7 @@ void P_ReadDemoWeaponsChunk(BYTE **demo)
for (i = 1; i < count; ++i)
{
s = ReadStringConst(demo);
type = PClass::FindClass(s);
type = dyn_cast<PClassWeapon>(PClass::FindClass(s));
// If a demo was recorded with a weapon that is no longer present,
// should we report it?
Weapons_ntoh[i] = type;
@ -1767,7 +1793,7 @@ void P_ReadDemoWeaponsChunk(BYTE **demo)
//
//===========================================================================
void Net_WriteWeapon(const PClass *type)
void Net_WriteWeapon(PClassWeapon *type)
{
int index, *index_p;
@ -1799,7 +1825,7 @@ void Net_WriteWeapon(const PClass *type)
//
//===========================================================================
const PClass *Net_ReadWeapon(BYTE **stream)
PClassWeapon *Net_ReadWeapon(BYTE **stream)
{
int index;
@ -1823,23 +1849,24 @@ const PClass *Net_ReadWeapon(BYTE **stream)
DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor)
{
ACTION_PARAM_START(2);
ACTION_PARAM_FLOAT(zoom, 0);
ACTION_PARAM_INT(flags, 1);
PARAM_ACTION_PROLOGUE;
PARAM_FLOAT_OPT (zoom) { zoom = 1; }
PARAM_INT_OPT (flags) { flags = 0; }
if (self->player != NULL && self->player->ReadyWeapon != NULL)
{
zoom = 1 / clamp(zoom, 0.1f, 50.f);
zoom = 1 / clamp(zoom, 0.1, 50.0);
if (flags & 1)
{ // Make the zoom instant.
self->player->FOV = self->player->DesiredFOV * zoom;
self->player->FOV = float(self->player->DesiredFOV * zoom);
}
if (flags & 2)
{ // Disable pitch/yaw scaling.
zoom = -zoom;
}
self->player->ReadyWeapon->FOVScale = zoom;
self->player->ReadyWeapon->FOVScale = float(zoom);
}
return 0;
}
//===========================================================================
@ -1850,11 +1877,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor)
DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_SetCrosshair)
{
ACTION_PARAM_START(1);
ACTION_PARAM_INT(xhair, 0);
PARAM_ACTION_PROLOGUE;
PARAM_INT(xhair);
if (self->player != NULL && self->player->ReadyWeapon != NULL)
{
self->player->ReadyWeapon->Crosshair = xhair;
}
return 0;
}

View file

@ -502,7 +502,7 @@ FTexture *FMugShot::GetFace(player_t *player, const char *default_face, int accu
}
if (CurrentState != NULL)
{
const char *skin_face = player->morphTics ? player->MorphedPlayerClass->Meta.GetMetaString(APMETA_Face) : skins[player->userinfo.GetSkin()].face;
const char *skin_face = player->morphTics ? player->MorphedPlayerClass->Face : skins[player->userinfo.GetSkin()].face;
return CurrentState->GetCurrentFrameTexture(default_face, skin_face, level, angle);
}
return NULL;

View file

@ -150,7 +150,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
{
type = INVENTORYICON;
const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(item)) //must be a kind of Inventory
if(item == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item)) //must be a kind of Inventory
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
}
@ -412,20 +412,20 @@ class CommandDrawSwitchableImage : public CommandDrawImage
return compare != value;
}
}
// Key species are used to allow altnerates for existing key slots.
// Key species are used to allow alternates for existing key slots.
static FName LookupKeySpecies(int keynum)
{
for(unsigned int i = 0;i < PClass::m_Types.Size();++i)
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
const PClass *cls = PClass::m_Types[i];
if(cls->IsDescendantOf(RUNTIME_CLASS(AKey)))
PClassActor *cls = PClassActor::AllActorClasses[i];
if (cls->IsDescendantOf(RUNTIME_CLASS(AKey)))
{
AKey *key = (AKey *)GetDefaultByType(cls);
if(key->KeyNumber == keynum)
if (key->KeyNumber == keynum)
return cls->TypeName;
}
}
return FName();
return NAME_None;
}
public:
@ -471,7 +471,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
{
inventoryItem[0] = sc.String;
const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(item)) //must be a kind of Inventory
if(item == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item)) //must be a kind of Inventory
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
}
@ -498,7 +498,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
sc.MustGetToken(TK_Identifier);
inventoryItem[1] = sc.String;
const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(item)) //must be a kind of Inventory
if(item == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item)) //must be a kind of Inventory
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
}
@ -529,7 +529,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
drawAlt = 1; //draw off state until we know we have something.
for (int i = 0; i < statusBar->CPlayer->weapons.Slots[conditionalValue[0]].Size(); i++)
{
const PClass *weap = statusBar->CPlayer->weapons.Slots[conditionalValue[0]].GetWeapon(i);
PClassActor *weap = statusBar->CPlayer->weapons.Slots[conditionalValue[0]].GetWeapon(i);
if(weap == NULL)
{
continue;
@ -616,12 +616,12 @@ class CommandDrawSwitchableImage : public CommandDrawImage
}
else //check the inventory items and draw selected sprite
{
AInventory* item = statusBar->CPlayer->mo->FindInventory(PClass::FindClass(inventoryItem[0]));
AInventory* item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(inventoryItem[0]));
if(item == NULL || !EvaluateOperation(conditionalOperator[0], conditionalValue[0], item->Amount))
drawAlt = 1;
if(conditionAnd)
{
item = statusBar->CPlayer->mo->FindInventory(PClass::FindClass(inventoryItem[1]));
item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(inventoryItem[1]));
bool secondCondition = item != NULL && EvaluateOperation(conditionalOperator[1], conditionalValue[1], item->Amount);
if((item != NULL && secondCondition) && drawAlt == 0) //both
{
@ -987,7 +987,7 @@ class CommandDrawString : public SBarInfoCommand
SBarInfoCoordinate startX;
SBarInfoCoordinate x;
SBarInfoCoordinate y;
int cache; /// General purpose cache.
intptr_t cache; /// General purpose cache.
StringValueType strValue;
int valueArgument;
FString str;
@ -996,11 +996,11 @@ class CommandDrawString : public SBarInfoCommand
private:
void SetStringToTag(AActor *actor)
{
if(actor != NULL)
if (actor != NULL)
{
if(actor->GetClass()->ClassIndex != cache)
if ((intptr_t)actor->GetClass() != cache)
{
cache = actor->GetClass()->ClassIndex;
cache = (intptr_t)actor->GetClass();
str = actor->GetTag();
RealignString();
}
@ -1077,7 +1077,7 @@ class CommandDrawNumber : public CommandDrawString
value = AMMO;
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(sc.String);
inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
@ -1093,7 +1093,7 @@ class CommandDrawNumber : public CommandDrawString
value = AMMOCAPACITY;
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(sc.String);
inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
@ -1159,7 +1159,7 @@ class CommandDrawNumber : public CommandDrawString
value = POWERUPTIME;
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(sc.String);
inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(inventoryItem))
{
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
@ -1171,7 +1171,7 @@ class CommandDrawNumber : public CommandDrawString
}
if(value == INVENTORY)
{
inventoryItem = PClass::FindClass(sc.String);
inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
@ -1405,7 +1405,7 @@ class CommandDrawNumber : public CommandDrawString
case POWERUPTIME:
{
//Get the PowerupType and check to see if the player has any in inventory.
const PClass* powerupType = ((APowerupGiver*) GetDefaultByType(inventoryItem))->PowerupType;
PClassActor* powerupType = ((APowerupGiver*) GetDefaultByType(inventoryItem))->PowerupType;
APowerup* powerup = (APowerup*) statusBar->CPlayer->mo->FindInventory(powerupType);
if(powerup != NULL)
num = powerup->EffectTics / TICRATE + 1;
@ -1543,7 +1543,7 @@ class CommandDrawNumber : public CommandDrawString
EColorRange highTranslation;
EColorRange normalTranslation;
ValueType value;
const PClass *inventoryItem;
PClassActor *inventoryItem;
FString prefixPadding;
@ -2560,7 +2560,7 @@ class CommandDrawBar : public SBarInfoCommand
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
type = AMMO;
data.inventoryItem = PClass::FindClass(sc.String);
data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo
{
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
@ -2587,8 +2587,8 @@ class CommandDrawBar : public SBarInfoCommand
type = POWERUPTIME;
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
data.inventoryItem = PClass::FindClass(sc.String);
sc.MustGetToken(TK_Identifier);
data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(data.inventoryItem))
{
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
@ -2600,7 +2600,7 @@ class CommandDrawBar : public SBarInfoCommand
else
{
type = INVENTORY;
data.inventoryItem = PClass::FindClass(sc.String);
data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem))
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
@ -2758,7 +2758,7 @@ class CommandDrawBar : public SBarInfoCommand
{
//Get the PowerupType and check to see if the player has any in inventory.
APowerupGiver *powerupGiver = (APowerupGiver*) GetDefaultByType(data.inventoryItem);
const PClass *powerupType = powerupGiver->PowerupType;
PClassActor *powerupType = powerupGiver->PowerupType;
APowerup *powerup = (APowerup*) statusBar->CPlayer->mo->FindInventory(powerupType);
if(powerup != NULL && powerupType != NULL && powerupGiver != NULL)
{
@ -2822,7 +2822,7 @@ class CommandDrawBar : public SBarInfoCommand
if(sc.CheckToken(TK_Identifier) || (extendedSyntax && sc.CheckToken(TK_StringConst))) //comparing reference
{
data.inventoryItem = PClass::FindClass(sc.String);
data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem)) //must be a kind of inventory
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
@ -2868,7 +2868,7 @@ class CommandDrawBar : public SBarInfoCommand
bool useMaximumConstant;
union
{
const PClass *inventoryItem;
PClassActor *inventoryItem;
int value;
};
};
@ -2968,10 +2968,10 @@ class CommandPlayerClass : public SBarInfoCommandFlowControl
bool foundClass = false;
for(unsigned int c = 0;c < PlayerClasses.Size();c++)
{
if(stricmp(sc.String, PlayerClasses[c].Type->Meta.GetMetaString(APMETA_DisplayName)) == 0)
if(stricmp(sc.String, PlayerClasses[c].Type->DisplayName) == 0)
{
foundClass = true;
classes.Push(PlayerClasses[c].Type->ClassIndex);
classes.Push(PlayerClasses[c].Type);
break;
}
}
@ -2992,7 +2992,7 @@ class CommandPlayerClass : public SBarInfoCommandFlowControl
if(statusBar->CPlayer->cls == NULL)
return; //No class so we can not continue
int spawnClass = statusBar->CPlayer->cls->ClassIndex;
PClass *spawnClass = statusBar->CPlayer->cls;
for(unsigned int i = 0;i < classes.Size();i++)
{
if(classes[i] == spawnClass)
@ -3004,7 +3004,7 @@ class CommandPlayerClass : public SBarInfoCommandFlowControl
SetTruth(false, block, statusBar);
}
protected:
TArray<int> classes;
TArray<PClass*> classes;
};
////////////////////////////////////////////////////////////////////////////////
@ -3374,7 +3374,7 @@ class CommandInInventory : public SBarInfoCommandFlowControl
}
for(int i = 0;i < 2;i++)
{
item[i] = PClass::FindClass(sc.String);
item[i] = PClass::FindActor(sc.String);
if(item[i] == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item[i]))
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
@ -3425,7 +3425,7 @@ class CommandInInventory : public SBarInfoCommandFlowControl
protected:
bool conditionAnd;
bool negate;
const PClass *item[2];
PClassActor *item[2];
int amount[2];
};

View file

@ -117,16 +117,14 @@ static int statspace;
void AM_GetPosition(fixed_t & x, fixed_t & y);
FTextureID GetHUDIcon(const PClass *cls)
FTextureID GetHUDIcon(PClassInventory *cls)
{
FTextureID tex;
tex.texnum = cls->Meta.GetMetaInt(HUMETA_AltIcon, 0);
return tex;
return cls->AltHUDIcon;
}
void SetHUDIcon(PClass *cls, FTextureID tex)
void SetHUDIcon(PClassInventory *cls, FTextureID tex)
{
cls->Meta.SetMetaInt(HUMETA_AltIcon, tex.GetIndex());
cls->AltHUDIcon = tex;
}
//---------------------------------------------------------------------------
@ -378,32 +376,33 @@ static void DrawArmor(ABasicArmor * barmor, AHexenArmor * harmor, int x, int y)
// this doesn't have to be done each frame
//
//---------------------------------------------------------------------------
static TArray<const PClass*> KeyTypes, UnassignedKeyTypes;
static TArray<PClassActor *> KeyTypes, UnassignedKeyTypes;
static int STACK_ARGS ktcmp(const void * a, const void * b)
{
AKey * key1 = (AKey*)GetDefaultByType ( *(const PClass**)a );
AKey * key2 = (AKey*)GetDefaultByType ( *(const PClass**)b );
AKey *key1 = (AKey*)GetDefaultByType ( *(PClassActor **)a );
AKey *key2 = (AKey*)GetDefaultByType ( *(PClassActor **)b );
return key1->KeyNumber - key2->KeyNumber;
}
static void SetKeyTypes()
{
for(unsigned int i=0;i<PClass::m_Types.Size();i++)
for(unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); i++)
{
const PClass * ti = PClass::m_Types[i];
PClass *ti = PClassActor::AllActorClasses[i];
if (ti->IsDescendantOf(RUNTIME_CLASS(AKey)))
{
AKey * key = (AKey*)GetDefaultByType(ti);
PClassActor *tia = static_cast<PClassActor *>(ti);
AKey *key = (AKey*)GetDefaultByType(tia);
if (key->Icon.isValid() && key->KeyNumber>0)
{
KeyTypes.Push(ti);
KeyTypes.Push(tia);
}
else
{
UnassignedKeyTypes.Push(ti);
UnassignedKeyTypes.Push(tia);
}
}
}
@ -414,7 +413,7 @@ static void SetKeyTypes()
else
{
// Don't leave the list empty
const PClass * ti = RUNTIME_CLASS(AKey);
PClassActor *ti = RUNTIME_CLASS(AKey);
KeyTypes.Push(ti);
}
}
@ -479,30 +478,30 @@ static int DrawKeys(player_t * CPlayer, int x, int y)
int xo=x;
int i;
int c=0;
AInventory * inv;
AInventory *inv;
if (!deathmatch)
{
if (KeyTypes.Size()==0) SetKeyTypes();
if (KeyTypes.Size() == 0) SetKeyTypes();
// First all keys that are assigned to locks (in reverse order of definition)
for(i=KeyTypes.Size()-1;i>=0;i--)
for (i = KeyTypes.Size()-1; i >= 0; i--)
{
if ((inv=CPlayer->mo->FindInventory(KeyTypes[i])))
if ((inv = CPlayer->mo->FindInventory(KeyTypes[i])))
{
DrawOneKey(xo, x, y, c, inv);
}
}
// And now the rest
for(i=UnassignedKeyTypes.Size()-1;i>=0;i--)
for (i = UnassignedKeyTypes.Size()-1; i >= 0; i--)
{
if ((inv=CPlayer->mo->FindInventory(UnassignedKeyTypes[i])))
if ((inv = CPlayer->mo->FindInventory(UnassignedKeyTypes[i])))
{
DrawOneKey(xo, x, y, c, inv);
}
}
}
if (x==xo && y!=yo) y+=11;
if (x == xo && y != yo) y+=11;
return y-11;
}
@ -512,14 +511,14 @@ static int DrawKeys(player_t * CPlayer, int x, int y)
// Drawing Ammo
//
//---------------------------------------------------------------------------
static TArray<const PClass *> orderedammos;
static TArray<PClassAmmo *> orderedammos;
static void AddAmmoToList(AWeapon * weapdef)
{
for(int i=0; i<2;i++)
{
const PClass * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2;
PClassAmmo * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2;
if (ti)
{
AAmmo * ammodef=(AAmmo*)GetDefaultByType(ti);
@ -559,7 +558,7 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
// Order ammo by use of weapons in the weapon slots
for (k = 0; k < NUM_WEAPON_SLOTS; k++) for(j = 0; j < CPlayer->weapons.Slots[k].Size(); j++)
{
const PClass *weap = CPlayer->weapons.Slots[k].GetWeapon(j);
PClassActor *weap = CPlayer->weapons.Slots[k].GetWeapon(j);
if (weap)
{
@ -592,7 +591,7 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
for(i=orderedammos.Size()-1;i>=0;i--)
{
const PClass * type = orderedammos[i];
PClassAmmo * type = orderedammos[i];
AAmmo * ammoitem = (AAmmo*)CPlayer->mo->FindInventory(type);
AAmmo * inv = ammoitem? ammoitem : (AAmmo*)GetDefaultByType(orderedammos[i]);
@ -681,7 +680,7 @@ static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon)
// Powered up weapons and inherited sister weapons are not displayed.
if (weapon->WeaponFlags & WIF_POWERED_UP) return;
if (weapon->SisterWeapon && weapon->IsKindOf(RUNTIME_TYPE(weapon->SisterWeapon))) return;
if (weapon->SisterWeapon && weapon->IsKindOf(weapon->SisterWeapon->GetClass())) return;
trans=0x6666;
if (CPlayer->ReadyWeapon)
@ -705,16 +704,16 @@ static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon)
}
static void DrawWeapons(player_t * CPlayer, int x, int y)
static void DrawWeapons(player_t *CPlayer, int x, int y)
{
int k,j;
AInventory * inv;
AInventory *inv;
// First draw all weapons in the inventory that are not assigned to a weapon slot
for(inv=CPlayer->mo->Inventory;inv;inv=inv->Inventory)
for(inv = CPlayer->mo->Inventory; inv; inv = inv->Inventory)
{
if (inv->IsKindOf(RUNTIME_CLASS(AWeapon)) &&
!CPlayer->weapons.LocateWeapon(RUNTIME_TYPE(inv), NULL, NULL))
!CPlayer->weapons.LocateWeapon(static_cast<AWeapon*>(inv)->GetClass(), NULL, NULL))
{
DrawOneWeapon(CPlayer, x, y, static_cast<AWeapon*>(inv));
}
@ -723,7 +722,7 @@ static void DrawWeapons(player_t * CPlayer, int x, int y)
// And now everything in the weapon slots back to front
for (k = NUM_WEAPON_SLOTS - 1; k >= 0; k--) for(j = CPlayer->weapons.Slots[k].Size() - 1; j >= 0; j--)
{
const PClass *weap = CPlayer->weapons.Slots[k].GetWeapon(j);
PClassActor *weap = CPlayer->weapons.Slots[k].GetWeapon(j);
if (weap)
{
inv=CPlayer->mo->FindInventory(weap);
@ -1180,7 +1179,7 @@ void HUD_InitHud()
}
else
{
const PClass * ti = PClass::FindClass(sc.String);
PClass *ti = PClass::FindClass(sc.String);
if (!ti)
{
Printf("Unknown item class '%s' in ALTHUDCF\n", sc.String);
@ -1199,9 +1198,8 @@ void HUD_InitHud()
}
else tex.SetInvalid();
if (ti) SetHUDIcon(const_cast<PClass*>(ti), tex);
if (ti) SetHUDIcon(static_cast<PClassInventory*>(ti), tex);
}
}
}
}

View file

@ -253,7 +253,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres)
void DBaseStatusBar::Destroy ()
{
for (unsigned int i = 0; i < countof(Messages); ++i)
for (size_t i = 0; i < countof(Messages); ++i)
{
DHUDMessage *msg = Messages[i];
while (msg)
@ -355,7 +355,7 @@ void DBaseStatusBar::MultiplayerChanged ()
void DBaseStatusBar::Tick ()
{
for (unsigned int i = 0; i < countof(Messages); ++i)
for (size_t i = 0; i < countof(Messages); ++i)
{
DHUDMessage *msg = Messages[i];
DHUDMessage **prev = &Messages[i];
@ -437,7 +437,7 @@ void DBaseStatusBar::AttachMessage (DHUDMessage *msg, DWORD id, int layer)
DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg)
{
for (unsigned int i = 0; i < countof(Messages); ++i)
for (size_t i = 0; i < countof(Messages); ++i)
{
DHUDMessage *probe = Messages[i];
DHUDMessage **prev = &Messages[i];
@ -464,7 +464,7 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg)
DHUDMessage *DBaseStatusBar::DetachMessage (DWORD id)
{
for (unsigned int i = 0; i < countof(Messages); ++i)
for (size_t i = 0; i < countof(Messages); ++i)
{
DHUDMessage *probe = Messages[i];
DHUDMessage **prev = &Messages[i];
@ -497,7 +497,7 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DWORD id)
void DBaseStatusBar::DetachAllMessages ()
{
for (unsigned int i = 0; i < countof(Messages); ++i)
for (size_t i = 0; i < countof(Messages); ++i)
{
DHUDMessage *probe = Messages[i];
@ -1681,7 +1681,7 @@ void DBaseStatusBar::Serialize (FArchive &arc)
}
else
{
for (unsigned int i = 0; i < countof(Messages); ++i)
for (size_t i = 0; i < countof(Messages); ++i)
{
arc << Messages[i];
}
@ -1693,7 +1693,7 @@ void DBaseStatusBar::ScreenSizeChanged ()
st_scale.Callback ();
ST_SetNeedRefresh();
for (unsigned int i = 0; i < countof(Messages); ++i)
for (size_t i = 0; i < countof(Messages); ++i)
{
DHUDMessage *message = Messages[i];
while (message != NULL)