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
@@ -32,6 +32,9 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
|
||||
Mob mobile = null;
|
||||
|
||||
if (DbManager.refuseStaticWrite(toAdd))
|
||||
return null;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
||||
|
||||
@@ -84,6 +87,9 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
|
||||
public boolean updateUpgradeTime(Mob mob, DateTime upgradeDateTime) {
|
||||
|
||||
if (DbManager.refuseStaticWrite(mob))
|
||||
return false;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_mob SET upgradeDate=? "
|
||||
+ "WHERE UID = ?")) {
|
||||
@@ -106,6 +112,10 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
public int DELETE_MOB(final Mob mob) {
|
||||
|
||||
int row_count = 0;
|
||||
|
||||
if (DbManager.refuseStaticWrite(mob))
|
||||
return 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ?")) {
|
||||
|
||||
@@ -146,6 +156,9 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
|
||||
public boolean ADD_GUARD_MINION(final long captainUID, final String minionName) {
|
||||
|
||||
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Mob, captainUID))
|
||||
return false;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guards` (`captainUID`, `minionName`) VALUES (?,?)")) {
|
||||
|
||||
@@ -162,6 +175,9 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
|
||||
public boolean REMOVE_GUARD_MINION(final long captainUID, final String minionName) {
|
||||
|
||||
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Mob, captainUID))
|
||||
return false;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=? AND `minionName`=? LIMIT 1;")) {
|
||||
|
||||
@@ -178,6 +194,9 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
|
||||
public boolean REMOVE_ALL_MINIONS(final long captainUID) {
|
||||
|
||||
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Mob, captainUID))
|
||||
return false;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guards` WHERE `captainUID`=?;")) {
|
||||
|
||||
@@ -212,6 +231,9 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
|
||||
int row_count = 0;
|
||||
|
||||
if (DbManager.refuseStaticWrite(mbEnums.GameObjectType.Mob, mobID))
|
||||
return 0;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `object` INNER JOIN `obj_mob` On `object`.`UID` = `obj_mob`.`UID` SET `object`.`parent`=?, `obj_mob`.`mob_spawnX`=?, `obj_mob`.`mob_spawnY`=?, `obj_mob`.`mob_spawnZ`=? WHERE `obj_mob`.`UID`=?;")) {
|
||||
|
||||
@@ -234,6 +256,9 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
|
||||
String result = "";
|
||||
|
||||
if (DbManager.refuseStaticWrite(m))
|
||||
return result;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL mob_SETPROP(?,?,?)")) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user