Add the static world ID counter and static flag
Static world objects take IDs from DbManager.nextStaticID(), counting down from -2 in a fixed load order (W2). Runtime negative IDs (loot, forged and contract items, pets and minions) now share ItemManager.lastNegativeID, which starts at -1,000,000; Mob.staticID is gone. Boot fails if the static counter reaches the runtime range. AbstractWorldObject gets a staticWorldObject flag for the factories to set. Nothing uses either yet. Value changes: runtime negative IDs start at -1,000,001 (-1,000,000 for forged items) instead of -1; pets and minions draw from the item counter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
740719aeb2
commit
c89bda35da
4 files changed
+31
-5
No files matched your search
@@ -23,10 +23,15 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.EnumMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public enum DbManager {
|
||||
DBMANAGER;
|
||||
|
||||
// Static world IDs count down from -2 (-1 means "not found"); runtime negative IDs start below them.
|
||||
public static final int RUNTIME_ID_START = -1_000_000;
|
||||
private static final AtomicInteger lastStaticID = new AtomicInteger(-1);
|
||||
|
||||
public static final dbAccountHandler AccountQueries = new dbAccountHandler();
|
||||
public static final dbBaneHandler BaneQueries = new dbBaneHandler();
|
||||
|
||||
@@ -70,6 +75,17 @@ public enum DbManager {
|
||||
public static Hasher hasher;
|
||||
private static HikariDataSource connectionPool = null;
|
||||
|
||||
// Only the static world factories may call this, in the fixed load order (W2); never renumber.
|
||||
public static int nextStaticID() {
|
||||
|
||||
int staticID = lastStaticID.decrementAndGet();
|
||||
|
||||
if (staticID <= RUNTIME_ID_START)
|
||||
throw new IllegalStateException("Static world ID " + staticID + " reached the runtime ID range at " + RUNTIME_ID_START);
|
||||
|
||||
return staticID;
|
||||
}
|
||||
|
||||
public static AbstractGameObject getObject(GameObjectType objectType, int objectUUID) {
|
||||
|
||||
AbstractGameObject outObject = null;
|
||||
|
||||
Reference in new issue
Block a user