Stop reading the replaced race, base class and promotion columns

static_rune_race is read only for the race ids and the server-only heights;
the hair/beard style, racebaseclass, baseclass and promotionrunereq queries
are gone. GET_BASE_CLASS is cache-only, which also drops the obj_account
cache-miss query. CSR/admin promotions 2901+ (no promotionrunereq rows) get an
empty allowed list. No value changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-22 12:41:06 -04:00
1 parent 658d52cf41
commit d576ed1468
6 files changed
+21 -224

No files matched your search

+1 -60
View File
@@ -13,13 +13,7 @@ import engine.gameManager.DbManager;
import engine.mbEnums;
import engine.mbEnums.GameObjectType;
import engine.objects.BaseClass;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
public class dbBaseClassHandler extends dbHandlerBase {
@@ -33,59 +27,6 @@ public class dbBaseClassHandler extends dbHandlerBase {
if (id == 0)
return null;
BaseClass baseClass = (BaseClass) DbManager.getFromCache(GameObjectType.BaseClass, id);
if (baseClass != null)
return baseClass;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `obj_account` WHERE `UID`=?")) {
preparedStatement.setLong(1, id);
ResultSet rs = preparedStatement.executeQuery();
baseClass = (BaseClass) getObjectFromRs(rs);
} catch (SQLException e) {
Logger.error(e);
}
return baseClass;
}
public ArrayList<BaseClass> GET_BASECLASS_FOR_RACE(final int id) {
ArrayList<BaseClass> baseClasses = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT b.* FROM `static_rune_baseclass` b, `static_rune_racebaseclass` r WHERE b.`ID` = r.`BaseClassID` && r.`RaceID` = ?")) {
preparedStatement.setInt(1, id);
ResultSet rs = preparedStatement.executeQuery();
baseClasses = getObjectsFromRs(rs, 20);
} catch (SQLException e) {
Logger.error(e);
}
return baseClasses;
}
public ArrayList<BaseClass> GET_ALL_BASE_CLASSES() {
ArrayList<BaseClass> baseClasses = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_baseclass`;")) {
ResultSet rs = preparedStatement.executeQuery();
baseClasses = getObjectsFromRs(rs, 20);
} catch (SQLException e) {
Logger.error(e);
}
return baseClasses;
return (BaseClass) DbManager.getFromCache(GameObjectType.BaseClass, id);
}
}
@@ -27,27 +27,6 @@ public class dbPromotionClassHandler extends dbHandlerBase {
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public ArrayList<Integer> GET_ALLOWED_RUNES(final PromotionClass pc) {
ArrayList<Integer> runeList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_promotionrunereq` WHERE `promoID`=?")) {
preparedStatement.setInt(1, pc.getObjectUUID());
ResultSet rs = preparedStatement.executeQuery();
while (rs.next())
runeList.add(rs.getInt("runereqID"));
} catch (SQLException e) {
Logger.error(e);
}
return runeList;
}
public PromotionClass GET_PROMOTION_CLASS(final int objectUUID) {
PromotionClass promotionClass;
+7 -60
View File
@@ -10,15 +10,14 @@
package engine.db.handlers;
import engine.gameManager.DbManager;
import engine.objects.Race;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;
public class dbRaceHandler extends dbHandlerBase {
@@ -46,27 +45,6 @@ public class dbRaceHandler extends dbHandlerBase {
return integerSet;
}
public HashSet<Integer> BEARD_STYLES_FOR_RACE(final int id) {
HashSet<Integer> integerSet = new HashSet<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `beardStyle` FROM `static_rune_racebeardstyle` WHERE `RaceID` = ?")) {
preparedStatement.setInt(1, id);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next())
integerSet.add(rs.getInt(1));
} catch (SQLException e) {
Logger.error(e);
}
return integerSet;
}
public HashSet<Integer> HAIR_COLORS_FOR_RACE(final int id) {
HashSet<Integer> integerSet = new HashSet<>();
@@ -89,28 +67,6 @@ public class dbRaceHandler extends dbHandlerBase {
}
public HashSet<Integer> HAIR_STYLES_FOR_RACE(final int id) {
HashSet<Integer> integerSet = new HashSet<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `hairStyle` FROM `static_rune_racehairstyle` WHERE `RaceID` = ?")) {
preparedStatement.setInt(1, id);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next())
integerSet.add(rs.getInt(1));
} catch (SQLException e) {
Logger.error(e);
}
return integerSet;
}
public HashSet<Integer> SKIN_COLOR_FOR_RACE(final int id) {
HashSet<Integer> integerSet = new HashSet<>();
@@ -132,32 +88,23 @@ public class dbRaceHandler extends dbHandlerBase {
return integerSet;
}
public ConcurrentHashMap<Integer, Race> LOAD_ALL_RACES() {
// Rune id -> {minHeight, strHeightMod}; the rows also decide which race runes are player races
public HashMap<Integer, float[]> LOAD_RACE_HEIGHTS() {
ConcurrentHashMap<Integer, Race> races;
Race thisRace;
races = new ConcurrentHashMap<>();
int recordsRead = 0;
HashMap<Integer, float[]> raceHeights = new HashMap<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_rune_race")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
recordsRead++;
thisRace = new Race(rs);
races.put(thisRace.getRaceRuneID(), thisRace);
}
while (rs.next())
raceHeights.put(rs.getInt("ID"), new float[]{rs.getFloat("minHeight"), rs.getFloat("strHeightMod")});
} catch (SQLException e) {
Logger.error(e);
}
Logger.info("read: " + recordsRead + " cached: " + races.size());
return races;
return raceHeights;
}
}
-25
View File
@@ -16,8 +16,6 @@ import engine.parsers.objects.RuneTemplate;
import engine.util.Hasher;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -85,29 +83,6 @@ public class BaseClass extends AbstractGameObject {
}
/**
* ResultSet Constructor
*/
public BaseClass(ResultSet rs) throws SQLException {
super(rs);
this.name = rs.getString("name");
this.description = rs.getString("description");
this.strMod = rs.getByte("strMod");
this.dexMod = rs.getByte("dexMod");
this.conMod = rs.getByte("conMod");
this.intMod = rs.getByte("intMod");
this.spiMod = rs.getByte("spiMod");
this.token = rs.getInt("token");
this.healthMod = rs.getInt("healthMod");
this.manaMod = rs.getInt("manaMod");
this.staminaMod = rs.getInt("staminaMod");
this.skillsGranted = SkillReq.getSkillReqsForRune(this.getObjectUUID());
this.powersGranted = PowerReq.getPowerReqsForRune(this.getObjectUUID());
this.effectsList = MobBaseEffects.getEffectsForRune(this.getObjectUUID());
}
/**
* Rune Template Constructor
*/
+2 -1
View File
@@ -70,6 +70,7 @@ public class PromotionClass extends AbstractGameObject {
/**
* ResultSet Constructor
* Only the CSR/admin rows 2901+ load from the DB; they have no promotion rune and allow no runes.
*/
public PromotionClass(ResultSet rs) throws SQLException {
super(rs);
@@ -80,7 +81,7 @@ public class PromotionClass extends AbstractGameObject {
this.healthMod = rs.getFloat("healthMod");
this.manaMod = rs.getFloat("manaMod");
this.staminaMod = rs.getFloat("staminaMod");
this.allowedRunes = DbManager.PromotionQueries.GET_ALLOWED_RUNES(this);
this.allowedRunes = new ArrayList<>();
this.skillsGranted = SkillReq.getSkillReqsForRune(this.getObjectUUID());
this.powersGranted = PowerReq.getPowerReqsForRune(this.getObjectUUID());
this.effectsList = MobBaseEffects.getEffectsForRune(this.getObjectUUID());
+11 -57
View File
@@ -11,7 +11,6 @@ package engine.objects;
import engine.gameManager.DbManager;
import engine.mbEnums;
import engine.mbEnums.RaceType;
import engine.net.ByteBufferWriter;
import engine.parsers.cache.CacheParserUtil;
import engine.parsers.objects.RuneTemplate;
@@ -19,10 +18,10 @@ import engine.server.MBServerStatics;
import engine.util.Hasher;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class Race {
@@ -70,55 +69,11 @@ public class Race {
private HashSet<Integer> beardStyles;
private ArrayList<MobBaseEffects> effectsList = new ArrayList<>();
/**
* ResultSet Constructor
*/
public Race(ResultSet rs) throws SQLException {
this.raceRuneID = rs.getInt("ID");
this.raceType = mbEnums.RaceType.getRaceTypebyRuneID(raceRuneID);
this.name = rs.getString("name");
this.description = rs.getString("description");
this.strStart = rs.getShort("strStart");
this.strMin = rs.getShort("strMin");
this.strMax = rs.getShort("strMax");
this.dexStart = rs.getShort("dexStart");
this.dexMin = rs.getShort("dexMin");
this.dexMax = rs.getShort("dexMax");
this.conStart = rs.getShort("conStart");
this.conMin = rs.getShort("conMin");
this.conMax = rs.getShort("conMax");
this.intStart = rs.getShort("intStart");
this.intMin = rs.getShort("intMin");
this.intMax = rs.getShort("intMax");
this.spiStart = rs.getShort("spiStart");
this.spiMin = rs.getShort("spiMin");
this.spiMax = rs.getShort("spiMax");
this.token = rs.getInt("token");
this.healthBonus = rs.getShort("healthBonus");
this.manaBonus = rs.getShort("manaBonus");
this.staminaBonus = rs.getShort("staminaBonus");
this.startingPoints = rs.getByte("startingPoints");
this.raceType = RaceType.getRaceTypebyRuneID(this.raceRuneID);
this.minHeight = rs.getFloat("minHeight");
this.strHeightMod = rs.getFloat("strHeightMod");
this.hairStyles = DbManager.RaceQueries.HAIR_STYLES_FOR_RACE(raceRuneID);
this.beardStyles = DbManager.RaceQueries.BEARD_STYLES_FOR_RACE(raceRuneID);
this.skinColors = DbManager.RaceQueries.SKIN_COLOR_FOR_RACE(raceRuneID);
this.beardColors = DbManager.RaceQueries.BEARD_COLORS_FOR_RACE(raceRuneID);
this.hairColors = DbManager.RaceQueries.HAIR_COLORS_FOR_RACE(raceRuneID);
this.baseClasses = DbManager.BaseClassQueries.GET_BASECLASS_FOR_RACE(raceRuneID);
this.skillsGranted = SkillReq.getSkillReqsForRune(raceRuneID);
this.powersGranted = PowerReq.getPowerReqsForRune(raceRuneID);
this.effectsList = MobBaseEffects.getEffectsForRune(this.raceRuneID);
}
/**
* Rune Template Constructor
* minHeight and strHeightMod are server-only and come from the static_rune_race row.
*/
public Race(RuneTemplate rune, Race dbRace) {
public Race(RuneTemplate rune, float[] heights) {
this.raceRuneID = rune.template_id;
this.raceType = mbEnums.RaceType.getRaceTypebyRuneID(raceRuneID);
@@ -144,8 +99,8 @@ public class Race {
this.manaBonus = (short) rune.rune_mana;
this.staminaBonus = (short) rune.rune_stamina;
this.startingPoints = (byte) (STARTING_POINT_POOL - rune.rune_creation_cost);
this.minHeight = dbRace.minHeight;
this.strHeightMod = dbRace.strHeightMod;
this.minHeight = heights[0];
this.strHeightMod = heights[1];
this.hairStyles = new HashSet<>(rune.rune_hair);
this.beardStyles = new HashSet<>(rune.rune_beard);
this.skinColors = DbManager.RaceQueries.SKIN_COLOR_FOR_RACE(raceRuneID);
@@ -193,23 +148,22 @@ public class Race {
public static void loadAllRaces() {
ConcurrentHashMap<Integer, Race> dbRaces;
HashMap<Integer, float[]> raceHeights;
ConcurrentHashMap<Integer, Race> races;
RuneTemplate rune;
dbRaces = DbManager.RaceQueries.LOAD_ALL_RACES();
raceHeights = DbManager.RaceQueries.LOAD_RACE_HEIGHTS();
races = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
for (Race dbRace : dbRaces.values()) {
rune = RuneTemplate._runes.get(dbRace.raceRuneID);
for (Map.Entry<Integer, float[]> raceRow : raceHeights.entrySet()) {
rune = RuneTemplate._runes.get(raceRow.getKey());
if (rune == null || rune.rune_type != mbEnums.RuneType.RACE) {
Logger.warn("Race " + dbRace.raceRuneID + " has no race rune; loaded from static_rune_race");
races.put(dbRace.raceRuneID, dbRace);
Logger.warn("Race " + raceRow.getKey() + " in static_rune_race has no race rune; skipped");
continue;
}
races.put(dbRace.raceRuneID, new Race(rune, dbRace));
races.put(rune.template_id, new Race(rune, raceRow.getValue()));
}
Race._raceByID = races;