diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 333c26fa..415f9c29 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -104,67 +104,67 @@ public enum BuildingManager { if (building == null) return false; + //cannot access destroyed buildings if (building.getRank() == -1) return false; - if (IsOwner(building, player)) - return true; - - //individual friend. - - if (building.getFriends() != null && building.getFriends().get(player.getObjectUUID()) != null) - return true; - - //Admins can access stuff - + //admin characters can always access buildings if (player.isCSR()) return true; - //Guild stuff - - if (building.getGuild().isGuildLeader(player.getObjectUUID())) - return true; - - if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8) - return true; - - if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9 && GuildStatusController.isInnerCouncil(player.getGuildStatus())) - return true; - - if (Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isInnerCouncil(player.getGuildStatus())) + //owner can always access their own building + if (IsOwner(building, player)) return true; - return Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isGuildLeader(player.getGuildStatus()); - - //TODO test friends list once added - //does not meet above criteria. Cannot access. - } - - public static boolean playerCanManageNotFriends(PlayerCharacter player, Building building) { - - //Player Can only Control Building if player is in Same Guild as Building and is higher rank than IC. - - if (player == null) - return false; - - if (building == null) - return false; - - if (building.getRank() == -1) - return false; + //check for default IC access if building belongs to same guild + if(player.guild.equals(building.getGuild())) { + if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() != null) { + switch (building.getBlueprint().getBuildingGroup()) { + case TOL: + case BARRACK: + case SPIRE: + case SHRINE: + case BANESTONE: + case MINE: + case WAREHOUSE: + case BULWARK: + case SIEGETENT: + if (GuildStatusController.isInnerCouncil(player.getGuildStatus())) + return true; + if (GuildStatusController.isGuildLeader(player.getGuildStatus())) + return true; + break; + } + } + } - if (IsOwner(building, player)) - return true; + //check against friends list entries if any present + if (building.getFriends() != null) { - //Somehow guild leader check fails? lets check if Player is true Guild GL. - if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID())) - return true; + //check individuals + if (building.getFriends().get(player.getObjectUUID()) != null) + return true; - if (!GuildStatusController.isGuildLeader(player.getGuildStatus()) && !GuildStatusController.isInnerCouncil(player.getGuildStatus())) - return false; + if (building.getFriends().get(player.guild.objectUUID) != null) { + + //check friend type for guild related access + switch (building.getFriends().get(player.guild.objectUUID).friendType) { + case 8: //full member + if (GuildStatusController.isFullMember(player.getGuildStatus())) + return true; + break; + case 9: //Inner Council + if (GuildStatusController.isInnerCouncil(player.getGuildStatus())) + return true; + if (GuildStatusController.isGuildLeader(player.getGuildStatus())) + return true; + break; + } + } + } + //did not meet access grant criteria, deny access return false; - } public static synchronized boolean lootBuilding(PlayerCharacter player, Building building) { diff --git a/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java b/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java index b3dfebe7..0fbe85cf 100644 --- a/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java +++ b/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java @@ -102,7 +102,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler { if (building.getGuild().isEmptyGuild()) return true; - if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building)) + if (!BuildingManager.playerCanManage(sourcePlayer, building)) return true; @@ -159,7 +159,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler { (building == null) || playerZone == null || playerCity == null) return true; - if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building)) + if (!BuildingManager.playerCanManage(sourcePlayer, building)) return true; boolean open = (msg.getMessageType() == OPEN_CITY); diff --git a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java index ec3782d3..1b4f8200 100644 --- a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java +++ b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java @@ -28,30 +28,6 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { super(); } - public static boolean playerCanManageNotFriends(PlayerCharacter player, Building building) { - - //Player Can only Control Building if player is in Same Guild as Building and is higher rank than IC. - - if (player == null) - return false; - - if (building.getRank() == -1) - return false; - - if (BuildingManager.IsOwner(building, player)) - return true; - - if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false) - return false; - - //Somehow guild leader check fails above? lets check if Player is true Guild GL. - if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID())) - return true; - - return Guild.sameGuild(building.getGuild(), player.getGuild()); - - } - @Override protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) { diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index b03c28f7..887bcea8 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -183,7 +183,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (building == null) return; - if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false) + if (BuildingManager.playerCanManage(player, building) == false) return; if (orderNpcMsg.getPatrolSize() >= 20) @@ -411,7 +411,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { case 2: player = SessionManager.getPlayerCharacter(origin); - if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false) + if (BuildingManager.playerCanManage(player, building) == false) return true; if (building.getHirelings().containsKey(npc) == false) diff --git a/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java b/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java index c5c0c72a..f5a6120c 100644 --- a/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java +++ b/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java @@ -53,7 +53,7 @@ public class TransferGoldToFromBuildingMsgHandler extends AbstractClientMsgHandl if (msg.getDirection() == 2) { - if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building)) + if (!BuildingManager.playerCanManage(player, building)) return true; if (building.setReserve(msg.getUnknown01(), player)) { dispatch = Dispatch.borrow(player, msg); diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index d218eb64..9ffbcf28 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -1447,7 +1447,7 @@ public class Building extends AbstractWorldObject { public synchronized boolean setReserve(int amount, PlayerCharacter player) { - if (!BuildingManager.playerCanManageNotFriends(player, this)) + if (!BuildingManager.playerCanManage(player, this)) return false; if (amount < 0)