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