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:
1 parent
4765e7993f
commit
765cb9edb6
4 files changed
+44
No files matched your search
@@ -10,6 +10,7 @@ package engine.objects;
|
||||
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mbEnums;
|
||||
import engine.parsers.objects.CObjectTemplate;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -157,6 +158,9 @@ public class ItemTemplate {
|
||||
public final ArrayList<Integer> rune_helper_monster_types = new ArrayList<>();
|
||||
public int item_bane_rank;
|
||||
|
||||
// Cache JSON counterpart, so consumers can move to the new templates one field at a time.
|
||||
public CObjectTemplate cacheTemplate;
|
||||
|
||||
public ItemTemplate(JSONObject jsonObject) {
|
||||
|
||||
try {
|
||||
@@ -646,4 +650,22 @@ public class ItemTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
// Run after CObjectIndex.build(); the DB templates load before the cache parsers.
|
||||
|
||||
public static void linkCacheTemplates() {
|
||||
|
||||
int missingCount = 0;
|
||||
|
||||
for (ItemTemplate template : templates.values()) {
|
||||
template.cacheTemplate = CObjectTemplate.lookup(template.template_id);
|
||||
|
||||
if (template.cacheTemplate == null) {
|
||||
missingCount++;
|
||||
Logger.warn(template.template_id + ": " + template.obj_name + " has no cache template");
|
||||
}
|
||||
}
|
||||
|
||||
Logger.info("Linked " + (templates.size() - missingCount) + " of " + templates.size() + " item templates to cache templates");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user