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:
1 parent
9af6dd30ea
commit
ff52d1d7e5
4 files changed
+58
-48
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user