Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update for CJT to work with 4.3 game files

  • Loading branch information...
commit 47963f9ff0b4aaa0445255b951f5637a19859f27 1 parent 3a52a20
@lemartin authored
View
8 tools/cjt/src/org/chardev/UpdateChardevDB.java
@@ -8,7 +8,7 @@
public class UpdateChardevDB {
- private static final int ITEM_SPARSE_SKIP = 0x698E8 - 32;
+ private static final int ITEM_SPARSE_SKIP = 0x739bc - 32;
private static final String dbs[] = new String[]{
"jdbc:mysql://localhost:3306/chardev_cataclysm?",
@@ -68,10 +68,10 @@ public static void main(String[] args) {
boolean skipLocale = false;
connectToDatabase(dbs[0]);
- cacheUpdate();
+ //cacheUpdate();
- connectToDatabase(dbs[2]);
- localeUpdate(basePaths[2],locales[2]);
+// connectToDatabase(dbs[2]);
+// localeUpdate(basePaths[2],locales[2]);
connectToDatabase(dbs[0]);
staticUpdate(basePaths[0]);
View
111 tools/cjt/src/org/chardev/cjt/util/UpdateCachedItemSetTables.java
@@ -0,0 +1,111 @@
+package org.chardev.cjt.util;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Java port of php/tools/update_items.php
+ *
+ * Updates <code>chardev_cataclysm.item_sparse</code> with the currently
+ * available and up to date items and sets additional cached item data in
+ * <code>chardev_cataclysm_static.chardev_item_stats</code>
+ *
+ * @author LeMartin
+ *
+ */
+public class UpdateCachedItemSetTables {
+
+ public static void main(String[] args) {
+ Connection connectionLocaleDB = Database
+ .connectToDatabase(Database.CHARDEV_CATACLYSM);
+ Connection connectionStaticDB = Database
+ .connectToDatabase(Database.CHARDEV_CATACLYSM_STATIC);
+ new UpdateCachedItemSetTables(connectionStaticDB, connectionLocaleDB);
+ }
+
+ protected final Connection connectionStaticDB, connectionLocaleDB;
+
+ /**
+ * Updates <code>chardev_cataclysm.item_sparse</code> with the currently
+ * available and up to date items.
+ *
+ * @param connectionStaticDB
+ * @param connectionLocaleDB
+ */
+ public UpdateCachedItemSetTables(Connection connectionStaticDB,
+ Connection connectionLocaleDB) {
+ //
+ this.connectionStaticDB = connectionStaticDB;
+ this.connectionLocaleDB = connectionLocaleDB;
+ //
+ try {
+ //
+ Statement stmt = connectionLocaleDB.createStatement();
+ ResultSet result = stmt.executeQuery("SELECT * FROM `itemset`");
+ //
+
+ while (result.next()) {
+ int minItemLevel = Integer.MAX_VALUE, maxItemLevel = 0, minReqLevel = 85, maxReqLevel = 0, items = 0, minQuality = Integer.MAX_VALUE, maxQuality = 0;
+
+ System.out.println(result.getString("Name"));
+ for( int i=1; i<= 10; i++ ) {
+ if( result.getInt("ItemID"+i) <= 0 ) {
+ continue;
+ }
+ Statement itemStmt = connectionLocaleDB.createStatement();
+ ResultSet itemResult = itemStmt.executeQuery("SELECT * FROM `item_sparse` WHERE `ID`="+result.getInt("ItemID"+i));
+
+ if (itemResult.next()) {
+ System.out.println("\t"+itemResult.getString("Name"));
+
+ int ilvl = itemResult.getInt("Level");
+ int clvl = itemResult.getInt("RequiredCharacterLevel");
+ int qua = itemResult.getInt("Quality");
+
+ if( ilvl < minItemLevel ) {
+ minItemLevel = ilvl;
+ }
+ if( ilvl > maxItemLevel ) {
+ maxItemLevel = ilvl;
+ }
+ if( clvl < minReqLevel ) {
+ minReqLevel = clvl;
+ }
+ if( clvl > maxReqLevel ) {
+ maxReqLevel = clvl;
+ }
+ if( qua < minQuality ) {
+ minQuality = qua;
+ }
+ if( qua > maxQuality ) {
+ maxQuality = qua;
+ }
+ items ++;
+ }
+ itemStmt.close();
+ }
+
+ if( items > 0 ) {
+ Statement insert = connectionStaticDB.createStatement();
+ insert.execute("REPLACE INTO `chardev_itemset_stats` values ( "+
+ result.getInt("ID")+
+ ", "+minItemLevel+
+ ", "+maxItemLevel+
+ ", "+minReqLevel+
+ ", "+maxReqLevel+
+ ", "+minQuality+
+ ", "+maxQuality+
+ ")"
+ );
+ insert.close();
+ }
+ }
+ stmt.close();
+ } catch (SQLException e) {
+ System.out.println(e);
+ throw new RuntimeException();
+ }
+ }
+}
View
2  tools/cjt/src/org/chardev/cjt/util/UpdateCachedItemTables.java
@@ -164,7 +164,7 @@ else if ((itemSubClassMask & (1 << 1 | 1 << 5 | 1 << 6
final int delay = result.getInt("Delay");
final float dmgRange = result
.getFloat("DamageRange");
- dps = dpsResult.getInt( new Integer(quality).toString());
+ dps = dpsResult.getFloat( new Integer(quality).toString());
minDmg = dps * delay / 1000 * (1 - dmgRange / 2);
maxDmg = dps * delay / 1000 * (1 + dmgRange / 2);
}
Please sign in to comment.
Something went wrong with that request. Please try again.