From b2c72f5c87cd3d8e2b185d99010035cc8c8c7db5 Mon Sep 17 00:00:00 2001 From: Cekis Date: Fri, 4 Dec 2015 06:18:39 +0100 Subject: [PATCH] Fixed issues with Class Cast Exceptions when crafting Armor --- .../compiled/game/script/library/armor.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/armor.java diff --git a/sku.0/sys.server/compiled/game/script/library/armor.java b/sku.0/sys.server/compiled/game/script/library/armor.java old mode 100644 new mode 100755 index bd0981bc7..5bfa3d4aa --- a/sku.0/sys.server/compiled/game/script/library/armor.java +++ b/sku.0/sys.server/compiled/game/script/library/armor.java @@ -770,13 +770,16 @@ public class armor extends script.base_script while (keys.hasMoreElements()) { String key = (String)(keys.nextElement()); - float value = componentData.getFloatObjVar(key); - float newValue = rescaleArmorData(key, fromRow, toRow, value); - if (newValue != Float.MIN_VALUE) - { - debugServerConsoleMsg(null, "Armor scaling component data " + key + " from " + value + " to " + newValue + "(fromRow = " + fromRow + ", toRow = " + toRow + ")"); - setObjVar(schematic, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + ".scaled." + key, newValue); - removeObjVar(schematic, craftinglib.COMPONENT_ATTRIBUTE_INTERNAL_OBJVAR_NAME + "." + key); + // scaling ignored the fact that not all objvars were floats. Instead of letting it throw a warning, just scale objvars that are floats and ints + if(componentData.isFloatObjVar(key) || componentData.isIntObjVar(key)) { + float value = (componentData.isFloatObjVar(key) ? componentData.getFloatObjVar(key) : componentData.getIntObjVar(key)); + float newValue = (float) rescaleArmorData(key, fromRow, toRow, value); + if (newValue != Float.MIN_VALUE) + { + debugServerConsoleMsg(null, "Armor scaling component data " + key + " from " + value + " to " + newValue + "(fromRow = " + fromRow + ", toRow = " + toRow + ")"); + setObjVar(schematic, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + ".scaled." + key, newValue); + removeObjVar(schematic, craftinglib.COMPONENT_ATTRIBUTE_INTERNAL_OBJVAR_NAME + "." + key); + } } } setObjVar(schematic, craftinglib.COMPONENT_ATTRIBUTE_INTERNAL_OBJVAR_NAME + ".isScaled", true);