- Made SBARINFO more tolerant of certain error conditions. (Why is there so much duplication of

code? It felt like I was changing the same lines over and over and over.)

SVN r2486 (trunk)
This commit is contained in:
Randy Heit 2010-08-01 20:05:52 +00:00
parent fc6e48dd3f
commit b2d018eccd

View file

@ -93,7 +93,10 @@ class CommandDrawImage : public SBarInfoCommand
else if(sc.Compare("amulet"))
type = HEXENARMOR_AMULET;
else
sc.ScriptError("Unkown armor type: '%s'", sc.String);
{
sc.ScriptMessage("Unkown armor type: '%s'", sc.String);
type = HEXENARMOR_ARMOR;
}
sc.MustGetToken(',');
getImage = true;
}
@ -108,9 +111,12 @@ class CommandDrawImage : public SBarInfoCommand
const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(item)) //must be a kind of Inventory
{
sc.ScriptError("'%s' is not a type of inventory item.", sc.String);
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
}
else
{
sprite = ((AInventory *)GetDefaultByType(item))->Icon;
}
sprite = ((AInventory *)GetDefaultByType(item))->Icon;
image = -1;
}
}
@ -324,7 +330,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(item)) //must be a kind of Inventory
{
sc.ScriptError("'%s' is not a type of inventory item.", sc.String);
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
}
GetOperation(sc, conditionalOperator[0], conditionalValue[0]);
}
@ -349,7 +355,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(item)) //must be a kind of Inventory
{
sc.ScriptError("'%s' is not a type of inventory item.", sc.String);
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
}
GetOperation(sc, conditionalOperator[1], conditionalValue[1]);
}
@ -529,7 +535,10 @@ class CommandDrawString : public SBarInfoCommand
sc.MustGetToken(TK_Identifier);
font = V_GetFont(sc.String);
if(font == NULL)
sc.ScriptError("Unknown font '%s'.", sc.String);
{
sc.ScriptMessage("Unknown font '%s'.", sc.String);
font = SmallFont;
}
sc.MustGetToken(',');
translation = GetTranslation(sc);
sc.MustGetToken(',');
@ -807,7 +816,10 @@ class CommandDrawNumber : public CommandDrawString
sc.MustGetToken(TK_Identifier);
font = V_GetFont(sc.String);
if(font == NULL)
sc.ScriptError("Unknown font '%s'.", sc.String);
{
sc.ScriptMessage("Unknown font '%s'.", sc.String);
font = SmallFont;
}
sc.MustGetToken(',');
normalTranslation = GetTranslation(sc);
sc.MustGetToken(',');
@ -837,7 +849,8 @@ class CommandDrawNumber : public CommandDrawString
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptError("'%s' is not a type of ammo.", sc.String);
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
inventoryItem = RUNTIME_CLASS(AAmmo);
}
}
else if(sc.Compare("ammocapacity"))
@ -847,7 +860,8 @@ class CommandDrawNumber : public CommandDrawString
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptError("'%s' is not a type of ammo.", sc.String);
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
inventoryItem = RUNTIME_CLASS(AAmmo);
}
}
else if(sc.Compare("frags"))
@ -889,18 +903,20 @@ class CommandDrawNumber : public CommandDrawString
value = POWERUPTIME;
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !PClass::FindClass("PowerupGiver")->IsAncestorOf(inventoryItem))
if(inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(inventoryItem))
{
sc.ScriptError("'%s' is not a type of PowerupGiver.", sc.String);
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
inventoryItem = RUNTIME_CLASS(APowerupGiver);
}
}
else
{
value = INVENTORY;
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(inventoryItem)) //must be a kind of ammo
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptError("'%s' is not a type of inventory item.", sc.String);
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
inventoryItem = RUNTIME_CLASS(AInventory);
}
}
sc.MustGetToken(',');
@ -1333,7 +1349,10 @@ class CommandDrawSelectedInventory : public SBarInfoCommandFlowControl, private
{
font = V_GetFont(sc.String);
if(font == NULL)
sc.ScriptError("Unknown font '%s'.", sc.String);
{
sc.ScriptMessage("Unknown font '%s'.", sc.String);
font = SmallFont;
}
sc.MustGetToken(',');
break;
}
@ -1815,7 +1834,10 @@ class CommandDrawInventoryBar : public SBarInfoCommand
sc.MustGetToken(TK_Identifier);
font = V_GetFont(sc.String);
if(font == NULL)
{
sc.ScriptError("Unknown font '%s'.", sc.String);
font = SmallFont;
}
sc.MustGetToken(',');
GetCoordinates(sc, fullScreenOffsets, x, y);
@ -2098,8 +2120,11 @@ class CommandDrawBar : public SBarInfoCommand
if(sc.CheckToken(TK_Identifier)) //comparing reference
{
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(inventoryItem)) //must be a kind of inventory
sc.ScriptError("'%s' is not a type of inventory item.", sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of inventory
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
inventoryItem = RUNTIME_CLASS(AInventory);
}
}
}
else if(sc.Compare("armor"))
@ -2108,8 +2133,11 @@ class CommandDrawBar : public SBarInfoCommand
if(sc.CheckToken(TK_Identifier))
{
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !PClass::FindClass("Inventory")->IsAncestorOf(inventoryItem)) //must be a kind of inventory
sc.ScriptError("'%s' is not a type of inventory item.", sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of inventory
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
inventoryItem = RUNTIME_CLASS(AInventory);
}
}
}
else if(sc.Compare("ammo1"))
@ -2123,7 +2151,8 @@ class CommandDrawBar : public SBarInfoCommand
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
{
sc.ScriptError("'%s' is not a type of ammo.", sc.String);
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
inventoryItem = RUNTIME_CLASS(AAmmo);
}
}
else if(sc.Compare("frags"))
@ -2141,9 +2170,10 @@ class CommandDrawBar : public SBarInfoCommand
type = POWERUPTIME;
sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !PClass::FindClass("PowerupGiver")->IsAncestorOf(inventoryItem))
if(inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(inventoryItem))
{
sc.ScriptError("'%s' is not a type of PowerupGiver.", sc.String);
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
inventoryItem = RUNTIME_CLASS(APowerupGiver);
}
}
else
@ -2152,7 +2182,8 @@ class CommandDrawBar : public SBarInfoCommand
inventoryItem = PClass::FindClass(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem))
{
sc.ScriptError("'%s' is not a type of inventory item.", sc.String);
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
inventoryItem = RUNTIME_CLASS(AInventory);
}
}
sc.MustGetToken(',');
@ -2401,7 +2432,10 @@ class CommandIsSelected : public SBarInfoCommandFlowControl
{
weapon[i] = PClass::FindClass(sc.String);
if(weapon[i] == NULL || !RUNTIME_CLASS(AWeapon)->IsAncestorOf(weapon[i]))
sc.ScriptError("'%s' is not a type of weapon.", sc.String);
{
sc.ScriptMessage("'%s' is not a type of weapon.", sc.String);
weapon[i] = RUNTIME_CLASS(AWeapon);
}
if(sc.CheckToken(','))
{
@ -2503,7 +2537,10 @@ class CommandHasWeaponPiece : public SBarInfoCommandFlowControl
sc.MustGetToken(TK_Identifier);
weapon = PClass::FindClass(sc.String);
if(weapon == NULL || !RUNTIME_CLASS(AWeapon)->IsAncestorOf(weapon)) //must be a weapon
sc.ScriptError("%s is not a kind of weapon.", sc.String);
{
sc.ScriptMessage("%s is not a kind of weapon.", sc.String);
weapon = RUNTIME_CLASS(AWeapon);
}
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
if(sc.Number < 1)
@ -2692,7 +2729,10 @@ class CommandWeaponAmmo : public SBarInfoCommandFlowControl
{
ammo[i] = PClass::FindClass(sc.String);
if(ammo[i] == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(ammo[i])) //must be a kind of ammo
sc.ScriptError("'%s' is not a type of ammo.", sc.String);
{
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
ammo[i] = RUNTIME_CLASS(AAmmo);
}
if(sc.CheckToken(TK_OrOr))
{
@ -2792,7 +2832,10 @@ class CommandInInventory : public SBarInfoCommandFlowControl
{
item[i] = PClass::FindClass(sc.String);
if(item[i] == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item[i]))
sc.ScriptError("'%s' is not a type of inventory item.", sc.String);
{
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
item[i] = RUNTIME_CLASS(AInventory);
}
if (sc.CheckToken(','))
{