Updated Meso & Arrow drops + Aran change jobs fix + improved concurrency

Added meso drop data for many mobs that were missing mesos.
Enhanced arrow drop data, now dropping bundles instead of unitary items.
Fixed issues with several Aran change jobs crashing the player shortly after changing jobs.
Improved concurrency in MapleGuild, MapleAlliance and MaplePlayerShop.
New tools: MapleArrowFetcher and MapleMesoFetcher, that were used to compile the updated drop data info.
This commit is contained in:
ronancpl
2017-11-01 13:34:26 -02:00
parent 44949aea37
commit 64af2cfa00
192 changed files with 44793 additions and 271 deletions

View File

@@ -0,0 +1,221 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package maplearrowfetcher;
import life.MapleLifeFactory;
import life.MapleMonsterStats;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import tools.DatabaseConnection;
import tools.Pair;
/**
*
* @author RonanLana
* This application traces arrow drop data on the underlying DB (that must be
* defined on the DatabaseConnection file of this project) and generates a SQL
* file that proposes updated arrow quantitty on drop entries for the drop_data table.
*
* The arrow quantity range is calculated accordingly with the target mob stats, such
* as level and if it's a boss or not.
*
*/
public class MapleArrowFetcher {
/**
* @param args the command line arguments
*/
private static PrintWriter printWriter;
private static String newFile = "lib/arrow_drop_data.sql";
private static int[] arrowWeight = new int[6];
private static int minArrowId = 2060000;
private static int maxArrowId = 2061004;
private static Map<Integer, MapleMonsterStats> mobStats;
private static Map<Integer, Pair<Integer, Integer>> mobRange = new HashMap<>();
private static Pair<Integer, Integer> calcArrowRange(int level, boolean boss) {
int minRange, maxRange;
// MIN range
minRange = (int)(1.895883884 * Math.exp(0.02673101054) * level * (boss ? 1.4 : 1.0));
// MAX range
maxRange = 3 * minRange;
return new Pair<>(minRange, maxRange);
}
private static void calcAllMobsArrowRange() {
System.out.print("Calculating range... ");
for(Entry<Integer, MapleMonsterStats> mobStat : mobStats.entrySet()) {
MapleMonsterStats mms = mobStat.getValue();
Pair<Integer, Integer> arrowRange;
arrowRange = calcArrowRange(mms.getLevel(), mms.isBoss());
mobRange.put(mobStat.getKey(), arrowRange);
}
System.out.println("done!");
}
private static void printSqlHeader() {
printWriter.println(" # SQL File autogenerated from the MapleArrowFetcher feature by Ronan Lana.");
printWriter.println(" # Generated data takes into account mob stats such as level and boss for the raw arrow ranges.");
printWriter.println(" # Only current arrows entries on the DB it was compiled are being updated here.");
printWriter.println();
printWriter.println("UPDATE drop_data");
printWriter.println("SET minimum_quantity = CASE");
}
private static void printSqlMiddle() {
printWriter.println(" ELSE minimum_quantity END,");
printWriter.println(" maximum_quantity = CASE");
}
private static void printSqlFooter() {
printWriter.println(" ELSE maximum_quantity END");
printWriter.println(";");
}
private static void updateSqlMobArrowMinEntry(int[] entry) {
printWriter.println(" WHEN dropperid = " + entry[0] + " AND itemid = " + entry[1] + " THEN " + entry[2]);
}
private static void updateSqlMobArrowMaxEntry(int[] entry) {
printWriter.println(" WHEN dropperid = " + entry[0] + " AND itemid = " + entry[1] + " THEN " + entry[3]);
}
private static List<int[]> getArrowEntryValues(Map<Integer, List<Integer>> existingEntries) {
List<int[]> entryValues = new ArrayList<>(200);
List<Entry<Integer, List<Integer>>> listEntries = new ArrayList<>(existingEntries.entrySet());
Collections.sort(listEntries, new Comparator<Entry<Integer, List<Integer>>>() {
@Override
public int compare(Entry<Integer, List<Integer>> o1, Entry<Integer, List<Integer>> o2) {
int val1 = o1.getKey();
int val2 = o2.getKey();
return (val1 < val2 ? -1 : (val1 == val2 ? 0 : 1));
}
});
for(Entry<Integer, List<Integer>> ee : listEntries) {
int mobid = ee.getKey();
Pair<Integer, Integer> mr = mobRange.get(mobid);
for(Integer itemid : ee.getValue()) {
int itemWeight = (itemid % 10) + 1;
int[] values = new int[4];
values[0] = mobid;
values[1] = itemid;
values[2] = (int) Math.ceil(mr.getLeft() / itemWeight); // weighted min quantity
values[3] = (int) Math.ceil(mr.getRight() / itemWeight); // weighted max quantity
entryValues.add(values);
}
}
return entryValues;
}
private static void updateMobsArrowRange() {
System.out.print("Generating updated ranges... ");
Connection con = DatabaseConnection.getConnection();
Map<Integer, List<Integer>> existingEntries = new HashMap<>(200);
try {
// select all arrow drop entries on the DB, to update their values
PreparedStatement ps = con.prepareStatement("SELECT dropperid, itemid FROM drop_data WHERE itemid >= " + minArrowId + " AND itemid <= " + maxArrowId + " ORDER BY itemid;");
ResultSet rs = ps.executeQuery();
if (rs.isBeforeFirst()) {
while(rs.next()) {
int mobid = rs.getInt(1);
int itemid = rs.getInt(2);
if(mobRange.containsKey(mobid)) {
List<Integer> em = existingEntries.get(mobid);
if(em == null) {
em = new ArrayList<>(2);
existingEntries.put(mobid, em);
}
em.add(itemid);
}
}
if(!existingEntries.isEmpty()) {
List<int[]> entryValues = getArrowEntryValues(existingEntries);
printWriter = new PrintWriter(newFile, "UTF-8");
printSqlHeader();
for(int[] arrowEntry : entryValues) {
updateSqlMobArrowMinEntry(arrowEntry);
}
printSqlMiddle();
for(int[] arrowEntry : entryValues) {
updateSqlMobArrowMaxEntry(arrowEntry);
}
printSqlFooter();
printWriter.close();
} else {
throw new Exception("NO DATA");
}
} else {
throw new Exception("NO DATA");
}
rs.close();
ps.close();
con.close();
System.out.println("done!");
} catch(Exception e) {
if(e.getMessage() != null && e.getMessage().equals("NO DATA")) {
System.out.println("failed! The DB has no arrow entry to be updated.");
} else {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
// load mob stats from WZ
mobStats = MapleLifeFactory.getAllMonsterStats();
calcAllMobsArrowRange();
updateMobsArrowRange();
}
}