- Fixed: Allow string constants in SBarInfo whenever an actor name is required. The only exception is drawing the inventory icon with drawimage since it would be ambiguous, so I would advise using valid identifiers for class names even if it isn't required. Parenthesized syntax is required to use this feature where applicable.

SVN r3677 (trunk)
This commit is contained in:
Braden Obrzut 2012-06-04 22:26:26 +00:00
parent ab737220f0
commit 9b7e44c026

View file

@ -315,31 +315,35 @@ class CommandDrawSwitchableImage : public CommandDrawImage
} }
void Parse(FScanner &sc, bool fullScreenOffsets) void Parse(FScanner &sc, bool fullScreenOffsets)
{ {
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
if(sc.Compare("weaponslot"))
{
condition = WEAPONSLOT;
sc.MustGetToken(TK_IntConst);
conditionalValue[0] = sc.Number;
}
else if(sc.Compare("invulnerable"))
{
condition = INVULNERABILITY;
}
else if(sc.Compare("keyslot"))
{
condition = KEYSLOT;
sc.MustGetToken(TK_IntConst);
conditionalValue[0] = sc.Number;
}
else if(sc.Compare("armortype"))
{
condition = ARMORTYPE;
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
armorType[0] = FName(sc.String).GetIndex(); if(sc.TokenType == TK_Identifier)
GetOperation(sc, conditionalOperator[0], conditionalValue[0]); {
if(sc.Compare("weaponslot"))
{
condition = WEAPONSLOT;
sc.MustGetToken(TK_IntConst);
conditionalValue[0] = sc.Number;
}
else if(sc.Compare("invulnerable"))
{
condition = INVULNERABILITY;
}
else if(sc.Compare("keyslot"))
{
condition = KEYSLOT;
sc.MustGetToken(TK_IntConst);
conditionalValue[0] = sc.Number;
}
else if(sc.Compare("armortype"))
{
condition = ARMORTYPE;
sc.MustGetToken(TK_Identifier);
armorType[0] = FName(sc.String).GetIndex();
GetOperation(sc, conditionalOperator[0], conditionalValue[0]);
}
} }
else if(condition == INVENTORY)
{ {
inventoryItem[0] = sc.String; inventoryItem[0] = sc.String;
const PClass* item = PClass::FindClass(sc.String); const PClass* item = PClass::FindClass(sc.String);
@ -905,119 +909,126 @@ class CommandDrawNumber : public CommandDrawString
} }
else else
{ {
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
if(sc.Compare("health"))
value = HEALTH;
else if(sc.Compare("armor"))
value = ARMOR;
else if(sc.Compare("ammo1"))
value = AMMO1;
else if(sc.Compare("ammo2"))
value = AMMO2;
else if(sc.Compare("ammo1capacity"))
value = AMMO1CAPACITY;
else if(sc.Compare("ammo2capacity"))
value = AMMO2CAPACITY;
else if(sc.Compare("score"))
value = SCORE;
else if(sc.Compare("ammo")) //request the next string to be an ammo type
{
bool parenthesized = sc.CheckToken('(');
value = AMMO;
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(sc.String); value = INVENTORY;
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo if(sc.TokenType == TK_Identifier)
{
if(sc.Compare("health"))
value = HEALTH;
else if(sc.Compare("armor"))
value = ARMOR;
else if(sc.Compare("ammo1"))
value = AMMO1;
else if(sc.Compare("ammo2"))
value = AMMO2;
else if(sc.Compare("ammo1capacity"))
value = AMMO1CAPACITY;
else if(sc.Compare("ammo2capacity"))
value = AMMO2CAPACITY;
else if(sc.Compare("score"))
value = SCORE;
else if(sc.Compare("ammo")) //request the next string to be an ammo type
{ {
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String); bool parenthesized = sc.CheckToken('(');
inventoryItem = RUNTIME_CLASS(AAmmo);
value = AMMO;
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(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);
inventoryItem = RUNTIME_CLASS(AAmmo);
}
if(parenthesized) sc.MustGetToken(')');
} }
else if(sc.Compare("ammocapacity"))
if(parenthesized) sc.MustGetToken(')');
}
else if(sc.Compare("ammocapacity"))
{
bool parenthesized = sc.CheckToken('(');
value = AMMOCAPACITY;
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(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); bool parenthesized = sc.CheckToken('(');
inventoryItem = RUNTIME_CLASS(AAmmo);
value = AMMOCAPACITY;
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(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);
inventoryItem = RUNTIME_CLASS(AAmmo);
}
if(parenthesized) sc.MustGetToken(')');
} }
else if(sc.Compare("frags"))
if(parenthesized) sc.MustGetToken(')'); value = FRAGS;
} else if(sc.Compare("kills"))
else if(sc.Compare("frags")) value = KILLS;
value = FRAGS; else if(sc.Compare("monsters"))
else if(sc.Compare("kills")) value = MONSTERS;
value = KILLS; else if(sc.Compare("items"))
else if(sc.Compare("monsters")) value = ITEMS;
value = MONSTERS; else if(sc.Compare("totalitems"))
else if(sc.Compare("items")) value = TOTALITEMS;
value = ITEMS; else if(sc.Compare("secrets"))
else if(sc.Compare("totalitems")) value = SECRETS;
value = TOTALITEMS; else if(sc.Compare("totalsecrets"))
else if(sc.Compare("secrets")) value = TOTALSECRETS;
value = SECRETS; else if(sc.Compare("armorclass"))
else if(sc.Compare("totalsecrets")) value = ARMORCLASS;
value = TOTALSECRETS; else if(sc.Compare("savepercent"))
else if(sc.Compare("armorclass")) value = SAVEPERCENT;
value = ARMORCLASS; else if(sc.Compare("airtime"))
else if(sc.Compare("savepercent")) value = AIRTIME;
value = SAVEPERCENT; else if(sc.Compare("accuracy"))
else if(sc.Compare("airtime")) value = ACCURACY;
value = AIRTIME; else if(sc.Compare("stamina"))
else if(sc.Compare("accuracy")) value = STAMINA;
value = ACCURACY; else if(sc.Compare("keys"))
else if(sc.Compare("stamina")) value = KEYS;
value = STAMINA; else if(sc.Compare("globalvar"))
else if(sc.Compare("keys"))
value = KEYS;
else if(sc.Compare("globalvar"))
{
bool parenthesized = sc.CheckToken('(');
value = GLOBALVAR;
sc.MustGetToken(TK_IntConst);
if(sc.Number < 0 || sc.Number >= NUM_GLOBALVARS)
sc.ScriptError("Global variable number out of range: %d", sc.Number);
valueArgument = sc.Number;
if(parenthesized) sc.MustGetToken(')');
}
else if(sc.Compare("globalarray")) //acts like variable[playernumber()]
{
bool parenthesized = sc.CheckToken('(');
value = GLOBALARRAY;
sc.MustGetToken(TK_IntConst);
if(sc.Number < 0 || sc.Number >= NUM_GLOBALVARS)
sc.ScriptError("Global variable number out of range: %d", sc.Number);
valueArgument = sc.Number;
if(parenthesized) sc.MustGetToken(')');
}
else if(sc.Compare("poweruptime"))
{
bool parenthesized = sc.CheckToken('(');
value = POWERUPTIME;
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(inventoryItem))
{ {
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String); bool parenthesized = sc.CheckToken('(');
inventoryItem = RUNTIME_CLASS(APowerupGiver);
}
if(parenthesized) sc.MustGetToken(')'); value = GLOBALVAR;
sc.MustGetToken(TK_IntConst);
if(sc.Number < 0 || sc.Number >= NUM_GLOBALVARS)
sc.ScriptError("Global variable number out of range: %d", sc.Number);
valueArgument = sc.Number;
if(parenthesized) sc.MustGetToken(')');
}
else if(sc.Compare("globalarray")) //acts like variable[playernumber()]
{
bool parenthesized = sc.CheckToken('(');
value = GLOBALARRAY;
sc.MustGetToken(TK_IntConst);
if(sc.Number < 0 || sc.Number >= NUM_GLOBALVARS)
sc.ScriptError("Global variable number out of range: %d", sc.Number);
valueArgument = sc.Number;
if(parenthesized) sc.MustGetToken(')');
}
else if(sc.Compare("poweruptime"))
{
bool parenthesized = sc.CheckToken('(');
value = POWERUPTIME;
if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(inventoryItem))
{
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
inventoryItem = RUNTIME_CLASS(APowerupGiver);
}
if(parenthesized) sc.MustGetToken(')');
}
} }
else if(value == INVENTORY)
{ {
value = INVENTORY;
inventoryItem = PClass::FindClass(sc.String); inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of ammo if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{ {
@ -2369,7 +2380,8 @@ class CommandDrawBar : public SBarInfoCommand
{ {
bool parenthesized = sc.CheckToken('('); bool parenthesized = sc.CheckToken('(');
sc.MustGetToken(TK_Identifier); if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
type = AMMO; type = AMMO;
data.inventoryItem = PClass::FindClass(sc.String); data.inventoryItem = PClass::FindClass(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo if(data.inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo
@ -2394,14 +2406,19 @@ class CommandDrawBar : public SBarInfoCommand
type = SAVEPERCENT; type = SAVEPERCENT;
else if(sc.Compare("poweruptime")) else if(sc.Compare("poweruptime"))
{ {
bool parenthesized = sc.CheckToken('(');
type = POWERUPTIME; type = POWERUPTIME;
sc.MustGetToken(TK_Identifier); if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
data.inventoryItem = PClass::FindClass(sc.String); data.inventoryItem = PClass::FindClass(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(data.inventoryItem)) if(data.inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(data.inventoryItem))
{ {
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String); sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
data.inventoryItem = RUNTIME_CLASS(APowerupGiver); data.inventoryItem = RUNTIME_CLASS(APowerupGiver);
} }
if(parenthesized) sc.MustGetToken(')');
} }
else else
{ {
@ -2619,7 +2636,7 @@ class CommandDrawBar : public SBarInfoCommand
{ {
bool extendedSyntax = sc.CheckToken('('); bool extendedSyntax = sc.CheckToken('(');
if(sc.CheckToken(TK_Identifier)) //comparing reference if(sc.CheckToken(TK_Identifier) || (extendedSyntax && sc.CheckToken(TK_StringConst))) //comparing reference
{ {
data.inventoryItem = PClass::FindClass(sc.String); data.inventoryItem = PClass::FindClass(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem)) //must be a kind of inventory if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem)) //must be a kind of inventory
@ -2700,7 +2717,6 @@ class CommandIsSelected : public SBarInfoCommandFlowControl
void Parse(FScanner &sc, bool fullScreenOffsets) void Parse(FScanner &sc, bool fullScreenOffsets)
{ {
//Using StringConst instead of Identifieres is deperecated!
if(sc.CheckToken(TK_Identifier)) if(sc.CheckToken(TK_Identifier))
{ {
if(sc.Compare("not")) if(sc.Compare("not"))
@ -2817,7 +2833,8 @@ class CommandPlayerType : public SBarInfoCommandFlowControl
void Parse(FScanner &sc, bool fullScreenOffsets) void Parse(FScanner &sc, bool fullScreenOffsets)
{ {
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
do do
{ {
bool foundClass = false; bool foundClass = false;
@ -2834,7 +2851,7 @@ class CommandPlayerType : public SBarInfoCommandFlowControl
if(!sc.CheckToken(',')) if(!sc.CheckToken(','))
break; break;
} }
while(sc.CheckToken(TK_Identifier)); while(sc.CheckToken(TK_Identifier) || sc.CheckToken(TK_StringConst));
SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets);
} }
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
@ -2870,7 +2887,8 @@ class CommandHasWeaponPiece : public SBarInfoCommandFlowControl
void Parse(FScanner &sc, bool fullScreenOffsets) void Parse(FScanner &sc, bool fullScreenOffsets)
{ {
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
weapon = PClass::FindClass(sc.String); weapon = PClass::FindClass(sc.String);
if(weapon == NULL || !RUNTIME_CLASS(AWeapon)->IsAncestorOf(weapon)) //must be a weapon if(weapon == NULL || !RUNTIME_CLASS(AWeapon)->IsAncestorOf(weapon)) //must be a weapon
{ {
@ -3055,11 +3073,13 @@ class CommandWeaponAmmo : public SBarInfoCommandFlowControl
void Parse(FScanner &sc, bool fullScreenOffsets) void Parse(FScanner &sc, bool fullScreenOffsets)
{ {
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
if(sc.Compare("not")) sc.MustGetToken(TK_Identifier);
if(sc.Compare("not") && sc.TokenType == TK_Identifier)
{ {
negate = true; negate = true;
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
} }
for(int i = 0;i < 2;i++) for(int i = 0;i < 2;i++)
{ {
@ -3073,12 +3093,14 @@ class CommandWeaponAmmo : public SBarInfoCommandFlowControl
if(sc.CheckToken(TK_OrOr)) if(sc.CheckToken(TK_OrOr))
{ {
conditionAnd = false; conditionAnd = false;
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
} }
else if(sc.CheckToken(TK_AndAnd)) else if(sc.CheckToken(TK_AndAnd))
{ {
conditionAnd = true; conditionAnd = true;
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
} }
else else
break; break;
@ -3158,11 +3180,13 @@ class CommandInInventory : public SBarInfoCommandFlowControl
void Parse(FScanner &sc, bool fullScreenOffsets) void Parse(FScanner &sc, bool fullScreenOffsets)
{ {
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
if(sc.Compare("not")) sc.MustGetToken(TK_Identifier);
if(sc.Compare("not") && sc.TokenType == TK_Identifier)
{ {
negate = true; negate = true;
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
} }
for(int i = 0;i < 2;i++) for(int i = 0;i < 2;i++)
{ {
@ -3182,12 +3206,14 @@ class CommandInInventory : public SBarInfoCommandFlowControl
if(sc.CheckToken(TK_OrOr)) if(sc.CheckToken(TK_OrOr))
{ {
conditionAnd = false; conditionAnd = false;
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
} }
else if(sc.CheckToken(TK_AndAnd)) else if(sc.CheckToken(TK_AndAnd))
{ {
conditionAnd = true; conditionAnd = true;
sc.MustGetToken(TK_Identifier); if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier);
} }
else else
break; break;