Browse Source

Templates backfilled with modtable data

combat-2
MagicBot 8 months ago
parent
commit
230679cef9
  1. 19
      src/engine/db/handlers/dbItemHandler.java
  2. 9
      src/engine/net/client/msg/ManageNPCMsg.java
  3. 3
      src/engine/objects/ItemFactory.java
  4. 1
      src/engine/objects/ItemTemplate.java
  5. 3
      src/engine/server/login/LoginServer.java
  6. 3
      src/engine/server/world/WorldServer.java

19
src/engine/db/handlers/dbItemHandler.java

@ -193,9 +193,26 @@ public class dbItemHandler extends dbHandlerBase {
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
} }
} }
public void LOAD_TEMPLATE_MODTABLES() {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_vendor_items`;");
ResultSet rs = preparedStatement.executeQuery()) {
while (rs.next()) {
int templateID = rs.getInt("templateID");
int modTable = rs.getInt("modTable");
ItemTemplate template = ItemTemplate.templates.get(templateID);
template.modTable = modTable;
}
} catch (Exception e) {
Logger.error(e);
}
}
public Item GET_ITEM(final int itemUUID) { public Item GET_ITEM(final int itemUUID) {
Item item; Item item;

9
src/engine/net/client/msg/ManageNPCMsg.java

@ -422,7 +422,6 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(rollableSet.size()); writer.putInt(rollableSet.size());
for (int templateID : rollableSet) { for (int templateID : rollableSet) {
ItemBase item = ItemBase.getItemBase(templateID);
ItemTemplate template = ItemTemplate.templates.get(templateID); ItemTemplate template = ItemTemplate.templates.get(templateID);
writer.put((byte) 1); writer.put((byte) 1);
writer.putInt(0); writer.putInt(0);
@ -430,10 +429,10 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(template.item_value); writer.putInt(template.item_value);
writer.putInt(600); writer.putInt(600);
writer.put((byte) 1); writer.put((byte) 1);
writer.put((byte) item.getModTable()); writer.put((byte) template.modTable);
writer.put((byte) item.getModTable()); writer.put((byte) template.modTable);
writer.put((byte) item.getModTable()); writer.put((byte) template.modTable);
writer.put((byte) item.getModTable());//EffectItemType writer.put((byte) template.modTable);//EffectItemType
} }
List<MobLoot> itemList = npc.getRolling(); List<MobLoot> itemList = npc.getRolling();

3
src/engine/objects/ItemFactory.java

@ -640,7 +640,6 @@ public class ItemFactory {
ModTableEntry prefixEntry = null; ModTableEntry prefixEntry = null;
ModTableEntry suffixEntry = null; ModTableEntry suffixEntry = null;
ItemBase ib = ItemBase.getItemBase(templateID);
ItemTemplate template = ItemTemplate.templates.get(templateID); ItemTemplate template = ItemTemplate.templates.get(templateID);
if (template == null) if (template == null)
@ -654,7 +653,7 @@ public class ItemFactory {
return null; return null;
} }
itemModTable = (byte) ib.getModTable(); itemModTable = (byte) template.modTable;
if (!vendor.getItemModTable().contains(itemModTable)) { if (!vendor.getItemModTable().contains(itemModTable)) {

1
src/engine/objects/ItemTemplate.java

@ -84,6 +84,7 @@ public class ItemTemplate {
public static HashMap<String, Integer> item_power_grant = new HashMap<>(); public static HashMap<String, Integer> item_power_grant = new HashMap<>();
public HashMap<String, int[]> item_power_action = new HashMap<>(); public HashMap<String, int[]> item_power_action = new HashMap<>();
public HashMap<Enum.ResourceType, Integer> item_resource_cost = new HashMap<>(); public HashMap<Enum.ResourceType, Integer> item_resource_cost = new HashMap<>();
public int modTable;
// Deed related fields // Deed related fields

3
src/engine/server/login/LoginServer.java

@ -263,9 +263,6 @@ public class LoginServer {
Logger.info("Initializing Blueprint data."); Logger.info("Initializing Blueprint data.");
Blueprint.loadAllBlueprints(); Blueprint.loadAllBlueprints();
Logger.info("Loading Item Templates");
DbManager.ItemQueries.LOAD_ITEM_TEMPLATES();
Logger.info("Loading Kits"); Logger.info("Loading Kits");
DbManager.KitQueries.GET_ALL_KITS(); DbManager.KitQueries.GET_ALL_KITS();

3
src/engine/server/world/WorldServer.java

@ -343,6 +343,9 @@ public class WorldServer {
Logger.info("Loading Item Templates"); Logger.info("Loading Item Templates");
DbManager.ItemQueries.LOAD_ITEM_TEMPLATES(); DbManager.ItemQueries.LOAD_ITEM_TEMPLATES();
Logger.info("Back fill template modTables");
DbManager.ItemQueries.LOAD_TEMPLATE_MODTABLES();
Logger.info("Loading ItemBases"); Logger.info("Loading ItemBases");
ItemBase.loadAllItemBases(); ItemBase.loadAllItemBases();

Loading…
Cancel
Save