BuildingModelBase no longer needed.
This commit is contained in:
@@ -474,7 +474,6 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += "BuildingID : " + targetMob.building + newline;
|
||||
output += "Bind Loc : " + targetMob.getBindLoc() + newline;
|
||||
output += "Curr Loc : " + targetMob.getLoc() + newline;
|
||||
output += "InBuildingLoc : " + targetMob.inBuildingLoc + newline;
|
||||
}else{
|
||||
output += newline;
|
||||
output += "No building found.";
|
||||
|
||||
@@ -42,6 +42,7 @@ import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@@ -1273,24 +1274,20 @@ public class Building extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public Vector3fImmutable getStuckLocation() {
|
||||
Vector3fImmutable stuckLocation;
|
||||
ArrayList<BuildingLocation> stuckLocations;
|
||||
|
||||
BuildingModelBase bmb = BuildingModelBase.getModelBase(this.meshUUID);
|
||||
Vector3fImmutable convertLoc = null;
|
||||
stuckLocations = BuildingManager._stuckLocations.get(this.meshUUID);
|
||||
|
||||
// Sanity check
|
||||
|
||||
if (bmb != null) {
|
||||
BuildingLocation bl = bmb.getStuckLocation();
|
||||
if (stuckLocations == null ||
|
||||
stuckLocations.isEmpty())
|
||||
return this.getLoc();
|
||||
|
||||
if (bl != null){
|
||||
stuckLocation = stuckLocations.get(ThreadLocalRandom.current().nextInt(stuckLocations.size())).getLoc();
|
||||
|
||||
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this, bl.getLoc());
|
||||
return buildingWorldLoc;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
return stuckLocation;
|
||||
}
|
||||
|
||||
public boolean isDoorOpen(int doorNumber) {
|
||||
|
||||
@@ -16,10 +16,7 @@ import engine.math.Vector3fImmutable;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
public class BuildingLocation extends AbstractGameObject {
|
||||
@@ -156,21 +153,4 @@ public class BuildingLocation extends AbstractGameObject {
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadAllLocations() {
|
||||
ArrayList<BuildingLocation> bls = DbManager.BuildingLocationQueries.LOAD_ALL_BUILDING_LOCATIONS();
|
||||
ConcurrentHashMap<Integer, BuildingModelBase> mbs = BuildingModelBase.getModelBases();
|
||||
for (BuildingLocation bl : bls) {
|
||||
int modelID = bl.buildingUUID;
|
||||
BuildingModelBase mb = null;
|
||||
if (!mbs.containsKey(modelID)) {
|
||||
mb = new BuildingModelBase(modelID);
|
||||
mbs.put(modelID, mb);
|
||||
} else
|
||||
mb = mbs.get(modelID);
|
||||
mb.addLocation(bl);
|
||||
|
||||
if (bl.type == 6)
|
||||
mb.addSlotLocation(bl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import engine.server.MBServerStatics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BuildingModelBase extends AbstractGameObject {
|
||||
|
||||
private ArrayList<BuildingLocation> locations = new ArrayList<>();
|
||||
private static ConcurrentHashMap<Integer, BuildingModelBase> modelBases = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
private final int buildingBaseID;
|
||||
|
||||
private ArrayList<BuildingLocation> slotLocations = new ArrayList<>();
|
||||
|
||||
public BuildingModelBase(int buildingBaseID) {
|
||||
super();
|
||||
this.buildingBaseID = buildingBaseID;
|
||||
}
|
||||
|
||||
public void addLocation(BuildingLocation bl) {
|
||||
this.locations.add(bl);
|
||||
}
|
||||
|
||||
public void addSlotLocation(BuildingLocation bl) {
|
||||
this.slotLocations.add(bl);
|
||||
}
|
||||
|
||||
public ArrayList<BuildingLocation> getLocations() {
|
||||
return this.locations;
|
||||
}
|
||||
|
||||
public BuildingLocation getNPCLocation(int slot) {
|
||||
for (BuildingLocation bl : this.locations) {
|
||||
if (bl.getType() == 6 && bl.getSlot() == slot)
|
||||
return bl;
|
||||
}
|
||||
return null; //not found
|
||||
}
|
||||
|
||||
public BuildingLocation getStuckLocation() {
|
||||
|
||||
for (BuildingLocation bl : this.locations) {
|
||||
if (bl.getType() == 8)
|
||||
return bl;
|
||||
}
|
||||
return null; //not found
|
||||
}
|
||||
|
||||
public BuildingLocation getSlotLocation(int slot) {
|
||||
|
||||
try{
|
||||
return this.slotLocations.get(slot - 1);
|
||||
}catch(Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateDatabase() {
|
||||
}
|
||||
|
||||
public int getBuildingBaseID() {
|
||||
return this.buildingBaseID;
|
||||
}
|
||||
|
||||
public static ConcurrentHashMap<Integer, BuildingModelBase> getModelBases() {
|
||||
return BuildingModelBase.modelBases;
|
||||
}
|
||||
|
||||
public static BuildingModelBase getModelBase(int ID) {
|
||||
if (!BuildingModelBase.modelBases.containsKey(ID))
|
||||
BuildingModelBase.modelBases.put(ID, new BuildingModelBase(ID));
|
||||
return BuildingModelBase.modelBases.get(ID);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -66,7 +66,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
public boolean hasLoot = false;
|
||||
public boolean isPlayerGuard = false;
|
||||
public AbstractCharacter npcOwner;
|
||||
public Vector3fImmutable inBuildingLoc = null;
|
||||
public long deathTime = 0;
|
||||
public String nameOverride = "";
|
||||
public int equipmentSetID = 0;
|
||||
@@ -506,14 +505,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
try {
|
||||
mob = DbManager.MobQueries.ADD_MOB(mobWithoutID);
|
||||
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
|
||||
mob.setMob();
|
||||
mob.setInBuildingLoc(building, mob);
|
||||
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(building, mob.inBuildingLoc);
|
||||
mob.setBindLoc(buildingWorldLoc);
|
||||
mob.setLoc(buildingWorldLoc);
|
||||
mob.region = AbstractWorldObject.GetRegionByWorldObject(mob);
|
||||
MovementManager.translocate(mob, buildingWorldLoc, mob.region);
|
||||
mob.runAfterLoad();
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error("SQLException:" + e.getMessage());
|
||||
mob = null;
|
||||
@@ -737,10 +729,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
slot += guardCaptain.siegeMinionMap.size() + 1;
|
||||
|
||||
guardCaptain.siegeMinionMap.put(mob, slot);
|
||||
mob.setInBuildingLoc(guardCaptain.building, guardCaptain);
|
||||
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(guardCaptain.building, mob.inBuildingLoc);
|
||||
mob.setBindLoc(buildingWorldLoc);
|
||||
mob.setLoc(buildingWorldLoc);
|
||||
mob.deathTime = System.currentTimeMillis();
|
||||
mob.spawnTime = 900;
|
||||
mob.npcOwner = guardCaptain;
|
||||
@@ -776,11 +764,10 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
else if (!owner.getSiegeMinionMap().containsValue(2)) slot = 2;
|
||||
|
||||
owner.getSiegeMinionMap().put(mob, slot);
|
||||
mob.setInBuildingLoc(owner.building, owner);
|
||||
|
||||
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(owner.building, mob.inBuildingLoc);
|
||||
mob.setBindLoc(buildingWorldLoc);
|
||||
mob.setLoc(buildingWorldLoc);
|
||||
// Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(owner.building, mob.inBuildingLoc);
|
||||
// mob.setBindLoc(buildingWorldLoc);
|
||||
// mob.setLoc(buildingWorldLoc);
|
||||
|
||||
mob.setSpawnTime(10);
|
||||
mob.setNpcOwner(owner);
|
||||
@@ -1724,45 +1711,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
}
|
||||
|
||||
public void setInBuildingLoc(Building inBuilding, AbstractCharacter ac) {
|
||||
|
||||
Mob mob = null;
|
||||
NPC npc = null;
|
||||
|
||||
if (ac.getObjectType().equals(GameObjectType.Mob)) mob = (Mob) ac;
|
||||
|
||||
else if (ac.getObjectType().equals(GameObjectType.NPC)) npc = (NPC) ac;
|
||||
|
||||
BuildingModelBase buildingModel = BuildingModelBase.getModelBase(inBuilding.getMeshUUID());
|
||||
|
||||
Vector3fImmutable slotLocation = Vector3fImmutable.ZERO;
|
||||
|
||||
if (buildingModel != null) {
|
||||
|
||||
int putSlot = -1;
|
||||
BuildingLocation buildingLocation;
|
||||
|
||||
//-1 slot means no slot available in building.
|
||||
|
||||
if (npc != null) {
|
||||
if (npc.getSiegeMinionMap().containsKey(this)) putSlot = npc.getSiegeMinionMap().get(this);
|
||||
} else if (mob != null) {
|
||||
if (mob.building.getHirelings().containsKey(this)) putSlot = mob.building.getHirelings().get(this);
|
||||
//putSlot = mob.building.getHirelings().size();
|
||||
}
|
||||
int count = 0;
|
||||
|
||||
for (BuildingLocation slotLoc : buildingModel.getLocations())
|
||||
if (slotLoc.getType() == 6) count++;
|
||||
|
||||
buildingLocation = buildingModel.getSlotLocation((count) - putSlot);
|
||||
|
||||
if (buildingLocation != null) slotLocation = buildingLocation.getLoc();
|
||||
|
||||
}
|
||||
|
||||
this.inBuildingLoc = slotLocation;
|
||||
}
|
||||
|
||||
public ItemBase getWeaponItemBase(boolean mainHand) {
|
||||
|
||||
|
||||
@@ -1448,26 +1448,6 @@ public class NPC extends AbstractCharacter {
|
||||
return equip;
|
||||
}
|
||||
|
||||
public static int getBuildingSlot(NPC npc){
|
||||
int slot = -1;
|
||||
|
||||
if (npc.building == null)
|
||||
return -1;
|
||||
|
||||
BuildingModelBase buildingModel = BuildingModelBase.getModelBase(npc.building.getMeshUUID());
|
||||
|
||||
if (buildingModel == null)
|
||||
return -1;
|
||||
|
||||
if (npc.building.getHirelings().containsKey(npc))
|
||||
slot = (npc.building.getHirelings().get(npc));
|
||||
|
||||
if (buildingModel.getNPCLocation(slot) == null)
|
||||
return -1;
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
public int getEquipmentSetID() {
|
||||
return equipmentSetID;
|
||||
}
|
||||
|
||||
@@ -336,8 +336,7 @@ public class WorldServer {
|
||||
Enum.RaceType.initRaceTypeTables();
|
||||
Race.loadAllRaces();
|
||||
|
||||
Logger.info("Loading building mountpoint data.");
|
||||
BuildingLocation.loadAllLocations();
|
||||
Logger.info("Loading building slot/stuck location data.");
|
||||
BuildingLocation.loadBuildingLocations();
|
||||
|
||||
// Starting before loading of structures/guilds/characters
|
||||
|
||||
Reference in New Issue
Block a user