Browse Source

null pointer evasion

master
FatBoy-DOTC 1 year ago
parent
commit
57a38303f8
  1. 12
      src/engine/loot/LootManager.java

12
src/engine/loot/LootManager.java

@ -123,7 +123,7 @@ public class LootManager { @@ -123,7 +123,7 @@ public class LootManager {
//iterate the booty tables and add items to mob inventory
MobLoot toAdd = getGenTableItem(bse.lootTable, mob);
if (toAdd != null) {
if(toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix().isEmpty() == true){
if(toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix()!= null && toAdd.getSuffix().isEmpty() == true){
toAdd.setIsID(true);
}
mob.getCharItemManager().addItemToInventory(toAdd);
@ -133,7 +133,7 @@ public class LootManager { @@ -133,7 +133,7 @@ public class LootManager {
int lootTableID = bse.lootTable + 1;
MobLoot toAddHZ = getGenTableItem(lootTableID, mob);
if (toAddHZ != null)
if(toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix().isEmpty() == true){
if(toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix()!= null && toAdd.getSuffix().isEmpty() == true){
toAdd.setIsID(true);
}
mob.getCharItemManager().addItemToInventory(toAddHZ);
@ -169,6 +169,7 @@ public class LootManager { @@ -169,6 +169,7 @@ public class LootManager {
public static MobLoot getGenTableItem(int genTableID, Mob mob) {
try {
if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) {
return null;
}
@ -199,7 +200,7 @@ public class LootManager { @@ -199,7 +200,7 @@ public class LootManager {
if (outItem.getItemBase().isGlass() == false) {
int prefixChanceRoll = ThreadLocalRandom.current().nextInt(101);
double prefixChance = 2.057 * mob.level - 28.67;
if(prefixChanceRoll < prefixChance) {
if (prefixChanceRoll < prefixChance) {
ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable);
int prefixroll = ThreadLocalRandom.current().nextInt(101);
@ -214,7 +215,7 @@ public class LootManager { @@ -214,7 +215,7 @@ public class LootManager {
}
int suffixChanceRoll = ThreadLocalRandom.current().nextInt(101);
double suffixChance = 2.057 * mob.level - 28.67;
if(suffixChanceRoll < suffixChance) {
if (suffixChanceRoll < suffixChance) {
int suffixroll = ThreadLocalRandom.current().nextInt(101);
ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable);
if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) {
@ -229,6 +230,9 @@ public class LootManager { @@ -229,6 +230,9 @@ public class LootManager {
}
}
return outItem;
}catch(Exception e){
return null;
}
}
private static int TableRoll(int mobLevel){
int max = (int)(4.882 * mobLevel + 121.0);

Loading…
Cancel
Save