nextStaticID now takes the object type and a natural manifest key, so no static ID is handed out without a manifest entry. After the world load the server diffs maps/<map>.manifest against the previous boot (moved, vanished, re-targeted IDs), writes the new one (old copy kept as .manifest.prev), and logs every negative reference in the Task 2.1 columns that no loaded static object of the right type holds. Value changes: none in play. Guilds are the only static IDs so far (-2..-25, keys guild:<first seed key>). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.0 KiB
Java
48 lines
2.0 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
// https://www.magicbane.com
|
|
|
|
package engine.db.handlers;
|
|
|
|
import engine.gameManager.DbManager;
|
|
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;
|
|
|
|
public class dbStaticWorldHandler extends dbHandlerBase {
|
|
|
|
public dbStaticWorldHandler() {
|
|
|
|
}
|
|
|
|
// Table and column come from StaticManifest's fixed list, never from input. -1 means "none" and is skipped.
|
|
public HashMap<Integer, Integer> GET_NEGATIVE_REFERENCES(String table, String column) {
|
|
|
|
HashMap<Integer, Integer> rowsByValue = new HashMap<>();
|
|
|
|
try (Connection connection = DbManager.getConnection();
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `" + column + "` AS `value`, COUNT(*) AS `rows` FROM `"
|
|
+ table + "` WHERE `" + column + "` < -1 GROUP BY `" + column + "`;")) {
|
|
|
|
ResultSet rs = preparedStatement.executeQuery();
|
|
|
|
while (rs.next())
|
|
rowsByValue.put(rs.getInt("value"), rs.getInt("rows"));
|
|
|
|
} catch (SQLException e) {
|
|
Logger.error(table + "." + column + ": " + e);
|
|
return null;
|
|
}
|
|
|
|
return rowsByValue;
|
|
}
|
|
}
|