Browse Source

Raised visibility of collection

bugfix-slot-update-2
MagicBot 11 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 { @@ -220,16 +220,16 @@ public class InfoCmd extends AbstractDevCmd {
// List hirelings
if (targetBuilding.getHirelings().isEmpty() == false) {
if (targetBuilding.hirelings.isEmpty() == false) {
output += newline;
output += "Hirelings List: name / slot / floor";
for (AbstractCharacter npc : targetBuilding.getHirelings().keySet()) {
for (AbstractCharacter npc : targetBuilding.hirelings.keySet()) {
if (npc.getObjectType() != GameObjectType.NPC)
continue;
output += newline + npc.getName() + " slot " + targetBuilding.getHirelings().get(npc);
output += newline + npc.getName() + " slot " + targetBuilding.hirelings.get(npc);
output += newline + "location " + npc.getLoc();
}
}

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

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

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

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

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

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

24
src/engine/gameManager/BuildingManager.java

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

5
src/engine/gameManager/NPCManager.java

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

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

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

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

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

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

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

8
src/engine/objects/Building.java

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

2
src/engine/objects/City.java

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

7
src/engine/objects/Mine.java

@ -11,7 +11,10 @@ package engine.objects; @@ -11,7 +11,10 @@ package engine.objects;
import engine.Enum;
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.client.msg.ErrorPopupMsg;
import engine.server.MBServerStatics;
@ -547,7 +550,7 @@ public class Mine extends AbstractGameObject { @@ -547,7 +550,7 @@ public class Mine extends AbstractGameObject {
Building mineBuilding = BuildingManager.getBuilding(this.buildingID);
if (mineBuilding == null)
return this.production.baseProduction;
for (AbstractCharacter harvester : mineBuilding.getHirelings().keySet()) {
for (AbstractCharacter harvester : mineBuilding.hirelings.keySet()) {
totalModded += baseModValue;
totalModded += rankModValue * harvester.getRank();
}

2
src/engine/objects/NPC.java

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

Loading…
Cancel
Save