Browse Source

Raised visibility of collection

bugfix-slot-update-2
MagicBot 9 months ago
parent
commit
fea1c2f06a
  1. 6
      src/engine/devcmd/cmds/InfoCmd.java
  2. 4
      src/engine/devcmd/cmds/PurgeObjectsCmd.java
  3. 11
      src/engine/devcmd/cmds/RemoveObjectCmd.java
  4. 6
      src/engine/devcmd/cmds/SlotTestCmd.java
  5. 24
      src/engine/gameManager/BuildingManager.java
  6. 5
      src/engine/gameManager/NPCManager.java
  7. 2
      src/engine/net/client/handlers/ActivateNPCMsgHandler.java
  8. 10
      src/engine/net/client/handlers/OrderNPCMsgHandler.java
  9. 10
      src/engine/net/client/msg/ManageCityAssetsMsg.java
  10. 8
      src/engine/objects/Building.java
  11. 2
      src/engine/objects/City.java
  12. 7
      src/engine/objects/Mine.java
  13. 2
      src/engine/objects/NPC.java

6
src/engine/devcmd/cmds/InfoCmd.java

@ -220,16 +220,16 @@ public class InfoCmd extends AbstractDevCmd {
// List hirelings // List hirelings
if (targetBuilding.getHirelings().isEmpty() == false) { if (targetBuilding.hirelings.isEmpty() == false) {
output += newline; output += newline;
output += "Hirelings List: name / slot / floor"; output += "Hirelings List: name / slot / floor";
for (AbstractCharacter npc : targetBuilding.getHirelings().keySet()) { for (AbstractCharacter npc : targetBuilding.hirelings.keySet()) {
if (npc.getObjectType() != GameObjectType.NPC) if (npc.getObjectType() != GameObjectType.NPC)
continue; continue;
output += newline + npc.getName() + " slot " + targetBuilding.getHirelings().get(npc); output += newline + npc.getName() + " slot " + targetBuilding.hirelings.get(npc);
output += newline + "location " + npc.getLoc(); output += newline + "location " + npc.getLoc();
} }
} }

4
src/engine/devcmd/cmds/PurgeObjectsCmd.java

@ -48,7 +48,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
for (Building building : zone.zoneBuildingSet) { for (Building building : zone.zoneBuildingSet) {
if (!BuildingManager.IsWallPiece(building)) if (!BuildingManager.IsWallPiece(building))
continue; continue;
for (AbstractCharacter ac : building.getHirelings().keySet()) { for (AbstractCharacter ac : building.hirelings.keySet()) {
NPC npc = null; NPC npc = null;
Mob mobA = null; Mob mobA = null;
@ -143,7 +143,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)) if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false); building.disableSpire(false);
for (AbstractCharacter ac : building.getHirelings().keySet()) { for (AbstractCharacter ac : building.hirelings.keySet()) {
NPC npc = null; NPC npc = null;
Mob mobA = null; Mob mobA = null;

11
src/engine/devcmd/cmds/RemoveObjectCmd.java

@ -13,7 +13,10 @@ import engine.Enum.BuildingGroup;
import engine.Enum.DbObjectType; import engine.Enum.DbObjectType;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.*; import engine.gameManager.BuildingManager;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.*; import engine.objects.*;
@ -141,7 +144,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
// Remove hirelings for this building // Remove hirelings for this building
for (AbstractCharacter abstractCharacter : building.getHirelings().keySet()) for (AbstractCharacter abstractCharacter : building.hirelings.keySet())
BuildingManager.removeHireling(building, abstractCharacter); BuildingManager.removeHireling(building, abstractCharacter);
Zone zone = building.getParentZone(); Zone zone = building.getParentZone();
@ -170,7 +173,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
// Remove npc from hirelings list. // Remove npc from hirelings list.
if (npc.building != null) if (npc.building != null)
npc.building.getHirelings().remove(npc); npc.building.hirelings.remove(npc);
for (Integer minionUUID : npc.minions) { for (Integer minionUUID : npc.minions) {
Mob minionMob = Mob.getMob(minionUUID); Mob minionMob = Mob.getMob(minionUUID);
@ -207,7 +210,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
// Remove npc from hirelings list. // Remove npc from hirelings list.
if (mob.building != null) if (mob.building != null)
mob.building.getHirelings().remove(mob); mob.building.hirelings.remove(mob);
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane.. mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc.. mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..

6
src/engine/devcmd/cmds/SlotTestCmd.java

@ -65,13 +65,13 @@ public class SlotTestCmd extends AbstractDevCmd {
outString += "\r\nNext Available Slot: " + BuildingManager.getAvailableSlot(building); outString += "\r\nNext Available Slot: " + BuildingManager.getAvailableSlot(building);
if (building.getHirelings().isEmpty() == false) { if (building.hirelings.isEmpty() == false) {
outString += "\r\n\r\n"; outString += "\r\n\r\n";
outString += "Hirelings List:"; outString += "Hirelings List:";
for (AbstractCharacter hireling : building.getHirelings().keySet()) for (AbstractCharacter hireling : building.hirelings.keySet())
outString += "\r\n" + hireling.getName() + " slot : " + building.getHirelings().get(hireling); outString += "\r\n" + hireling.getName() + " slot : " + building.hirelings.get(hireling);
} }

24
src/engine/gameManager/BuildingManager.java

@ -58,7 +58,7 @@ public enum BuildingManager {
for (int i = 1; i <= numOfSlots; i++) { for (int i = 1; i <= numOfSlots; i++) {
if (!building.getHirelings().containsValue(i)) if (!building.hirelings.containsValue(i))
return i; return i;
} }
return -1; return -1;
@ -78,7 +78,7 @@ public enum BuildingManager {
for (int i = numOfSlots; i > 0; i--) { for (int i = numOfSlots; i > 0; i--) {
if (!building.getHirelings().containsValue(i)) if (!building.hirelings.containsValue(i))
return i; return i;
} }
return -1; return -1;
@ -291,7 +291,7 @@ public enum BuildingManager {
// Method transfers ownership of all hirelings in a building // Method transfers ownership of all hirelings in a building
public static void refreshHirelings(Building building) { public static void updateHirelingGuilds(Building building) {
if (building == null) if (building == null)
return; return;
@ -303,7 +303,7 @@ public enum BuildingManager {
else else
newGuild = building.getOwner().getGuild(); newGuild = building.getOwner().getGuild();
for (AbstractCharacter hireling : building.getHirelings().keySet()) { for (AbstractCharacter hireling : building.hirelings.keySet()) {
hireling.setGuild(newGuild); hireling.setGuild(newGuild);
WorldGrid.updateObject(hireling); WorldGrid.updateObject(hireling);
} }
@ -336,7 +336,7 @@ public enum BuildingManager {
// Remove hireling from building // Remove hireling from building
building.getHirelings().remove(hireling); building.hirelings.remove(hireling);
// Remove from zone mob set // Remove from zone mob set
@ -388,7 +388,7 @@ public enum BuildingManager {
if (building.getRank() < 1) { if (building.getRank() < 1) {
for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) for (AbstractCharacter slottedNPC : building.hirelings.keySet())
BuildingManager.removeHireling(building, slottedNPC); BuildingManager.removeHireling(building, slottedNPC);
return; return;
@ -396,14 +396,14 @@ public enum BuildingManager {
// Delete hireling if building has deranked. // Delete hireling if building has deranked.
for (AbstractCharacter hireling : building.getHirelings().keySet()) { for (AbstractCharacter hireling : building.hirelings.keySet()) {
if (building.getHirelings().get(hireling) > building.getBlueprint().getSlotsForRank(building.getRank())) if (building.hirelings.get(hireling) > building.getBlueprint().getSlotsForRank(building.getRank()))
BuildingManager.removeHireling(building, hireling); BuildingManager.removeHireling(building, hireling);
} }
refreshHirelings(building); updateHirelingGuilds(building);
} }
public static Building getBuilding(int id) { public static Building getBuilding(int id) {
@ -564,7 +564,7 @@ public enum BuildingManager {
if (building.getBlueprintUUID() == 0) if (building.getBlueprintUUID() == 0)
return false; return false;
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) if (building.getBlueprint().getMaxSlots() == building.hirelings.size())
return false; return false;
String pirateName = NPCManager.getPirateName(contract.getMobbaseID()); String pirateName = NPCManager.getPirateName(contract.getMobbaseID());
@ -804,7 +804,7 @@ public enum BuildingManager {
} }
if (!building.getHirelings().containsKey(npc)) if (!building.hirelings.containsKey(npc))
return; return;
if (!npc.remove()) { if (!npc.remove()) {
@ -812,7 +812,7 @@ public enum BuildingManager {
return; return;
} }
building.getHirelings().remove(npc); building.hirelings.remove(npc);
itemBase = ItemBase.getItemBase(contract.getContractID()); itemBase = ItemBase.getItemBase(contract.getContractID());

5
src/engine/gameManager/NPCManager.java

@ -5,17 +5,14 @@ import engine.InterestManagement.WorldGrid;
import engine.math.Quaternion; import engine.math.Quaternion;
import engine.math.Vector3f; import engine.math.Vector3f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.mobileAI.MobAI;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.msg.PetMsg; import engine.net.client.msg.PetMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import engine.powers.PowersBase;
import engine.powers.RuneSkillAdjustEntry; import engine.powers.RuneSkillAdjustEntry;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import javax.smartcardio.ATR;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -200,7 +197,7 @@ public enum NPCManager {
// Pets are regular mobiles not hirelings (Siege engines) // Pets are regular mobiles not hirelings (Siege engines)
if (abstractCharacter.contract != null) if (abstractCharacter.contract != null)
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); abstractCharacter.building.hirelings.put(abstractCharacter, buildingSlot);
// Override bind and location for this npc derived // Override bind and location for this npc derived
// from BuildingManager slot location data. // from BuildingManager slot location data.

2
src/engine/net/client/handlers/ActivateNPCMsgHandler.java

@ -78,7 +78,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
return false; return false;
} }
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) if (building.getBlueprint().getMaxSlots() == building.hirelings.size())
return false; return false;
Item contractItem = Item.getFromCache(msg.getContractItem()); Item contractItem = Item.getFromCache(msg.getContractItem());

10
src/engine/net/client/handlers/OrderNPCMsgHandler.java

@ -54,7 +54,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
return; return;
} }
if (!building.getHirelings().containsKey(hireling)) if (!building.hirelings.containsKey(hireling))
return; return;
BuildingManager.removeHireling(building, hireling); BuildingManager.removeHireling(building, hireling);
@ -402,7 +402,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (building == null) if (building == null)
return true; return true;
if (building.getHirelings().containsKey(npc) == false) if (building.hirelings.containsKey(npc) == false)
return true; return true;
@ -421,7 +421,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false) if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false)
return true; return true;
if (building.getHirelings().containsKey(npc) == false) if (building.hirelings.containsKey(npc) == false)
return true; return true;
if (npc.remove() == false) { if (npc.remove() == false) {
@ -515,7 +515,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (building == null) if (building == null)
return true; return true;
if (!building.getHirelings().containsKey(mob)) if (!building.hirelings.containsKey(mob))
return true; return true;
if (player.getCharItemManager().getTradingWith() != null) { if (player.getCharItemManager().getTradingWith() != null) {
@ -531,7 +531,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (BuildingManager.playerCanManage(player, building) == false) if (BuildingManager.playerCanManage(player, building) == false)
return true; return true;
if (building.getHirelings().containsKey(mob) == false) if (building.hirelings.containsKey(mob) == false)
return true; return true;
BuildingManager.removeHireling(building, mob); BuildingManager.removeHireling(building, mob);

10
src/engine/net/client/msg/ManageCityAssetsMsg.java

@ -229,8 +229,8 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
writer.putInt(asset.getObjectUUID()); writer.putInt(asset.getObjectUUID());
writer.putInt(0); writer.putInt(0);
writer.putInt(0); writer.putInt(0);
writer.putInt(asset.getHirelings().size()); writer.putInt(asset.hirelings.size());
for (AbstractCharacter hireling : asset.getHirelings().keySet()) { for (AbstractCharacter hireling : asset.hirelings.keySet()) {
if (!hireling.getObjectType().equals(GameObjectType.NPC)) if (!hireling.getObjectType().equals(GameObjectType.NPC))
writer.putString(hireling.getName()); writer.putString(hireling.getName());
else { else {
@ -262,9 +262,9 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
for (int a = 0; a < 5; a++) for (int a = 0; a < 5; a++)
writer.putInt(0); writer.putInt(0);
writer.putInt(asset.getHirelings().size()); writer.putInt(asset.hirelings.size());
for (AbstractCharacter npcHire : asset.getHirelings().keySet()) { for (AbstractCharacter npcHire : asset.hirelings.keySet()) {
writer.putInt(npcHire.getObjectType().ordinal()); writer.putInt(npcHire.getObjectType().ordinal());
writer.putInt(npcHire.getObjectUUID()); writer.putInt(npcHire.getObjectUUID());
if (npcHire.getObjectType() == GameObjectType.NPC) if (npcHire.getObjectType() == GameObjectType.NPC)
@ -669,7 +669,7 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
} }
ConcurrentHashMap<AbstractCharacter, Integer> npcList = building.getHirelings(); ConcurrentHashMap<AbstractCharacter, Integer> npcList = building.hirelings;
writer.putInt(npcList.size()); writer.putInt(npcList.size());
if (npcList.size() > 0) { if (npcList.size() > 0) {
for (AbstractCharacter npcHire : npcList.keySet()) { for (AbstractCharacter npcHire : npcList.keySet()) {

8
src/engine/objects/Building.java

@ -51,7 +51,7 @@ public class Building extends AbstractWorldObject {
// Used for thread safety // Used for thread safety
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
private final ConcurrentHashMap<AbstractCharacter, Integer> hirelings = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public final ConcurrentHashMap<AbstractCharacter, Integer> hirelings = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private final HashMap<Integer, DoorCloseJob> doorJobs = new HashMap<>(); private final HashMap<Integer, DoorCloseJob> doorJobs = new HashMap<>();
public int meshUUID; public int meshUUID;
public Zone parentZone; public Zone parentZone;
@ -1031,7 +1031,7 @@ public class Building extends AbstractWorldObject {
// Set new guild for hirelings and refresh all clients // Set new guild for hirelings and refresh all clients
this.refreshGuild(); this.refreshGuild();
BuildingManager.refreshHirelings(this); BuildingManager.updateHirelingGuilds(this);
} catch (Exception e) { } catch (Exception e) {
Logger.error("Error updating owner! UUID: " + this.getObjectUUID()); Logger.error("Error updating owner! UUID: " + this.getObjectUUID());
@ -1213,10 +1213,6 @@ public class Building extends AbstractWorldObject {
this.updateEffects(); this.updateEffects();
} }
public ConcurrentHashMap<AbstractCharacter, Integer> getHirelings() {
return hirelings;
}
public final boolean isSpireIsActive() { public final boolean isSpireIsActive() {
return spireIsActive; return spireIsActive;
} }

2
src/engine/objects/City.java

@ -656,7 +656,7 @@ public class City extends AbstractWorldObject {
if (this.getTOL() == null) if (this.getTOL() == null)
return outNPC; return outNPC;
for (AbstractCharacter npc : getTOL().getHirelings().keySet()) { for (AbstractCharacter npc : getTOL().hirelings.keySet()) {
if (npc.getObjectType() == GameObjectType.NPC) if (npc.getObjectType() == GameObjectType.NPC)
if (((NPC) npc).getContract().isRuneMaster() == true) if (((NPC) npc).getContract().isRuneMaster() == true)
outNPC = (NPC) npc; outNPC = (NPC) npc;

7
src/engine/objects/Mine.java

@ -11,7 +11,10 @@ package engine.objects;
import engine.Enum; import engine.Enum;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.gameManager.*; import engine.gameManager.BuildingManager;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager;
import engine.net.ByteBufferWriter; import engine.net.ByteBufferWriter;
import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.ErrorPopupMsg;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
@ -547,7 +550,7 @@ public class Mine extends AbstractGameObject {
Building mineBuilding = BuildingManager.getBuilding(this.buildingID); Building mineBuilding = BuildingManager.getBuilding(this.buildingID);
if (mineBuilding == null) if (mineBuilding == null)
return this.production.baseProduction; return this.production.baseProduction;
for (AbstractCharacter harvester : mineBuilding.getHirelings().keySet()) { for (AbstractCharacter harvester : mineBuilding.hirelings.keySet()) {
totalModded += baseModValue; totalModded += baseModValue;
totalModded += rankModValue * harvester.getRank(); totalModded += rankModValue * harvester.getRank();
} }

2
src/engine/objects/NPC.java

@ -1119,7 +1119,7 @@ public class NPC extends AbstractCharacter {
building = this.building; building = this.building;
if (building != null) { if (building != null) {
building.getHirelings().remove(this); building.hirelings.remove(this);
this.removeMinions(); this.removeMinions();
} }

Loading…
Cancel
Save