Hash negative zone IDs for warehouse records without failing

Hasher.encode indexes arrays with the number, so a negative static zone
ID (World Boot Plan 2.4) throws. encryptObjectID hashes a negative ID as
the pair (0, -id), which no single positive ID can produce; positive IDs
hash as before. Static zones and PvP records use it; mine records read
the zone's stored hash.

Value changes: none until static zones take negative IDs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-27 23:31:24 -04:00
1 parent 3fbf07c2cb
commit 2f64fd43a3
3 files changed
+12 -2

No files matched your search

+1 -1
View File
@@ -280,7 +280,7 @@ public class PvpRecord extends DataRecord {
outStatement.setString(7, DataWarehouse.hasher.encrypt(victimGuild.getNation().getObjectUUID()));
outStatement.setInt(8, this.victim.getLevel());
outStatement.setString(9, DataWarehouse.hasher.encrypt(zone.getObjectUUID()));
outStatement.setString(9, DataWarehouse.hasher.encryptObjectID(zone.getObjectUUID()));
outStatement.setString(10, zone.zoneName);
outStatement.setFloat(11, this.location.getX());
outStatement.setFloat(12, -this.location.getZ()); // flip sign on 'y' coordinate
+1 -1
View File
@@ -135,7 +135,7 @@ public class Zone extends AbstractWorldObject {
zone.max_level = MACRO_ZONE_MAX_LEVEL;
}
zone.hash = DataWarehouse.hasher.encrypt(zone.getObjectUUID());
zone.hash = DataWarehouse.hasher.encryptObjectID(zone.getObjectUUID());
return zone;
}
+10
View File
@@ -245,6 +245,16 @@ public class Hasher {
return encode(numbers, alphabet_, salt_, minHashLength_);
}
// encode() fails on negative numbers, and static world objects have negative IDs. A static ID hashes as
// the pair (0, -id), which no single positive ID can produce.
public String encryptObjectID(long objectID) {
if (objectID < 0)
return encrypt(0, -objectID);
return encrypt(objectID);
}
public long[] decrypt(String hash) {
return decode(hash);
}