Refuse DB writes for static world objects
DbManager.refuseStaticWrite logs the handler method and its caller and stops the write (W3). It guards every write whose row belongs to a Building, Zone, City, Guild, Mob or NPC: 69 handler methods, including friends/condemned/patrol lists, guard minions, NPC profits and guild banish/alliance lists. ID-only methods look the object up in the cache. Writes that only reference a static object (character guild history, another guild's alliance row) are not guarded. Value changes: none; nothing is flagged static yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c89bda35da
commit
731425e85a
7 files changed
+240
No files matched your search
@@ -86,6 +86,38 @@ public enum DbManager {
|
||||
return staticID;
|
||||
}
|
||||
|
||||
// W3: static world objects never reach the DB. Logs the refused handler method and its caller.
|
||||
public static boolean refuseStaticWrite(AbstractWorldObject worldObject) {
|
||||
|
||||
StackTraceElement[] stack;
|
||||
String caller;
|
||||
int frame = 1;
|
||||
|
||||
if (worldObject == null || !worldObject.isStaticWorldObject())
|
||||
return false;
|
||||
|
||||
stack = new Throwable().getStackTrace();
|
||||
|
||||
while (frame < stack.length - 1 && stack[frame].getClassName().equals(DbManager.class.getName()))
|
||||
frame++;
|
||||
|
||||
caller = (frame + 1 < stack.length) ? stack[frame + 1].toString() : "unknown";
|
||||
|
||||
Logger.error("Refused DB write for static " + worldObject.getObjectType() + " " + worldObject.getObjectUUID()
|
||||
+ " in " + stack[frame] + " called from " + caller);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean refuseStaticWrite(GameObjectType objectType, long objectUUID) {
|
||||
|
||||
AbstractGameObject gameObject = getFromCache(objectType, (int) objectUUID);
|
||||
|
||||
if (gameObject instanceof AbstractWorldObject)
|
||||
return refuseStaticWrite((AbstractWorldObject) gameObject);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static AbstractGameObject getObject(GameObjectType objectType, int objectUUID) {
|
||||
|
||||
AbstractGameObject outObject = null;
|
||||
|
||||
Reference in new issue
Block a user