From 2e49b90bde599ffed1e467298945577ba820fdec Mon Sep 17 00:00:00 2001 From: Cekis Date: Tue, 8 Dec 2015 02:31:28 +0100 Subject: [PATCH] Made a few optimizations by removing unused code. Also made some changes where data types were mixed. --- .../compiled/game/script/item/armor/new_armor.java | 12 ++++++++++++ .../compiled/game/script/library/craftinglib.java | 7 +++++-- .../game/script/systems/crafting/crafting_base.java | 13 +++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/item/armor/new_armor.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/craftinglib.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/crafting/crafting_base.java diff --git a/sku.0/sys.server/compiled/game/script/item/armor/new_armor.java b/sku.0/sys.server/compiled/game/script/item/armor/new_armor.java old mode 100644 new mode 100755 index 90d0e0b22..9a8b544b5 --- a/sku.0/sys.server/compiled/game/script/item/armor/new_armor.java +++ b/sku.0/sys.server/compiled/game/script/item/armor/new_armor.java @@ -58,8 +58,20 @@ public class new_armor extends script.base_script public int OnAttach(obj_id self) throws InterruptedException { int ourType = getGameObjectType(self); + System.out.println("---- Checking to see if I should remove the script. ----"); + System.out.println("--- Found type: " + ourType); + System.out.println("--- GOT_armor: " + GOT_armor); + System.out.println("--- GOT_component_armor: " + GOT_component_armor); + System.out.println("--- GOT_component_new_armor: " + GOT_component_new_armor); + System.out.println("--- GOT_cybernetic: " + GOT_cybernetic); + System.out.println("--- GOT_cybernetic_arm: " + GOT_cybernetic_arm); + System.out.println("--- GOT_cybernetic_legs: " + GOT_cybernetic_legs); + System.out.println("--- GOT_cybernetic_torso: " + GOT_cybernetic_torso); if (!isGameObjectTypeOf(ourType, GOT_armor) && !isGameObjectTypeOf(ourType, GOT_component_armor) && !isGameObjectTypeOf(ourType, GOT_component_new_armor) && !isGameObjectTypeOf(ourType, GOT_cybernetic) && !isGameObjectTypeOf(ourType, GOT_cybernetic_arm) && !isGameObjectTypeOf(ourType, GOT_cybernetic_legs) && !isGameObjectTypeOf(ourType, GOT_cybernetic_torso)) { + System.out.println("!!!!Removing armor script!!!!!"); + System.out.println("--- This is probably bad... removing because game object type of item () doesn't match one of the exceptions: "); + detachScript(self, "item.armor.new_armor"); } return SCRIPT_CONTINUE; diff --git a/sku.0/sys.server/compiled/game/script/library/craftinglib.java b/sku.0/sys.server/compiled/game/script/library/craftinglib.java old mode 100644 new mode 100755 index 5d94f4658..965e0c226 --- a/sku.0/sys.server/compiled/game/script/library/craftinglib.java +++ b/sku.0/sys.server/compiled/game/script/library/craftinglib.java @@ -1139,7 +1139,9 @@ public class craftinglib extends script.base_script } if (hasObjVar(stationId, OBJVAR_CRAFTING_STATION_BONUS) == true) { - craftingStationMod = getFloatObjVar(stationId, OBJVAR_CRAFTING_STATION_BONUS) / 10; + // Cekis: not sure why a float divided by an int is desired here (was just 10), so changing the int to a float + // as the former would have resulted in potential loss in precision. + craftingStationMod = getFloatObjVar(stationId, OBJVAR_CRAFTING_STATION_BONUS) / 10.0f; } debugServerConsoleMsg(null, "craftinglib::calcPerExperimentationCheckMod - craftingStationMod = " + craftingStationMod); float playerSkillMod = 0; @@ -1686,7 +1688,8 @@ public class craftinglib extends script.base_script public static boolean storeSecondarySkillBonuses(obj_id prototype, draft_schematic schematic) throws InterruptedException { draft_schematic.slot[] slots = schematic.getSlots(); - draft_schematic.attribute[] objectAttribs = schematic.getAttribs(); + // Cekis: never used - waste of processing. + // draft_schematic.attribute[] objectAttribs = schematic.getAttribs(); String category = getProtoTypeCategory(prototype); for (int i = 0; i < slots.length; ++i) { diff --git a/sku.0/sys.server/compiled/game/script/systems/crafting/crafting_base.java b/sku.0/sys.server/compiled/game/script/systems/crafting/crafting_base.java old mode 100644 new mode 100755 index 13a688c75..498716f9c --- a/sku.0/sys.server/compiled/game/script/systems/crafting/crafting_base.java +++ b/sku.0/sys.server/compiled/game/script/systems/crafting/crafting_base.java @@ -138,11 +138,12 @@ public class crafting_base extends script.base_script { if (component.getData() instanceof Integer) { - itemAttributes[i].currentValue = component.getIntData(); + itemAttributes[i].currentValue = (float) component.getIntData(); } else if (itemAttributes[i].minValue != itemAttributes[i].maxValue) { debugServerConsoleMsg(null, "updating attrib " + (itemAttributes[i].name).getAsciiId() + ", current value = " + itemAttributes[i].currentValue + " by component value " + component.getFloatData()); + // Cekis: This may be a bug - why incremenet if a float (in this condition), but just re-assign if an int? itemAttributes[i].currentValue += component.getFloatData(); } else @@ -209,11 +210,13 @@ public class crafting_base extends script.base_script draft_schematic.slot[] slots = schematic.getSlots(); draft_schematic.attribute[] objectAttribs = schematic.getAttribs(); draft_schematic.attribute[] experimentalAttribs = schematic.getExperimentalAttribs(); + /* Cekis: pointless loop. for (int i = 0; i < objectAttribs.length; ++i) { float modifiedValue = objectAttribs[i].currentValue; String attribName = (objectAttribs[i].name).getAsciiId(); } + */ String[] obj_attributes = new String[objectAttribs.length]; for (int i = 0; i < obj_attributes.length; ++i) { @@ -533,11 +536,13 @@ public class crafting_base extends script.base_script } draft_schematic.attribute[] objectAttribs = schematic.getAttribs(); dictionary craftingValuesDictionary = new dictionary(); + /* Cekis: this is a totally pointless loop! Commenting out for now. for (int i = 0; i < objectAttribs.length; ++i) { float modifiedValue = objectAttribs[i].currentValue; String attribName = (objectAttribs[i].name).getAsciiId(); } + */ calcAndSetPrototypeProperties(prototype, objectAttribs, craftingValuesDictionary); setSchematicAttributes(self, objectAttribs); craftinglib.storeTissueDataAsObjvars(craftingValuesDictionary, objectAttribs, prototype, true); @@ -582,6 +587,7 @@ public class crafting_base extends script.base_script } public int OnManufactureObject(obj_id self, obj_id player, obj_id newObject, draft_schematic schematic, boolean isPrototype, boolean isRealObject) throws InterruptedException { + /* Cekis: unused vars and a pointless loop. Commenting out for now. draft_schematic.attribute[] objectAttribs = schematic.getAttribs(); draft_schematic.attribute[] experimentalAttribs = schematic.getExperimentalAttribs(); for (int i = 0; i < objectAttribs.length; ++i) @@ -589,6 +595,7 @@ public class crafting_base extends script.base_script float modifiedValue = objectAttribs[i].currentValue; String attribName = (objectAttribs[i].name).getAsciiId(); } + */ if (isPrototype) { OnFinalizeSchematic(self, player, newObject, schematic); @@ -651,6 +658,7 @@ public class crafting_base extends script.base_script } public int OnMakeCraftedItem(obj_id self, obj_id prototype, draft_schematic schematic, float qualityPercent) throws InterruptedException { + /* Cekis: look kids! Pointless vars and Another pointless loop! Commenting out for now. draft_schematic.attribute[] objectAttribs = schematic.getAttribs(); draft_schematic.attribute[] experimentalAttribs = schematic.getExperimentalAttribs(); for (int i = 0; i < objectAttribs.length; ++i) @@ -658,11 +666,12 @@ public class crafting_base extends script.base_script float modifiedValue = objectAttribs[i].currentValue; String attribName = (objectAttribs[i].name).getAsciiId(); } + */ debugServerConsoleMsg(null, "OnMakeCraftedItem enter, quality = " + qualityPercent); dictionary craftingValuesDictionary = new dictionary(); for (int i = 0; i < objectAttribs.length; ++i) { - objectAttribs[i].currentValue = objectAttribs[i].minValue + (objectAttribs[i].maxValue - objectAttribs[i].minValue) * (qualityPercent / 100.0f); + objectAttribs[i].currentValue = objectAttribs[i].maxValue * (qualityPercent / 100.0f); } setSchematicAttributes(self, objectAttribs); calcAndSetPrototypeProperties(prototype, objectAttribs);