LoadAllRuneBases builds one RuneBase per static_rune_runebase row from the rune
with the same id (all 315 have one) and fills runeBaseAttributeMap from the
rune; the row now only supplies type, subtype, the runereq maps and effects. A
row without a rune would stay the DB object, without attributes, with a
warning. static_rune_runebaseattribute is no longer read at boot (the
LoadAllAttributes calls are gone from both servers). The SQL loaders stay until
task 2.11.
Value changes (decisions: JSON, D2):
- name: Confesser -> Confessor, Theif -> Thief, LagMaster -> Lagmaster,
WP Dev -> Wolfpack Developer, Exception X -> Exceptional X (Strength,
Dexterity, Constitution, Intelligence, Spirit). No code matches these names.
- description: '' / CSR text -> rune_dsc (unread)
- attributes added where the DB had none:
- admin 2905 Lagmaster spi +200, spi max +200; 2907 Watcher con +200;
2909 Feature Character every max +200; 2911 QA Test Rune con +200
(applies to characters granted them; none hold them on dev)
- creation cost 5/12/10/10/10 on 250116, 250117, 250123-250125 (duplicate
talents not offered at creation)
- base classes 2500-2503, Pet 2522, guards 252621-252623: start/max
attributes (never player CharacterRunes; NPC rune attributes are unread)
All 365 DB attribute rows match the JSON; final parity before the switch
(scripts/p24.py): 0 other differences. The static_rune_runebase comparator is
removed; it would only compare the JSON with itself now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.1 KiB
Java
85 lines
3.1 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
// https://www.magicbane.com
|
|
|
|
package engine.parsers.cache;
|
|
|
|
import engine.gameManager.ConfigManager;
|
|
import org.pmw.tinylog.Logger;
|
|
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Objects;
|
|
import java.util.function.Consumer;
|
|
|
|
// Dev-only check that compares DB-built objects with the cache JSON before a loader is switched.
|
|
// Enabled by the optional env var MB_PARITY_CHECK; not in the ConfigManager enum, which requires every entry.
|
|
|
|
public class ParityCheck {
|
|
|
|
private static final String FLAG_NAME = "MB_PARITY_CHECK";
|
|
private static final LinkedHashMap<String, Consumer<ParityCheck>> comparators = new LinkedHashMap<>();
|
|
|
|
private final String table;
|
|
private int comparedCount = 0;
|
|
private int differenceCount = 0;
|
|
private int missingCount = 0;
|
|
|
|
private ParityCheck(String table) {
|
|
this.table = table;
|
|
}
|
|
|
|
public static boolean isEnabled() {
|
|
return ConfigManager.configMap.getOrDefault(FLAG_NAME, "false").equalsIgnoreCase("true");
|
|
}
|
|
|
|
public static void register(String table, Consumer<ParityCheck> comparator) {
|
|
comparators.put(table, comparator);
|
|
}
|
|
|
|
public static void run() {
|
|
|
|
ParityCheck check;
|
|
|
|
for (String table : comparators.keySet()) {
|
|
check = new ParityCheck(table);
|
|
|
|
try {
|
|
comparators.get(table).accept(check);
|
|
} catch (Exception e) {
|
|
Logger.error("Parity: " + table + ": comparator failed: " + e);
|
|
}
|
|
|
|
Logger.info("Parity: " + table + ": " + check.comparedCount + " compared, "
|
|
+ check.differenceCount + " differences, " + check.missingCount + " missing in json");
|
|
}
|
|
}
|
|
|
|
// Returns false when the row has no JSON counterpart, so the comparator can skip its fields.
|
|
|
|
public boolean compareRow(int id, Object jsonObject) {
|
|
|
|
comparedCount++;
|
|
|
|
if (jsonObject == null) {
|
|
missingCount++;
|
|
Logger.warn("Parity: " + table + "/" + id + ": missing in json");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public void compareField(int id, String field, Object dbValue, Object jsonValue) {
|
|
|
|
if (Objects.equals(dbValue, jsonValue))
|
|
return;
|
|
|
|
differenceCount++;
|
|
Logger.warn("Parity: " + table + "/" + id + "/" + field + ": db=" + dbValue + " json=" + jsonValue);
|
|
}
|
|
}
|