Bridge legacy ItemTemplate to its cache template

Each engine.objects.ItemTemplate gets a cacheTemplate field, filled by
linkCacheTemplates() right after CObjectIndex.build() on both servers,
so consumers can move to CObjectTemplate one field at a time.

ParityCheck gains a static_item_templates comparator: a null bridge is
reported as missing in json, and obj_name and item_type are compared
through the interface to catch a wrong folder pick.

Import convention until the legacy class is removed (Task 1.8): the
legacy engine.objects.ItemTemplate keeps the plain import; the cache
class is always written engine.parsers.objects.ItemTemplate. Migrated
consumers should depend on CObjectTemplate instead.

JSON-Refactor-Plan Task 1.1. No consumers change; no values change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-19 11:21:47 -04:00
1 parent 4765e7993f
commit 765cb9edb6
4 files changed
+44

No files matched your search

+16
View File
@@ -13,6 +13,7 @@ import engine.gameManager.DbManager;
import engine.mbEnums;
import engine.objects.AbstractGameObject;
import engine.objects.BaseClass;
import engine.objects.ItemTemplate;
import engine.parsers.objects.RuneTemplate;
import org.pmw.tinylog.Logger;
@@ -36,6 +37,7 @@ public class ParityCheck {
static {
register("static_rune_baseclass", ParityCheck::compareBaseClasses);
register("static_item_templates", ParityCheck::compareItemTemplates);
}
private ParityCheck(String table) {
@@ -115,4 +117,18 @@ public class ParityCheck {
check.compareField(baseClass.getObjectUUID(), "name", baseClass.getName(), rune.obj_name);
}
}
// A wrong item_type means the bridge picked the wrong folder for an id found in more than one.
private static void compareItemTemplates(ParityCheck check) {
for (ItemTemplate template : ItemTemplate.templates.values()) {
if (!check.compareRow(template.template_id, template.cacheTemplate))
continue;
check.compareField(template.template_id, "obj_name", template.obj_name, template.cacheTemplate.getObjName());
check.compareField(template.template_id, "item_type", template.item_type, template.cacheTemplate.getItemType());
}
}
}