Project cleanup pre merge.

This commit is contained in:
2023-07-15 09:23:48 -04:00
parent 134b651df8
commit 9bbdef224d
747 changed files with 99704 additions and 101200 deletions
+51 -52
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.gameManager;
import engine.Enum;
@@ -315,7 +314,7 @@ public enum BuildingManager {
for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) {
if (slottedNPC.getObjectType() == Enum.GameObjectType.NPC)
((NPC)slottedNPC).remove();
((NPC) slottedNPC).remove();
else if (slottedNPC.getObjectType() == Enum.GameObjectType.Mob)
NPCManager.removeMobileFromBuilding(((Mob) slottedNPC), building);
}
@@ -493,7 +492,7 @@ public enum BuildingManager {
NPC npc = null;
npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, false, zone, (short)rank, building);
npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, false, zone, (short) rank, building);
if (npc == null)
return false;
@@ -519,7 +518,8 @@ public enum BuildingManager {
if (item.getChargesRemaining() > 0)
rank = item.getChargesRemaining() * 10;
else rank = 10;
else
rank = 10;
Mob mob;
NPC npc;
@@ -595,10 +595,10 @@ public enum BuildingManager {
public static boolean IsOwner(Building building, PlayerCharacter player) {
if (building == null || player == null)
return false;
if (building.getOwner() == null)
return false;
return false;
return building.getOwner().getObjectUUID() == player.getObjectUUID();
@@ -650,54 +650,53 @@ public enum BuildingManager {
}
return null;
}
public static Vector3fImmutable GetBindLocationForBuilding(Building building){
Vector3fImmutable bindLoc = null;
if (building == null)
return Enum.Ruins.getRandomRuin().getLocation();
bindLoc = building.getLoc();
float radius = Bounds.meshBoundsCache.get(building.getMeshUUID()).radius;
if ( building.getRank() == 8){
bindLoc = building.getStuckLocation();
if (bindLoc != null)
return bindLoc;
}
float x = bindLoc.getX();
float z = bindLoc.getZ();
float offset = ((ThreadLocalRandom.current().nextFloat() * 2) - 1) * radius;
int direction = ThreadLocalRandom.current().nextInt(4);
public static Vector3fImmutable GetBindLocationForBuilding(Building building) {
Vector3fImmutable bindLoc = null;
if (building == null)
return Enum.Ruins.getRandomRuin().getLocation();
bindLoc = building.getLoc();
float radius = Bounds.meshBoundsCache.get(building.getMeshUUID()).radius;
if (building.getRank() == 8) {
bindLoc = building.getStuckLocation();
if (bindLoc != null)
return bindLoc;
}
float x = bindLoc.getX();
float z = bindLoc.getZ();
float offset = ((ThreadLocalRandom.current().nextFloat() * 2) - 1) * radius;
int direction = ThreadLocalRandom.current().nextInt(4);
switch (direction) {
case 0:
x += radius;
z += offset;
break;
case 1:
x += offset;
z -= radius;
break;
case 2:
x -= radius;
z += offset;
break;
case 3:
x += offset;
z += radius;
break;
}
bindLoc = new Vector3fImmutable(x, bindLoc.getY(), z);
return bindLoc;
switch (direction) {
case 0:
x += radius;
z += offset;
break;
case 1:
x += offset;
z -= radius;
break;
case 2:
x -= radius;
z += offset;
break;
case 3:
x += offset;
z += radius;
break;
}
bindLoc = new Vector3fImmutable(x, bindLoc.getY(), z);
return bindLoc;
}
}
+35 -34
View File
@@ -47,6 +47,7 @@ public enum ChatManager {
private static final String FLOOD_USER_ERROR = "You talk too much!";
private static final String SILENCED = "You find yourself mute!";
private static final String UNKNOWN_COMMAND = "No such command.";
/**
* This method used when handling a ChatMsg received from the network.
*/
@@ -107,8 +108,8 @@ public enum ChatManager {
ChatManager.chatIC(pc, (ChatICMsg) msg);
return;
case LEADERCHANNELMESSAGE:
ChatManager.chatGlobal(pc, msg.getMessage(), isFlood);
return;
ChatManager.chatGlobal(pc, msg.getMessage(), isFlood);
return;
case GLOBALCHANNELMESSAGE:
case CHATPVP:
case CHATCITY:
@@ -199,7 +200,7 @@ public enum ChatManager {
}
if (ChatManager.isVersionRequest(text) == true) {
sendSystemMessage(pcSender, ConfigManager.MB_WORLD_GREETING.getValue());
sendSystemMessage(pcSender, ConfigManager.MB_WORLD_GREETING.getValue());
return;
}
@@ -247,7 +248,7 @@ public enum ChatManager {
* Shout
*/
public static void chatShout(AbstractWorldObject sender, String text,
boolean isFlood) {
boolean isFlood) {
PlayerCharacter pcSender = null;
@@ -267,34 +268,34 @@ public enum ChatManager {
DispatchMessage.dispatchMsgToInterestArea(pcSender, msg, engine.Enum.DispatchChannel.SECONDARY, MBServerStatics.SHOUT_RANGE, true, true);
}
public static void chatGlobal(PlayerCharacter sender, String text,
boolean isFlood) {
boolean isFlood) {
PlayerCharacter pcSender = null;
PlayerCharacter pcSender = null;
if (sender.getObjectType().equals(GameObjectType.PlayerCharacter))
pcSender = (PlayerCharacter) sender;
if (sender.getObjectType().equals(GameObjectType.PlayerCharacter))
pcSender = (PlayerCharacter) sender;
if (isFlood) {
ChatManager.chatSayError(pcSender, FLOOD_USER_ERROR);
return;
}
if (isFlood) {
ChatManager.chatSayError(pcSender, FLOOD_USER_ERROR);
return;
}
if (pcSender != null && testSilenced(pcSender))
return;
if (pcSender != null && testSilenced(pcSender))
return;
// Make the Message
ChatGlobalMsg msg = new ChatGlobalMsg(sender, text);
DispatchMessage.dispatchMsgToAll(sender, msg, true);
ChatGlobalMsg msg = new ChatGlobalMsg(sender, text);
DispatchMessage.dispatchMsgToAll(sender, msg, true);
}
}
/*
* Tell
*/
public static void chatTell(AbstractWorldObject sender, String recipient,
String text, boolean isFlood) {
String text, boolean isFlood) {
if (text.isEmpty())
return;
@@ -323,7 +324,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
}
public static void chatTell(AbstractWorldObject sender,
AbstractWorldObject recipient, String text) {
AbstractWorldObject recipient, String text) {
PlayerCharacter pcSender = null;
@@ -538,7 +539,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
}
public static void GuildEnterWorldMsg(PlayerCharacter sender,
ClientConnection origin) {
ClientConnection origin) {
// Verify sender has PlayerCharacter
if (sender == null)
return;
@@ -643,7 +644,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
ChatManager.chatSystemSend(senderList, textToThief, 1, 2);
if (target != null && !textToVictim.isEmpty()) {
HashSet<AbstractWorldObject> victimList = new HashSet<>();
HashSet<AbstractWorldObject> victimList = new HashSet<>();
victimList.add(target);
ChatManager.chatSystemSend(victimList, textToVictim, 1, 2);
}
@@ -774,7 +775,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
}
public static void chatGroupInfoCanSee(PlayerCharacter pc, String text) {
HashSet<AbstractWorldObject> distroList = null;
HashSet<AbstractWorldObject> distroList = null;
Group group = GroupManager.getGroup(pc);
if (group != null) {
@@ -838,7 +839,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
// Send Info Message to guild channel based on guild
public static void chatGuildInfo(Guild guild, String text) {
HashSet<AbstractWorldObject> distroList = null;
HashSet<AbstractWorldObject> distroList = null;
if (guild != null)
distroList = ChatManager.getGuildList(guild, null);
ChatManager.chatSystemSend(distroList, text, 12, 2);
@@ -846,7 +847,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
public static void chatSystemMOTD(PlayerCharacter sender, String text,
int channel, int messageType) {
HashSet<AbstractWorldObject> distroList = ChatManager.getOwnPlayer(sender);
HashSet<AbstractWorldObject> distroList = ChatManager.getOwnPlayer(sender);
ChatManager.chatSystemSend(distroList, text, channel, messageType);
}
@@ -857,7 +858,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
}
public static void chatInfo(String text) {
HashSet<AbstractWorldObject> distroList = ChatManager.getAllPlayers(null);
HashSet<AbstractWorldObject> distroList = ChatManager.getAllPlayers(null);
chatSystemSend(distroList, text, 1, 2);
}
@@ -871,7 +872,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
public static void chatSystem(PlayerCharacter sender, String text, int channel,
int messageType) {
HashSet<AbstractWorldObject> distroList = null;
HashSet<AbstractWorldObject> distroList = null;
if (channel == 1) // System Channel Message
distroList = ChatManager.getAllPlayers(sender);
@@ -924,7 +925,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
public static void chatSystemGuild(Guild sender, String text, int channel,
int messageType) {
HashSet<AbstractWorldObject> distroList = null;
HashSet<AbstractWorldObject> distroList = null;
if (channel == 5) { // Nation Channel, get Nation list
if (sender != null) {
@@ -976,7 +977,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
// Get distroList for guild
public static HashSet<AbstractWorldObject> getGuildList(Guild guild, PlayerCharacter source) {
HashSet<AbstractWorldObject> distroList = new HashSet<>();
HashSet<AbstractWorldObject> distroList = new HashSet<>();
for (PlayerCharacter playerCharacter : SessionManager.getAllActivePlayerCharacters()) {
@@ -992,7 +993,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
// Get distroList for guild IC's
public static HashSet<AbstractWorldObject> getGuildICList(Guild guild, PlayerCharacter source) {
HashSet<AbstractWorldObject> distroList = new HashSet<>();
HashSet<AbstractWorldObject> distroList = new HashSet<>();
for (PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()) {
@@ -1008,7 +1009,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
// Get distroList for group
public static HashSet<AbstractWorldObject> getGroupList(Group group, PlayerCharacter source) {
HashSet<AbstractWorldObject> distroList = new HashSet<>();
HashSet<AbstractWorldObject> distroList = new HashSet<>();
Set<PlayerCharacter> players = group.getMembers();
for (PlayerCharacter pc : players) {
if (source != null && pc.isIgnoringPlayer(source))
@@ -1020,7 +1021,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
// Get distroList for nation
public static HashSet<AbstractWorldObject> getNationList(Guild nation, PlayerCharacter source) {
HashSet<AbstractWorldObject> distroList = new HashSet<>();
HashSet<AbstractWorldObject> distroList = new HashSet<>();
for (PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()) {
@@ -1056,7 +1057,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
// Get distroList for all players
public static HashSet<AbstractWorldObject> getAllPlayers(PlayerCharacter source) {
HashSet<AbstractWorldObject> distroList = new HashSet<>();
HashSet<AbstractWorldObject> distroList = new HashSet<>();
for (PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()) {
if (source != null && pc.isIgnoringPlayer(source))
continue; // dont add if recip has ignored source
@@ -1218,7 +1219,7 @@ DispatchMessage.dispatchMsgToAll(sender, msg, true);
else if (cmd.compareTo("getinfo") == 0)
devCmd = "info";
else if (devCmd.isEmpty()) {
Logger.info( "Unhandled admin command was used: /"
Logger.info("Unhandled admin command was used: /"
+ cmd);
return;
}
+134 -166
View File
@@ -9,7 +9,6 @@
package engine.gameManager;
import engine.Enum.*;
import engine.ai.MobileFSM;
import engine.exception.MsgSendException;
import engine.job.JobContainer;
import engine.job.JobScheduler;
@@ -28,7 +27,6 @@ import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
@@ -38,6 +36,8 @@ public enum CombatManager {
COMBATMANAGER;
public static int animation = 0;
/**
* Message sent by player to attack something.
*/
@@ -60,7 +60,7 @@ public enum CombatManager {
//source must match player this account belongs to
if (player.getObjectUUID() != msg.getSourceID() || player.getObjectType().ordinal() != msg.getSourceType()) {
Logger.error("Msg Source ID " + msg.getSourceID() + " Does not Match Player ID " + player.getObjectUUID() );
Logger.error("Msg Source ID " + msg.getSourceID() + " Does not Match Player ID " + player.getObjectUUID());
return;
}
@@ -73,7 +73,7 @@ public enum CombatManager {
target = BuildingManager.getBuildingFromCache(msg.getTargetID());
} else if (targetType == GameObjectType.Mob.ordinal()) {
target = Mob.getFromCache(msg.getTargetID());
}else{
} else {
player.setCombatTarget(null);
return; //not valid type to attack
}
@@ -137,7 +137,7 @@ public enum CombatManager {
}
}
City playerCity = ZoneManager.getCityAtLocation(playerCharacter.getLoc());
if( playerCity != null && playerCity.getGuild().getNation().equals(playerCharacter.getGuild().getNation()) == false && playerCity.cityOutlaws.contains(playerCharacter.getObjectUUID()) == false)
if (playerCity != null && playerCity.getGuild().getNation().equals(playerCharacter.getGuild().getNation()) == false && playerCity.cityOutlaws.contains(playerCharacter.getObjectUUID()) == false)
playerCity.cityOutlaws.add(playerCharacter.getObjectUUID());
}
@@ -173,7 +173,7 @@ public enum CombatManager {
pet.setCombatTarget(null);
return; //not valid type to attack
}
if (pet.equals(target))
return;
@@ -184,10 +184,9 @@ public enum CombatManager {
return;
//set sources target
pet.setCombatTarget(target);
// setFirstHitCombatTarget(player,target);
// setFirstHitCombatTarget(player,target);
//put in combat if not already
if (!pet.isCombat())
@@ -292,10 +291,10 @@ public enum CombatManager {
AbstractWorldObject target = abstractCharacter.getCombatTarget();
if (target == null){
if (target == null) {
return 0;
}
//target must be valid type
if (AbstractWorldObject.IsAbstractCharacter(target)) {
@@ -303,11 +302,9 @@ public enum CombatManager {
//must be alive, attackable and in World
if (!tar.isAlive()) {
return 0;
}
else if (tar.isSafeMode()) {
} else if (tar.isSafeMode()) {
return 0;
}
else if (!tar.isActive()) {
} else if (!tar.isActive()) {
return 0;
}
@@ -327,8 +324,7 @@ public enum CombatManager {
}
}
}
}
else if (target.getObjectType().equals(GameObjectType.Building)) {
} else if (target.getObjectType().equals(GameObjectType.Building)) {
Building tar = (Building) target;
// Cannot attack an invuln building
@@ -337,16 +333,14 @@ public enum CombatManager {
return 0;
}
}
else {
} else {
return 0; //only characters and buildings may be attacked
}
//source must be in world and alive
if (!abstractCharacter.isActive()) {
return 0;
}
else if (!abstractCharacter.isAlive()) {
} else if (!abstractCharacter.isAlive()) {
return 0;
}
@@ -384,13 +378,11 @@ public enum CombatManager {
ItemBase wb = null;
if (weapon == null) {
isWeapon = false;
}
else {
} else {
ItemBase ib = weapon.getItemBase();
if (ib == null || !ib.getType().equals(ItemType.WEAPON)) {
isWeapon = false;
}
else {
} else {
wb = ib;
}
}
@@ -405,17 +397,14 @@ public enum CombatManager {
ItemBase ib = weaponOff.getItemBase();
if (ib == null || !ib.getType().equals(ItemType.WEAPON)) {
hasNoWeapon = true;
}
else {
} else {
// debugCombat(ac, "mainhand, weapon in other hand");
return 1; //no need to attack with this hand
}
}
else {
} else {
hasNoWeapon = true;
}
}
else {
} else {
if (equipped.get(MBServerStatics.SLOT_MAINHAND) == null) {
// debgCombat(ac, "offhand, weapon in other hand");
return 1; //no need to attack with this hand
@@ -439,8 +428,7 @@ public enum CombatManager {
// debugCombat(ac, "Not enough stamina to attack");
attackFailure = true;
}
}
else if (abstractCharacter.getStamina() < wb.getWeight()) {
} else if (abstractCharacter.getStamina() < wb.getWeight()) {
// debugCombat(ac, "Not enough stamina to attack");
attackFailure = true;
}
@@ -453,7 +441,7 @@ public enum CombatManager {
// }
//see if attacker is stunned. If so, stop here
bonus = abstractCharacter.getBonuses();
if (bonus != null && bonus.getBool(ModType.Stunned,SourceType.None)) {
if (bonus != null && bonus.getBool(ModType.Stunned, SourceType.None)) {
// debugCombat(ac, "Cannot attack while stunned");
attackFailure = true;
}
@@ -462,13 +450,12 @@ public enum CombatManager {
float range;
if (hasNoWeapon) {
range = MBServerStatics.NO_WEAPON_RANGE;
}
else {
} else {
range = getWeaponRange(wb);
if (bonus != null){
if (bonus != null) {
float buffRange = 1;
buffRange += bonus.getFloat(ModType.WeaponRange, SourceType.None) *.01f;
range*= buffRange;
buffRange += bonus.getFloat(ModType.WeaponRange, SourceType.None) * .01f;
range *= buffRange;
}
}
@@ -504,8 +491,7 @@ public enum CombatManager {
if (!attackFailure) {
if (hasNoWeapon || abstractCharacter.getObjectType().equals(GameObjectType.Mob)) {
createTimer(abstractCharacter, slot, 20, true); //2 second for no weapon
}
else {
} else {
int wepSpeed = (int) (wb.getSpeed());
if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.None) != 0f) //add weapon speed bonus
{
@@ -525,14 +511,13 @@ public enum CombatManager {
return 0;
attack(abstractCharacter, target, weapon, wb, (slot == MBServerStatics.SLOT_MAINHAND) ? true : false);
}
else {
} else {
// changed this to half a second to make combat attempts more aggressive than movement sync
createTimer(abstractCharacter, slot, 5, false); //0.5 second timer if attack fails
//System.out.println("Attack attempt failed");
}
} catch(Exception e) {
} catch (Exception e) {
return 0;
}
return 2;
@@ -576,7 +561,7 @@ public enum CombatManager {
job = JobScheduler.getInstance().scheduleJob(aj, (time * 100));
timers.put("Attack" + slot, job);
} else {
Logger.error( "Unable to find Timers for Character " + ac.getObjectUUID());
Logger.error("Unable to find Timers for Character " + ac.getObjectUUID());
}
}
@@ -601,8 +586,7 @@ public enum CombatManager {
atr = ac.getAtrHandOne();
minDamage = ac.getMinDamageHandOne();
maxDamage = ac.getMaxDamageHandOne();
}
else {
} else {
atr = ac.getAtrHandTwo();
minDamage = ac.getMinDamageHandTwo();
maxDamage = ac.getMaxDamageHandTwo();
@@ -612,20 +596,20 @@ public enum CombatManager {
if (target.getObjectTypeMask() == MBServerStatics.MASK_RAT)
tarIsRat = true;
else if (target.getObjectType() == GameObjectType.PlayerCharacter){
PlayerCharacter pTar = (PlayerCharacter)target;
for (Effect eff: pTar.getEffects().values()){
if (eff.getPowerToken() == 429513599 || eff.getPowerToken() == 429415295){
else if (target.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pTar = (PlayerCharacter) target;
for (Effect eff : pTar.getEffects().values()) {
if (eff.getPowerToken() == 429513599 || eff.getPowerToken() == 429415295) {
tarIsRat = true;
}
}
}
//Dont think we need to do this anymore.
if (tarIsRat){
if (tarIsRat) {
//strip away current % dmg buffs then add with rat %
if (ac.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat) != 0){
if (ac.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat) != 0) {
float percent = 1 + ac.getBonuses().getFloatPercentAll(ModType.Slay, SourceType.Rat);
@@ -640,8 +624,7 @@ public enum CombatManager {
//subtract stamina
if (wb == null) {
ac.modifyStamina(-0.5f, ac, true);
}
else {
} else {
float stam = wb.getWeight() / 3;
stam = (stam < 1) ? 1 : stam;
ac.modifyStamina(-(stam), ac, true);
@@ -655,8 +638,7 @@ public enum CombatManager {
if (target.getObjectType().equals(GameObjectType.PlayerCharacter) && target.getObjectUUID() != ac.getObjectUUID() && ac.getObjectType() == GameObjectType.PlayerCharacter) {
ac.setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
((PlayerCharacter) target).setTimeStamp("LastCombatPlayer", System.currentTimeMillis());
}
else {
} else {
ac.setTimeStamp("LastCombatMob", System.currentTimeMillis());
}
@@ -665,20 +647,20 @@ public enum CombatManager {
//Get defense for target
float defense;
if (target.getObjectType().equals(GameObjectType.Building)) {
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null){
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
ac.setCombatTarget(null);
return;
}
defense = 0;
Building building = (Building)target;
if (building.getParentZone() != null && building.getParentZone().isPlayerCity()){
Building building = (Building) target;
if (building.getParentZone() != null && building.getParentZone().isPlayerCity()) {
if (System.currentTimeMillis() > building.getTimeStamp("CallForHelp")){
if (System.currentTimeMillis() > building.getTimeStamp("CallForHelp")) {
building.getTimestamps().put("CallForHelp", System.currentTimeMillis() + 15000);
int count = 0;
for (Mob mob:building.getParentZone().zoneMobSet){
for (Mob mob : building.getParentZone().zoneMobSet) {
if (!mob.isPlayerGuard())
continue;
if (mob.getCombatTarget() != null)
@@ -694,11 +676,10 @@ public enum CombatManager {
count++;
mob.setCombatTarget(ac);
}
}
}
}
}
else {
} else {
AbstractCharacter tar = (AbstractCharacter) target;
defense = tar.getDefenseRating();
//Handle target attacking back if in combat and has no other target
@@ -712,11 +693,9 @@ public enum CombatManager {
float dif = atr - defense;
if (dif > 100) {
chance = 94;
}
else if (dif < -100) {
} else if (dif < -100) {
chance = 4;
}
else {
} else {
chance = (int) ((0.45 * dif) + 49);
}
@@ -755,11 +734,11 @@ public enum CombatManager {
dpj.attack(target, attackRange);
if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518))
((PlayerCharacter)ac).setWeaponPower(dpj);
((PlayerCharacter) ac).setWeaponPower(dpj);
}
}
//check to apply second backstab.
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) && !mainHand){
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) && !mainHand) {
dpj = ((PlayerCharacter) ac).getWeaponPower();
if (dpj != null && dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) {
float attackRange = getWeaponRange(wb);
@@ -780,7 +759,7 @@ public enum CombatManager {
if (!target.isAlive())
return;
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_BLOCK, dpj,mainHand);
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_BLOCK, dpj, mainHand);
passiveFired = true;
}
@@ -789,7 +768,7 @@ public enum CombatManager {
if (canTestParry(ac, target) && testPassive(ac, tarAc, "Parry")) {
if (!target.isAlive())
return;
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_PARRY, dpj,mainHand);
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_PARRY, dpj, mainHand);
passiveFired = true;
}
}
@@ -804,7 +783,7 @@ public enum CombatManager {
if (!target.isAlive())
return;
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_DODGE, dpj,mainHand);
sendPassiveDefenseMessage(ac, wb, target, MBServerStatics.COMBAT_SEND_DODGE, dpj, mainHand);
passiveFired = true;
}
}
@@ -827,11 +806,9 @@ public enum CombatManager {
DamageType damageType;
if (wb != null) {
damageType = wb.getDamageType();
}
else if (ac.getObjectType().equals(GameObjectType.Mob) && ((Mob) ac).isSiege()) {
} else if (ac.getObjectType().equals(GameObjectType.Mob) && ((Mob) ac).isSiege()) {
damageType = DamageType.Siege;
}
else {
} else {
damageType = DamageType.Crush;
}
@@ -842,14 +819,13 @@ public enum CombatManager {
if (tarAc != null) {
resists = tarAc.getResists();
}
else if (target.getObjectType().equals(GameObjectType.Building)) {
} else if (target.getObjectType().equals(GameObjectType.Building)) {
resists = ((Building) target).getResists();
}
//make sure target is not immune to damage type;
if (resists != null && resists.immuneTo(damageType)) {
sendCombatMessage(ac, target, 0f, wb, dpj,mainHand);
sendCombatMessage(ac, target, 0f, wb, dpj, mainHand);
return;
}
@@ -865,8 +841,7 @@ public enum CombatManager {
if (wb != null) {
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
}
else {
} else {
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
}
@@ -887,10 +862,9 @@ public enum CombatManager {
if (tarAc.getHealth() > 0)
d = tarAc.modifyHealth(-damage, ac, false);
}
else if (target.getObjectType().equals(GameObjectType.Building)) {
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null){
} else if (target.getObjectType().equals(GameObjectType.Building)) {
if (BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
ac.setCombatTarget(null);
return;
}
@@ -910,7 +884,7 @@ public enum CombatManager {
//test double death fix
if (d != 0) {
sendCombatMessage(ac, target, damage, wb, dpj,mainHand); //send damage message
sendCombatMessage(ac, target, damage, wb, dpj, mainHand); //send damage message
}
errorTrack = 14;
@@ -945,8 +919,7 @@ public enum CombatManager {
if (ac.isAlive() && tarAc != null && tarAc.isAlive()) {
handleDamageShields(ac, tarAc, damage);
}
}
else {
} else {
int animationOverride = 0;
// Apply Weapon power effect if any.
// don't try to apply twice if dual wielding.
@@ -958,9 +931,8 @@ public enum CombatManager {
PowersBase wp = dpj.getPower();
if (wp.requiresHitRoll() == false) {
float attackRange = getWeaponRange(wb);
dpj.attack(target,attackRange);
}
else {
dpj.attack(target, attackRange);
} else {
((PlayerCharacter) ac).setWeaponPower(null);
}
@@ -973,7 +945,7 @@ public enum CombatManager {
errorTrack = 17;
//miss, Send miss message
sendCombatMessage(ac, target, 0f, wb, dpj,mainHand);
sendCombatMessage(ac, target, 0f, wb, dpj, mainHand);
//if attacker is player, set last attack timestamp
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter)) {
@@ -1026,7 +998,6 @@ public enum CombatManager {
return false;
Item tarOff = tarItem.getItemFromEquipped(2);
@@ -1060,7 +1031,7 @@ public enum CombatManager {
//Damage is calculated twice to average a more central point
float damage = ThreadLocalRandom.current().nextFloat() * range;
damage = (damage + (ThreadLocalRandom.current().nextFloat() * range)) *.5f;
damage = (damage + (ThreadLocalRandom.current().nextFloat() * range)) * .5f;
//put it back between min and max
damage += minDamage;
@@ -1075,29 +1046,29 @@ public enum CombatManager {
private static void sendPassiveDefenseMessage(AbstractCharacter source, ItemBase wb, AbstractWorldObject target, int passiveType, DeferredPowerJob dpj, boolean mainHand) {
int swingAnimation = getSwingAnimation(wb, dpj,mainHand);
int swingAnimation = getSwingAnimation(wb, dpj, mainHand);
if (dpj != null){
if(PowersManager.AnimationOverrides.containsKey(dpj.getAction().getEffectID()))
if (dpj != null) {
if (PowersManager.AnimationOverrides.containsKey(dpj.getAction().getEffectID()))
swingAnimation = PowersManager.AnimationOverrides.get(dpj.getAction().getEffectID());
}
TargetedActionMsg cmm = new TargetedActionMsg(source,swingAnimation, target, passiveType);
TargetedActionMsg cmm = new TargetedActionMsg(source, swingAnimation, target, passiveType);
DispatchMessage.sendToAllInRange(target, cmm);
}
private static void sendCombatMessage(AbstractCharacter source, AbstractWorldObject target, float damage, ItemBase wb, DeferredPowerJob dpj, boolean mainHand) {
int swingAnimation = getSwingAnimation(wb, dpj,mainHand);
int swingAnimation = getSwingAnimation(wb, dpj, mainHand);
if (dpj != null){
if(PowersManager.AnimationOverrides.containsKey(dpj.getAction().getEffectID()))
if (dpj != null) {
if (PowersManager.AnimationOverrides.containsKey(dpj.getAction().getEffectID()))
swingAnimation = PowersManager.AnimationOverrides.get(dpj.getAction().getEffectID());
}
if (source.getObjectType() == GameObjectType.PlayerCharacter){
for (Effect eff: source.getEffects().values()){
if (eff.getPower() != null && (eff.getPower().getToken() == 429506943 || eff.getPower().getToken() == 429408639 || eff.getPower().getToken() == 429513599 ||eff.getPower().getToken() == 429415295))
if (source.getObjectType() == GameObjectType.PlayerCharacter) {
for (Effect eff : source.getEffects().values()) {
if (eff.getPower() != null && (eff.getPower().getToken() == 429506943 || eff.getPower().getToken() == 429408639 || eff.getPower().getToken() == 429513599 || eff.getPower().getToken() == 429415295))
swingAnimation = 0;
}
}
@@ -1105,8 +1076,6 @@ public enum CombatManager {
DispatchMessage.sendToAllInRange(target, cmm);
}
public static int animation = 0;
public static int getSwingAnimation(ItemBase wb, DeferredPowerJob dpj, boolean mainHand) {
int token = 0;
if (dpj != null) {
@@ -1125,57 +1094,56 @@ public enum CombatManager {
if (wb == null) {
return 75;
}
if (mainHand){
if (wb.getAnimations().size() > 0){
if (mainHand) {
if (wb.getAnimations().size() > 0) {
int animation = wb.getAnimations().get(0);
int random = ThreadLocalRandom.current().nextInt(wb.getAnimations().size());
try{
try {
animation = wb.getAnimations().get(random);
return animation;
}catch(Exception e){
Logger.error( e.getMessage());
} catch (Exception e) {
Logger.error(e.getMessage());
return wb.getAnimations().get(0);
}
}else if (wb.getOffHandAnimations().size() > 0){
} else if (wb.getOffHandAnimations().size() > 0) {
int animation = wb.getOffHandAnimations().get(0);
int random = ThreadLocalRandom.current().nextInt(wb.getOffHandAnimations().size());
try{
try {
animation = wb.getOffHandAnimations().get(random);
return animation;
}catch(Exception e){
Logger.error( e.getMessage());
} catch (Exception e) {
Logger.error(e.getMessage());
return wb.getOffHandAnimations().get(0);
}
}
}else{
if (wb.getOffHandAnimations().size() > 0){
} else {
if (wb.getOffHandAnimations().size() > 0) {
int animation = wb.getOffHandAnimations().get(0);
int random = ThreadLocalRandom.current().nextInt(wb.getOffHandAnimations().size());
try{
try {
animation = wb.getOffHandAnimations().get(random);
return animation;
}catch(Exception e){
Logger.error( e.getMessage());
} catch (Exception e) {
Logger.error(e.getMessage());
return wb.getOffHandAnimations().get(0);
}
}else
if (wb.getAnimations().size() > 0){
int animation = wb.getAnimations().get(0);
int random = ThreadLocalRandom.current().nextInt(wb.getAnimations().size());
try{
animation = wb.getAnimations().get(random);
return animation;
}catch(Exception e){
Logger.error( e.getMessage());
return wb.getAnimations().get(0);
}
} else if (wb.getAnimations().size() > 0) {
int animation = wb.getAnimations().get(0);
int random = ThreadLocalRandom.current().nextInt(wb.getAnimations().size());
try {
animation = wb.getAnimations().get(random);
return animation;
} catch (Exception e) {
Logger.error(e.getMessage());
return wb.getAnimations().get(0);
}
}
}
@@ -1290,7 +1258,7 @@ public enum CombatManager {
UpdateStateMsg rwss = new UpdateStateMsg();
rwss.setPlayer(pc);
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true,false);
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
}
public static boolean NotInRange(AbstractCharacter ac, AbstractWorldObject target, float range) {
@@ -1313,16 +1281,16 @@ public enum CombatManager {
if (ac.equals(tarAc)) {
return;
}
if (tarAc.isMoving() && tarAc.getObjectType().equals(GameObjectType.PlayerCharacter))
return;
if (!tarAc.isAlive() || !ac.isAlive())
return;
boolean isCombat = tarAc.isCombat();
//If target in combat and has no target, then attack back
AbstractWorldObject awoCombTar = tarAc.getCombatTarget();
if ((tarAc.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() ||tarAc.isCombat() && NotInRange(tarAc, awoCombTar, tarAc.getRange()))) || (tarAc != null && tarAc.getObjectType() == GameObjectType.Mob && ((Mob) tarAc).isSiege())) {
if ((tarAc.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || tarAc.isCombat() && NotInRange(tarAc, awoCombTar, tarAc.getRange()))) || (tarAc != null && tarAc.getObjectType() == GameObjectType.Mob && ((Mob) tarAc).isSiege())) {
// we are in combat with no valid target
if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) {
PlayerCharacter pc = (PlayerCharacter) tarAc;
@@ -1341,7 +1309,7 @@ public enum CombatManager {
Mob pet = ((PlayerCharacter) tarAc).getPet();
if (pet != null && pet.assist() && pet.getCombatTarget() == null) {
pet.setCombatTarget(ac);
}
}
}
//Handle Mob Retaliate.
@@ -1353,7 +1321,7 @@ public enum CombatManager {
return;
retaliater.setCombatTarget(ac);
}
}
}
public static void handleDamageShields(AbstractCharacter ac, AbstractCharacter target, float damage) {
@@ -1385,7 +1353,7 @@ public enum CombatManager {
//apply Damage back
ac.modifyHealth(-total, target, true);
TargetedActionMsg cmm = new TargetedActionMsg(ac,ac, total, 0);
TargetedActionMsg cmm = new TargetedActionMsg(ac, ac, total, 0);
DispatchMessage.sendToAllInRange(target, cmm);
}
@@ -1395,32 +1363,32 @@ public enum CombatManager {
public static float calcHitBox(AbstractWorldObject ac) {
//TODO Figure out how Str Affects HitBox
float hitBox = 1;
switch(ac.getObjectType()){
case PlayerCharacter:
PlayerCharacter pc = (PlayerCharacter)ac;
if (MBServerStatics.COMBAT_TARGET_HITBOX_DEBUG) {
Logger.info("Hit box radius for " + pc.getFirstName() + " is " + ((int) pc.statStrBase / 20f));
}
hitBox = 1.5f + (int) ((PlayerCharacter) ac).statStrBase / 20f;
break;
switch (ac.getObjectType()) {
case PlayerCharacter:
PlayerCharacter pc = (PlayerCharacter) ac;
if (MBServerStatics.COMBAT_TARGET_HITBOX_DEBUG) {
Logger.info("Hit box radius for " + pc.getFirstName() + " is " + ((int) pc.statStrBase / 20f));
}
hitBox = 1.5f + (int) ((PlayerCharacter) ac).statStrBase / 20f;
break;
case Mob:
Mob mob = (Mob)ac;
if (MBServerStatics.COMBAT_TARGET_HITBOX_DEBUG)
Logger.info( "Hit box radius for " + mob.getFirstName()
+ " is " + ((Mob) ac).getMobBase().getHitBoxRadius());
case Mob:
Mob mob = (Mob) ac;
if (MBServerStatics.COMBAT_TARGET_HITBOX_DEBUG)
Logger.info("Hit box radius for " + mob.getFirstName()
+ " is " + ((Mob) ac).getMobBase().getHitBoxRadius());
hitBox = ((Mob) ac).getMobBase().getHitBoxRadius();
break;
case Building:
Building building = (Building)ac;
if (building.getBlueprint() == null)
return 32;
hitBox = Math.max(building.getBlueprint().getBuildingGroup().getExtents().x,
building.getBlueprint().getBuildingGroup().getExtents().y);
if (MBServerStatics.COMBAT_TARGET_HITBOX_DEBUG)
Logger.info( "Hit box radius for " + building.getName() + " is " + hitBox);
break;
hitBox = ((Mob) ac).getMobBase().getHitBoxRadius();
break;
case Building:
Building building = (Building) ac;
if (building.getBlueprint() == null)
return 32;
hitBox = Math.max(building.getBlueprint().getBuildingGroup().getExtents().x,
building.getBlueprint().getBuildingGroup().getExtents().y);
if (MBServerStatics.COMBAT_TARGET_HITBOX_DEBUG)
Logger.info("Hit box radius for " + building.getName() + " is " + hitBox);
break;
}
return hitBox;
+6 -3
View File
@@ -132,8 +132,11 @@ public enum ConfigManager {
// Get the value associated with this enumeration
public String getValue() {
return configMap.get(this.name());
public String getValue() {
return configMap.get(this.name());
}
public void setValue(String value) {
configMap.put(this.name(), value);
}
public void setValue(String value) { configMap.put(this.name(), value); }
}
+274 -279
View File
@@ -25,304 +25,299 @@ import java.util.EnumMap;
import java.util.concurrent.ConcurrentHashMap;
public enum DbManager {
DBMANAGER;
DBMANAGER;
public static final dbAccountHandler AccountQueries = new dbAccountHandler();
public static final dbBaneHandler BaneQueries = new dbBaneHandler();
//Local Object Caching
public static final dbBaseClassHandler BaseClassQueries = new dbBaseClassHandler();
public static final dbBuildingHandler BuildingQueries = new dbBuildingHandler();
public static final dbBuildingLocationHandler BuildingLocationQueries = new dbBuildingLocationHandler();
public static final dbCharacterPowerHandler CharacterPowerQueries = new dbCharacterPowerHandler();
public static final dbCharacterRuneHandler CharacterRuneQueries = new dbCharacterRuneHandler();
public static final dbCharacterSkillHandler CharacterSkillQueries = new dbCharacterSkillHandler();
public static final dbCityHandler CityQueries = new dbCityHandler();
public static final dbContractHandler ContractQueries = new dbContractHandler();
public static final dbWarehouseHandler WarehouseQueries = new dbWarehouseHandler();
// Omg refactor this out, somebody!
public static final dbCSSessionHandler CSSessionQueries = new dbCSSessionHandler();
public static final dbEnchantmentHandler EnchantmentQueries = new dbEnchantmentHandler();
public static final dbEffectsResourceCostHandler EffectsResourceCostsQueries = new dbEffectsResourceCostHandler();
public static final dbGuildHandler GuildQueries = new dbGuildHandler();
public static final dbItemHandler ItemQueries = new dbItemHandler();
public static final dbItemBaseHandler ItemBaseQueries = new dbItemBaseHandler();
public static final dbKitHandler KitQueries = new dbKitHandler();
public static final dbLootTableHandler LootQueries = new dbLootTableHandler();
public static final dbMenuHandler MenuQueries = new dbMenuHandler();
public static final dbMineHandler MineQueries = new dbMineHandler();
public static final dbMobHandler MobQueries = new dbMobHandler();
public static final dbMobBaseHandler MobBaseQueries = new dbMobBaseHandler();
public static final dbNPCHandler NPCQueries = new dbNPCHandler();
public static final dbPlayerCharacterHandler PlayerCharacterQueries = new dbPlayerCharacterHandler();
public static final dbPromotionClassHandler PromotionQueries = new dbPromotionClassHandler();
public static final dbRaceHandler RaceQueries = new dbRaceHandler();
public static final dbResistHandler ResistQueries = new dbResistHandler();
public static final dbRuneBaseAttributeHandler RuneBaseAttributeQueries = new dbRuneBaseAttributeHandler();
public static final dbRuneBaseEffectHandler RuneBaseEffectQueries = new dbRuneBaseEffectHandler();
public static final dbRuneBaseHandler RuneBaseQueries = new dbRuneBaseHandler();
public static final dbSkillBaseHandler SkillsBaseQueries = new dbSkillBaseHandler();
public static final dbSkillReqHandler SkillReqQueries = new dbSkillReqHandler();
public static final dbVendorDialogHandler VendorDialogQueries = new dbVendorDialogHandler();
public static final dbZoneHandler ZoneQueries = new dbZoneHandler();
public static final dbRealmHandler RealmQueries = new dbRealmHandler();
public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler();
public static final dbBoonHandler BoonQueries = new dbBoonHandler();
public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
public static final dbHeightMapHandler HeightMapQueries = new dbHeightMapHandler();
public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler();
private static final EnumMap<GameObjectType, ConcurrentHashMap<Integer, AbstractGameObject>> objectCache = new EnumMap<>(GameObjectType.class);
public static Hasher hasher;
private static HikariDataSource connectionPool = null;
public static AbstractGameObject getObject(GameObjectType objectType, int objectUUID) {
AbstractGameObject outObject = null;
switch (objectType) {
case PlayerCharacter:
outObject = PlayerCharacter.getPlayerCharacter(objectUUID);
break;
case NPC:
outObject = NPC.getNPC(objectUUID);
break;
case Mob:
outObject = Mob.getFromCache(objectUUID);
break;
case Building:
outObject = BuildingManager.getBuilding(objectUUID);
break;
case Guild:
outObject = Guild.getGuild(objectUUID);
break;
case Item:
outObject = Item.getFromCache(objectUUID);
break;
case MobLoot:
outObject = MobLoot.getFromCache(objectUUID);
break;
case City:
outObject = City.getCity(objectUUID);
break;
default:
Logger.error("Attempt to retrieve nonexistant " + objectType +
" from object cache.");
break;
}
return outObject;
}
public static boolean inCache(GameObjectType gameObjectType, int uuid) {
if (objectCache.get(gameObjectType) == null)
return false;
return (objectCache.get(gameObjectType).containsKey(uuid));
}
public static AbstractGameObject getFromCache(GameObjectType gameObjectType, int uuid) {
if (objectCache.get(gameObjectType) == null)
return null;
return objectCache.get(gameObjectType).get(uuid);
}
public static void removeFromCache(GameObjectType gameObjectType, int uuid) {
AbstractGameObject abstractGameObject;
if (objectCache.get(gameObjectType) == null)
return;
abstractGameObject = objectCache.get(gameObjectType).get(uuid);
if (abstractGameObject == null)
return;
removeFromCache(abstractGameObject);
}
public static void removeFromCache(AbstractGameObject abstractGameObject) {
if (abstractGameObject == null)
return;
if (objectCache.get(abstractGameObject.getObjectType()) == null)
return;
// Remove object from game cache
objectCache.get(abstractGameObject.getObjectType()).remove(abstractGameObject.getObjectUUID());
// Release bounds as we're dispensing with this object.
if (abstractGameObject instanceof AbstractWorldObject) {
AbstractWorldObject abstractWorldObject = (AbstractWorldObject) abstractGameObject;
if (abstractWorldObject.getBounds() != null) {
abstractWorldObject.getBounds().release();
abstractWorldObject.setBounds(null);
}
}
private static HikariDataSource connectionPool = null;
}
public static Hasher hasher;
public static boolean addToCache(AbstractGameObject gameObject) {
//Local Object Caching
boolean isWorldServer = ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER);
private static final EnumMap<GameObjectType, ConcurrentHashMap<Integer, AbstractGameObject>> objectCache = new EnumMap<>(GameObjectType.class);
if (!isWorldServer) {
if (MBServerStatics.SKIP_CACHE_LOGIN)
return true;
if (MBServerStatics.SKIP_CACHE_LOGIN_PLAYER
&& (gameObject.getObjectType() == GameObjectType.PlayerCharacter))
return true;
if (MBServerStatics.SKIP_CACHE_LOGIN_ITEM &&
(gameObject.getObjectType() == GameObjectType.Item))
return true;
}
public static AbstractGameObject getObject(GameObjectType objectType, int objectUUID) {
// First time this object type has been cached. Create the hashmap.
AbstractGameObject outObject = null;
if (objectCache.get(gameObject.getObjectType()) == null) {
switch (objectType) {
case PlayerCharacter:
outObject = PlayerCharacter.getPlayerCharacter(objectUUID);
break;
case NPC:
outObject = NPC.getNPC(objectUUID);
break;
case Mob:
outObject = Mob.getFromCache(objectUUID);
break;
case Building:
outObject = BuildingManager.getBuilding(objectUUID);
break;
case Guild:
outObject = Guild.getGuild(objectUUID);
break;
case Item:
outObject = Item.getFromCache(objectUUID);
break;
case MobLoot:
outObject = MobLoot.getFromCache(objectUUID);
break;
case City:
outObject = City.getCity(objectUUID);
break;
default:
Logger.error("Attempt to retrieve nonexistant " + objectType +
" from object cache." );
break;
int initialCapacity;
}
// Provide initial sizing hints
return outObject;
}
switch (gameObject.getObjectType()) {
case Building:
initialCapacity = 46900;
break;
case Mob:
initialCapacity = 11700;
break;
case NPC:
initialCapacity = 900;
break;
case Zone:
initialCapacity = 1070;
break;
case Account:
initialCapacity = 10000;
break;
case Guild:
initialCapacity = 100;
break;
case ItemContainer:
initialCapacity = 100;
break;
case Item:
initialCapacity = 1000;
break;
case MobLoot:
initialCapacity = 10000;
break;
case PlayerCharacter:
initialCapacity = 100;
break;
default:
initialCapacity = 100; // Lookup api default should be ok for small maps
break;
}
objectCache.put(gameObject.getObjectType(), new ConcurrentHashMap<>(initialCapacity));
}
// Add the object to the cache. This will overwrite the current map entry.
public static boolean inCache(GameObjectType gameObjectType, int uuid) {
objectCache.get(gameObject.getObjectType()).put(gameObject.getObjectUUID(), gameObject);
if (objectCache.get(gameObjectType) == null)
return false;
return true;
}
return (objectCache.get(gameObjectType).containsKey(uuid));
public static java.util.Collection<AbstractGameObject> getList(GameObjectType gameObjectType) {
}
if (objectCache.get(gameObjectType) == null)
return null;
public static AbstractGameObject getFromCache(GameObjectType gameObjectType, int uuid) {
return objectCache.get(gameObjectType).values();
}
if (objectCache.get(gameObjectType) == null)
return null;
public static PreparedStatement prepareStatement(String sql) throws SQLException {
return getConnection().prepareStatement(sql, 1);
}
return objectCache.get(gameObjectType).get(uuid);
public static ConcurrentHashMap<Integer, AbstractGameObject> getMap(
GameObjectType gameObjectType) {
}
if (objectCache.get(gameObjectType) == null)
return null;
return objectCache.get(gameObjectType);
}
public static void printCacheCount(PlayerCharacter pc) {
ChatManager.chatSystemInfo(pc, "Cache Lists");
for (GameObjectType gameObjectType : GameObjectType.values()) {
if (objectCache.get(gameObjectType) == null)
continue;
String ret = gameObjectType.name() + ": " + objectCache.get(gameObjectType).size();
ChatManager.chatSystemInfo(pc, ret + '\n');
}
}
/**
* @return the conn
*/
//XXX I think we have a severe resource leak here! No one is putting the connections back!
public static Connection getConnection() {
try {
return DbManager.connectionPool.getConnection();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
public static void configureConnectionPool() {
HikariConfig config = new HikariConfig();
int connectionCount = (Runtime.getRuntime().availableProcessors() * 2) + 1;
config.setMaximumPoolSize(connectionCount);
config.setJdbcUrl("jdbc:mysql://" + ConfigManager.MB_DATABASE_ADDRESS.getValue() +
":" + ConfigManager.MB_DATABASE_PORT.getValue() + "/" +
ConfigManager.MB_DATABASE_NAME.getValue());
config.setUsername(ConfigManager.MB_DATABASE_USER.getValue());
config.setPassword(ConfigManager.MB_DATABASE_PASS.getValue());
// Must be set lower than SQL server connection lifetime!
config.addDataSourceProperty("maxLifetime", "3600000");
config.addDataSourceProperty("characterEncoding", "utf8");
config.addDataSourceProperty("useServerPrepStmts", "true");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "500");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
public static void removeFromCache(GameObjectType gameObjectType, int uuid) {
config.addDataSourceProperty("leakDetectionThreshold", "5000");
config.addDataSourceProperty("cacheServerConfiguration", "true");
AbstractGameObject abstractGameObject;
connectionPool = new HikariDataSource(config); // setup the connection pool
if (objectCache.get(gameObjectType) == null)
return;
abstractGameObject = objectCache.get(gameObjectType).get(uuid);
if (abstractGameObject == null)
return;
removeFromCache(abstractGameObject);
}
public static void removeFromCache(AbstractGameObject abstractGameObject) {
if (abstractGameObject == null)
return;
if (objectCache.get(abstractGameObject.getObjectType()) == null)
return;
// Remove object from game cache
objectCache.get(abstractGameObject.getObjectType()).remove(abstractGameObject.getObjectUUID());
// Release bounds as we're dispensing with this object.
if (abstractGameObject instanceof AbstractWorldObject) {
AbstractWorldObject abstractWorldObject = (AbstractWorldObject)abstractGameObject;
if (abstractWorldObject.getBounds() != null) {
abstractWorldObject.getBounds().release();
abstractWorldObject.setBounds(null);
}
}
}
public static boolean addToCache(AbstractGameObject gameObject) {
boolean isWorldServer = ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER);
if (!isWorldServer) {
if (MBServerStatics.SKIP_CACHE_LOGIN)
return true;
if (MBServerStatics.SKIP_CACHE_LOGIN_PLAYER
&& (gameObject.getObjectType() == GameObjectType.PlayerCharacter))
return true;
if (MBServerStatics.SKIP_CACHE_LOGIN_ITEM &&
(gameObject.getObjectType() == GameObjectType.Item))
return true;
}
// First time this object type has been cached. Create the hashmap.
if (objectCache.get(gameObject.getObjectType()) == null) {
int initialCapacity;
// Provide initial sizing hints
switch (gameObject.getObjectType()) {
case Building:
initialCapacity = 46900;
break;
case Mob:
initialCapacity = 11700;
break;
case NPC:
initialCapacity = 900;
break;
case Zone:
initialCapacity = 1070;
break;
case Account:
initialCapacity = 10000;
break;
case Guild:
initialCapacity = 100;
break;
case ItemContainer:
initialCapacity = 100;
break;
case Item:
initialCapacity = 1000;
break;
case MobLoot:
initialCapacity = 10000;
break;
case PlayerCharacter:
initialCapacity = 100;
break;
default:
initialCapacity = 100; // Lookup api default should be ok for small maps
break;
}
objectCache.put(gameObject.getObjectType(), new ConcurrentHashMap<>(initialCapacity));
}
// Add the object to the cache. This will overwrite the current map entry.
objectCache.get(gameObject.getObjectType()).put(gameObject.getObjectUUID(), gameObject);
return true;
}
public static java.util.Collection<AbstractGameObject> getList(GameObjectType gameObjectType) {
if (objectCache.get(gameObjectType) == null)
return null;
return objectCache.get(gameObjectType).values();
}
public static PreparedStatement prepareStatement(String sql) throws SQLException {
return getConnection().prepareStatement(sql, 1);
}
// Omg refactor this out, somebody!
public static ConcurrentHashMap<Integer, AbstractGameObject> getMap(
GameObjectType gameObjectType) {
if (objectCache.get(gameObjectType) == null)
return null;
return objectCache.get(gameObjectType);
}
public static void printCacheCount(PlayerCharacter pc) {
ChatManager.chatSystemInfo(pc, "Cache Lists");
for (GameObjectType gameObjectType : GameObjectType.values()) {
if (objectCache.get(gameObjectType) == null)
continue;
String ret = gameObjectType.name() + ": " + objectCache.get(gameObjectType).size();
ChatManager.chatSystemInfo(pc, ret + '\n');
}
}
/**
* @return the conn
*/
//XXX I think we have a severe resource leak here! No one is putting the connections back!
public static Connection getConnection() {
try {
return DbManager.connectionPool.getConnection();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
public static final dbAccountHandler AccountQueries = new dbAccountHandler();
public static final dbBaneHandler BaneQueries = new dbBaneHandler();
public static final dbBaseClassHandler BaseClassQueries = new dbBaseClassHandler();
public static final dbBuildingHandler BuildingQueries = new dbBuildingHandler();
public static final dbBuildingLocationHandler BuildingLocationQueries = new dbBuildingLocationHandler();
public static final dbCharacterPowerHandler CharacterPowerQueries = new dbCharacterPowerHandler();
public static final dbCharacterRuneHandler CharacterRuneQueries = new dbCharacterRuneHandler();
public static final dbCharacterSkillHandler CharacterSkillQueries = new dbCharacterSkillHandler();
public static final dbCityHandler CityQueries = new dbCityHandler();
public static final dbContractHandler ContractQueries = new dbContractHandler();
public static final dbWarehouseHandler WarehouseQueries = new dbWarehouseHandler();
public static final dbCSSessionHandler CSSessionQueries = new dbCSSessionHandler();
public static final dbEnchantmentHandler EnchantmentQueries = new dbEnchantmentHandler();
public static final dbEffectsResourceCostHandler EffectsResourceCostsQueries = new dbEffectsResourceCostHandler();
public static final dbGuildHandler GuildQueries = new dbGuildHandler();
public static final dbItemHandler ItemQueries = new dbItemHandler();
public static final dbItemBaseHandler ItemBaseQueries = new dbItemBaseHandler();
public static final dbKitHandler KitQueries = new dbKitHandler();
public static final dbLootTableHandler LootQueries = new dbLootTableHandler();
public static final dbMenuHandler MenuQueries = new dbMenuHandler();
public static final dbMineHandler MineQueries = new dbMineHandler();
public static final dbMobHandler MobQueries = new dbMobHandler();
public static final dbMobBaseHandler MobBaseQueries = new dbMobBaseHandler();
public static final dbNPCHandler NPCQueries = new dbNPCHandler();
public static final dbPlayerCharacterHandler PlayerCharacterQueries = new dbPlayerCharacterHandler();
public static final dbPromotionClassHandler PromotionQueries = new dbPromotionClassHandler();
public static final dbRaceHandler RaceQueries = new dbRaceHandler();
public static final dbResistHandler ResistQueries = new dbResistHandler();
public static final dbRuneBaseAttributeHandler RuneBaseAttributeQueries = new dbRuneBaseAttributeHandler();
public static final dbRuneBaseEffectHandler RuneBaseEffectQueries = new dbRuneBaseEffectHandler();
public static final dbRuneBaseHandler RuneBaseQueries = new dbRuneBaseHandler();
public static final dbSkillBaseHandler SkillsBaseQueries = new dbSkillBaseHandler();
public static final dbSkillReqHandler SkillReqQueries = new dbSkillReqHandler();
public static final dbVendorDialogHandler VendorDialogQueries = new dbVendorDialogHandler();
public static final dbZoneHandler ZoneQueries = new dbZoneHandler();
public static final dbRealmHandler RealmQueries = new dbRealmHandler();
public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler();
public static final dbBoonHandler BoonQueries = new dbBoonHandler();
public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
public static final dbHeightMapHandler HeightMapQueries = new dbHeightMapHandler();
public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler();
public static void configureConnectionPool() {
HikariConfig config = new HikariConfig();
int connectionCount = (Runtime.getRuntime().availableProcessors() * 2) + 1;
config.setMaximumPoolSize(connectionCount);
config.setJdbcUrl("jdbc:mysql://" + ConfigManager.MB_DATABASE_ADDRESS.getValue() +
":" + ConfigManager.MB_DATABASE_PORT.getValue() + "/" +
ConfigManager.MB_DATABASE_NAME.getValue());
config.setUsername(ConfigManager.MB_DATABASE_USER.getValue());
config.setPassword(ConfigManager.MB_DATABASE_PASS.getValue());
// Must be set lower than SQL server connection lifetime!
config.addDataSourceProperty("maxLifetime", "3600000");
config.addDataSourceProperty("characterEncoding", "utf8");
config.addDataSourceProperty("useServerPrepStmts", "true");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "500");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty("leakDetectionThreshold", "5000");
config.addDataSourceProperty("cacheServerConfiguration", "true");
connectionPool = new HikariDataSource(config); // setup the connection pool
Logger.info("Database configured with " + connectionCount + " connections");
}
Logger.info("Database configured with " + connectionCount + " connections");
}
}
+176 -175
View File
@@ -22,202 +22,203 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
public enum DevCmdManager {
DEV_CMD_MANAGER;
DEV_CMD_MANAGER;
public static ConcurrentHashMap<String, AbstractDevCmd> devCmds;
public static ConcurrentHashMap<String, AbstractDevCmd> devCmds;
DevCmdManager() {
init();
}
public static void init() {
DevCmdManager.devCmds = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
DevCmdManager.registerCommands();
}
DevCmdManager() {
init();
}
/**
*
*/
private static void registerCommands() {
// Player
DevCmdManager.registerDevCmd(new DistanceCmd());;
DevCmdManager.registerDevCmd(new HelpCmd());
DevCmdManager.registerDevCmd(new GetZoneCmd());
DevCmdManager.registerDevCmd(new GetZoneMobsCmd());
DevCmdManager.registerDevCmd(new PrintBankCmd());
DevCmdManager.registerDevCmd(new PrintEquipCmd());
DevCmdManager.registerDevCmd(new PrintInventoryCmd());
DevCmdManager.registerDevCmd(new PrintVaultCmd());
DevCmdManager.registerDevCmd(new PrintStatsCmd());
DevCmdManager.registerDevCmd(new PrintSkillsCmd());
DevCmdManager.registerDevCmd(new PrintPowersCmd());
DevCmdManager.registerDevCmd(new PrintBonusesCmd());
DevCmdManager.registerDevCmd(new PrintResistsCmd());
DevCmdManager.registerDevCmd(new PrintLocationCmd());
DevCmdManager.registerDevCmd(new InfoCmd());
DevCmdManager.registerDevCmd(new aiInfoCmd());
DevCmdManager.registerDevCmd(new simulateBootyCmd());
DevCmdManager.registerDevCmd(new GetHeightCmd());
public static void init() {
DevCmdManager.devCmds = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
DevCmdManager.registerCommands();
}
// Tester
DevCmdManager.registerDevCmd(new JumpCmd());
DevCmdManager.registerDevCmd(new GotoCmd());
DevCmdManager.registerDevCmd(new SummonCmd());
DevCmdManager.registerDevCmd(new SetHealthCmd());
DevCmdManager.registerDevCmd(new SetManaCmd());
DevCmdManager.registerDevCmd(new SetStaminaCmd());
DevCmdManager.registerDevCmd(new FindBuildingsCmd());
DevCmdManager.registerDevCmd(new TeleportModeCmd());
DevCmdManager.registerDevCmd(new SetLevelCmd());
DevCmdManager.registerDevCmd(new SetBaseClassCmd());
DevCmdManager.registerDevCmd(new SetPromotionClassCmd());
DevCmdManager.registerDevCmd(new EffectCmd());
DevCmdManager.registerDevCmd(new SetRuneCmd());
DevCmdManager.registerDevCmd(new GetOffsetCmd());
DevCmdManager.registerDevCmd(new DebugCmd());
DevCmdManager.registerDevCmd(new AddGoldCmd());
DevCmdManager.registerDevCmd(new ZoneInfoCmd());
DevCmdManager.registerDevCmd(new DebugMeleeSyncCmd());
DevCmdManager.registerDevCmd(new HotzoneCmd());
DevCmdManager.registerDevCmd(new MineActiveCmd());
// Dev
DevCmdManager.registerDevCmd(new ApplyStatModCmd());
DevCmdManager.registerDevCmd(new AddBuildingCmd());
DevCmdManager.registerDevCmd(new AddNPCCmd());
DevCmdManager.registerDevCmd(new AddMobCmd());
DevCmdManager.registerDevCmd(new RemoveObjectCmd());
DevCmdManager.registerDevCmd(new RotateCmd());
DevCmdManager.registerDevCmd(new FlashMsgCmd());
DevCmdManager.registerDevCmd(new SysMsgCmd());
DevCmdManager.registerDevCmd(new GetBankCmd());
DevCmdManager.registerDevCmd(new GetVaultCmd());
DevCmdManager.registerDevCmd(new CombatMessageCmd());
DevCmdManager.registerDevCmd(new RenameCmd());
DevCmdManager.registerDevCmd(new CreateItemCmd());
DevCmdManager.registerDevCmd(new GetMemoryCmd());
DevCmdManager.registerDevCmd(new SetRankCmd());
DevCmdManager.registerDevCmd(new MakeBaneCmd());
DevCmdManager.registerDevCmd(new RemoveBaneCmd());
DevCmdManager.registerDevCmd(new SetBaneActiveCmd());
DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
DevCmdManager.registerDevCmd(new SetInvulCmd());
DevCmdManager.registerDevCmd(new MakeItemCmd());
DevCmdManager.registerDevCmd(new EnchantCmd());
DevCmdManager.registerDevCmd(new SetSubRaceCmd());
// Admin
DevCmdManager.registerDevCmd(new GetCacheCountCmd());
DevCmdManager.registerDevCmd(new GetRuneDropRateCmd());
DevCmdManager.registerDevCmd(new DecachePlayerCmd());
DevCmdManager.registerDevCmd(new AuditMobsCmd());
DevCmdManager.registerDevCmd(new ChangeNameCmd());
DevCmdManager.registerDevCmd(new SetGuildCmd());
DevCmdManager.registerDevCmd(new SetOwnerCmd());
DevCmdManager.registerDevCmd(new NetDebugCmd());
DevCmdManager.registerDevCmd(new SqlDebugCmd());
DevCmdManager.registerDevCmd(new PullCmd());
DevCmdManager.registerDevCmd(new PurgeObjectsCmd());
DevCmdManager.registerDevCmd(new SplatMobCmd());
DevCmdManager.registerDevCmd(new SlotNpcCmd());
DevCmdManager.registerDevCmd(new SetAICmd());
DevCmdManager.registerDevCmd(new GateInfoCmd());
DevCmdManager.registerDevCmd(new ShowOffsetCmd());
DevCmdManager.registerDevCmd(new RealmInfoCmd());
DevCmdManager.registerDevCmd(new RebootCmd());
DevCmdManager.registerDevCmd(new SetMineTypeCmd());
DevCmdManager.registerDevCmd(new SetMineExpansion());
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
DevCmdManager.registerDevCmd(new GotoObj());
DevCmdManager.registerDevCmd(new convertLoc());
DevCmdManager.registerDevCmd(new GetMobBaseLoot());
DevCmdManager.registerDevCmd(new MBDropCmd());
DevCmdManager.registerDevCmd(new AuditHeightMapCmd());
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
DevCmdManager.registerDevCmd(new ResetLevelCmd());
DevCmdManager.registerDevCmd(new HeartbeatCmd());
DevCmdManager.registerDevCmd(new SetNpcNameCmd());
DevCmdManager.registerDevCmd(new SetNpcMobbaseCmd());
DevCmdManager.registerDevCmd(new DespawnCmd());
DevCmdManager.registerDevCmd(new BoundsCmd());
DevCmdManager.registerDevCmd(new GotoBoundsCmd());
DevCmdManager.registerDevCmd(new RegionCmd());
DevCmdManager.registerDevCmd(new SetMaintCmd());
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
DevCmdManager.registerDevCmd(new SlotTestCmd());
/**
*
*/
private static void registerCommands() {
}
// Player
DevCmdManager.registerDevCmd(new DistanceCmd());
;
DevCmdManager.registerDevCmd(new HelpCmd());
DevCmdManager.registerDevCmd(new GetZoneCmd());
DevCmdManager.registerDevCmd(new GetZoneMobsCmd());
DevCmdManager.registerDevCmd(new PrintBankCmd());
DevCmdManager.registerDevCmd(new PrintEquipCmd());
DevCmdManager.registerDevCmd(new PrintInventoryCmd());
DevCmdManager.registerDevCmd(new PrintVaultCmd());
DevCmdManager.registerDevCmd(new PrintStatsCmd());
DevCmdManager.registerDevCmd(new PrintSkillsCmd());
DevCmdManager.registerDevCmd(new PrintPowersCmd());
DevCmdManager.registerDevCmd(new PrintBonusesCmd());
DevCmdManager.registerDevCmd(new PrintResistsCmd());
DevCmdManager.registerDevCmd(new PrintLocationCmd());
DevCmdManager.registerDevCmd(new InfoCmd());
DevCmdManager.registerDevCmd(new aiInfoCmd());
DevCmdManager.registerDevCmd(new simulateBootyCmd());
DevCmdManager.registerDevCmd(new GetHeightCmd());
private static void registerDevCmd(AbstractDevCmd cmd) {
ArrayList<String> cmdStrings = cmd.getCmdStrings();
for (String cmdString : cmdStrings) {
DevCmdManager.devCmds.put(cmdString, cmd);
}
}
// Tester
DevCmdManager.registerDevCmd(new JumpCmd());
DevCmdManager.registerDevCmd(new GotoCmd());
DevCmdManager.registerDevCmd(new SummonCmd());
DevCmdManager.registerDevCmd(new SetHealthCmd());
DevCmdManager.registerDevCmd(new SetManaCmd());
DevCmdManager.registerDevCmd(new SetStaminaCmd());
DevCmdManager.registerDevCmd(new FindBuildingsCmd());
DevCmdManager.registerDevCmd(new TeleportModeCmd());
DevCmdManager.registerDevCmd(new SetLevelCmd());
DevCmdManager.registerDevCmd(new SetBaseClassCmd());
DevCmdManager.registerDevCmd(new SetPromotionClassCmd());
DevCmdManager.registerDevCmd(new EffectCmd());
DevCmdManager.registerDevCmd(new SetRuneCmd());
DevCmdManager.registerDevCmd(new GetOffsetCmd());
DevCmdManager.registerDevCmd(new DebugCmd());
DevCmdManager.registerDevCmd(new AddGoldCmd());
DevCmdManager.registerDevCmd(new ZoneInfoCmd());
DevCmdManager.registerDevCmd(new DebugMeleeSyncCmd());
DevCmdManager.registerDevCmd(new HotzoneCmd());
DevCmdManager.registerDevCmd(new MineActiveCmd());
// Dev
DevCmdManager.registerDevCmd(new ApplyStatModCmd());
DevCmdManager.registerDevCmd(new AddBuildingCmd());
DevCmdManager.registerDevCmd(new AddNPCCmd());
DevCmdManager.registerDevCmd(new AddMobCmd());
DevCmdManager.registerDevCmd(new RemoveObjectCmd());
DevCmdManager.registerDevCmd(new RotateCmd());
DevCmdManager.registerDevCmd(new FlashMsgCmd());
DevCmdManager.registerDevCmd(new SysMsgCmd());
DevCmdManager.registerDevCmd(new GetBankCmd());
DevCmdManager.registerDevCmd(new GetVaultCmd());
DevCmdManager.registerDevCmd(new CombatMessageCmd());
DevCmdManager.registerDevCmd(new RenameCmd());
DevCmdManager.registerDevCmd(new CreateItemCmd());
DevCmdManager.registerDevCmd(new GetMemoryCmd());
DevCmdManager.registerDevCmd(new SetRankCmd());
DevCmdManager.registerDevCmd(new MakeBaneCmd());
DevCmdManager.registerDevCmd(new RemoveBaneCmd());
DevCmdManager.registerDevCmd(new SetBaneActiveCmd());
DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
DevCmdManager.registerDevCmd(new SetInvulCmd());
DevCmdManager.registerDevCmd(new MakeItemCmd());
DevCmdManager.registerDevCmd(new EnchantCmd());
DevCmdManager.registerDevCmd(new SetSubRaceCmd());
// Admin
DevCmdManager.registerDevCmd(new GetCacheCountCmd());
DevCmdManager.registerDevCmd(new GetRuneDropRateCmd());
DevCmdManager.registerDevCmd(new DecachePlayerCmd());
DevCmdManager.registerDevCmd(new AuditMobsCmd());
DevCmdManager.registerDevCmd(new ChangeNameCmd());
DevCmdManager.registerDevCmd(new SetGuildCmd());
DevCmdManager.registerDevCmd(new SetOwnerCmd());
DevCmdManager.registerDevCmd(new NetDebugCmd());
DevCmdManager.registerDevCmd(new SqlDebugCmd());
DevCmdManager.registerDevCmd(new PullCmd());
DevCmdManager.registerDevCmd(new PurgeObjectsCmd());
DevCmdManager.registerDevCmd(new SplatMobCmd());
DevCmdManager.registerDevCmd(new SlotNpcCmd());
DevCmdManager.registerDevCmd(new SetAICmd());
DevCmdManager.registerDevCmd(new GateInfoCmd());
DevCmdManager.registerDevCmd(new ShowOffsetCmd());
DevCmdManager.registerDevCmd(new RealmInfoCmd());
DevCmdManager.registerDevCmd(new RebootCmd());
DevCmdManager.registerDevCmd(new SetMineTypeCmd());
DevCmdManager.registerDevCmd(new SetMineExpansion());
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
DevCmdManager.registerDevCmd(new GotoObj());
DevCmdManager.registerDevCmd(new convertLoc());
DevCmdManager.registerDevCmd(new GetMobBaseLoot());
DevCmdManager.registerDevCmd(new MBDropCmd());
DevCmdManager.registerDevCmd(new AuditHeightMapCmd());
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
DevCmdManager.registerDevCmd(new ResetLevelCmd());
DevCmdManager.registerDevCmd(new HeartbeatCmd());
DevCmdManager.registerDevCmd(new SetNpcNameCmd());
DevCmdManager.registerDevCmd(new SetNpcMobbaseCmd());
DevCmdManager.registerDevCmd(new DespawnCmd());
DevCmdManager.registerDevCmd(new BoundsCmd());
DevCmdManager.registerDevCmd(new GotoBoundsCmd());
DevCmdManager.registerDevCmd(new RegionCmd());
DevCmdManager.registerDevCmd(new SetMaintCmd());
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
DevCmdManager.registerDevCmd(new SlotTestCmd());
public static AbstractDevCmd getDevCmd(String cmd) {
String lowercase = cmd.toLowerCase();
return DevCmdManager.devCmds.get(lowercase);
}
}
public static boolean handleDevCmd(PlayerCharacter pcSender, String cmd,
String argString, AbstractGameObject target) {
private static void registerDevCmd(AbstractDevCmd cmd) {
ArrayList<String> cmdStrings = cmd.getCmdStrings();
for (String cmdString : cmdStrings) {
DevCmdManager.devCmds.put(cmdString, cmd);
}
}
if (pcSender == null) {
return false;
}
public static AbstractDevCmd getDevCmd(String cmd) {
String lowercase = cmd.toLowerCase();
return DevCmdManager.devCmds.get(lowercase);
}
Account a = SessionManager.getAccount(pcSender);
public static boolean handleDevCmd(PlayerCharacter pcSender, String cmd,
String argString, AbstractGameObject target) {
if (a == null) {
return false;
}
if (pcSender == null) {
return false;
}
AbstractDevCmd adc = DevCmdManager.getDevCmd(cmd);
Account a = SessionManager.getAccount(pcSender);
if (adc == null) {
return false;
}
if (a == null) {
return false;
}
//kill any commands not available to everyone on production server
//only admin level can run dev commands on production
AbstractDevCmd adc = DevCmdManager.getDevCmd(cmd);
if (a.status.equals(Enum.AccountStatus.ADMIN) == false) {
Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd);
return false;
}
if (adc == null) {
return false;
}
// TODO add a job here to separate calling thread form executing thread?
// Log
//kill any commands not available to everyone on production server
//only admin level can run dev commands on production
String accName = a.getUname();
String pcName = pcSender.getCombinedName();
String logString = pcName + '(' + accName
+ ") '";
logString += cmd + ' ' + argString + '\'';
Logger.info( logString);
DbManager.AccountQueries.WRITE_ADMIN_LOG(pcName, "COMMAND: " + cmd + " " + argString);
if (a.status.equals(Enum.AccountStatus.ADMIN) == false) {
Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd);
return false;
}
// execute command;
try {
adc.doCmd(pcSender, argString, target);
} catch (Exception e) {
Logger.error(e.toString());
e.printStackTrace();
}
// TODO add a job here to separate calling thread form executing thread?
// Log
return true;
}
String accName = a.getUname();
String pcName = pcSender.getCombinedName();
String logString = pcName + '(' + accName
+ ") '";
logString += cmd + ' ' + argString + '\'';
Logger.info(logString);
DbManager.AccountQueries.WRITE_ADMIN_LOG(pcName, "COMMAND: " + cmd + " " + argString);
public static String getCmdsForAccessLevel() {
String out = "";
// execute command;
try {
adc.doCmd(pcSender, argString, target);
} catch (Exception e) {
Logger.error(e.toString());
e.printStackTrace();
}
for (Entry<String, AbstractDevCmd> e : DevCmdManager.devCmds.entrySet())
out += e.getKey() + ", ";
return true;
}
return out;
}
public static String getCmdsForAccessLevel() {
String out = "";
for (Entry<String, AbstractDevCmd> e : DevCmdManager.devCmds.entrySet())
out += e.getKey() + ", ";
return out;
}
}
+9 -12
View File
@@ -304,7 +304,7 @@ public enum GroupManager {
public static boolean goldSplit(PlayerCharacter pc, Item item, ClientConnection origin, AbstractWorldObject tar) {
if (item == null || pc == null || tar == null || item.getItemBase() == null) {
Logger.error( "null something");
Logger.error("null something");
return false;
}
@@ -321,7 +321,7 @@ public enum GroupManager {
//get group members
for (PlayerCharacter groupMember: group.getMembers()){
for (PlayerCharacter groupMember : group.getMembers()) {
if (pc.getLoc().distanceSquared2D(groupMember.getLoc()) > MBServerStatics.CHARACTER_LOAD_RANGE * MBServerStatics.CHARACTER_LOAD_RANGE)
continue;
@@ -343,27 +343,24 @@ public enum GroupManager {
int dif = total - (size * amount);
if (AbstractWorldObject.IsAbstractCharacter(tar)) {
}
else if (tar.getObjectType().equals(Enum.GameObjectType.Corpse)) {
} else if (tar.getObjectType().equals(Enum.GameObjectType.Corpse)) {
Corpse corpse = (Corpse) tar;
corpse.getInventory().remove(item);
}
else {
} else {
Logger.error("target not corpse or character");
return false;
}
if (item.getObjectType() == Enum.GameObjectType.MobLoot){
if (tar.getObjectType() == Enum.GameObjectType.Mob){
((Mob)tar).getCharItemManager().delete(item);
}else
if (item.getObjectType() == Enum.GameObjectType.MobLoot) {
if (tar.getObjectType() == Enum.GameObjectType.Mob) {
((Mob) tar).getCharItemManager().delete(item);
} else
item.setNumOfItems(0);
}else
} else
item.setNumOfItems(0);
for (PlayerCharacter splitPlayer : playersSplit) {
int amt = (group.isGroupLead(splitPlayer)) ? (amount + dif) : amount;
if (amt > 0)
splitPlayer.getCharItemManager().addGoldToInventory(amt, false);
+137 -139
View File
@@ -19,188 +19,186 @@ import engine.net.client.msg.guild.GuildInfoMsg;
import engine.objects.*;
import org.joda.time.DateTime;
public enum GuildManager {
public enum GuildManager {
GUILDMANAGER;
GUILDMANAGER;
//Guild Error Message
public static final int FAILURE_TO_SWEAR_GUILD = 45; //45: Failure to swear guild
public static final int MUST_LEAVE_GUILD = 75;//75: You must leave your current guild before you can repledge
public static final int NO_CHARTER_FOUND = 148; //148: Unable to find a matching petition to complete guild creation
public static final int PROFANE_NAME = 149; //149: Guild name fails profanity check
public static final int PROFANE_MOTTO = 150; //150: Guild motto fails profanity check
public static final int UNIQUE_NAME = 151;//151: Guild name is not unique
public static final int UNIQUE_CREST = 152;//152: Guild crest is not unique
public static final int CREST_RESERVED = 153; //153: Guild crest is reserved
public static final int CREST_COLOR_ERROR = 154; //154: All three crest colors cannot be the same
//Guild Error Message
public static final int FAILURE_TO_SWEAR_GUILD = 45; //45: Failure to swear guild
public static final int MUST_LEAVE_GUILD = 75;//75: You must leave your current guild before you can repledge
public static final int NO_CHARTER_FOUND = 148; //148: Unable to find a matching petition to complete guild creation
public static final int PROFANE_NAME = 149; //149: Guild name fails profanity check
public static final int PROFANE_MOTTO = 150; //150: Guild motto fails profanity check
public static final int UNIQUE_NAME = 151;//151: Guild name is not unique
public static final int UNIQUE_CREST = 152;//152: Guild crest is not unique
public static final int CREST_RESERVED = 153; //153: Guild crest is reserved
public static final int CREST_COLOR_ERROR = 154; //154: All three crest colors cannot be the same
public static boolean joinGuild(PlayerCharacter pc, Guild guild, GuildHistoryType historyType) {
return joinGuild(pc, guild, 0, historyType);
}
public static boolean joinGuild(PlayerCharacter pc, Guild guild, GuildHistoryType historyType) {
return joinGuild(pc, guild, 0, historyType);
}
//Used when repledging
public static boolean joinGuild(PlayerCharacter pc, Guild guild, int cityID, GuildHistoryType historyType) {
return joinGuild(pc, guild, cityID, true,historyType);
}
//Used when repledging
public static boolean joinGuild(PlayerCharacter pc, Guild guild, int cityID, GuildHistoryType historyType) {
return joinGuild(pc, guild, cityID, true, historyType);
}
public static boolean joinGuild(PlayerCharacter playerCharacter, Guild guild, int cityID, boolean fromTeleportScreen, GuildHistoryType historyType) {
public static boolean joinGuild(PlayerCharacter playerCharacter, Guild guild, int cityID, boolean fromTeleportScreen, GuildHistoryType historyType) {
// Member variable delcaration
// Member variable delcaration
ClientConnection origin;
AcceptInviteToGuildMsg msg;
Dispatch dispatch;
ClientConnection origin;
AcceptInviteToGuildMsg msg;
Dispatch dispatch;
if (playerCharacter == null || guild == null)
return false;
if (playerCharacter == null || guild == null)
return false;
// Member variable assignment
// Member variable assignment
origin = SessionManager.getClientConnection(playerCharacter);
origin = SessionManager.getClientConnection(playerCharacter);
if (origin == null)
return false;
if (origin == null)
return false;
if (playerCharacter.getGuild().isEmptyGuild() == false && GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus()))
return false;
if (playerCharacter.getGuild().isEmptyGuild() == false && GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus()))
return false;
if (playerCharacter.getGuild() != null && playerCharacter.getGuild().isGuildLeader(playerCharacter.getObjectUUID()))
return false;
if (playerCharacter.getGuild() != null && playerCharacter.getGuild().isGuildLeader(playerCharacter.getObjectUUID()))
return false;
if (playerCharacter.getGuild() != null && !playerCharacter.getGuild().isEmptyGuild()){
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(playerCharacter.getGuildUUID(), playerCharacter, DateTime.now(), GuildHistoryType.LEAVE)){
GuildHistory guildHistory = new GuildHistory(playerCharacter.getGuildUUID(),playerCharacter.getGuild().getName(),DateTime.now(), GuildHistoryType.LEAVE) ;
playerCharacter.getGuildHistory().add(guildHistory);
}
}
if (playerCharacter.getGuild() != null && !playerCharacter.getGuild().isEmptyGuild()) {
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(playerCharacter.getGuildUUID(), playerCharacter, DateTime.now(), GuildHistoryType.LEAVE)) {
GuildHistory guildHistory = new GuildHistory(playerCharacter.getGuildUUID(), playerCharacter.getGuild().getName(), DateTime.now(), GuildHistoryType.LEAVE);
playerCharacter.getGuildHistory().add(guildHistory);
}
}
playerCharacter.setInnerCouncil(false);
playerCharacter.setGuildLeader(false);
playerCharacter.setGuild(guild);
playerCharacter.setInnerCouncil(false);
playerCharacter.setGuildLeader(false);
playerCharacter.setGuild(guild);
// Cleanup guild stuff
playerCharacter.resetGuildStatuses();
// Cleanup guild stuff
playerCharacter.resetGuildStatuses();
// send success message to client
if (fromTeleportScreen && guild.isNPCGuild())
playerCharacter.setFullMember(true);
// send success message to client
if (fromTeleportScreen && guild.isNPCGuild())
playerCharacter.setFullMember(true);
msg = new AcceptInviteToGuildMsg(guild.getObjectUUID(), 1, 0);
msg = new AcceptInviteToGuildMsg(guild.getObjectUUID(), 1, 0);
if (fromTeleportScreen) {
dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
}
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), playerCharacter, DateTime.now(), historyType)){
GuildHistory guildHistory = new GuildHistory(guild.getObjectUUID(),guild.getName(),DateTime.now(), historyType) ;
playerCharacter.getGuildHistory().add(guildHistory);
}
if (fromTeleportScreen) {
dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
}
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), playerCharacter, DateTime.now(), historyType)) {
GuildHistory guildHistory = new GuildHistory(guild.getObjectUUID(), guild.getName(), DateTime.now(), historyType);
playerCharacter.getGuildHistory().add(guildHistory);
}
DispatchMessage.sendToAllInRange(playerCharacter, new GuildInfoMsg(playerCharacter, guild, 2));
DispatchMessage.sendToAllInRange(playerCharacter, new GuildInfoMsg(playerCharacter, guild, 2));
// Send guild join message
ChatManager.chatGuildInfo(playerCharacter,
playerCharacter.getFirstName() + " has joined the guild");
// Send guild join message
ChatManager.chatGuildInfo(playerCharacter,
playerCharacter.getFirstName() + " has joined the guild");
playerCharacter.incVer();
playerCharacter.incVer();
return true;
// TODO update player to world
}
return true;
// TODO update player to world
}
public static void enterWorldMOTD(PlayerCharacter pc) {
public static void enterWorldMOTD(PlayerCharacter pc) {
Guild guild;
Guild nation;
Guild guild;
Guild nation;
if (pc == null) {
return;
}
if (pc == null) {
return;
}
guild = pc.getGuild();
guild = pc.getGuild();
if (guild == null || guild.getObjectUUID() == 0) // Don't send to errant
return;
if (guild == null || guild.getObjectUUID() == 0) // Don't send to errant
return;
// Send Guild MOTD
String motd = guild.getMOTD();
if (motd.length() > 0) {
ChatManager.chatGuildMOTD(pc, motd);
}
// Send Guild MOTD
String motd = guild.getMOTD();
if (motd.length() > 0) {
ChatManager.chatGuildMOTD(pc, motd);
}
// Send Nation MOTD
nation = guild.getNation();
// Send Nation MOTD
nation = guild.getNation();
if (nation != null) {
if (nation.getObjectUUID() != 0) { // Don't send to errant nation
motd = nation.getMOTD();
if (motd.length() > 0) {
ChatManager.chatNationMOTD(pc, motd);
}
}
}
if (nation != null) {
if (nation.getObjectUUID() != 0) { // Don't send to errant nation
motd = nation.getMOTD();
if (motd.length() > 0) {
ChatManager.chatNationMOTD(pc, motd);
}
}
}
// Send IC MOTD if player is IC
if (GuildStatusController.isInnerCouncil(pc.getGuildStatus())) {
motd = guild.getICMOTD();
if (motd.length() > 0) {
ChatManager.chatICMOTD(pc, motd);
}
}
}
// Send IC MOTD if player is IC
if (GuildStatusController.isInnerCouncil(pc.getGuildStatus())) {
motd = guild.getICMOTD();
if (motd.length() > 0) {
ChatManager.chatICMOTD(pc, motd);
}
}
}
//Updates the bind point for everyone in guild
//Updates the bind point for everyone in guild
public static void updateAllGuildBinds(Guild guild, City city) {
public static void updateAllGuildBinds(Guild guild, City city) {
if (guild == null)
return;
if (guild == null)
return;
int cityID = (city != null) ? city.getObjectUUID() : 0;
int cityID = (city != null) ? city.getObjectUUID() : 0;
//update binds ingame
for (PlayerCharacter playerCharacter : Guild.GuildRoster(guild)) {
boolean updateBindBuilding = false;
Building oldBoundBuilding = BuildingManager.getBuildingFromCache(playerCharacter.getBindBuildingID());
if (oldBoundBuilding == null || oldBoundBuilding.getBlueprint() == null || oldBoundBuilding.getBlueprint().getBuildingGroup().equals(BuildingGroup.TOL))
updateBindBuilding = true;
if (updateBindBuilding){
Building bindBuilding = null;
if (city != null)
if (city.getTOL() != null)
bindBuilding = city.getTOL();
if (bindBuilding == null)
bindBuilding = PlayerCharacter.getBindBuildingForGuild(playerCharacter);
playerCharacter.setBindBuildingID(bindBuilding != null ? bindBuilding.getObjectUUID() : 0);
}
//update binds ingame
}
}
//This updates tags for all online players in a guild.
public static void updateAllGuildTags(Guild guild) {
for (PlayerCharacter playerCharacter : Guild.GuildRoster(guild)) {
boolean updateBindBuilding = false;
if (guild == null)
return;
Building oldBoundBuilding = BuildingManager.getBuildingFromCache(playerCharacter.getBindBuildingID());
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
if (oldBoundBuilding == null || oldBoundBuilding.getBlueprint() == null || oldBoundBuilding.getBlueprint().getBuildingGroup().equals(BuildingGroup.TOL))
updateBindBuilding = true;
if (player.getGuild().equals(guild))
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player , guild, 2));
}
}
if (updateBindBuilding) {
Building bindBuilding = null;
if (city != null)
if (city.getTOL() != null)
bindBuilding = city.getTOL();
if (bindBuilding == null)
bindBuilding = PlayerCharacter.getBindBuildingForGuild(playerCharacter);
playerCharacter.setBindBuildingID(bindBuilding != null ? bindBuilding.getObjectUUID() : 0);
}
}
}
//This updates tags for all online players in a guild.
public static void updateAllGuildTags(Guild guild) {
if (guild == null)
return;
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
if (player.getGuild().equals(guild))
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, guild, 2));
}
}
}
@@ -122,7 +122,7 @@ public enum MaintenanceManager {
//no maintenance if day of week doesnt match
if(LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()){
if (LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()) {
continue;
}
// Add building to maintenance queue
+437 -442
View File
@@ -32,474 +32,469 @@ import static engine.math.FastMath.sqr;
public enum MovementManager {
MOVEMENTMANAGER;
MOVEMENTMANAGER;
private static final String changeAltitudeTimerJobName = "ChangeHeight";
private static final String flightTimerJobName = "Flight";
private static final String changeAltitudeTimerJobName = "ChangeHeight";
private static final String flightTimerJobName = "Flight";
public static void sendOOS(PlayerCharacter pc) {
pc.setWalkMode(true);
MovementManager.sendRWSSMsg(pc);
}
public static void sendOOS(PlayerCharacter pc) {
pc.setWalkMode(true);
MovementManager.sendRWSSMsg(pc);
}
public static void sendRWSSMsg(AbstractCharacter ac) {
public static void sendRWSSMsg(AbstractCharacter ac) {
if (!ac.isAlive())
return;
UpdateStateMsg rssm = new UpdateStateMsg();
rssm.setPlayer(ac);
if (ac.getObjectType() == GameObjectType.PlayerCharacter)
DispatchMessage.dispatchMsgToInterestArea(ac, rssm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
else
DispatchMessage.sendToAllInRange(ac, rssm);
}
if (!ac.isAlive())
return;
UpdateStateMsg rssm = new UpdateStateMsg();
rssm.setPlayer(ac);
if (ac.getObjectType() == GameObjectType.PlayerCharacter)
DispatchMessage.dispatchMsgToInterestArea(ac, rssm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
else
DispatchMessage.sendToAllInRange(ac, rssm);
}
/*
* Sets the first combat target for the AbstractCharacter. Used to clear the
* combat
* target upon each move, unless something has set the firstHitCombatTarget
* Also used to determine the size of a monster's hitbox
*/
public static void movement(MoveToPointMsg msg, AbstractCharacter toMove) throws MsgSendException {
/*
* Sets the first combat target for the AbstractCharacter. Used to clear the
* combat
* target upon each move, unless something has set the firstHitCombatTarget
* Also used to determine the size of a monster's hitbox
*/
public static void movement(MoveToPointMsg msg, AbstractCharacter toMove) throws MsgSendException {
// check for stun/root
if (!toMove.isAlive())
return;
// check for stun/root
if (!toMove.isAlive())
return;
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)){
if (((PlayerCharacter)toMove).isCasting())
((PlayerCharacter)toMove).update();
}
toMove.setIsCasting(false);
toMove.setItemCasting(false);
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
if (((PlayerCharacter) toMove).isCasting())
((PlayerCharacter) toMove).update();
}
toMove.setIsCasting(false);
toMove.setItemCasting(false);
if (toMove.getBonuses().getBool(ModType.Stunned, SourceType.None) || toMove.getBonuses().getBool(ModType.CannotMove, SourceType.None)) {
return;
}
if (msg.getEndLat() > MBServerStatics.MAX_WORLD_WIDTH)
msg.setEndLat((float) MBServerStatics.MAX_WORLD_WIDTH);
if (msg.getEndLon() < MBServerStatics.MAX_WORLD_HEIGHT) {
msg.setEndLon((float) MBServerStatics.MAX_WORLD_HEIGHT);
}
if (toMove.getBonuses().getBool(ModType.Stunned, SourceType.None) || toMove.getBonuses().getBool(ModType.CannotMove, SourceType.None)) {
return;
}
if (msg.getEndLat() > MBServerStatics.MAX_WORLD_WIDTH)
msg.setEndLat((float) MBServerStatics.MAX_WORLD_WIDTH);
if (msg.getEndLon() < MBServerStatics.MAX_WORLD_HEIGHT){
msg.setEndLon((float) MBServerStatics.MAX_WORLD_HEIGHT);
}
// if (msg.getEndLat() < 0)
// msg.setEndLat(0);
//
// if (msg.getEndLon() > 0)
// msg.setEndLon(0);
if (!toMove.isMoving())
toMove.resetLastSetLocUpdate();
else
toMove.update();
// Update movement for the player
// else if (toMove.getObjectType() == GameObjectType.Mob)
// ((Mob)toMove).updateLocation();
// get start and end locations for the move
Vector3fImmutable startLocation = new Vector3fImmutable(msg.getStartLat(), msg.getStartAlt(), msg.getStartLon());
Vector3fImmutable endLocation = new Vector3fImmutable(msg.getEndLat(), msg.getEndAlt(), msg.getEndLon());
// if (toMove.getObjectType() == GameObjectType.PlayerCharacter)
// if (msg.getEndAlt() == 0 && msg.getTargetID() == 0){
// MovementManager.sendRWSSMsg(toMove);
// }
//If in Building, let's see if we need to Fix
// if inside a building, convert both locations from the building local reference frame to the world reference frame
if (msg.getTargetID() > 0) {
Building building = BuildingManager.getBuildingFromCache(msg.getTargetID());
if (building != null) {
Vector3fImmutable convertLocEnd = new Vector3fImmutable(ZoneManager.convertLocalToWorld(building, endLocation));
// if (!Bounds.collide(convertLocEnd, b) || !b.loadObjectsInside()) {
// toMove.setInBuilding(-1);
// toMove.setInFloorID(-1);
// toMove.setInBuildingID(0);
// }
// else {
toMove.setInBuilding(msg.getInBuilding());
toMove.setInFloorID(msg.getUnknown01());
toMove.setInBuildingID(msg.getTargetID());
msg.setStartCoord(ZoneManager.convertWorldToLocal(building, toMove.getLoc()));
if (toMove.getObjectType() == GameObjectType.PlayerCharacter) {
if (convertLocEnd.distanceSquared2D(toMove.getLoc()) > 6000 * 6000) {
Logger.info( "ENDLOC:" + convertLocEnd.x + ',' + convertLocEnd.y + ',' + convertLocEnd.z +
',' + "GETLOC:" + toMove.getLoc().x + ',' + toMove.getLoc().y + ',' + toMove.getLoc().z + " Name " + ((PlayerCharacter) toMove).getCombinedName());
toMove.teleport(toMove.getLoc());
return;
}
}
startLocation = toMove.getLoc();
endLocation = convertLocEnd;
} else {
toMove.setInBuilding(-1);
toMove.setInFloorID(-1);
toMove.setInBuildingID(0);
//SYNC PLAYER
toMove.teleport(toMove.getLoc());
return;
}
} else {
toMove.setInBuildingID(0);
toMove.setInFloorID(-1);
toMove.setInBuilding(-1);
msg.setStartCoord(toMove.getLoc());
}
//make sure we set the correct player.
msg.setSourceType(toMove.getObjectType().ordinal());
msg.setSourceID(toMove.getObjectUUID());
//if player in region, modify location to local location of building. set target to building.
if (toMove.region != null) {
Building regionBuilding = Regions.GetBuildingForRegion(toMove.region);
if (regionBuilding != null) {
msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc()));
msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation));
msg.setInBuilding(toMove.region.level);
msg.setUnknown01(toMove.region.room);
msg.setTargetType(GameObjectType.Building.ordinal());
msg.setTargetID(regionBuilding.getObjectUUID());
}
} else {
toMove.setInBuildingID(0);
toMove.setInFloorID(-1);
toMove.setInBuilding(-1);
msg.setStartCoord(toMove.getLoc());
msg.setEndCoord(endLocation);
msg.setTargetType(0);
msg.setTargetID(0);
}
//checks sync between character and server, if out of sync, teleport player to original position and return.
if (toMove.getObjectType() == GameObjectType.PlayerCharacter) {
boolean startLocInSync = checkSync(toMove, startLocation, toMove.getLoc());
if (!startLocInSync){
syncLoc(toMove, toMove.getLoc(), startLocInSync);
return;
}
}
// set direction, based on the current location which has just been sync'd
// with the client and the calc'd destination
toMove.setFaceDir(endLocation.subtract2D(toMove.getLoc()).normalize());
boolean collide = false;
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
Vector3fImmutable collidePoint = Bounds.PlayerBuildingCollisionPoint((PlayerCharacter)toMove, toMove.getLoc(), endLocation);
if (collidePoint != null) {
msg.setEndCoord(collidePoint);
endLocation = collidePoint;
collide = true;
}
}
if (toMove.getObjectType() == GameObjectType.PlayerCharacter && ((PlayerCharacter) toMove).isTeleportMode()) {
toMove.teleport(endLocation);
return;
}
// move to end location, this can interrupt the current move
toMove.setEndLoc(endLocation);
// ChatManager.chatSystemInfo((PlayerCharacter)toMove, "Moving to " + Vector3fImmutable.toString(endLocation));
// make sure server knows player is not sitting
toMove.setSit(false);
// cancel any effects that break upon movement
toMove.cancelOnMove();
//cancel any attacks for manual move.
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) && msg.getUnknown02() == 0)
toMove.setCombatTarget(null);
// If it's not a player moving just send the message
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) == false) {
DispatchMessage.sendToAllInRange(toMove, msg);
return;
}
// If it's a player who is moving then we need to handle characters
// who should see the message via group follow
PlayerCharacter player = (PlayerCharacter) toMove;
player.setTimeStamp("lastMoveGate", System.currentTimeMillis());
if (collide)
DispatchMessage.dispatchMsgToInterestArea(player, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
else
DispatchMessage.dispatchMsgToInterestArea(player, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
// Handle formation movement if needed
if (player.getFollow() == false)
return;
City cityObject = null;
Zone serverZone = null;
serverZone = ZoneManager.findSmallestZone(player.getLoc());
cityObject = (City) DbManager.getFromCache(GameObjectType.City, serverZone.getPlayerCityUUID());
// Do not send group messages if player is on grid
if (cityObject != null)
return;
// If player is not in a group we can exit here
Group group = GroupManager.getGroup(player);
if (group == null)
return;
// Echo group movement messages
if (group.getGroupLead().getObjectUUID() == player.getObjectUUID())
moveGroup(player, player.getClientConnection(), msg);
}
if (!toMove.isMoving())
toMove.resetLastSetLocUpdate();
else
toMove.update();
// Update movement for the player
// else if (toMove.getObjectType() == GameObjectType.Mob)
// ((Mob)toMove).updateLocation();
// get start and end locations for the move
Vector3fImmutable startLocation = new Vector3fImmutable(msg.getStartLat(), msg.getStartAlt(), msg.getStartLon());
Vector3fImmutable endLocation = new Vector3fImmutable(msg.getEndLat(), msg.getEndAlt(), msg.getEndLon());
// if (toMove.getObjectType() == GameObjectType.PlayerCharacter)
// if (msg.getEndAlt() == 0 && msg.getTargetID() == 0){
// MovementManager.sendRWSSMsg(toMove);
// }
//If in Building, let's see if we need to Fix
// if inside a building, convert both locations from the building local reference frame to the world reference frame
if (msg.getTargetID() > 0) {
Building building = BuildingManager.getBuildingFromCache(msg.getTargetID());
if (building != null) {
Vector3fImmutable convertLocEnd = new Vector3fImmutable(ZoneManager.convertLocalToWorld(building, endLocation));
// if (!Bounds.collide(convertLocEnd, b) || !b.loadObjectsInside()) {
// toMove.setInBuilding(-1);
// toMove.setInFloorID(-1);
// toMove.setInBuildingID(0);
// }
// else {
toMove.setInBuilding(msg.getInBuilding());
toMove.setInFloorID(msg.getUnknown01());
toMove.setInBuildingID(msg.getTargetID());
msg.setStartCoord(ZoneManager.convertWorldToLocal(building, toMove.getLoc()));
if (toMove.getObjectType() == GameObjectType.PlayerCharacter) {
if (convertLocEnd.distanceSquared2D(toMove.getLoc()) > 6000 * 6000) {
Logger.info("ENDLOC:" + convertLocEnd.x + ',' + convertLocEnd.y + ',' + convertLocEnd.z +
',' + "GETLOC:" + toMove.getLoc().x + ',' + toMove.getLoc().y + ',' + toMove.getLoc().z + " Name " + ((PlayerCharacter) toMove).getCombinedName());
toMove.teleport(toMove.getLoc());
return;
}
}
startLocation = toMove.getLoc();
endLocation = convertLocEnd;
} else {
toMove.setInBuilding(-1);
toMove.setInFloorID(-1);
toMove.setInBuildingID(0);
//SYNC PLAYER
toMove.teleport(toMove.getLoc());
return;
}
/**
* compare client and server location to verify that the two are in sync
*
* @param ac the player character
* @param clientLoc location as reported by the client
* @param serverLoc location known to the server
* @return true if the two are in sync
*/
private static boolean checkSync(AbstractCharacter ac, Vector3fImmutable clientLoc, Vector3fImmutable serverLoc) {
} else {
toMove.setInBuildingID(0);
toMove.setInFloorID(-1);
toMove.setInBuilding(-1);
msg.setStartCoord(toMove.getLoc());
}
float desyncDist = clientLoc.distanceSquared2D(serverLoc);
//make sure we set the correct player.
msg.setSourceType(toMove.getObjectType().ordinal());
msg.setSourceID(toMove.getObjectUUID());
// desync logging
if (MBServerStatics.MOVEMENT_SYNC_DEBUG)
if (desyncDist > MBServerStatics.MOVEMENT_DESYNC_TOLERANCE * MBServerStatics.MOVEMENT_DESYNC_TOLERANCE)
// our current location server side is a calc of last known loc + direction + speed and known time of last update
Logger.debug("Movement out of sync for " + ac.getFirstName()
+ ", Server Loc: " + serverLoc.getX() + ' ' + serverLoc.getZ()
+ " , Client loc: " + clientLoc.getX() + ' ' + clientLoc.getZ()
+ " desync distance " + desyncDist
+ " moving=" + ac.isMoving());
else
Logger.debug( "Movement sync is good - desyncDist = " + desyncDist);
//if player in region, modify location to local location of building. set target to building.
if (toMove.region != null) {
Building regionBuilding = Regions.GetBuildingForRegion(toMove.region);
if (regionBuilding != null) {
msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc()));
msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation));
msg.setInBuilding(toMove.region.level);
msg.setUnknown01(toMove.region.room);
msg.setTargetType(GameObjectType.Building.ordinal());
msg.setTargetID(regionBuilding.getObjectUUID());
}
if (ac.getDebug(1) && ac.getObjectType().equals(GameObjectType.PlayerCharacter))
if (desyncDist > MBServerStatics.MOVEMENT_DESYNC_TOLERANCE * MBServerStatics.MOVEMENT_DESYNC_TOLERANCE) {
PlayerCharacter pc = (PlayerCharacter) ac;
ChatManager.chatSystemInfo(pc,
"Movement out of sync for " + ac.getFirstName()
+ ", Server Loc: " + serverLoc.getX() + ' ' + serverLoc.getZ()
+ " , Client loc: " + clientLoc.getX() + ' ' + clientLoc.getZ()
+ " desync distance " + desyncDist
+ " moving=" + ac.isMoving());
}
} else {
toMove.setInBuildingID(0);
toMove.setInFloorID(-1);
toMove.setInBuilding(-1);
msg.setStartCoord(toMove.getLoc());
msg.setEndCoord(endLocation);
msg.setTargetType(0);
msg.setTargetID(0);
}
// return indicator that the two are in sync or not
return (desyncDist < 100f * 100f);
//checks sync between character and server, if out of sync, teleport player to original position and return.
if (toMove.getObjectType() == GameObjectType.PlayerCharacter) {
boolean startLocInSync = checkSync(toMove, startLocation, toMove.getLoc());
}
if (!startLocInSync) {
syncLoc(toMove, toMove.getLoc(), startLocInSync);
return;
}
}
// set direction, based on the current location which has just been sync'd
// with the client and the calc'd destination
toMove.setFaceDir(endLocation.subtract2D(toMove.getLoc()).normalize());
public static void finishChangeAltitude(AbstractCharacter ac, float targetAlt) {
boolean collide = false;
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
Vector3fImmutable collidePoint = Bounds.PlayerBuildingCollisionPoint((PlayerCharacter) toMove, toMove.getLoc(), endLocation);
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) == false)
return;
if (collidePoint != null) {
msg.setEndCoord(collidePoint);
endLocation = collidePoint;
collide = true;
}
//reset the getLoc timer before we clear other timers
// otherwise the next call to getLoc will not be correct
ac.resetLastSetLocUpdate();
}
// call getLoc once as it processes loc to the ms
Vector3fImmutable curLoc = ac.getLoc();
if (toMove.getObjectType() == GameObjectType.PlayerCharacter && ((PlayerCharacter) toMove).isTeleportMode()) {
toMove.teleport(endLocation);
return;
}
// move to end location, this can interrupt the current move
toMove.setEndLoc(endLocation);
// ChatManager.chatSystemInfo((PlayerCharacter)toMove, "Moving to " + Vector3fImmutable.toString(endLocation));
if (MBServerStatics.MOVEMENT_SYNC_DEBUG)
Logger.info("Finished Alt change, setting the end location to "
+ ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ()
+ " moving=" + ac.isMoving()
+ " and current location is " + curLoc.getX() + ' ' + curLoc.getZ());
if (ac.getDebug(1) && ac.getObjectType().equals(GameObjectType.PlayerCharacter))
ChatManager.chatSystemInfo((PlayerCharacter) ac, "Finished Alt change, setting the end location to " + ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ() + " moving=" + ac.isMoving() + " and current location is " + curLoc.getX() + ' ' + curLoc.getZ());
//Send run/walk/sit/stand to tell the client we are flying / landing etc
ac.update();
ac.stopMovement(ac.getLoc());
if (ac.isAlive())
MovementManager.sendRWSSMsg(ac);
//Check collision again
}
// Handle formation movement in group
public static void moveGroup(PlayerCharacter pc, ClientConnection origin, MoveToPointMsg msg) throws MsgSendException {
// get forward vector
Vector3f faceDir = new Vector3f(pc.getFaceDir().x, 0, pc.getFaceDir().z).normalize();
// get perpendicular vector
Vector3f crossDir = new Vector3f(faceDir.z, 0, -faceDir.x);
//get source loc with altitude
Vector3f sLoc = new Vector3f(pc.getLoc().x, pc.getAltitude(), pc.getLoc().z);
Group group = GroupManager.getGroup(pc);
Set<PlayerCharacter> members = group.getMembers();
int pos = 0;
for (PlayerCharacter member : members) {
if (member == null)
continue;
if (member.getObjectUUID() == pc.getObjectUUID())
continue;
MoveToPointMsg groupMsg = new MoveToPointMsg(msg);
// Verify group member should be moved
pos++;
if (member.getFollow() != true)
continue;
//get member loc with altitude, then range against source loc
Vector3f mLoc = new Vector3f(member.getLoc().x, member.getAltitude(), member.getLoc().z);
if (sLoc.distanceSquared2D(mLoc) > sqr(MBServerStatics.FORMATION_RANGE))
continue;
//don't move if player has taken damage from another player in last 60 seconds
long lastAttacked = System.currentTimeMillis() - pc.getLastPlayerAttackTime();
if (lastAttacked < 60000)
continue;
if (!member.isAlive())
continue;
//don't move if player is stunned or rooted
PlayerBonuses bonus = member.getBonuses();
if (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotMove, SourceType.None))
continue;
member.update();
// All checks passed, let's move the player
// First get the offset position
Vector3f offset = Formation.getOffset(group.getFormation(), pos);
Vector3fImmutable destination = pc.getEndLoc();
// offset forwards or backwards
destination = destination.add(faceDir.mult(offset.z));
// offset left or right
destination = destination.add(crossDir.mult(offset.x));
// ArrayList<AbstractWorldObject> awoList = WorldGrid.INSTANCE.getObjectsInRangePartial(member, member.getLoc().distance2D(destination) +1000, MBServerStatics.MASK_BUILDING);
//
// boolean skip = false;
//
// for (AbstractWorldObject awo: awoList){
// Building building = (Building)awo;
//
// if (building.getBounds() != null){
// if (Bounds.collide(building, member.getLoc(), destination)){
// skip = true;
// break;
// }
//
// }
//
// }
//
// if (skip)
// continue;
// if (member.isMoving())
// member.stopMovement();
// Update player speed to match group lead speed and make standing
if (member.isSit() || (member.isWalk() != pc.isWalk())) {
member.setSit(false);
member.setWalkMode(pc.isWalk());
MovementManager.sendRWSSMsg(member);
}
//cancel any effects that break upon movement
member.cancelOnMove();
// send movement for other players to see
groupMsg.setSourceID(member.getObjectUUID());
groupMsg.setStartCoord(member.getLoc());
groupMsg.setEndCoord(destination);
groupMsg.clearTarget();
DispatchMessage.sendToAllInRange(member, groupMsg);
// update group member
member.setFaceDir(destination.subtract2D(member.getLoc()).normalize());
member.setEndLoc(destination);
}
}
public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc, Regions region) {
if (targetLoc == null)
return;
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
teleporter.stopMovement(targetLoc);
teleporter.setRegion(region);
//mobs ignore region sets for now.
if (teleporter.getObjectType().equals(GameObjectType.Mob)){
teleporter.setInBuildingID(0);
teleporter.setInBuilding(-1);
teleporter.setInFloorID(-1);
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
return;
}
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
//we shouldnt need to send teleport message to new area, as loadjob should pick it up.
// DispatchMessage.dispatchMsgToInterestArea(teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
if (teleporter.getObjectType().equals(GameObjectType.PlayerCharacter))
InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter)teleporter);
}
private static void syncLoc(AbstractCharacter ac, Vector3fImmutable clientLoc, boolean useClientLoc) {
ac.teleport(ac.getLoc());
}
// make sure server knows player is not sitting
toMove.setSit(false);
// cancel any effects that break upon movement
toMove.cancelOnMove();
//cancel any attacks for manual move.
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) && msg.getUnknown02() == 0)
toMove.setCombatTarget(null);
// If it's not a player moving just send the message
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) == false) {
DispatchMessage.sendToAllInRange(toMove, msg);
return;
}
// If it's a player who is moving then we need to handle characters
// who should see the message via group follow
PlayerCharacter player = (PlayerCharacter) toMove;
player.setTimeStamp("lastMoveGate", System.currentTimeMillis());
if (collide)
DispatchMessage.dispatchMsgToInterestArea(player, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
else
DispatchMessage.dispatchMsgToInterestArea(player, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
// Handle formation movement if needed
if (player.getFollow() == false)
return;
City cityObject = null;
Zone serverZone = null;
serverZone = ZoneManager.findSmallestZone(player.getLoc());
cityObject = (City) DbManager.getFromCache(GameObjectType.City, serverZone.getPlayerCityUUID());
// Do not send group messages if player is on grid
if (cityObject != null)
return;
// If player is not in a group we can exit here
Group group = GroupManager.getGroup(player);
if (group == null)
return;
// Echo group movement messages
if (group.getGroupLead().getObjectUUID() == player.getObjectUUID())
moveGroup(player, player.getClientConnection(), msg);
}
/**
* compare client and server location to verify that the two are in sync
*
* @param ac the player character
* @param clientLoc location as reported by the client
* @param serverLoc location known to the server
* @return true if the two are in sync
*/
private static boolean checkSync(AbstractCharacter ac, Vector3fImmutable clientLoc, Vector3fImmutable serverLoc) {
float desyncDist = clientLoc.distanceSquared2D(serverLoc);
// desync logging
if (MBServerStatics.MOVEMENT_SYNC_DEBUG)
if (desyncDist > MBServerStatics.MOVEMENT_DESYNC_TOLERANCE * MBServerStatics.MOVEMENT_DESYNC_TOLERANCE)
// our current location server side is a calc of last known loc + direction + speed and known time of last update
Logger.debug("Movement out of sync for " + ac.getFirstName()
+ ", Server Loc: " + serverLoc.getX() + ' ' + serverLoc.getZ()
+ " , Client loc: " + clientLoc.getX() + ' ' + clientLoc.getZ()
+ " desync distance " + desyncDist
+ " moving=" + ac.isMoving());
else
Logger.debug("Movement sync is good - desyncDist = " + desyncDist);
if (ac.getDebug(1) && ac.getObjectType().equals(GameObjectType.PlayerCharacter))
if (desyncDist > MBServerStatics.MOVEMENT_DESYNC_TOLERANCE * MBServerStatics.MOVEMENT_DESYNC_TOLERANCE) {
PlayerCharacter pc = (PlayerCharacter) ac;
ChatManager.chatSystemInfo(pc,
"Movement out of sync for " + ac.getFirstName()
+ ", Server Loc: " + serverLoc.getX() + ' ' + serverLoc.getZ()
+ " , Client loc: " + clientLoc.getX() + ' ' + clientLoc.getZ()
+ " desync distance " + desyncDist
+ " moving=" + ac.isMoving());
}
// return indicator that the two are in sync or not
return (desyncDist < 100f * 100f);
}
public static void finishChangeAltitude(AbstractCharacter ac, float targetAlt) {
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter) == false)
return;
//reset the getLoc timer before we clear other timers
// otherwise the next call to getLoc will not be correct
ac.resetLastSetLocUpdate();
// call getLoc once as it processes loc to the ms
Vector3fImmutable curLoc = ac.getLoc();
if (MBServerStatics.MOVEMENT_SYNC_DEBUG)
Logger.info("Finished Alt change, setting the end location to "
+ ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ()
+ " moving=" + ac.isMoving()
+ " and current location is " + curLoc.getX() + ' ' + curLoc.getZ());
if (ac.getDebug(1) && ac.getObjectType().equals(GameObjectType.PlayerCharacter))
ChatManager.chatSystemInfo((PlayerCharacter) ac, "Finished Alt change, setting the end location to " + ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ() + " moving=" + ac.isMoving() + " and current location is " + curLoc.getX() + ' ' + curLoc.getZ());
//Send run/walk/sit/stand to tell the client we are flying / landing etc
ac.update();
ac.stopMovement(ac.getLoc());
if (ac.isAlive())
MovementManager.sendRWSSMsg(ac);
//Check collision again
}
// Handle formation movement in group
public static void moveGroup(PlayerCharacter pc, ClientConnection origin, MoveToPointMsg msg) throws MsgSendException {
// get forward vector
Vector3f faceDir = new Vector3f(pc.getFaceDir().x, 0, pc.getFaceDir().z).normalize();
// get perpendicular vector
Vector3f crossDir = new Vector3f(faceDir.z, 0, -faceDir.x);
//get source loc with altitude
Vector3f sLoc = new Vector3f(pc.getLoc().x, pc.getAltitude(), pc.getLoc().z);
Group group = GroupManager.getGroup(pc);
Set<PlayerCharacter> members = group.getMembers();
int pos = 0;
for (PlayerCharacter member : members) {
if (member == null)
continue;
if (member.getObjectUUID() == pc.getObjectUUID())
continue;
MoveToPointMsg groupMsg = new MoveToPointMsg(msg);
// Verify group member should be moved
pos++;
if (member.getFollow() != true)
continue;
//get member loc with altitude, then range against source loc
Vector3f mLoc = new Vector3f(member.getLoc().x, member.getAltitude(), member.getLoc().z);
if (sLoc.distanceSquared2D(mLoc) > sqr(MBServerStatics.FORMATION_RANGE))
continue;
//don't move if player has taken damage from another player in last 60 seconds
long lastAttacked = System.currentTimeMillis() - pc.getLastPlayerAttackTime();
if (lastAttacked < 60000)
continue;
if (!member.isAlive())
continue;
//don't move if player is stunned or rooted
PlayerBonuses bonus = member.getBonuses();
if (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotMove, SourceType.None))
continue;
member.update();
// All checks passed, let's move the player
// First get the offset position
Vector3f offset = Formation.getOffset(group.getFormation(), pos);
Vector3fImmutable destination = pc.getEndLoc();
// offset forwards or backwards
destination = destination.add(faceDir.mult(offset.z));
// offset left or right
destination = destination.add(crossDir.mult(offset.x));
// ArrayList<AbstractWorldObject> awoList = WorldGrid.INSTANCE.getObjectsInRangePartial(member, member.getLoc().distance2D(destination) +1000, MBServerStatics.MASK_BUILDING);
//
// boolean skip = false;
//
// for (AbstractWorldObject awo: awoList){
// Building building = (Building)awo;
//
// if (building.getBounds() != null){
// if (Bounds.collide(building, member.getLoc(), destination)){
// skip = true;
// break;
// }
//
// }
//
// }
//
// if (skip)
// continue;
// if (member.isMoving())
// member.stopMovement();
// Update player speed to match group lead speed and make standing
if (member.isSit() || (member.isWalk() != pc.isWalk())) {
member.setSit(false);
member.setWalkMode(pc.isWalk());
MovementManager.sendRWSSMsg(member);
}
//cancel any effects that break upon movement
member.cancelOnMove();
// send movement for other players to see
groupMsg.setSourceID(member.getObjectUUID());
groupMsg.setStartCoord(member.getLoc());
groupMsg.setEndCoord(destination);
groupMsg.clearTarget();
DispatchMessage.sendToAllInRange(member, groupMsg);
// update group member
member.setFaceDir(destination.subtract2D(member.getLoc()).normalize());
member.setEndLoc(destination);
}
}
public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc, Regions region) {
if (targetLoc == null)
return;
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
teleporter.stopMovement(targetLoc);
teleporter.setRegion(region);
//mobs ignore region sets for now.
if (teleporter.getObjectType().equals(GameObjectType.Mob)) {
teleporter.setInBuildingID(0);
teleporter.setInBuilding(-1);
teleporter.setInFloorID(-1);
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
return;
}
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
//we shouldnt need to send teleport message to new area, as loadjob should pick it up.
// DispatchMessage.dispatchMsgToInterestArea(teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
if (teleporter.getObjectType().equals(GameObjectType.PlayerCharacter))
InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter) teleporter);
}
private static void syncLoc(AbstractCharacter ac, Vector3fImmutable clientLoc, boolean useClientLoc) {
ac.teleport(ac.getLoc());
}
}
-1
View File
@@ -199,7 +199,6 @@ public enum NPCManager {
}
public static void removeSiegeMinions(Mob mobile) {
for (Mob toRemove : mobile.siegeMinionMap.keySet()) {
File diff suppressed because it is too large Load Diff
+202 -205
View File
@@ -25,265 +25,262 @@ import java.util.concurrent.ConcurrentHashMap;
public enum SessionManager {
SESSIONMANAGER;
SESSIONMANAGER;
// TODO add session activity timestamping & timeout monitors
// TODO add session activity timestamping & timeout monitors
private static ConcurrentHashMap<SessionID, Session> sessionIDtoSession = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_HIGH);
private static ConcurrentHashMap<PlayerCharacter, Session> pcToSession = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_HIGH);
private static ConcurrentHashMap<Account, Session> accountToSession = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_HIGH);
private static ConcurrentHashMap<ClientConnection, Session> connToSession = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_HIGH);
public static int _maxPopulation = 0;
public static int _maxPopulation = 0;
private static ConcurrentHashMap<SessionID, Session> sessionIDtoSession = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_HIGH);
private static ConcurrentHashMap<PlayerCharacter, Session> pcToSession = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_HIGH);
private static ConcurrentHashMap<Account, Session> accountToSession = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_HIGH);
private static ConcurrentHashMap<ClientConnection, Session> connToSession = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_HIGH);
// 0 = login server
// 1 = gateway server
// 2 = all other servers
private static int crossServerBehavior = 2;
// 0 = login server
// 1 = gateway server
// 2 = all other servers
private static int crossServerBehavior = 2;
public static Session getNewSession(SessionID sesID, Account a, ClientConnection c) {
Session ses = new Session(sesID, a, c);
public static Session getNewSession(SessionID sesID, Account a, ClientConnection c) {
Session ses = new Session(sesID, a, c);
SessionManager.sessionIDtoSession.put(sesID, ses);
SessionManager.accountToSession.put(a, ses);
SessionManager.connToSession.put(c, ses);
SessionManager.sessionIDtoSession.put(sesID, ses);
SessionManager.accountToSession.put(a, ses);
SessionManager.connToSession.put(c, ses);
if (crossServerBehavior == 0)
if (!CSSession.addCrossServerSession(ByteUtils.byteArrayToSafeStringHex(c.getSecretKeyBytes()), a, c.getSocketChannel()
.socket().getInetAddress(), c.machineID))
Logger.warn("Failed to create cross server session: " + a.getUname());
if (crossServerBehavior == 0)
if (!CSSession.addCrossServerSession(ByteUtils.byteArrayToSafeStringHex(c.getSecretKeyBytes()), a, c.getSocketChannel()
.socket().getInetAddress(), c.machineID))
Logger.warn("Failed to create cross server session: " + a.getUname());
return ses;
}
return ses;
}
public static Session getNewSession(Account a, ClientConnection c) {
SessionID sesID = c.getSessionID();
return SessionManager.getNewSession(sesID, a, c);
}
public static Session getNewSession(Account a, ClientConnection c) {
SessionID sesID = c.getSessionID();
return SessionManager.getNewSession(sesID, a, c);
}
public static void cSessionCleanup(String key) {
if (!CSSession.deleteCrossServerSession(key))
Logger.warn(
"Failed to remove cross server session for key: " + key);
}
public static void cSessionCleanup(String key) {
if (!CSSession.deleteCrossServerSession(key))
Logger.warn(
"Failed to remove cross server session for key: " + key);
}
public static void remSession(Session s) {
public static void remSession(Session s) {
if (s == null) {
return;
}
if (s == null) {
return;
}
SessionManager.remSessionID(s);
SessionManager.remAccount(s);
SessionManager.remClientConnection(s);
SessionManager.remPlayerCharacter(s);
SessionManager.remSessionID(s);
SessionManager.remAccount(s);
SessionManager.remClientConnection(s);
SessionManager.remPlayerCharacter(s);
//TODO LATER fix
s.setAccount(null);
s.setConn(null);
s.setPlayerCharacter(null);
s.setSessionID(null);
}
//TODO LATER fix
s.setAccount(null);
s.setConn(null);
s.setPlayerCharacter(null);
s.setSessionID(null);
}
/*
* Get Sessions
*/
public static Session getSession(SessionID id) {
return SessionManager.sessionIDtoSession.get(id);
}
/*
* Get Sessions
*/
public static Session getSession(SessionID id) {
return SessionManager.sessionIDtoSession.get(id);
}
public static Session getSession(PlayerCharacter pc) {
return SessionManager.pcToSession.get(pc);
}
public static Session getSession(PlayerCharacter pc) {
return SessionManager.pcToSession.get(pc);
}
public static Session getSession(Account a) {
return SessionManager.accountToSession.get(a);
}
public static Session getSession(Account a) {
return SessionManager.accountToSession.get(a);
}
public static Session getSession(ClientConnection cc) {
return SessionManager.connToSession.get(cc);
}
public static Session getSession(ClientConnection cc) {
return SessionManager.connToSession.get(cc);
}
/*
* Get Connections
*/
public static ClientConnection getClientConnection(SessionID id) {
Session s = SessionManager.getSession(id);
return (s == null) ? null : s.getConn();
}
/*
* Get Connections
*/
public static ClientConnection getClientConnection(SessionID id) {
Session s = SessionManager.getSession(id);
return (s == null) ? null : s.getConn();
}
public static ClientConnection getClientConnection(PlayerCharacter pc) {
Session s = SessionManager.getSession(pc);
return (s == null) ? null : s.getConn();
}
public static ClientConnection getClientConnection(PlayerCharacter pc) {
Session s = SessionManager.getSession(pc);
return (s == null) ? null : s.getConn();
}
public static ClientConnection getClientConnection(Account a) {
Session s = SessionManager.getSession(a);
return (s == null) ? null : s.getConn();
}
public static ClientConnection getClientConnection(Account a) {
Session s = SessionManager.getSession(a);
return (s == null) ? null : s.getConn();
}
/*
* Get PlayerCharacter
*/
public static PlayerCharacter getPlayerCharacter(SessionID id) {
Session s = SessionManager.getSession(id);
return (s == null) ? null : s.getPlayerCharacter();
}
/*
* Get PlayerCharacter
*/
public static PlayerCharacter getPlayerCharacter(SessionID id) {
Session s = SessionManager.getSession(id);
return (s == null) ? null : s.getPlayerCharacter();
}
public static PlayerCharacter getPlayerCharacter(ClientConnection conn) {
Session s = SessionManager.getSession(conn);
return (s == null) ? null : s.getPlayerCharacter();
}
public static PlayerCharacter getPlayerCharacter(ClientConnection conn) {
Session s = SessionManager.getSession(conn);
return (s == null) ? null : s.getPlayerCharacter();
}
public static PlayerCharacter getPlayerCharacter(Account a) {
Session s = SessionManager.getSession(a);
return (s == null) ? null : s.getPlayerCharacter();
}
public static PlayerCharacter getPlayerCharacter(Account a) {
Session s = SessionManager.getSession(a);
return (s == null) ? null : s.getPlayerCharacter();
}
/*
* Get Account
*/
public static Account getAccount(SessionID id) {
Session s = SessionManager.getSession(id);
return (s == null) ? null : s.getAccount();
}
/*
* Get Account
*/
public static Account getAccount(SessionID id) {
Session s = SessionManager.getSession(id);
return (s == null) ? null : s.getAccount();
}
public static Account getAccount(ClientConnection conn) {
Session s = SessionManager.getSession(conn);
return (s == null) ? null : s.getAccount();
}
public static Account getAccount(ClientConnection conn) {
Session s = SessionManager.getSession(conn);
return (s == null) ? null : s.getAccount();
}
public static Account getAccount(PlayerCharacter pc) {
Session s = SessionManager.getSession(pc);
return (s == null) ? null : s.getAccount();
}
public static Account getAccount(PlayerCharacter pc) {
Session s = SessionManager.getSession(pc);
return (s == null) ? null : s.getAccount();
}
public static void setPlayerCharacter(Session s, PlayerCharacter pc) {
SessionManager.pcToSession.put(pc, s);
s.setPlayerCharacter(pc);
// Update max player
SessionManager._maxPopulation = Math.max(_maxPopulation, SessionManager.pcToSession.size());
}
public static void setPlayerCharacter(Session s, PlayerCharacter pc) {
SessionManager.pcToSession.put(pc, s);
s.setPlayerCharacter(pc);
public static void remPlayerCharacter(Session s) {
if (s.getPlayerCharacter() != null) {
SessionManager.pcToSession.remove(s.getPlayerCharacter());
s.setPlayerCharacter(null);
}
}
// Update max player
SessionManager._maxPopulation = Math.max(_maxPopulation, SessionManager.pcToSession.size());
protected static void remAccount(Session s) {
if (s.getAccount() != null) {
SessionManager.accountToSession.remove(s.getAccount());
s.setAccount(null);
}
}
}
protected static void remSessionID(Session s) {
public static void remPlayerCharacter(Session s) {
if (s.getPlayerCharacter() != null) {
SessionManager.pcToSession.remove(s.getPlayerCharacter());
s.setPlayerCharacter(null);
}
}
if (s.getSessionID() != null) {
SessionManager.sessionIDtoSession.remove(s.getSessionID());
s.setSessionID(null);
}
}
protected static void remAccount(Session s) {
if (s.getAccount() != null) {
SessionManager.accountToSession.remove(s.getAccount());
s.setAccount(null);
}
}
protected static void remClientConnection(Session s) {
if (s.getConn() != null) {
SessionManager.connToSession.remove(s.getConn());
s.setConn(null);
}
}
protected static void remSessionID(Session s) {
if (s.getSessionID() != null) {
SessionManager.sessionIDtoSession.remove(s.getSessionID());
s.setSessionID(null);
}
}
protected static void remClientConnection(Session s) {
if (s.getConn() != null) {
SessionManager.connToSession.remove(s.getConn());
s.setConn(null);
}
}
/*
* Utils
*/
/*
* Utils
*/
public static void setCrossServerBehavior(int type) {
crossServerBehavior = type;
}
public static void setCrossServerBehavior(int type) {
crossServerBehavior = type;
}
/**
*
* @return a new HashSet<ClientConnection> object so the caller cannot
* modify the internal Set
*/
public static Collection<ClientConnection> getAllActiveClientConnections() {
return SessionManager.connToSession.keySet();
}
/**
* @return a new HashSet<ClientConnection> object so the caller cannot
* modify the internal Set
*/
public static Collection<ClientConnection> getAllActiveClientConnections() {
return SessionManager.connToSession.keySet();
}
/**
*
* @return a new HashSet<PlayerCharacter> object so the caller cannot modify
* the internal Set
*/
public static Collection<PlayerCharacter> getAllActivePlayerCharacters() {
return SessionManager.pcToSession.keySet();
}
/**
* @return a new HashSet<PlayerCharacter> object so the caller cannot modify
* the internal Set
*/
public static Collection<PlayerCharacter> getAllActivePlayerCharacters() {
public static Collection<PlayerCharacter> getAllActivePlayers() {
return SessionManager.pcToSession.keySet();
}
return SessionManager.pcToSession.keySet();
}
public static int getActivePlayerCharacterCount() {
public static Collection<PlayerCharacter> getAllActivePlayers() {
return SessionManager.pcToSession.keySet().size();
}
return SessionManager.pcToSession.keySet();
}
public static ArrayList<PlayerCharacter> getActivePCsInGuildID(int id) {
ArrayList<PlayerCharacter> pcs = new ArrayList<>();
public static int getActivePlayerCharacterCount() {
for (PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()) {
Guild g = pc.getGuild();
if (g != null && g.getObjectUUID() == id) {
pcs.add(pc);
}
}
return SessionManager.pcToSession.keySet().size();
}
return pcs;
}
public static ArrayList<PlayerCharacter> getActivePCsInGuildID(int id) {
ArrayList<PlayerCharacter> pcs = new ArrayList<>();
public static PlayerCharacter getPlayerCharacterByLowerCaseName(String name) {
for (PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()) {
Guild g = pc.getGuild();
if (g != null && g.getObjectUUID() == id) {
pcs.add(pc);
}
}
String queryName = name.toLowerCase();
return pcs;
}
for (PlayerCharacter playerCharacter : SessionManager.getAllActivePlayerCharacters()) {
public static PlayerCharacter getPlayerCharacterByLowerCaseName(String name) {
if ((playerCharacter.getFirstName().toLowerCase()).equals(queryName)) {
return playerCharacter;
}
}
return null;
}
String queryName = name.toLowerCase();
public static PlayerCharacter getPlayerCharacterByID(int UUID) {
for (PlayerCharacter playerCharacter : SessionManager.getAllActivePlayerCharacters()) {
for (PlayerCharacter playerCharacter : SessionManager.getAllActivePlayerCharacters()) {
if ((playerCharacter.getFirstName().toLowerCase()).equals(queryName)) {
return playerCharacter;
}
}
return null;
}
if (playerCharacter.getObjectUUID() == UUID) {
return playerCharacter;
}
}
return null;
}
public static PlayerCharacter getPlayerCharacterByID(int UUID) {
public static Collection<Account> getAllActiveAccounts() {
return SessionManager.accountToSession.keySet();
}
for (PlayerCharacter playerCharacter : SessionManager.getAllActivePlayerCharacters()) {
public static Account getAccountByID(int UUID) {
if (playerCharacter.getObjectUUID() == UUID) {
return playerCharacter;
}
}
return null;
}
for (Account acc : SessionManager.getAllActiveAccounts()) {
public static Collection<Account> getAllActiveAccounts() {
return SessionManager.accountToSession.keySet();
}
if (acc.getObjectUUID() == UUID)
return acc;
public static Account getAccountByID(int UUID) {
}
return null;
}
for (Account acc : SessionManager.getAllActiveAccounts()) {
if (acc.getObjectUUID() == UUID)
return acc;
}
return null;
}
}
+141 -144
View File
@@ -30,197 +30,194 @@ import java.util.Collection;
*/
public enum SimulationManager {
SERVERHEARTBEAT;
SERVERHEARTBEAT;
private static SimulationManager instance = null;
private static final long CITY_PULSE = 2000;
private static final long RUNEGATE_PULSE = 3000;
private static final long UPDATE_PULSE = 1000;
private static final long FlIGHT_PULSE = 100;
public static Duration executionTime = Duration.ofNanos(1);
public static Duration executionMax = Duration.ofNanos(1);
private static SimulationManager instance = null;
private long _cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
private long _runegatePulseTime = System.currentTimeMillis()
+ RUNEGATE_PULSE;
private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE;
private long _flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE;
private static final long CITY_PULSE = 2000;
private static final long RUNEGATE_PULSE = 3000;
private static final long UPDATE_PULSE = 1000;
private static final long FlIGHT_PULSE = 100;
private SimulationManager() {
private long _cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
private long _runegatePulseTime = System.currentTimeMillis()
+ RUNEGATE_PULSE;
private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE;
private long _flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE;
// don't allow instantiation.
}
public static Duration executionTime = Duration.ofNanos(1);
public static Duration executionMax = Duration.ofNanos(1);
public static String getPopulationString() {
private SimulationManager() {
String popString = "";
// don't allow instantiation.
}
try (Connection connection = DbManager.getConnection();
PreparedStatement getPopString = connection.prepareStatement("CALL GET_POPULATION_STRING()");) {
public static String getPopulationString() {
ResultSet rs = getPopString.executeQuery();
String popString = "";
if (rs.next())
popString = rs.getString("popstring");
try (Connection connection = DbManager.getConnection();
PreparedStatement getPopString = connection.prepareStatement("CALL GET_POPULATION_STRING()");) {
} catch (SQLException e) {
Logger.error(e.toString());
}
ResultSet rs = getPopString.executeQuery();
return popString;
}
if (rs.next())
popString = rs.getString("popstring");
/*
* Update the simulation. *** Important: Whatever you do in here, do it damn
* quick!
*/
public void tick() {
} catch (SQLException e) {
Logger.error(e.toString());
}
/*
* As we're on the main thread we must be sure to catch any possible
* errors.
*
* IF something does occur, disable that particular heartbeat. Better
* runegates stop working than the game itself!
*/
return popString;
}
Instant startTime = Instant.now();
/*
* Update the simulation. *** Important: Whatever you do in here, do it damn
* quick!
*/
public void tick() {
try {
if ((_flightPulseTime != 0)
&& (System.currentTimeMillis() > _flightPulseTime))
pulseFlight();
} catch (Exception e) {
Logger.error(
"Fatal error in City Pulse: DISABLED. Error Message : "
+ e.getMessage());
}
try {
/*
* As we're on the main thread we must be sure to catch any possible
* errors.
*
* IF something does occur, disable that particular heartbeat. Better
* runegates stop working than the game itself!
*/
Instant startTime = Instant.now();
if ((_updatePulseTime != 0)
&& (System.currentTimeMillis() > _updatePulseTime))
pulseUpdate();
} catch (Exception e) {
Logger.error(
"Fatal error in Update Pulse: DISABLED");
// _runegatePulseTime = 0;
}
try {
if ((_flightPulseTime != 0)
&& (System.currentTimeMillis() > _flightPulseTime))
pulseFlight();
} catch (Exception e) {
Logger.error(
"Fatal error in City Pulse: DISABLED. Error Message : "
+ e.getMessage());
}
try {
try {
if ((_runegatePulseTime != 0)
&& (System.currentTimeMillis() > _runegatePulseTime))
pulseRunegates();
} catch (Exception e) {
Logger.error(
"Fatal error in Runegate Pulse: DISABLED");
_runegatePulseTime = 0;
}
if ((_updatePulseTime != 0)
&& (System.currentTimeMillis() > _updatePulseTime))
pulseUpdate();
} catch (Exception e) {
Logger.error(
"Fatal error in Update Pulse: DISABLED");
// _runegatePulseTime = 0;
}
try {
if ((_cityPulseTime != 0)
&& (System.currentTimeMillis() > _cityPulseTime))
pulseCities();
} catch (Exception e) {
Logger.error(
"Fatal error in City Pulse: DISABLED. Error Message : "
+ e.getMessage());
e.printStackTrace();
try {
if ((_runegatePulseTime != 0)
&& (System.currentTimeMillis() > _runegatePulseTime))
pulseRunegates();
} catch (Exception e) {
Logger.error(
"Fatal error in Runegate Pulse: DISABLED");
_runegatePulseTime = 0;
}
}
try {
if ((_cityPulseTime != 0)
&& (System.currentTimeMillis() > _cityPulseTime))
pulseCities();
} catch (Exception e) {
Logger.error(
"Fatal error in City Pulse: DISABLED. Error Message : "
+ e.getMessage());
e.printStackTrace();
}
SimulationManager.executionTime = Duration.between(startTime, Instant.now());
SimulationManager.executionTime = Duration.between(startTime, Instant.now());
if (executionTime.compareTo(executionMax) > 0)
executionMax = executionTime;
}
if (executionTime.compareTo(executionMax) > 0)
executionMax = executionTime;
}
/*
* Mainline simulation update method: handles movement and regen for all
* player characters
*/
/*
* Mainline simulation update method: handles movement and regen for all
* player characters
*/
private void pulseUpdate() {
private void pulseUpdate() {
Collection<AbstractGameObject> playerList;
Collection<AbstractGameObject> playerList;
playerList = DbManager.getList(GameObjectType.PlayerCharacter);
playerList = DbManager.getList(GameObjectType.PlayerCharacter);
// Call update() on each player in game
// Call update() on each player in game
if (playerList == null)
return;
if (playerList == null)
return;
for (AbstractGameObject ago : playerList) {
PlayerCharacter player = (PlayerCharacter) ago;
for (AbstractGameObject ago : playerList) {
PlayerCharacter player = (PlayerCharacter)ago;
if (player == null)
continue;
player.update();
}
if (player == null)
continue;
player.update();
}
_updatePulseTime = System.currentTimeMillis() + 500;
}
private void pulseFlight() {
}
Collection<AbstractGameObject> playerList;
private void pulseFlight() {
playerList = DbManager.getList(GameObjectType.PlayerCharacter);
Collection<AbstractGameObject> playerList;
// Call update() on each player in game
playerList = DbManager.getList(GameObjectType.PlayerCharacter);
if (playerList == null)
return;
// Call update() on each player in game
for (AbstractGameObject ago : playerList) {
PlayerCharacter player = (PlayerCharacter)ago;
if (playerList == null)
return;
if (player == null)
continue;
player.updateFlight();
}
for (AbstractGameObject ago : playerList) {
PlayerCharacter player = (PlayerCharacter) ago;
if (player == null)
continue;
player.updateFlight();
}
_flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE;
}
}
private void pulseCities() {
private void pulseCities() {
City city;
City city;
// *** Refactor: Need a list cached somewhere as it doesn't change very
// often at all. Have a cityListIsDirty boolean that gets set if it
// needs an update. Will speed up this method a great deal.
// *** Refactor: Need a list cached somewhere as it doesn't change very
// often at all. Have a cityListIsDirty boolean that gets set if it
// needs an update. Will speed up this method a great deal.
Collection<AbstractGameObject> cityList = DbManager.getList(Enum.GameObjectType.City);
Collection<AbstractGameObject> cityList = DbManager.getList(Enum.GameObjectType.City);
if (cityList == null) {
Logger.info( "City List null");
return;
}
if (cityList == null) {
Logger.info("City List null");
return;
}
for (AbstractGameObject cityObject : cityList) {
city = (City) cityObject;
city.onEnter();
}
for (AbstractGameObject cityObject : cityList) {
city = (City) cityObject;
city.onEnter();
}
_cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
}
_cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
}
/*
* Method runs proximity collision detection for all active portals on the
* game's Runegates
*/
private void pulseRunegates() {
/*
* Method runs proximity collision detection for all active portals on the
* game's Runegates
*/
private void pulseRunegates() {
for (Runegate runegate : Runegate._runegates.values()) {
runegate.collidePortals();
}
for (Runegate runegate : Runegate._runegates.values()) {
runegate.collidePortals();
}
_runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE;
_runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE;
}
}
}
+36 -38
View File
@@ -24,10 +24,10 @@ public enum TradeManager {
public static void tradeRequest(TradeRequestMsg msg, ClientConnection origin) {
PlayerCharacter source = origin.getPlayerCharacter();
if (source == null)
return;
return;
source.getCharItemManager().tradeRequest(msg);
}
@@ -36,17 +36,17 @@ public enum TradeManager {
public static void acceptTradeRequest(AcceptTradeRequestMsg msg, ClientConnection origin) {
PlayerCharacter source = origin.getPlayerCharacter();
if (source == null)
return;
return;
try {
source.getCharItemManager().acceptTradeRequest(msg);
} catch (Exception e) {
Logger.error(e);
// TODO Auto-generated catch block
}
source.getCharItemManager().acceptTradeRequest(msg);
} catch (Exception e) {
Logger.error(e);
// TODO Auto-generated catch block
}
}
public static void rejectTradeRequest(RejectTradeRequestMsg msg, ClientConnection origin) {
@@ -54,16 +54,16 @@ public enum TradeManager {
}
public static void addItemToTradeWindow(AddItemToTradeWindowMsg msg, ClientConnection origin) {
PlayerCharacter source = origin.getPlayerCharacter();
if (source == null || !source.isAlive())
return;
try{
try {
source.getCharItemManager().addItemToTradeWindow(msg);
}catch(Exception e){
Logger.error(e);
} catch (Exception e) {
Logger.error(e);
}
}
@@ -74,18 +74,17 @@ public enum TradeManager {
if (source == null || !source.isAlive())
return;
CharacterItemManager sourceItemMan = source.getCharItemManager();
if (sourceItemMan == null)
return;
try{
try {
sourceItemMan.addGoldToTradeWindow(msg);
}catch(Exception e){
Logger.error(e);
} catch (Exception e) {
Logger.error(e);
}
}
@@ -102,11 +101,11 @@ public enum TradeManager {
return;
try {
sourceItemMan.commitToTrade(msg);
} catch (Exception e) {
// TODO Auto-generated catch block
Logger.error(e);
}
sourceItemMan.commitToTrade(msg);
} catch (Exception e) {
// TODO Auto-generated catch block
Logger.error(e);
}
}
public static void uncommitToTrade(UncommitToTradeMsg msg, ClientConnection origin) {
@@ -120,17 +119,16 @@ public enum TradeManager {
if (sourceItemMan == null)
return;
try {
sourceItemMan.uncommitToTrade(msg);
} catch (Exception e) {
// TODO Auto-generated catch block
Logger.error(e);
}
sourceItemMan.uncommitToTrade(msg);
} catch (Exception e) {
// TODO Auto-generated catch block
Logger.error(e);
}
}
public static void closeTradeWindow(CloseTradeWindowMsg msg, ClientConnection origin) {
@@ -145,10 +143,10 @@ public enum TradeManager {
return;
try {
sourceItemMan.closeTradeWindow(msg, true);
sourceItemMan.closeTradeWindow(msg, true);
} catch (Exception e) {
// TODO Auto-generated catch block
Logger.error(e);
// TODO Auto-generated catch block
Logger.error(e);
}
}