- Improved DrawSwitchableImage keyslot condition to include key species.

- Fixed: currentpos command would crash if not in game.
This commit is contained in:
Braden Obrzut 2016-01-23 21:47:20 -05:00
parent 5abacf0b2f
commit fc15be8689
2 changed files with 43 additions and 7 deletions

View file

@ -1083,8 +1083,15 @@ CCMD(nextsecret)
CCMD(currentpos) CCMD(currentpos)
{ {
AActor *mo = players[consoleplayer].mo; AActor *mo = players[consoleplayer].mo;
Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", if(mo)
FIXED2FLOAT(mo->X()), FIXED2FLOAT(mo->Y()), FIXED2FLOAT(mo->Z()), mo->angle/float(ANGLE_1), FIXED2FLOAT(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); {
Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n",
FIXED2FLOAT(mo->X()), FIXED2FLOAT(mo->Y()), FIXED2FLOAT(mo->Z()), mo->angle/float(ANGLE_1), FIXED2FLOAT(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel);
}
else
{
Printf("You are not in game!");
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -412,6 +412,21 @@ class CommandDrawSwitchableImage : public CommandDrawImage
return compare != value; return compare != value;
} }
} }
// Key species are used to allow altnerates for existing key slots.
static FName LookupKeySpecies(int keynum)
{
for(unsigned int i = 0;i < PClass::m_Types.Size();++i)
{
const PClass *cls = PClass::m_Types[i];
if(cls->IsDescendantOf(RUNTIME_CLASS(AKey)))
{
AKey *key = (AKey *)GetDefaultByType(cls);
if(key->KeyNumber == keynum)
return cls->TypeName;
}
}
return FName();
}
public: public:
CommandDrawSwitchableImage(SBarInfo *script) : CommandDrawImage(script), CommandDrawSwitchableImage(SBarInfo *script) : CommandDrawImage(script),
@ -442,6 +457,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
condition = KEYSLOT; condition = KEYSLOT;
sc.MustGetToken(TK_IntConst); sc.MustGetToken(TK_IntConst);
conditionalValue[0] = sc.Number; conditionalValue[0] = sc.Number;
keySpecies[0] = LookupKeySpecies(conditionalValue[0]);
} }
else if(sc.Compare("armortype")) else if(sc.Compare("armortype"))
{ {
@ -468,6 +484,8 @@ class CommandDrawSwitchableImage : public CommandDrawImage
{ {
sc.MustGetToken(TK_IntConst); sc.MustGetToken(TK_IntConst);
conditionalValue[1] = sc.Number; conditionalValue[1] = sc.Number;
if(condition == KEYSLOT)
keySpecies[1] = LookupKeySpecies(conditionalValue[1]);
} }
else if(condition == ARMORTYPE) else if(condition == ARMORTYPE)
{ {
@ -541,11 +559,21 @@ class CommandDrawSwitchableImage : public CommandDrawImage
if(item->IsKindOf(RUNTIME_CLASS(AKey))) if(item->IsKindOf(RUNTIME_CLASS(AKey)))
{ {
int keynum = static_cast<AKey *>(item)->KeyNumber; int keynum = static_cast<AKey *>(item)->KeyNumber;
if(keynum)
if(keynum == conditionalValue[0]) {
found1 = true; if(keynum == conditionalValue[0])
if(conditionAnd && keynum == conditionalValue[1]) // two keys found1 = true;
found2 = true; if(conditionAnd && keynum == conditionalValue[1]) // two keys
found2 = true;
}
else
{
FName species = item->GetSpecies();
if(species == keySpecies[0])
found1 = true;
if(conditionAnd && species == keySpecies[1])
found2 = true;
}
} }
} }
@ -639,6 +667,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
Operator conditionalOperator[2]; Operator conditionalOperator[2];
FString inventoryItem[2]; FString inventoryItem[2];
int armorType[2]; int armorType[2];
FName keySpecies[2];
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////