Build SkillsBase from Skills.cfg

SkillsBase name, description, token (SBStringHash of the name) and
attribute weights now come from SkillTemplate._skills. The skill ids
stay in static_skill_skillsbase (ID, name), which dyn_character_skill
and SkillReq use; the loader joins each row's name to the cfg skill and
logs an error for a name with no cfg entry. Both servers load all 63 at
boot after Skills.cfg; GET_BASE/GET_BASE_BY_NAME/GET_BASE_BY_TOKEN read
the boot caches only. The other 31 cfg skills stay in SkillTemplate.

Parity (scripts/p43.py, dev DB): 63/63 names, 63/63 tokens, 63/63
weights. Only value change: description was empty for all 63 in the DB
and is now the cfg text (no server reader).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-25 11:14:19 -04:00
1 parent 9af6dd30ea
commit ff52d1d7e5
4 files changed
+58 -48

No files matched your search

+11 -48
View File
@@ -19,6 +19,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
public class dbSkillBaseHandler extends dbHandlerBase {
@@ -28,71 +29,33 @@ public class dbSkillBaseHandler extends dbHandlerBase {
}
public SkillsBase GET_BASE(final int objectUUID) {
SkillsBase skillsBase = (SkillsBase) DbManager.getFromCache(GameObjectType.SkillsBase, objectUUID);
if (skillsBase != null)
return skillsBase;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE ID = ?")) {
preparedStatement.setInt(1, objectUUID);
ResultSet rs = preparedStatement.executeQuery();
skillsBase = (SkillsBase) getObjectFromRs(rs);
} catch (SQLException e) {
Logger.error(e);
}
SkillsBase.putInCache(skillsBase);
return skillsBase;
return (SkillsBase) DbManager.getFromCache(GameObjectType.SkillsBase, objectUUID);
}
public SkillsBase GET_BASE_BY_NAME(String name) {
SkillsBase skillsBase = SkillsBase.getFromCache(name);
if (skillsBase != null)
return skillsBase;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE name = ?")) {
preparedStatement.setString(1, name);
ResultSet rs = preparedStatement.executeQuery();
skillsBase = (SkillsBase) getObjectFromRs(rs);
} catch (SQLException e) {
Logger.error(e);
}
SkillsBase.putInCache(skillsBase);
return skillsBase;
return SkillsBase.getFromCache(name);
}
public SkillsBase GET_BASE_BY_TOKEN(final int token) {
return SkillsBase.getFromCache(token);
}
SkillsBase skillsBase = SkillsBase.getFromCache(token);
public HashMap<Integer, String> GET_ALL_SKILL_NAMES() {
if (skillsBase != null)
return skillsBase;
HashMap<Integer, String> skillNames = new HashMap<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE token = ?")) {
PreparedStatement preparedStatement = connection.prepareStatement("SELECT ID, name FROM static_skill_skillsbase")) {
preparedStatement.setInt(1, token);
ResultSet rs = preparedStatement.executeQuery();
skillsBase = (SkillsBase) getObjectFromRs(rs);
while (rs.next())
skillNames.put(rs.getInt("ID"), rs.getString("name"));
} catch (SQLException e) {
Logger.error(e);
}
SkillsBase.putInCache(skillsBase);
return skillsBase;
return skillNames;
}
}
+41
View File
@@ -10,8 +10,10 @@
package engine.objects;
import engine.gameManager.DbManager;
import engine.mbEnums.AttributeType;
import engine.mbEnums.SourceType;
import engine.parsers.objects.RuneTemplate;
import engine.parsers.objects.wpak.SkillTemplate;
import engine.server.MBServerStatics;
import engine.util.Hasher;
import org.pmw.tinylog.Logger;
@@ -75,6 +77,20 @@ public class SkillsBase extends AbstractGameObject {
this.spiMod = spiMod;
}
public SkillsBase(int skillsBaseID, SkillTemplate template) {
super(skillsBaseID);
this.name = template.skill_name;
this.nameNoSpace = name.replace(" ", "");
this.description = template.description;
this.sourceType = SourceType.GetSourceType(this.nameNoSpace.replace("-", "").replace("\"", "").replace(",", ""));
this.token = Hasher.SBStringHash(this.name);
this.strMod = template.attr_weights.getOrDefault(AttributeType.Strength, 0).shortValue();
this.dexMod = template.attr_weights.getOrDefault(AttributeType.Dexterity, 0).shortValue();
this.conMod = template.attr_weights.getOrDefault(AttributeType.Constitution, 0).shortValue();
this.intMod = template.attr_weights.getOrDefault(AttributeType.Intelligence, 0).shortValue();
this.spiMod = template.attr_weights.getOrDefault(AttributeType.Spirit, 0).shortValue();
}
/**
* ResultSet Constructor
*/
@@ -107,6 +123,31 @@ public class SkillsBase extends AbstractGameObject {
return null;
}
// Skill ids stay in static_skill_skillsbase (dyn_character_skill and SkillReq use them); everything else is Skills.cfg
public static void LoadAllSkillsBase() {
HashMap<String, SkillTemplate> skillsByName = new HashMap<>();
HashMap<Integer, String> skillNames = DbManager.SkillsBaseQueries.GET_ALL_SKILL_NAMES();
SkillTemplate template;
for (SkillTemplate skill : SkillTemplate._skills.values())
skillsByName.put(skill.skill_name, skill);
for (Map.Entry<Integer, String> skillName : skillNames.entrySet()) {
template = skillsByName.get(skillName.getValue());
if (template == null) {
Logger.error("static_skill_skillsbase " + skillName.getKey() + " '" + skillName.getValue() + "' has no Skills.cfg entry");
continue;
}
putInCache(new SkillsBase(skillName.getKey(), template));
}
Logger.info("Loaded " + skillsCache.size() + " skills of " + SkillTemplate._skills.size() + " in Skills.cfg");
}
// Level 0 adjusts are the skills a rune grants outright; higher levels are trainer caps
public static void LoadAllRuneSkills() {
+3
View File
@@ -349,6 +349,9 @@ public class LoginServer {
exit(1);
}
Logger.info("Loading SkillsBase");
SkillsBase.LoadAllSkillsBase();
Logger.info("Loading Starting Kits");
StartingKitTemplate._kits = StartingKitParser.parseStartingKitFile();
+3
View File
@@ -349,6 +349,9 @@ public class WorldServer {
exit(1);
}
Logger.info("Loading SkillsBase");
SkillsBase.LoadAllSkillsBase();
Logger.info("Loading Starting Kits");
StartingKitTemplate._kits = StartingKitParser.parseStartingKitFile();