- allow locks to check for a key's species so that newly defined keys can open previously defined locks without the need to redefine them.

This commit is contained in:
Christoph Oelckers 2014-05-29 17:30:01 +02:00
parent b285cbebe4
commit 75cde0b221

View file

@ -19,12 +19,29 @@ struct OneKey
bool check(AActor * owner)
{
// P_GetMapColorForKey() checks the key directly
if (owner->IsKindOf (RUNTIME_CLASS(AKey)))
if (owner->IsKindOf(RUNTIME_CLASS(AKey)))
{
// P_GetMapColorForKey() checks the key directly
return owner->IsA(key);
// Other calls check an actor that may have a key in its inventory.
else
return !!owner->FindInventory(key);
}
else
{
// Other calls check an actor that may have a key in its inventory.
AInventory *item;
for (item = owner->Inventory; item != NULL; item = item->Inventory)
{
if (item->IsA(key))
{
return true;
}
else if (item->GetSpecies() == key->TypeName)
{
return true;
}
}
return false;
}
}
};