mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- scriptified the remains of AKey.
- replaced Key.KeyNumber with special1. This is only for internal bookkeeping purposes so there's really no need to complicate this with a new variable when this one works just as well.
This commit is contained in:
parent
d9fd2d509f
commit
d8acf774a6
12 changed files with 57 additions and 78 deletions
|
@ -1145,7 +1145,6 @@ set (PCH_SOURCES
|
|||
w_wad.cpp
|
||||
wi_stuff.cpp
|
||||
zstrformat.cpp
|
||||
g_inventory/a_ammo.cpp
|
||||
g_inventory/a_armor.cpp
|
||||
g_inventory/a_keys.cpp
|
||||
g_inventory/a_pickups.cpp
|
||||
|
|
|
@ -2740,8 +2740,8 @@ void AM_drawKeys ()
|
|||
mpoint_t p;
|
||||
DAngle angle;
|
||||
|
||||
TThinkerIterator<AKey> it;
|
||||
AKey *key;
|
||||
TThinkerIterator<AInventory> it(NAME_Key);
|
||||
AInventory *key;
|
||||
|
||||
while ((key = it.Next()) != NULL)
|
||||
{
|
||||
|
@ -2853,7 +2853,7 @@ void AM_drawThings ()
|
|||
// Find the key's own color.
|
||||
// Only works correctly if single-key locks have lower numbers than any-key locks.
|
||||
// That is the case for all default keys, however.
|
||||
if (t->IsKindOf(RUNTIME_CLASS(AKey)))
|
||||
if (t->IsKindOf(PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
if (G_SkillProperty(SKILLP_EasyKey))
|
||||
{
|
||||
|
@ -2863,7 +2863,7 @@ void AM_drawThings ()
|
|||
else if (am_showkeys)
|
||||
{
|
||||
int P_GetMapColorForKey (AInventory * key);
|
||||
int c = P_GetMapColorForKey(static_cast<AKey *>(t));
|
||||
int c = P_GetMapColorForKey(static_cast<AInventory *>(t));
|
||||
|
||||
if (c >= 0) color.FromRGB(RPART(c), GPART(c), BPART(c));
|
||||
else color = AMColors[AMColors.ThingColor_CountItem];
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -63,14 +62,10 @@ struct OneKey
|
|||
int count;
|
||||
|
||||
bool check(AActor *owner)
|
||||
{
|
||||
if (owner->IsKindOf(RUNTIME_CLASS(AKey)))
|
||||
{
|
||||
// P_GetMapColorForKey() checks the key directly
|
||||
return owner->IsA(key) || owner->GetSpecies() == key->TypeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (owner->IsA(key) || owner->GetSpecies() == key->TypeName) return true;
|
||||
|
||||
// Other calls check an actor that may have a key in its inventory.
|
||||
AInventory *item;
|
||||
|
||||
|
@ -87,7 +82,6 @@ struct OneKey
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
@ -138,9 +132,10 @@ struct Lock
|
|||
// An empty key list means that any key will do
|
||||
if (!keylist.Size())
|
||||
{
|
||||
auto kt = PClass::FindActor(NAME_Key);
|
||||
for (AInventory * item = owner->Inventory; item != NULL; item = item->Inventory)
|
||||
{
|
||||
if (item->IsKindOf (RUNTIME_CLASS(AKey)))
|
||||
if (item->IsKindOf (kt))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -192,12 +187,12 @@ static void AddOneKey(Keygroup *keygroup, PClassActor *mi, FScanner &sc)
|
|||
keygroup->anykeylist.Push (k);
|
||||
|
||||
//... but only keys get key numbers!
|
||||
if (mi->IsDescendantOf(RUNTIME_CLASS(AKey)))
|
||||
if (mi->IsDescendantOf(PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
if (!ignorekey &&
|
||||
static_cast<AKey*>(GetDefaultByType(mi))->KeyNumber == 0)
|
||||
GetDefaultByType(mi)->special1 == 0)
|
||||
{
|
||||
static_cast<AKey*>(GetDefaultByType(mi))->KeyNumber=++currentnumber;
|
||||
GetDefaultByType(mi)->special1 = ++currentnumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -387,14 +382,15 @@ static void ParseLock(FScanner &sc)
|
|||
static void ClearLocks()
|
||||
{
|
||||
unsigned int i;
|
||||
auto kt = PClass::FindActor(NAME_Key);
|
||||
for(i = 0; i < PClassActor::AllActorClasses.Size(); i++)
|
||||
{
|
||||
if (PClassActor::AllActorClasses[i]->IsDescendantOf(RUNTIME_CLASS(AKey)))
|
||||
if (PClassActor::AllActorClasses[i]->IsDescendantOf(kt))
|
||||
{
|
||||
AKey *key = static_cast<AKey*>(GetDefaultByType(PClassActor::AllActorClasses[i]));
|
||||
auto key = GetDefaultByType(PClassActor::AllActorClasses[i]);
|
||||
if (key != NULL)
|
||||
{
|
||||
key->KeyNumber = 0;
|
||||
key->special1 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -523,15 +519,6 @@ bool P_CheckKeys (AActor *owner, int keynum, bool remote)
|
|||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// AKey implementation
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
IMPLEMENT_CLASS(AKey, false, false)
|
||||
DEFINE_FIELD(AKey, KeyNumber)
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// These functions can be used to get color information for
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
#ifndef A_KEYS_H
|
||||
#define A_KEYS_H
|
||||
|
||||
#include "a_pickups.h"
|
||||
|
||||
class AKey : public AInventory
|
||||
{
|
||||
DECLARE_CLASS (AKey, AInventory)
|
||||
public:
|
||||
BYTE KeyNumber;
|
||||
};
|
||||
class AActor;
|
||||
class AInventory;
|
||||
|
||||
bool P_CheckKeys (AActor *owner, int keynum, bool remote);
|
||||
void P_InitKeyMessages ();
|
||||
|
|
|
@ -416,10 +416,10 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
||||
{
|
||||
PClassActor *cls = PClassActor::AllActorClasses[i];
|
||||
if (cls->IsDescendantOf(RUNTIME_CLASS(AKey)))
|
||||
if (cls->IsDescendantOf(PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
AKey *key = (AKey *)GetDefaultByType(cls);
|
||||
if (key->KeyNumber == keynum)
|
||||
auto key = GetDefaultByType(cls);
|
||||
if (key->special1 == keynum)
|
||||
return cls->TypeName;
|
||||
}
|
||||
}
|
||||
|
@ -554,9 +554,9 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
|
||||
for(AInventory *item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory)
|
||||
{
|
||||
if(item->IsKindOf(RUNTIME_CLASS(AKey)))
|
||||
if(item->IsKindOf(PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
int keynum = static_cast<AKey *>(item)->KeyNumber;
|
||||
int keynum = item->special1;
|
||||
if(keynum)
|
||||
{
|
||||
if(keynum == conditionalValue[0])
|
||||
|
@ -1474,7 +1474,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
num = 0;
|
||||
for(AInventory *item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory)
|
||||
{
|
||||
if(item->IsKindOf(RUNTIME_CLASS(AKey)))
|
||||
if(item->IsKindOf(PClass::FindActor(NAME_Key)))
|
||||
num++;
|
||||
}
|
||||
break;
|
||||
|
@ -2429,7 +2429,7 @@ class CommandDrawKeyBar : public SBarInfoCommand
|
|||
int rowWidth = 0;
|
||||
for(unsigned int i = 0;i < number+keyOffset;i++)
|
||||
{
|
||||
while(!item->Icon.isValid() || !item->IsKindOf(RUNTIME_CLASS(AKey)))
|
||||
while(!item->Icon.isValid() || !item->IsKindOf(PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
item = item->Inventory;
|
||||
if(item == NULL)
|
||||
|
|
|
@ -385,9 +385,9 @@ static TArray<PClassActor *> KeyTypes, UnassignedKeyTypes;
|
|||
|
||||
static int ktcmp(const void * a, const void * b)
|
||||
{
|
||||
AKey *key1 = (AKey*)GetDefaultByType ( *(PClassActor **)a );
|
||||
AKey *key2 = (AKey*)GetDefaultByType ( *(PClassActor **)b );
|
||||
return key1->KeyNumber - key2->KeyNumber;
|
||||
auto key1 = GetDefaultByType ( *(PClassActor **)a );
|
||||
auto key2 = GetDefaultByType ( *(PClassActor **)b );
|
||||
return key1->special1 - key2->special1;
|
||||
}
|
||||
|
||||
static void SetKeyTypes()
|
||||
|
@ -395,13 +395,14 @@ static void SetKeyTypes()
|
|||
for(unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); i++)
|
||||
{
|
||||
PClass *ti = PClassActor::AllActorClasses[i];
|
||||
auto kt = PClass::FindActor(NAME_Key);
|
||||
|
||||
if (ti->IsDescendantOf(RUNTIME_CLASS(AKey)))
|
||||
if (ti->IsDescendantOf(kt))
|
||||
{
|
||||
PClassActor *tia = static_cast<PClassActor *>(ti);
|
||||
AKey *key = (AKey*)GetDefaultByType(tia);
|
||||
AInventory *key = (AInventory*)(GetDefaultByType(tia));
|
||||
|
||||
if (key->Icon.isValid() && key->KeyNumber>0)
|
||||
if (key->Icon.isValid() && key->special1 > 0)
|
||||
{
|
||||
KeyTypes.Push(tia);
|
||||
}
|
||||
|
@ -418,8 +419,7 @@ static void SetKeyTypes()
|
|||
else
|
||||
{
|
||||
// Don't leave the list empty
|
||||
PClassActor *ti = RUNTIME_CLASS(AKey);
|
||||
KeyTypes.Push(ti);
|
||||
KeyTypes.Push(PClass::FindActor(NAME_Key));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ public:
|
|||
item != NULL;
|
||||
item = item->Inventory)
|
||||
{
|
||||
if (item->IsKindOf (RUNTIME_CLASS(AKey)))
|
||||
if (item->IsKindOf (PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
if (i == KeyPopPos)
|
||||
{
|
||||
|
@ -633,7 +633,7 @@ private:
|
|||
i < endpos && item != NULL;
|
||||
item = item->Inventory)
|
||||
{
|
||||
if (!item->IsKindOf (RUNTIME_CLASS(AKey)))
|
||||
if (!item->IsKindOf (PClass::FindActor(NAME_Key)))
|
||||
continue;
|
||||
|
||||
if (i < pos)
|
||||
|
@ -678,7 +678,7 @@ private:
|
|||
item != NULL;
|
||||
item = item->Inventory)
|
||||
{
|
||||
if (item->IsKindOf (RUNTIME_CLASS(AKey)))
|
||||
if (item->IsKindOf (PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -717,6 +717,7 @@ xx(Strength)
|
|||
xx(Mode)
|
||||
xx(PowerupType)
|
||||
xx(PlayerPawn)
|
||||
xx(Key)
|
||||
|
||||
// Decorate compatibility functions
|
||||
xx(BuiltinTypeCheck)
|
||||
|
|
|
@ -642,7 +642,7 @@ static void TakeStrifeItem (player_t *player, PClassActor *itemtype, int amount)
|
|||
return;
|
||||
|
||||
// Don't take keys.
|
||||
if (itemtype->IsDescendantOf (RUNTIME_CLASS(AKey)))
|
||||
if (itemtype->IsDescendantOf (PClass::FindActor(NAME_Key)))
|
||||
return;
|
||||
|
||||
// Don't take the sigil.
|
||||
|
|
|
@ -1075,12 +1075,12 @@ void APlayerPawn::GiveDeathmatchInventory()
|
|||
{
|
||||
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
||||
{
|
||||
if (PClassActor::AllActorClasses[i]->IsDescendantOf (RUNTIME_CLASS(AKey)))
|
||||
if (PClassActor::AllActorClasses[i]->IsDescendantOf (PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
AKey *key = (AKey *)GetDefaultByType (PClassActor::AllActorClasses[i]);
|
||||
if (key->KeyNumber != 0)
|
||||
AInventory *key = (AInventory*)GetDefaultByType (PClassActor::AllActorClasses[i]);
|
||||
if (key->special1 != 0)
|
||||
{
|
||||
key = static_cast<AKey *>(Spawn(static_cast<PClassActor *>(PClassActor::AllActorClasses[i])));
|
||||
key = (AInventory*)Spawn(PClassActor::AllActorClasses[i]);
|
||||
if (!key->CallTryPickup (this))
|
||||
{
|
||||
key->Destroy ();
|
||||
|
@ -1133,7 +1133,7 @@ void APlayerPawn::FilterCoopRespawnInventory (APlayerPawn *oldplayer)
|
|||
|
||||
if ((dmflags & DF_COOP_LOSE_KEYS) &&
|
||||
defitem == NULL &&
|
||||
item->IsKindOf(RUNTIME_CLASS(AKey)))
|
||||
item->IsKindOf(PClass::FindActor(NAME_Key)))
|
||||
{
|
||||
item->Destroy();
|
||||
}
|
||||
|
|
|
@ -28,10 +28,8 @@ class ScoreItem : Inventory
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
class Key : Inventory native
|
||||
class Key : Inventory
|
||||
{
|
||||
native uint8 KeyNumber;
|
||||
|
||||
Default
|
||||
{
|
||||
+DONTGIB; // Don't disappear due to a crusher
|
||||
|
|
|
@ -157,8 +157,8 @@ extend class PlayerPawn
|
|||
{
|
||||
if (AllActorClasses[i] is "Key")
|
||||
{
|
||||
readonly<Key> keyitem = GetDefaultByType ((class<Key>)(AllActorClasses[i]));
|
||||
if (keyitem.KeyNumber != 0)
|
||||
let keyitem = GetDefaultByType (AllActorClasses[i]);
|
||||
if (keyitem.special1 != 0)
|
||||
{
|
||||
let item = Inventory(Spawn(AllActorClasses[i]));
|
||||
if (!item.CallTryPickup (self))
|
||||
|
|
Loading…
Reference in a new issue