Made a few optimizations by removing unused code. Also made some changes where data types were mixed.

This commit is contained in:
Cekis
2015-12-08 02:31:28 +01:00
parent ef936839a4
commit 2e49b90bde
3 changed files with 28 additions and 4 deletions
+12
View File
@@ -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;
+5 -2
View File
@@ -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)
{
+11 -2
View File
@@ -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);