Compare commits

..

2 Commits

Author SHA1 Message Date
MagicBot c02564d7af state updated properly 2026-05-07 15:38:21 -04:00
MagicBot 945f85443d db call added 2026-05-07 15:20:24 -04:00
4 changed files with 36 additions and 47 deletions
+1 -5
View File
@@ -243,12 +243,8 @@ public class dbNPCHandler extends dbHandlerBase {
public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) { public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) {
// Column name must match what NPC/Mob loaders read ("equipmentSet").
// Using the wrong column here causes the update to fail silently and
// dev command to report "Unable to find Equipset" despite a valid ID.
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipmentSet`=? WHERE `UID`=?")) { PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipsetID`=? WHERE `UID`=?")) {
preparedStatement.setInt(1, equipSetID); preparedStatement.setInt(1, equipSetID);
preparedStatement.setLong(2, npc.getObjectUUID()); preparedStatement.setLong(2, npc.getObjectUUID());
@@ -15,6 +15,7 @@ import engine.Enum.GuildState;
import engine.exception.MsgSendException; import engine.exception.MsgSendException;
import engine.gameManager.ChatManager; import engine.gameManager.ChatManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.GuildManager;
import engine.gameManager.SessionManager; import engine.gameManager.SessionManager;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
@@ -26,8 +27,6 @@ import engine.objects.Guild;
import engine.objects.GuildStatusController; import engine.objects.GuildStatusController;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import java.util.ArrayList;
public class AcceptSubInviteHandler extends AbstractClientMsgHandler { public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
public AcceptSubInviteHandler() { public AcceptSubInviteHandler() {
@@ -38,69 +37,74 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg; AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
PlayerCharacter sourcePlayer; PlayerCharacter playerCharacter;
Guild sourceGuild; Guild protectorate;
Guild targetGuild; Guild nation;
Dispatch dispatch; Dispatch dispatch;
// get PlayerCharacter of person sending sub invite // get PlayerCharacter of person sending sub invite
sourcePlayer = SessionManager.getPlayerCharacter(origin); playerCharacter = SessionManager.getPlayerCharacter(origin);
if (sourcePlayer == null) if (playerCharacter == null)
return true; return true;
sourceGuild = sourcePlayer.getGuild(); protectorate = playerCharacter.getGuild();
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID()); nation = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
//must be source guild to sub to //must be source guild to sub to
if (targetGuild == null) { if (nation == null) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
return true; return true;
} }
if (sourceGuild == null) { if (protectorate == null) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
return true; return true;
} }
if (sourceGuild.equals(targetGuild)) if (protectorate.equals(nation))
return true; return true;
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) { if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus()) == false) {
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only a guild leader can accept fealty!"); ErrorPopupMsg.sendErrorMsg(playerCharacter, "Only a guild leader can accept fealty!");
return true; return true;
} }
//source guild is limited to 7 subs //source guild is limited to 7 subs
//TODO this should be based on TOL rank //TODO this should be based on TOL rank
if (!targetGuild.canSubAGuild(sourceGuild)) { if (!nation.canSubAGuild(protectorate)) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
return true; return true;
} }
//all tests passed, let's Handle code //all tests passed, let's Handle code
//Update Target Guild State.
sourceGuild.upgradeGuildState(false); // Update database
//Add sub so GuildMaster can Swear in. if (!DbManager.GuildQueries.UPDATE_PARENT(protectorate.getObjectUUID(), nation.getObjectUUID())) {
ErrorPopupMsg.sendErrorMsg(playerCharacter, "A Serious error has occured. Please post details for to ensure transaction integrity");
return true;
}
ArrayList<Guild> subs = targetGuild.getSubGuildList(); //update Guild states.
subs.add(sourceGuild);
targetGuild.setGuildState(GuildState.Nation); protectorate.setNation(nation);
GuildManager.updateAllGuildTags(protectorate);
protectorate.upgradeGuildState(false);
if (nation.getGuildState() == GuildState.Sovereign)
nation.upgradeGuildState(true);
//Let's send the message back. //Let's send the message back.
msg.setUnknown02(1); msg.setUnknown02(1);
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.'); msg.setResponse("Your guild is now a " + protectorate.getGuildState().name() + '.');
dispatch = Dispatch.borrow(sourcePlayer, msg); dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.'); ChatManager.chatSystemInfo(playerCharacter, "Your guild is now a " + protectorate.getGuildState().name() + '.');
return true; return true;
} }
} }
+1 -11
View File
@@ -541,18 +541,8 @@ public class Mob extends AbstractIntelligenceAgent {
mobWithoutID.parentZone = parent; mobWithoutID.parentZone = parent;
mobWithoutID.parentZoneID = parent.getObjectUUID(); mobWithoutID.parentZoneID = parent.getObjectUUID();
// Ensure spawn coordinates are persisted for DB insert
// statLat/statAlt/statLon represent local (zone-relative) spawn
// coordinates used by the DB handler when creating the mob row.
if (spawn != null && parent != null) {
// Convert world coordinates to zone-local spawn coordinates
Vector3fImmutable localSpawn = spawn.subtract(parent.getLoc());
mobWithoutID.statLat = localSpawn.x;
mobWithoutID.statAlt = localSpawn.y;
mobWithoutID.statLon = localSpawn.z;
}
// NPC in a Building derives position from slot // NPC in a Building derives position from slot
if (mobWithoutID.building != null) if (mobWithoutID.building != null)
mobWithoutID.bindLoc = Vector3fImmutable.ZERO; mobWithoutID.bindLoc = Vector3fImmutable.ZERO;
+1 -2
View File
@@ -470,8 +470,7 @@ public class NPC extends AbstractCharacter {
newNPC.bindLoc = Vector3fImmutable.ZERO; newNPC.bindLoc = Vector3fImmutable.ZERO;
newNPC.parentZoneUUID = parent.getObjectUUID(); newNPC.parentZoneUUID = parent.getObjectUUID();
// guild may be null when spawning via ./npc; default to 0 newNPC.guildUUID = guild.getObjectUUID();
newNPC.guildUUID = (guild != null) ? guild.getObjectUUID() : 0;
if (building == null) if (building == null)
newNPC.buildingUUID = 0; newNPC.buildingUUID = 0;