Browse Source

Project cleanup pre merge.

master
MagicBot 2 years ago
parent
commit
9bbdef224d
  1. 15
      README.md
  2. 2
      src/discord/DiscordAccount.java
  3. 255
      src/discord/MagicBot.java
  4. 3
      src/discord/handlers/ChatChannelHandler.java
  5. 1
      src/discord/handlers/DevRequestHandler.java
  6. 316
      src/engine/InterestManagement/HeightMap.java
  7. 242
      src/engine/InterestManagement/InterestManager.java
  8. 2
      src/engine/InterestManagement/RealmMap.java
  9. 2
      src/engine/InterestManagement/WorldGrid.java
  10. 35
      src/engine/ai/MobileFSM.java
  11. 5
      src/engine/ai/MobileFSMManager.java
  12. 47
      src/engine/core/ControlledRunnable.java
  13. 6
      src/engine/db/archive/BaneRecord.java
  14. 3
      src/engine/db/archive/CharacterRecord.java
  15. 3
      src/engine/db/archive/CityRecord.java
  16. 1
      src/engine/db/archive/DataRecord.java
  17. 36
      src/engine/db/archive/DataWarehouse.java
  18. 13
      src/engine/db/archive/GuildRecord.java
  19. 6
      src/engine/db/archive/MineRecord.java
  20. 3
      src/engine/db/archive/PvpRecord.java
  21. 3
      src/engine/db/archive/RealmRecord.java
  22. 120
      src/engine/devcmd/AbstractDevCmd.java
  23. 1
      src/engine/devcmd/cmds/AddGoldCmd.java
  24. 1
      src/engine/devcmd/cmds/AddMobCmd.java
  25. 1
      src/engine/devcmd/cmds/AddNPCCmd.java
  26. 2
      src/engine/devcmd/cmds/ApplyBonusCmd.java
  27. 9
      src/engine/devcmd/cmds/ApplyStatModCmd.java
  28. 3
      src/engine/devcmd/cmds/AuditFailedItemsCmd.java
  29. 1
      src/engine/devcmd/cmds/AuditHeightMapCmd.java
  30. 5
      src/engine/devcmd/cmds/AuditMobsCmd.java
  31. 5
      src/engine/devcmd/cmds/CombatMessageCmd.java
  32. 1
      src/engine/devcmd/cmds/CreateItemCmd.java
  33. 17
      src/engine/devcmd/cmds/DebugCmd.java
  34. 1
      src/engine/devcmd/cmds/DebugMeleeSyncCmd.java
  35. 7
      src/engine/devcmd/cmds/DespawnCmd.java
  36. 3
      src/engine/devcmd/cmds/DistanceCmd.java
  37. 2
      src/engine/devcmd/cmds/EffectCmd.java
  38. 1
      src/engine/devcmd/cmds/EnchantCmd.java
  39. 3
      src/engine/devcmd/cmds/FlashMsgCmd.java
  40. 1
      src/engine/devcmd/cmds/GateInfoCmd.java
  41. 8
      src/engine/devcmd/cmds/GetBankCmd.java
  42. 11
      src/engine/devcmd/cmds/GetHeightCmd.java
  43. 27
      src/engine/devcmd/cmds/GetMemoryCmd.java
  44. 1
      src/engine/devcmd/cmds/GetMobBaseLoot.java
  45. 3
      src/engine/devcmd/cmds/GetOffsetCmd.java
  46. 3
      src/engine/devcmd/cmds/GetRuneDropRateCmd.java
  47. 6
      src/engine/devcmd/cmds/GetVaultCmd.java
  48. 3
      src/engine/devcmd/cmds/GetZoneCmd.java
  49. 6
      src/engine/devcmd/cmds/GetZoneMobsCmd.java
  50. 1
      src/engine/devcmd/cmds/GotoBoundsCmd.java
  51. 1
      src/engine/devcmd/cmds/GotoCmd.java
  52. 1
      src/engine/devcmd/cmds/GotoObj.java
  53. 1
      src/engine/devcmd/cmds/HeartbeatCmd.java
  54. 2
      src/engine/devcmd/cmds/HotzoneCmd.java
  55. 7
      src/engine/devcmd/cmds/InfoCmd.java
  56. 2
      src/engine/devcmd/cmds/MBDropCmd.java
  57. 3
      src/engine/devcmd/cmds/MakeBaneCmd.java
  58. 2
      src/engine/devcmd/cmds/MakeItemCmd.java
  59. 42
      src/engine/devcmd/cmds/NetDebugCmd.java
  60. 3
      src/engine/devcmd/cmds/PrintBonusesCmd.java
  61. 3
      src/engine/devcmd/cmds/PrintInventoryCmd.java
  62. 1
      src/engine/devcmd/cmds/PrintLocationCmd.java
  63. 22
      src/engine/devcmd/cmds/PrintStatsCmd.java
  64. 76
      src/engine/devcmd/cmds/PullCmd.java
  65. 221
      src/engine/devcmd/cmds/PurgeObjectsCmd.java
  66. 1
      src/engine/devcmd/cmds/RealmInfoCmd.java
  67. 4
      src/engine/devcmd/cmds/RebootCmd.java
  68. 1
      src/engine/devcmd/cmds/RegionCmd.java
  69. 1
      src/engine/devcmd/cmds/RemoveBaneCmd.java
  70. 2
      src/engine/devcmd/cmds/RenameCmd.java
  71. 1
      src/engine/devcmd/cmds/ResetLevelCmd.java
  72. 2
      src/engine/devcmd/cmds/SetAICmd.java
  73. 2
      src/engine/devcmd/cmds/SetAdminRuneCmd.java
  74. 1
      src/engine/devcmd/cmds/SetBaneActiveCmd.java
  75. 1
      src/engine/devcmd/cmds/SetBuildingAltitudeCmd.java
  76. 1
      src/engine/devcmd/cmds/SetForceRenameCityCmd.java
  77. 8
      src/engine/devcmd/cmds/SetGuildCmd.java
  78. 1
      src/engine/devcmd/cmds/SetHealthCmd.java
  79. 3
      src/engine/devcmd/cmds/SetInvulCmd.java
  80. 1
      src/engine/devcmd/cmds/SetMaintCmd.java
  81. 4
      src/engine/devcmd/cmds/SetNpcEquipSetCmd.java
  82. 1
      src/engine/devcmd/cmds/SetNpcMobbaseCmd.java
  83. 2
      src/engine/devcmd/cmds/SetNpcNameCmd.java
  84. 11
      src/engine/devcmd/cmds/SetOwnerCmd.java
  85. 2
      src/engine/devcmd/cmds/SetRankCmd.java
  86. 2
      src/engine/devcmd/cmds/SetRuneCmd.java
  87. 1
      src/engine/devcmd/cmds/SetStaminaCmd.java
  88. 13
      src/engine/devcmd/cmds/SetSubRaceCmd.java
  89. 1
      src/engine/devcmd/cmds/ShowOffsetCmd.java
  90. 1
      src/engine/devcmd/cmds/SlotTestCmd.java
  91. 77
      src/engine/devcmd/cmds/SplatMobCmd.java
  92. 42
      src/engine/devcmd/cmds/SqlDebugCmd.java
  93. 1
      src/engine/devcmd/cmds/SummonCmd.java
  94. 1
      src/engine/devcmd/cmds/UnloadFurnitureCmd.java
  95. 1
      src/engine/devcmd/cmds/ZoneInfoCmd.java
  96. 14
      src/engine/devcmd/cmds/aiInfoCmd.java
  97. 3
      src/engine/devcmd/cmds/convertLoc.java
  98. 4
      src/engine/devcmd/cmds/simulateBootyCmd.java
  99. 5
      src/engine/gameManager/BuildingManager.java
  100. 1
      src/engine/gameManager/ChatManager.java
  101. Some files were not shown because too many files have changed in this diff Show More

15
README.md

@ -1,17 +1,23 @@ @@ -1,17 +1,23 @@
![Logo](https://magicbane.com/images/MBLogo.jpg)
# Magicbane Open-Source MMO Project
### *The Community written Shadowbane emulator*
[Magicbane](http://www.magicbane.com)
</BR>
[Public Repository](http://repo.magicbane.com)
<BR>
<magicbot@magicbane.com>
> Magicbane is an emulator for the long dead but much beloved Ubisoft MMO, [Shadowbane](https://en.wikipedia.org/wiki/Shadowbane).
The project was founded in 2013 with the concept of free availability of gameplay; players unencumbered by any factor other than a desire to again play a game they once loved. A game where the developers do not play is guaranteed to be the fairest game.
> Magicbane is an emulator for the long dead but much beloved Ubisoft
> MMO, [Shadowbane](https://en.wikipedia.org/wiki/Shadowbane).
> The project was founded in 2013 with the concept of free availability of gameplay; players unencumbered by any factor
> other than a desire to again play a game they once loved. A game where the developers do not play is guaranteed to be
> the fairest game.
The Magicbane Team has wanted to open source Shadowbane for half a decade. We are excited to now finally have the opportunity, along with some new technology, to truly democratize Shadowbane.
The Magicbane Team has wanted to open source Shadowbane for half a decade. We are excited to now finally have the
opportunity, along with some new technology, to truly democratize Shadowbane.
- Written in some 80k lines of Java 8 and bash.
- Project with real infrastructure; Production and development servers supporting multiple containerized apps.
@ -27,4 +33,5 @@ The Magicbane Team has wanted to open source Shadowbane for half a decade. We a @@ -27,4 +33,5 @@ The Magicbane Team has wanted to open source Shadowbane for half a decade. We a
## Support
Documentation is available through the Magicbane [Wiki](http://repo.magicbane.com/MagicBane/Server/wiki) and [Discord server](www.magicbane.com).
Documentation is available through the Magicbane [Wiki](http://repo.magicbane.com/MagicBane/Server/wiki)
and [Discord server](www.magicbane.com).

2
src/discord/DiscordAccount.java

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
// www.magicbane.com
package discord;
import engine.Enum;
import java.time.LocalDateTime;
@ -18,6 +19,7 @@ public class DiscordAccount { @@ -18,6 +19,7 @@ public class DiscordAccount {
public LocalDateTime registrationDate;
public LocalDateTime lastUpdateRequest;
public byte isDiscordAdmin;
public DiscordAccount() {
}

255
src/discord/MagicBot.java

@ -59,10 +59,10 @@ import static discord.ChatChannel.ADMINLOG; @@ -59,10 +59,10 @@ import static discord.ChatChannel.ADMINLOG;
*/
public class MagicBot extends ListenerAdapter {
public static JDA jda;
public static Database database;
public static final Pattern accountNameRegex = Pattern.compile("^[\\p{Alnum}]{6,20}$");
public static final Pattern passwordRegex = Pattern.compile("^[\\p{Alnum}]{6,20}$");
public static JDA jda;
public static Database database;
public static long discordServerID;
public static long discordRoleID;
@ -132,6 +132,130 @@ public class MagicBot extends ListenerAdapter { @@ -132,6 +132,130 @@ public class MagicBot extends ListenerAdapter {
}
public static void sendResponse(MessageReceivedEvent event, String responseContent) {
// Send a formatted MagicBot response to a Discord user
String discordUserName;
MessageChannel channel;
// Exit if discord is offline
if (jda.getStatus().equals(JDA.Status.CONNECTED) == false)
return;
discordUserName = event.getAuthor().getName();
channel = event.getMessage().getChannel();
channel.sendMessage(
"```\n" + "Hello Player " + discordUserName + "\n\n" +
responseContent + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```").queue();
}
public static boolean isAdminEvent(MessageReceivedEvent event) {
String discordAccountID = event.getAuthor().getId();
List<DiscordAccount> discordAccounts;
DiscordAccount discordAccount;
// Note that database errors will cause this to return false.
// After the database is offline Avail status must be set
// to true before any subsequent admin commands will function.
if (Database.online == false)
return false;
discordAccounts = database.getDiscordAccounts(discordAccountID);
if (discordAccounts.isEmpty())
return false;
discordAccount = discordAccounts.get(0);
return (discordAccount.isDiscordAdmin == 1);
}
public static String generatePassword(int length) {
String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
StringBuilder passwordBuilder = new StringBuilder(length);
Random random = new Random();
// Generate alphanumeric password of a given length.
// Could not find a good method of generating a password
// based upon a given regex.
for (int i = 0; i < length; i++)
passwordBuilder.append(ALPHABET.charAt(random.nextInt(ALPHABET.length())));
return new String(passwordBuilder);
}
public static String readLogFile(String filePath, int lineCount) {
ProcessBuilder builder = new ProcessBuilder("/bin/bash", "-c", "tail -n " + lineCount + " " + filePath);
builder.redirectErrorStream(true);
Process process = null;
String line = null;
String logOutput = "";
try {
process = builder.start();
InputStream is = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
logOutput += line + "\n";
}
} catch (IOException e) {
Logger.error(e.toString());
return "Error while reading logfile";
}
return logOutput;
}
private static void junkbot(String command, String[] inString) {
String outString;
Writer fileWriter;
if (inString == null)
return;
;
outString = command + String.join(" ", inString);
outString += "\n";
try {
fileWriter = new BufferedWriter(new FileWriter("junkbot.txt", true));
fileWriter.append(outString);
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void SendAdminLogUpdates() {
HashMap<Integer, String> adminEvents = database.getAdminEvents();
for (int adminEvent : adminEvents.keySet()) {
// Set event as read
database.setAdminEventAsRead(adminEvent);
String outString =
"```\n" + "Hello Players \n\n" +
adminEvents.get(adminEvent) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
if (ADMINLOG.textChannel.canTalk())
ADMINLOG.textChannel.sendMessage(outString).queue();
}
}
@Override
public void onMessageReceived(MessageReceivedEvent event) {
@ -142,7 +266,8 @@ public class MagicBot extends ListenerAdapter { @@ -142,7 +266,8 @@ public class MagicBot extends ListenerAdapter {
// Early exit if message sent to us by another bot or ourselves.
if (event.getAuthor().isBot()) return;
if (event.getAuthor().isBot())
return;
// Extract message and origin channel from event
@ -247,49 +372,6 @@ public class MagicBot extends ListenerAdapter { @@ -247,49 +372,6 @@ public class MagicBot extends ListenerAdapter {
}
}
public static void sendResponse(MessageReceivedEvent event, String responseContent) {
// Send a formatted MagicBot response to a Discord user
String discordUserName;
MessageChannel channel;
// Exit if discord is offline
if (jda.getStatus().equals(JDA.Status.CONNECTED) == false)
return;
discordUserName = event.getAuthor().getName();
channel = event.getMessage().getChannel();
channel.sendMessage(
"```\n" + "Hello Player " + discordUserName + "\n\n" +
responseContent + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```").queue();
}
public static boolean isAdminEvent(MessageReceivedEvent event) {
String discordAccountID = event.getAuthor().getId();
List<DiscordAccount> discordAccounts;
DiscordAccount discordAccount;
// Note that database errors will cause this to return false.
// After the database is offline Avail status must be set
// to true before any subsequent admin commands will function.
if (Database.online == false)
return false;
discordAccounts = database.getDiscordAccounts(discordAccountID);
if (discordAccounts.isEmpty())
return false;
discordAccount = discordAccounts.get(0);
return (discordAccount.isDiscordAdmin == 1);
}
public void handleHelpRequest(MessageReceivedEvent event) {
// Help is kept here in the main class instead of a handler as a
@ -322,85 +404,4 @@ public class MagicBot extends ListenerAdapter { @@ -322,85 +404,4 @@ public class MagicBot extends ListenerAdapter {
"#trash <blank>/detail/flush";
sendResponse(event, helpString);
}
public static String generatePassword(int length) {
String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
StringBuilder passwordBuilder = new StringBuilder(length);
Random random = new Random();
// Generate alphanumeric password of a given length.
// Could not find a good method of generating a password
// based upon a given regex.
for (int i = 0; i < length; i++)
passwordBuilder.append(ALPHABET.charAt(random.nextInt(ALPHABET.length())));
return new String(passwordBuilder);
}
public static String readLogFile(String filePath, int lineCount) {
ProcessBuilder builder = new ProcessBuilder("/bin/bash", "-c", "tail -n " + lineCount + " " + filePath);
builder.redirectErrorStream(true);
Process process = null;
String line = null;
String logOutput = "";
try {
process = builder.start();
InputStream is = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
logOutput += line + "\n";
}
} catch (IOException e) {
Logger.error(e.toString());
return "Error while reading logfile";
}
return logOutput;
}
private static void junkbot(String command, String[] inString) {
String outString;
Writer fileWriter;
if (inString == null)
return;
;
outString = command + String.join(" ", inString);
outString += "\n";
try {
fileWriter = new BufferedWriter(new FileWriter("junkbot.txt", true));
fileWriter.append(outString);
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void SendAdminLogUpdates() {
HashMap<Integer, String> adminEvents = database.getAdminEvents();
for (int adminEvent : adminEvents.keySet()) {
// Set event as read
database.setAdminEventAsRead(adminEvent);
String outString =
"```\n" + "Hello Players \n\n" +
adminEvents.get(adminEvent) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
if (ADMINLOG.textChannel.canTalk())
ADMINLOG.textChannel.sendMessage(outString).queue();
}
}
}

3
src/discord/handlers/ChatChannelHandler.java

@ -42,7 +42,8 @@ public class ChatChannelHandler { @@ -42,7 +42,8 @@ public class ChatChannelHandler {
"```\n" + "Hello Players \n\n" +
chatText.substring(3) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
else outString = chatText;
else
outString = chatText;
// Write string to changelog channel

1
src/discord/handlers/DevRequestHandler.java

@ -89,6 +89,7 @@ public class DevRequestHandler { @@ -89,6 +89,7 @@ public class DevRequestHandler {
"Use #dev lastout to view results");
}
private static String getLastOutput() {
String outString = null;

316
src/engine/InterestManagement/HeightMap.java

@ -206,88 +206,6 @@ public class HeightMap { @@ -206,88 +206,6 @@ public class HeightMap {
}
public Vector2f getGridSquare(Vector2f zoneLoc) {
if (zoneLoc.x < 0)
zoneLoc.setX(0);
if (zoneLoc.x > this.fullExtentsX - 1)
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
if (zoneLoc.y < 0)
zoneLoc.setY(0);
if (zoneLoc.y > this.fullExtentsY - 1)
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
float xBucket = (zoneLoc.x / this.bucketWidthX);
float yBucket = (zoneLoc.y / this.bucketWidthY);
return new Vector2f(xBucket, yBucket);
}
public float getInterpolatedTerrainHeight(Vector2f zoneLoc) {
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
if (gridX > maxX)
gridX = maxX;
if (gridY > maxY)
gridY = maxY;
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = 0;
float topRightHeight = 0;
float bottomLeftHeight = 0;
float bottomRightHeight = 0;
int nextY = gridY +1;
int nextX = gridX + 1;
if (nextY > maxY)
nextY = gridY;
if (nextX > maxX)
nextX = gridX;
topLeftHeight = pixelColorValues[gridX][gridY];
topRightHeight = pixelColorValues[nextX][gridY];
bottomLeftHeight = pixelColorValues[gridX][nextY];
bottomRightHeight = pixelColorValues[nextX][nextY];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public static Zone getNextZoneWithTerrain(Zone zone) {
Zone nextZone = zone;
@ -505,48 +423,6 @@ public class HeightMap { @@ -505,48 +423,6 @@ public class HeightMap {
return realWorldAltitude;
}
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = pixelColorValues[gridX][gridY];
float topRightHeight = pixelColorValues[gridX + 1][gridY];
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public static float getOutsetHeight(float interpolatedAltitude, Zone zone, Vector3fImmutable worldLocation) {
Vector2f parentLoc;
@ -620,24 +496,6 @@ public class HeightMap { @@ -620,24 +496,6 @@ public class HeightMap {
return outsetALt;
}
private void generatePixelData() {
Color color;
// Generate altitude lookup table for this heightmap
this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()];
for (int y = 0; y < this.heightmapImage.getHeight(); y++) {
for (int x = 0; x < this.heightmapImage.getWidth(); x++) {
color = new Color(this.heightmapImage.getRGB(x, y));
pixelColorValues[x][y] = color.getRed();
}
}
}
public static Vector2f getGridOffset(Vector2f gridSquare) {
int floorX = (int) gridSquare.x;
@ -647,11 +505,6 @@ public class HeightMap { @@ -647,11 +505,6 @@ public class HeightMap {
}
public float getScaledHeightForColor(float color) {
return (color / 256) * this.maxHeight;
}
public static void loadAlHeightMaps() {
// Load the heightmaps into staging hashmap keyed by HashMapID
@ -672,6 +525,164 @@ public class HeightMap { @@ -672,6 +525,164 @@ public class HeightMap {
Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached.");
}
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
float localAltitude = HeightMap.getWorldHeight(currentLoc);
Zone zone = ZoneManager.findSmallestZone(currentLoc);
if (localAltitude < zone.getSeaLevel())
return true;
return false;
}
public Vector2f getGridSquare(Vector2f zoneLoc) {
if (zoneLoc.x < 0)
zoneLoc.setX(0);
if (zoneLoc.x > this.fullExtentsX - 1)
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
if (zoneLoc.y < 0)
zoneLoc.setY(0);
if (zoneLoc.y > this.fullExtentsY - 1)
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
float xBucket = (zoneLoc.x / this.bucketWidthX);
float yBucket = (zoneLoc.y / this.bucketWidthY);
return new Vector2f(xBucket, yBucket);
}
public float getInterpolatedTerrainHeight(Vector2f zoneLoc) {
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
if (gridX > maxX)
gridX = maxX;
if (gridY > maxY)
gridY = maxY;
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = 0;
float topRightHeight = 0;
float bottomLeftHeight = 0;
float bottomRightHeight = 0;
int nextY = gridY + 1;
int nextX = gridX + 1;
if (nextY > maxY)
nextY = gridY;
if (nextX > maxX)
nextX = gridX;
topLeftHeight = pixelColorValues[gridX][gridY];
topRightHeight = pixelColorValues[nextX][gridY];
bottomLeftHeight = pixelColorValues[gridX][nextY];
bottomRightHeight = pixelColorValues[nextX][nextY];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = pixelColorValues[gridX][gridY];
float topRightHeight = pixelColorValues[gridX + 1][gridY];
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
private void generatePixelData() {
Color color;
// Generate altitude lookup table for this heightmap
this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()];
for (int y = 0; y < this.heightmapImage.getHeight(); y++) {
for (int x = 0; x < this.heightmapImage.getWidth(); x++) {
color = new Color(this.heightmapImage.getRGB(x, y));
pixelColorValues[x][y] = color.getRed();
}
}
}
public float getScaledHeightForColor(float color) {
return (color / 256) * this.maxHeight;
}
public float getBucketWidthX() {
return bucketWidthX;
}
@ -692,15 +703,4 @@ public class HeightMap { @@ -692,15 +703,4 @@ public class HeightMap {
return seaLevel;
}
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
float localAltitude = HeightMap.getWorldHeight(currentLoc);
Zone zone = ZoneManager.findSmallestZone(currentLoc);
if (localAltitude < zone.getSeaLevel())
return true;
return false;
}
}

242
src/engine/InterestManagement/InterestManager.java

@ -38,14 +38,128 @@ public enum InterestManager implements Runnable { @@ -38,14 +38,128 @@ public enum InterestManager implements Runnable {
private static long lastTime;
private static boolean keepGoing = true;
public void shutdown() {
this.keepGoing = false;
}
InterestManager() {
Logger.info(" Interest Management thread is running.");
}
public static void forceLoad(AbstractWorldObject awo) {
AbstractNetMsg msg = null;
LoadStructureMsg lsm;
LoadCharacterMsg lcm;
NPC npc;
Corpse corpse;
HashSet<AbstractWorldObject> toUpdate;
switch (awo.getObjectType()) {
case Building:
lsm = new LoadStructureMsg();
lsm.addObject((Building) awo);
msg = lsm;
break;
case Corpse:
corpse = (Corpse) awo;
lcm = new LoadCharacterMsg(corpse, false);
msg = lcm;
break;
case NPC:
npc = (NPC) awo;
lcm = new LoadCharacterMsg(npc, false);
msg = lcm;
break;
default:
return;
}
toUpdate = WorldGrid.getObjectsInRangePartial(awo.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
boolean send;
for (AbstractWorldObject tar : toUpdate) {
PlayerCharacter player = (PlayerCharacter) tar;
HashSet<AbstractWorldObject> loadedStaticObjects = player.getLoadedStaticObjects();
send = false;
if (!loadedStaticObjects.contains(awo)) {
loadedStaticObjects.add(awo);
send = true;
}
if (send) {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
}
}
}
public static void HandleSpecialUnload(Building building, ClientConnection origin) {
if (Regions.FurnitureRegionMap.get(building.getObjectUUID()) == null)
return;
Regions buildingRegion = Regions.FurnitureRegionMap.get(building.getObjectUUID());
if (!buildingRegion.isOutside())
return;
MoveToPointMsg moveMsg = new MoveToPointMsg(building);
if (origin != null)
origin.sendMsg(moveMsg);
}
public static void reloadCharacter(AbstractCharacter absChar) {
UnloadObjectsMsg uom = new UnloadObjectsMsg();
uom.addObject(absChar);
LoadCharacterMsg lcm = new LoadCharacterMsg(absChar, false);
HashSet<AbstractWorldObject> toSend = WorldGrid.getObjectsInRangePartial(absChar.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE,
MBServerStatics.MASK_PLAYER);
PlayerCharacter pc = null;
if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter))
pc = (PlayerCharacter) absChar;
for (AbstractWorldObject awo : toSend) {
PlayerCharacter pcc = (PlayerCharacter) awo;
if (pcc == null)
continue;
ClientConnection cc = SessionManager.getClientConnection(pcc);
if (cc == null)
continue;
if (pcc.getObjectUUID() == absChar.getObjectUUID())
continue;
else {
if (pc != null)
if (pcc.getSeeInvis() < pc.getHidden())
continue;
if (!cc.sendMsg(uom)) {
String classType = uom.getClass().getSimpleName();
Logger.error("Failed to send message ");
}
if (!cc.sendMsg(lcm)) {
String classType = lcm.getClass().getSimpleName();
Logger.error("Failed to send message");
}
}
}
}
public void shutdown() {
this.keepGoing = false;
}
@Override
public void run() {
beginLoadJob();
@ -84,6 +198,9 @@ public enum InterestManager implements Runnable { @@ -84,6 +198,9 @@ public enum InterestManager implements Runnable {
return dur;
}
// Forces the loading of static objects (corpses and buildings).
// Needed to override threshold limits on loading statics
private void updateAllPlayers() {
// get all players
@ -385,76 +502,6 @@ public enum InterestManager implements Runnable { @@ -385,76 +502,6 @@ public enum InterestManager implements Runnable {
//JobScheduler.getInstance().scheduleJob(new LoadEffectsJob(players, origin), MBServerStatics.LOAD_OBJECT_DELAY);
}
// Forces the loading of static objects (corpses and buildings).
// Needed to override threshold limits on loading statics
public static void forceLoad(AbstractWorldObject awo) {
AbstractNetMsg msg = null;
LoadStructureMsg lsm;
LoadCharacterMsg lcm;
NPC npc;
Corpse corpse;
HashSet<AbstractWorldObject> toUpdate;
switch (awo.getObjectType()) {
case Building:
lsm = new LoadStructureMsg();
lsm.addObject((Building) awo);
msg = lsm;
break;
case Corpse:
corpse = (Corpse) awo;
lcm = new LoadCharacterMsg(corpse, false);
msg = lcm;
break;
case NPC:
npc = (NPC) awo;
lcm = new LoadCharacterMsg(npc, false);
msg = lcm;
break;
default:
return;
}
toUpdate = WorldGrid.getObjectsInRangePartial(awo.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
boolean send;
for (AbstractWorldObject tar : toUpdate) {
PlayerCharacter player = (PlayerCharacter) tar;
HashSet<AbstractWorldObject> loadedStaticObjects = player.getLoadedStaticObjects();
send = false;
if (!loadedStaticObjects.contains(awo)) {
loadedStaticObjects.add(awo);
send = true;
}
if (send) {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
}
}
}
public static void HandleSpecialUnload(Building building, ClientConnection origin) {
if (Regions.FurnitureRegionMap.get(building.getObjectUUID()) == null)
return;
Regions buildingRegion = Regions.FurnitureRegionMap.get(building.getObjectUUID());
if (!buildingRegion.isOutside())
return;
MoveToPointMsg moveMsg = new MoveToPointMsg(building);
if (origin != null)
origin.sendMsg(moveMsg);
}
public synchronized void HandleLoadForEnterWorld(PlayerCharacter player) {
if (player == null)
@ -504,51 +551,4 @@ public enum InterestManager implements Runnable { @@ -504,51 +551,4 @@ public enum InterestManager implements Runnable {
Logger.error("InterestManager.updateAllMobilePlayers: " + player.getObjectUUID(), e);
}
}
public static void reloadCharacter(AbstractCharacter absChar) {
UnloadObjectsMsg uom = new UnloadObjectsMsg();
uom.addObject(absChar);
LoadCharacterMsg lcm = new LoadCharacterMsg(absChar, false);
HashSet<AbstractWorldObject> toSend = WorldGrid.getObjectsInRangePartial(absChar.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE,
MBServerStatics.MASK_PLAYER);
PlayerCharacter pc = null;
if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter))
pc = (PlayerCharacter) absChar;
for (AbstractWorldObject awo : toSend) {
PlayerCharacter pcc = (PlayerCharacter) awo;
if (pcc == null)
continue;
ClientConnection cc = SessionManager.getClientConnection(pcc);
if (cc == null)
continue;
if (pcc.getObjectUUID() == absChar.getObjectUUID())
continue;
else {
if (pc != null)
if (pcc.getSeeInvis() < pc.getHidden())
continue;
if (!cc.sendMsg(uom)) {
String classType = uom.getClass().getSimpleName();
Logger.error("Failed to send message ");
}
if (!cc.sendMsg(lcm)) {
String classType = lcm.getClass().getSimpleName();
Logger.error("Failed to send message");
}
}
}
}
}

2
src/engine/InterestManagement/RealmMap.java

@ -36,8 +36,8 @@ public enum RealmMap { @@ -36,8 +36,8 @@ public enum RealmMap {
// Spatial hashmap. Used for determining which Realm
// a player is currently located within.
public static int[][] _realmImageMap;
private static final HashMap<Color, Integer> _rgbToIDMap = new HashMap<>();
public static int[][] _realmImageMap;
public static int getRealmIDByColor(Color color) {

2
src/engine/InterestManagement/WorldGrid.java

@ -30,6 +30,7 @@ public class WorldGrid { @@ -30,6 +30,7 @@ public class WorldGrid {
public static ConcurrentHashMap<Integer, AbstractWorldObject>[][] StaticGridMap;
private static float dynamicBucketScale = 0.00390625f; // 256 bucket size, 1/256
private static float staticBucketScale = 0.00390625f;
public static void startLoadJob() {
Thread loadJobThread;
@ -66,7 +67,6 @@ public class WorldGrid { @@ -66,7 +67,6 @@ public class WorldGrid {
int startingZ = gridZ + bucketSize;
int limitX = Math.abs((int) (MBServerStatics.MAX_WORLD_WIDTH * scale));
int limitZ = Math.abs((int) (MBServerStatics.MAX_WORLD_HEIGHT * scale)); //LimitZ is negative, remember to flip sign.

35
src/engine/ai/MobileFSM.java

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.ai;
import engine.Enum;
import engine.Enum.DispatchChannel;
import engine.InterestManagement.WorldGrid;
@ -22,12 +23,15 @@ import engine.objects.*; @@ -22,12 +23,15 @@ import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import static engine.math.FastMath.sqr;
public class MobileFSM {
private static void AttackTarget(Mob mob, AbstractWorldObject target) {
if (mob == null)
@ -58,6 +62,7 @@ public class MobileFSM { @@ -58,6 +62,7 @@ public class MobileFSM {
break;
}
}
public static void AttackPlayer(Mob mob, PlayerCharacter target) {
if (!mob.canSee(target)) {
mob.setCombatTarget(null);
@ -100,6 +105,7 @@ public class MobileFSM { @@ -100,6 +105,7 @@ public class MobileFSM {
}
}
}
public static void AttackBuilding(Mob mob, Building target) {
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
mob.setCombatTarget(null);
@ -140,6 +146,7 @@ public class MobileFSM { @@ -140,6 +146,7 @@ public class MobileFSM {
DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
}
}
public static void AttackMob(Mob mob, Mob target) {
if (mob.getRange() >= 30 && mob.isMoving())
return;
@ -166,6 +173,7 @@ public class MobileFSM { @@ -166,6 +173,7 @@ public class MobileFSM {
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
}
}
private static void Patrol(Mob mob) {
//make sure mob is out of combat stance
if (mob.isCombat() && mob.getCombatTarget() == null) {
@ -214,6 +222,7 @@ public class MobileFSM { @@ -214,6 +222,7 @@ public class MobileFSM {
}
}
}
public static boolean canCast(Mob mob) {
// Performs validation to determine if a
// mobile in the proper state to cast.
@ -229,6 +238,7 @@ public class MobileFSM { @@ -229,6 +238,7 @@ public class MobileFSM {
mob.nextCastTime = System.currentTimeMillis();
return mob.nextCastTime <= System.currentTimeMillis();
}
public static boolean MobCast(Mob mob) {
// Method picks a random spell from a mobile's list of powers
// and casts it on the current target (or itself). Validation
@ -291,6 +301,7 @@ public class MobileFSM { @@ -291,6 +301,7 @@ public class MobileFSM {
}
return false;
}
public static void MobCallForHelp(Mob mob) {
boolean callGotResponse = false;
if (mob.nextCallForHelp == 0) {
@ -311,6 +322,7 @@ public class MobileFSM { @@ -311,6 +322,7 @@ public class MobileFSM {
//wait 60 seconds to call for help again
mob.nextCallForHelp = System.currentTimeMillis() + 60000;
}
public static void DetermineAction(Mob mob) {
if (mob == null)
return;
@ -375,6 +387,7 @@ public class MobileFSM { @@ -375,6 +387,7 @@ public class MobileFSM {
break;
}
}
private static void CheckForAggro(Mob aiAgent) {
//looks for and sets mobs combatTarget
if (!aiAgent.isAlive())
@ -405,6 +418,7 @@ public class MobileFSM { @@ -405,6 +418,7 @@ public class MobileFSM {
}
}
}
private static void CheckMobMovement(Mob mob) {
if (!MovementUtilities.canMove(mob))
return;
@ -446,6 +460,7 @@ public class MobileFSM { @@ -446,6 +460,7 @@ public class MobileFSM {
break;
}
}
private static void CheckForRespawn(Mob aiAgent) {
if (aiAgent.deathTime == 0) {
aiAgent.setDeathTime(System.currentTimeMillis());
@ -479,6 +494,7 @@ public class MobileFSM { @@ -479,6 +494,7 @@ public class MobileFSM {
aiAgent.respawn();
}
}
public static void CheckForAttack(Mob mob) {
//checks if mob can attack based on attack timer and range
if (mob.isAlive() == false)
@ -505,10 +521,10 @@ public class MobileFSM { @@ -505,10 +521,10 @@ public class MobileFSM {
if (System.currentTimeMillis() > mob.getLastAttackTime())
AttackTarget(mob, mob.getCombatTarget());
}
private static void CheckToSendMobHome(Mob mob) {
if (mob.BehaviourType.isAgressive) {
if(mob.isPlayerGuard())
{
if (mob.isPlayerGuard()) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
CheckForPlayerGuardAggro(mob);
}
@ -533,8 +549,7 @@ public class MobileFSM { @@ -533,8 +549,7 @@ public class MobileFSM {
}
}
}
}
else if(MovementUtilities.inRangeOfBindLocation(mob) == false) {
} else if (MovementUtilities.inRangeOfBindLocation(mob) == false) {
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40);
@ -544,6 +559,7 @@ public class MobileFSM { @@ -544,6 +559,7 @@ public class MobileFSM {
}
}
}
private static void chaseTarget(Mob mob) {
mob.updateMovementState();
if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) {
@ -560,6 +576,7 @@ public class MobileFSM { @@ -560,6 +576,7 @@ public class MobileFSM {
}
}
}
private static void SafeGuardAggro(Mob mob) {
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB);
for (AbstractWorldObject awoMob : awoList) {
@ -575,12 +592,14 @@ public class MobileFSM { @@ -575,12 +592,14 @@ public class MobileFSM {
mob.setCombatTarget(aggroMob);
}
}
public static void GuardCaptainLogic(Mob mob) {
if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob);
CheckMobMovement(mob);
CheckForAttack(mob);
}
public static void GuardMinionLogic(Mob mob) {
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) {
CheckForPlayerGuardAggro(mob);
@ -592,12 +611,14 @@ public class MobileFSM { @@ -592,12 +611,14 @@ public class MobileFSM {
CheckMobMovement(mob);
CheckForAttack(mob);
}
public static void GuardWallArcherLogic(Mob mob) {
if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob);
else
CheckForAttack(mob);
}
private static void PetLogic(Mob mob) {
if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive())
mob.setCombatTarget(null);
@ -605,6 +626,7 @@ public class MobileFSM { @@ -605,6 +626,7 @@ public class MobileFSM {
CheckMobMovement(mob);
CheckForAttack(mob);
}
private static void HamletGuardLogic(Mob mob) {
if (mob.getCombatTarget() == null) {
//safehold guard
@ -616,6 +638,7 @@ public class MobileFSM { @@ -616,6 +638,7 @@ public class MobileFSM {
}
CheckForAttack(mob);
}
private static void DefaultLogic(Mob mob) {
if (mob.getObjectUUID() == 40548) {
int thing = 0;
@ -643,6 +666,7 @@ public class MobileFSM { @@ -643,6 +666,7 @@ public class MobileFSM {
if (!mob.BehaviourType.isWimpy && !mob.isMoving() && mob.combatTarget != null)
CheckForAttack(mob);
}
public static void CheckForPlayerGuardAggro(Mob mob) {
//looks for and sets mobs combatTarget
if (!mob.isAlive())
@ -673,6 +697,7 @@ public class MobileFSM { @@ -673,6 +697,7 @@ public class MobileFSM {
}
}
}
public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) {
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false;
@ -713,6 +738,7 @@ public class MobileFSM { @@ -713,6 +738,7 @@ public class MobileFSM {
}
return false;
}
public static void randomGuardPatrolPoint(Mob mob) {
if (mob.isMoving() == true) {
//early exit for a mob who is already moving to a patrol point
@ -750,6 +776,7 @@ public class MobileFSM { @@ -750,6 +776,7 @@ public class MobileFSM {
}
}
}
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) {
float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {

5
src/engine/ai/MobileFSMManager.java

@ -25,9 +25,6 @@ public class MobileFSMManager { @@ -25,9 +25,6 @@ public class MobileFSMManager {
private static final MobileFSMManager INSTANCE = new MobileFSMManager();
public static Duration executionTime = Duration.ofNanos(1);
public static Duration executionMax = Duration.ofNanos(1);
private volatile boolean alive;
private long timeOfKill = -1;
//AI variables moved form mb_server_statics
public static int AI_BASE_AGGRO_RANGE = 60;
public static int AI_DROP_AGGRO_RANGE = 60;
@ -37,6 +34,8 @@ public class MobileFSMManager { @@ -37,6 +34,8 @@ public class MobileFSMManager {
public static int AI_PATROL_DIVISOR = 15;
public static int AI_POWER_DIVISOR = 20;
public static float AI_MAX_ANGLE = 10f;
private volatile boolean alive;
private long timeOfKill = -1;
private MobileFSMManager() {

47
src/engine/core/ControlledRunnable.java

@ -17,10 +17,16 @@ import java.util.ArrayList; @@ -17,10 +17,16 @@ import java.util.ArrayList;
*
*/
public abstract class ControlledRunnable implements Runnable {
// Runnable tracking
private static final ArrayList<ControlledRunnable> runnables = new ArrayList<>();
private final String threadName;
protected boolean runCmd = false;
protected boolean runStatus = false;
private Thread thisThread;
private final String threadName;
/*
* Main loop
*/
public ControlledRunnable(String threadName) {
super();
@ -28,9 +34,14 @@ public abstract class ControlledRunnable implements Runnable { @@ -28,9 +34,14 @@ public abstract class ControlledRunnable implements Runnable {
ControlledRunnable.runnables.add(this);
}
/*
* Main loop
*/
public static void shutdownAllRunnables() {
for (ControlledRunnable cr : ControlledRunnable.runnables) {
//Use Direct logging since JobManager is a runnable.
Logger.info("ControlledRunnable",
"Sending Shutdown cmd to: " + cr.threadName);
cr.shutdown();
}
}
/**
* This is the method called when ControlledRunnable.thisThread.start() is
@ -62,6 +73,10 @@ public abstract class ControlledRunnable implements Runnable { @@ -62,6 +73,10 @@ public abstract class ControlledRunnable implements Runnable {
*/
protected abstract boolean _preRun();
/*
* Control
*/
/**
* _Run() is called after _startup() and contains should contain the main
* loop.
@ -78,10 +93,6 @@ public abstract class ControlledRunnable implements Runnable { @@ -78,10 +93,6 @@ public abstract class ControlledRunnable implements Runnable {
*/
protected abstract boolean _postRun();
/*
* Control
*/
/**
* startup() initializes the internal thread, sets the runCMD to true, and
* calls _startup() prior to starting of the internal Thread.
@ -141,6 +152,10 @@ public abstract class ControlledRunnable implements Runnable { @@ -141,6 +152,10 @@ public abstract class ControlledRunnable implements Runnable {
}
}
/*
* Instance monitoring and tools
*/
/**
* @return the thisThread
*/
@ -155,20 +170,4 @@ public abstract class ControlledRunnable implements Runnable { @@ -155,20 +170,4 @@ public abstract class ControlledRunnable implements Runnable {
return threadName;
}
/*
* Instance monitoring and tools
*/
// Runnable tracking
private static final ArrayList<ControlledRunnable> runnables = new ArrayList<>();
public static void shutdownAllRunnables() {
for (ControlledRunnable cr : ControlledRunnable.runnables) {
//Use Direct logging since JobManager is a runnable.
Logger.info("ControlledRunnable",
"Sending Shutdown cmd to: " + cr.threadName);
cr.shutdown();
}
}
}

6
src/engine/db/archive/BaneRecord.java

@ -50,8 +50,7 @@ public class BaneRecord extends DataRecord { @@ -50,8 +50,7 @@ public class BaneRecord extends DataRecord {
if (baneRecord == null) {
baneRecord = new BaneRecord(bane);
baneRecord.eventType = eventType;
}
else {
} else {
baneRecord.recordType = Enum.DataRecordType.BANE;
baneRecord.eventType = eventType;
@ -67,8 +66,7 @@ public class BaneRecord extends DataRecord { @@ -67,8 +66,7 @@ public class BaneRecord extends DataRecord {
baneRecord.baneDropperHash = "ERRANT";
baneRecord.baneGuildHash = "ERRANT";
baneRecord.baneNationHash = "ERRANT";
}
else {
} else {
baneRecord.baneDropperHash = DataWarehouse.hasher.encrypt(bane.getOwner().getObjectUUID()); // getPlayerCharacter didn't check hash first? OMFG

3
src/engine/db/archive/CharacterRecord.java

@ -44,8 +44,7 @@ public class CharacterRecord extends DataRecord { @@ -44,8 +44,7 @@ public class CharacterRecord extends DataRecord {
if (characterRecord == null) {
characterRecord = new CharacterRecord(player);
}
else {
} else {
characterRecord.recordType = Enum.DataRecordType.CHARACTER;
characterRecord.player = player;

3
src/engine/db/archive/CityRecord.java

@ -46,8 +46,7 @@ public class CityRecord extends DataRecord { @@ -46,8 +46,7 @@ public class CityRecord extends DataRecord {
if (cityRecord == null) {
cityRecord = new CityRecord(city);
cityRecord.eventType = eventType;
}
else {
} else {
cityRecord.recordType = Enum.DataRecordType.CITY;
cityRecord.eventType = eventType;
cityRecord.city = city;

1
src/engine/db/archive/DataRecord.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.db.archive;
import engine.Enum;

36
src/engine/db/archive/DataWarehouse.java

@ -188,6 +188,24 @@ public class DataWarehouse implements Runnable { @@ -188,6 +188,24 @@ public class DataWarehouse implements Runnable {
return false;
}
private static void configureRemoteConnectionPool() {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(1); // Only the server talks to remote, so yeah.
config.setJdbcUrl(ConfigManager.MB_WAREHOUSE_ADDR.getValue());
config.setUsername(ConfigManager.MB_WAREHOUSE_USER.getValue());
config.setPassword(ConfigManager.MB_WAREHOUSE_PASS.getValue());
config.addDataSourceProperty("characterEncoding", "utf8");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
remoteConnectionPool = new HikariDataSource(config); // setup the connection pool
Logger.info("remote warehouse connection configured");
}
public void run() {
// Working variable set
@ -269,22 +287,4 @@ public class DataWarehouse implements Runnable { @@ -269,22 +287,4 @@ public class DataWarehouse implements Runnable {
}
}
private static void configureRemoteConnectionPool() {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(1); // Only the server talks to remote, so yeah.
config.setJdbcUrl(ConfigManager.MB_WAREHOUSE_ADDR.getValue());
config.setUsername(ConfigManager.MB_WAREHOUSE_USER.getValue());
config.setPassword(ConfigManager.MB_WAREHOUSE_PASS.getValue());
config.addDataSourceProperty("characterEncoding", "utf8");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
remoteConnectionPool = new HikariDataSource(config); // setup the connection pool
Logger.info("remote warehouse connection configured");
}
}

13
src/engine/db/archive/GuildRecord.java

@ -27,9 +27,11 @@ import java.util.concurrent.LinkedBlockingQueue; @@ -27,9 +27,11 @@ import java.util.concurrent.LinkedBlockingQueue;
public class GuildRecord extends DataRecord {
private static final LinkedBlockingQueue<GuildRecord> recordPool = new LinkedBlockingQueue<>();
public static HashMap<Integer, GuildRecord> GuildRecordCache = null;
public String guildHash;
public int guildID;
private Enum.RecordEventType eventType;
private Guild guild;
public String guildHash;
private String guildName;
private String charterName;
private String GLHash;
@ -39,12 +41,8 @@ public class GuildRecord extends DataRecord { @@ -39,12 +41,8 @@ public class GuildRecord extends DataRecord {
private int bgColour2;
private int fgIcon;
private int fgColour;
public int guildID;
private java.time.LocalDateTime eventDatetime;
public static HashMap<Integer, GuildRecord> GuildRecordCache = null;
private GuildRecord(Guild guild) {
this.recordType = Enum.DataRecordType.GUILD;
this.guild = guild;
@ -52,7 +50,6 @@ public class GuildRecord extends DataRecord { @@ -52,7 +50,6 @@ public class GuildRecord extends DataRecord {
}
public GuildRecord(ResultSet rs) throws SQLException {
super();
this.eventType = RecordEventType.valueOf(rs.getString("eventType"));
@ -74,7 +71,6 @@ public class GuildRecord extends DataRecord { @@ -74,7 +71,6 @@ public class GuildRecord extends DataRecord {
}
public static GuildRecord borrow(Guild guild, Enum.RecordEventType eventType) {
GuildRecord guildRecord;
//add
@ -83,8 +79,7 @@ public class GuildRecord extends DataRecord { @@ -83,8 +79,7 @@ public class GuildRecord extends DataRecord {
if (guildRecord == null) {
guildRecord = new GuildRecord(guild);
guildRecord.eventType = eventType;
}
else {
} else {
guildRecord.guild = guild;
guildRecord.recordType = Enum.DataRecordType.GUILD;
guildRecord.eventType = eventType;

6
src/engine/db/archive/MineRecord.java

@ -47,8 +47,7 @@ public class MineRecord extends DataRecord { @@ -47,8 +47,7 @@ public class MineRecord extends DataRecord {
if (mineRecord == null) {
mineRecord = new MineRecord();
mineRecord.eventType = eventType;
}
else {
} else {
mineRecord.recordType = Enum.DataRecordType.MINE;
mineRecord.eventType = eventType;
}
@ -58,8 +57,7 @@ public class MineRecord extends DataRecord { @@ -58,8 +57,7 @@ public class MineRecord extends DataRecord {
if (character.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
player = (PlayerCharacter) character;
mineRecord.charHash = player.getHash();
}
else
} else
mineRecord.charHash = character.getName();
DataWarehouse.hasher.encrypt(0);

3
src/engine/db/archive/PvpRecord.java

@ -51,8 +51,7 @@ public class PvpRecord extends DataRecord { @@ -51,8 +51,7 @@ public class PvpRecord extends DataRecord {
if (pvpRecord == null) {
pvpRecord = new PvpRecord(player, victim, location, pvpExp);
}
else {
} else {
pvpRecord.recordType = DataRecordType.PVP;
pvpRecord.player = player;
pvpRecord.victim = victim;

3
src/engine/db/archive/RealmRecord.java

@ -44,8 +44,7 @@ public class RealmRecord extends DataRecord { @@ -44,8 +44,7 @@ public class RealmRecord extends DataRecord {
if (realmRecord == null) {
realmRecord = new RealmRecord(realm);
realmRecord.eventType = eventType;
}
else {
} else {
realmRecord.recordType = Enum.DataRecordType.REALM;
realmRecord.eventType = eventType;
realmRecord.realm = realm;

120
src/engine/devcmd/AbstractDevCmd.java

@ -29,6 +29,60 @@ public abstract class AbstractDevCmd { @@ -29,6 +29,60 @@ public abstract class AbstractDevCmd {
this.rsult = "";
}
/*
* Misc tools/helpers
*/
protected static Building getTargetAsBuilding(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Building.ordinal()) {
Building b = (Building) DbManager
.getFromCache(GameObjectType.Building, targetID);
if (b == null) {
ChatManager.chatSystemError(
pc,
"Command Failed. Could not find building of ID "
+ targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static Mob getTargetAsMob(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Mob.ordinal()) {
Mob b = Mob.getMob(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find Mob of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static NPC getTargetAsNPC(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.NPC.ordinal()) {
NPC b = NPC.getFromCache(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find NPC of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
/**
* This function is called by the DevCmdManager. Method splits argString
* into a String array and then calls the subclass specific _doCmd method.
@ -89,22 +143,22 @@ public abstract class AbstractDevCmd { @@ -89,22 +143,22 @@ public abstract class AbstractDevCmd {
this.cmdStrings.add(lowercase);
}
public void setTarget(AbstractGameObject ago) {
this.tr = ago;
}
public AbstractGameObject getTarget() {
return this.tr;
}
public void setResult(String result) {
this.rsult = result;
public void setTarget(AbstractGameObject ago) {
this.tr = ago;
}
public String getResult() {
return this.rsult;
}
public void setResult(String result) {
this.rsult = result;
}
/*
* Helper functions
*/
@ -124,58 +178,4 @@ public abstract class AbstractDevCmd { @@ -124,58 +178,4 @@ public abstract class AbstractDevCmd {
ChatManager.chatSystemInfo(pc, msgText);
}
/*
* Misc tools/helpers
*/
protected static Building getTargetAsBuilding(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Building.ordinal()) {
Building b = (Building) DbManager
.getFromCache(GameObjectType.Building, targetID);
if (b == null) {
ChatManager.chatSystemError(
pc,
"Command Failed. Could not find building of ID "
+ targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static Mob getTargetAsMob(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Mob.ordinal()) {
Mob b = Mob.getMob(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find Mob of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static NPC getTargetAsNPC(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.NPC.ordinal()) {
NPC b = NPC.getFromCache(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find NPC of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
}

1
src/engine/devcmd/cmds/AddGoldCmd.java

@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter; @@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class AddGoldCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/AddMobCmd.java

@ -20,7 +20,6 @@ import org.pmw.tinylog.Logger; @@ -20,7 +20,6 @@ import org.pmw.tinylog.Logger;
/**
* @author Eighty
*
*/
public class AddMobCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/AddNPCCmd.java

@ -18,7 +18,6 @@ import org.pmw.tinylog.Logger; @@ -18,7 +18,6 @@ import org.pmw.tinylog.Logger;
/**
* @author Eighty
*
*/
public class AddNPCCmd extends AbstractDevCmd {

2
src/engine/devcmd/cmds/ApplyBonusCmd.java

@ -124,8 +124,6 @@ public class ApplyBonusCmd extends AbstractDevCmd { @@ -124,8 +124,6 @@ public class ApplyBonusCmd extends AbstractDevCmd {
break;
}
}

9
src/engine/devcmd/cmds/ApplyStatModCmd.java

@ -21,18 +21,16 @@ import engine.powers.PowersBase; @@ -21,18 +21,16 @@ import engine.powers.PowersBase;
import java.util.ArrayList;
/**
*
* @author Eighty
*
*/
public class ApplyStatModCmd extends AbstractDevCmd {
private static int cnt = 0;
public ApplyStatModCmd() {
super("applystatmod");
}
private static int cnt = 0;
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
@ -72,9 +70,6 @@ public class ApplyStatModCmd extends AbstractDevCmd { @@ -72,9 +70,6 @@ public class ApplyStatModCmd extends AbstractDevCmd {
pbList.add(PowersManager.getPowerByToken(431081336));
for (PowersBase pb : pbList) {
if (amount <= 0) {
if (pb.getToken() == 428677994)

3
src/engine/devcmd/cmds/AuditFailedItemsCmd.java

@ -29,7 +29,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd { @@ -29,7 +29,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
AbstractGameObject target) {
if (ItemProductionManager.FailedItems.isEmpty())
return;
@ -103,8 +102,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd { @@ -103,8 +102,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
}
auditFailedItem += newLine;
auditFailedItem += itemName + " | " + prefix + " | " + suffix + " | " + failedItem.getNpcUID() + ":" + npcName + " | " + contractName + " | " + failedItem.getPlayerID() + ":" + playerName;

1
src/engine/devcmd/cmds/AuditHeightMapCmd.java

@ -36,7 +36,6 @@ public class AuditHeightMapCmd extends AbstractDevCmd { @@ -36,7 +36,6 @@ public class AuditHeightMapCmd extends AbstractDevCmd {
Zone currentZone = ZoneManager.findSmallestZone(pcSender.getLoc());
Vector3fImmutable currentLoc = Vector3fImmutable.getRandomPointInCircle(currentZone.getLoc(), currentZone.getBounds().getHalfExtents().x < currentZone.getBounds().getHalfExtents().y ? currentZone.getBounds().getHalfExtents().x : currentZone.getBounds().getHalfExtents().y);
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentLoc, currentZone);

5
src/engine/devcmd/cmds/AuditMobsCmd.java

@ -24,7 +24,8 @@ public class AuditMobsCmd extends AbstractDevCmd { @@ -24,7 +24,8 @@ public class AuditMobsCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
//get Zone to check mobs against
@ -83,12 +84,10 @@ public class AuditMobsCmd extends AbstractDevCmd { @@ -83,12 +84,10 @@ public class AuditMobsCmd extends AbstractDevCmd {
throwbackInfo(pcSender, "UUID, dbID, inRespawnMap, isAlive, activeAI, Loc");
//mob not found in spawn map, check respawn
boolean inRespawn = false;
}

5
src/engine/devcmd/cmds/CombatMessageCmd.java

@ -7,9 +7,6 @@ @@ -7,9 +7,6 @@
// www.magicbane.com
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
@ -27,9 +24,7 @@ import engine.objects.AbstractGameObject; @@ -27,9 +24,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class CombatMessageCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/CreateItemCmd.java

@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter; @@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class CreateItemCmd extends AbstractDevCmd {

17
src/engine/devcmd/cmds/DebugCmd.java

@ -17,12 +17,19 @@ import engine.objects.PlayerCharacter; @@ -17,12 +17,19 @@ import engine.objects.PlayerCharacter;
public class DebugCmd extends AbstractDevCmd {
public DebugCmd() {
super("debug");
// super("debug", MBServerStatics.ACCESS_GROUP_ALL_TEAM, 0, false, false);
}
private static void toggleDebugTimer(PlayerCharacter pc, String name, int num, int duration, boolean toggle) {
if (toggle) {
DebugTimerJob dtj = new DebugTimerJob(pc, name, num, duration);
pc.renewTimer(name, dtj, duration);
} else
pc.cancelTimer(name);
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
@ -112,12 +119,4 @@ public class DebugCmd extends AbstractDevCmd { @@ -112,12 +119,4 @@ public class DebugCmd extends AbstractDevCmd {
protected String _getUsageString() {
return "'./Debug command on/off'";
}
private static void toggleDebugTimer(PlayerCharacter pc, String name, int num, int duration, boolean toggle) {
if (toggle) {
DebugTimerJob dtj = new DebugTimerJob(pc, name, num, duration);
pc.renewTimer(name, dtj, duration);
} else
pc.cancelTimer(name);
}
}

1
src/engine/devcmd/cmds/DebugMeleeSyncCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;

7
src/engine/devcmd/cmds/DespawnCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -27,17 +26,11 @@ public class DespawnCmd extends AbstractDevCmd { @@ -27,17 +26,11 @@ public class DespawnCmd extends AbstractDevCmd {
AbstractGameObject target) {
if (pc == null) {
return;
}
Mob mob = null;
if (target != null && target.getObjectType().equals(GameObjectType.Mob))

3
src/engine/devcmd/cmds/DistanceCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@ -27,8 +26,6 @@ public class DistanceCmd extends AbstractDevCmd { @@ -27,8 +26,6 @@ public class DistanceCmd extends AbstractDevCmd {
AbstractGameObject target) {
// Arg Count Check
if (words.length != 1) {
this.sendUsage(pc);

2
src/engine/devcmd/cmds/EffectCmd.java

@ -17,9 +17,7 @@ import engine.objects.PlayerCharacter; @@ -17,9 +17,7 @@ import engine.objects.PlayerCharacter;
import engine.powers.EffectsBase;
/**
*
* @author Eighty
*
*/
public class EffectCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/EnchantCmd.java

@ -35,7 +35,6 @@ public class EnchantCmd extends AbstractDevCmd { @@ -35,7 +35,6 @@ public class EnchantCmd extends AbstractDevCmd {
}
Item item;
if (target == null || target instanceof Item)
item = (Item) target;

3
src/engine/devcmd/cmds/FlashMsgCmd.java

@ -15,9 +15,7 @@ import engine.objects.AbstractGameObject; @@ -15,9 +15,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class FlashMsgCmd extends AbstractDevCmd {
@ -39,7 +37,6 @@ public class FlashMsgCmd extends AbstractDevCmd { @@ -39,7 +37,6 @@ public class FlashMsgCmd extends AbstractDevCmd {
* This function is called by the DevCmdManager. Override to avoid splitting
* argString into String array, since flash displays full String as message,
* then calls the subclass specific _doCmd method.
*
*/
@Override

1
src/engine/devcmd/cmds/GateInfoCmd.java

@ -81,5 +81,4 @@ public class GateInfoCmd extends AbstractDevCmd { @@ -81,5 +81,4 @@ public class GateInfoCmd extends AbstractDevCmd {
}
}

8
src/engine/devcmd/cmds/GetBankCmd.java

@ -17,9 +17,7 @@ import engine.objects.AbstractGameObject; @@ -17,9 +17,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class GetBankCmd extends AbstractDevCmd {
@ -30,10 +28,12 @@ public class GetBankCmd extends AbstractDevCmd { @@ -30,10 +28,12 @@ public class GetBankCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
ClientConnection cc = SessionManager.getClientConnection(pcSender);
if (cc == null) return;
if (cc == null)
return;
VendorDialogMsg.getBank(pcSender, null, cc);
this.setTarget(pcSender); //for logging

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

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.InterestManagement.HeightMap;
@ -88,8 +87,6 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -88,8 +87,6 @@ public class GetHeightCmd extends AbstractDevCmd {
this.throwbackInfo(pc, "SeaFloor Local : " + seaFloorLocalLoc.x + " , " + seaFloorLocalLoc.y);
this.throwbackInfo(pc, "Local Zone Location : " + zoneLoc.x + " , " + zoneLoc.y);
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone);
Vector3fImmutable parentLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone.getParent());
@ -102,7 +99,8 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -102,7 +99,8 @@ public class GetHeightCmd extends AbstractDevCmd {
if ((parentZone != null) && (parentZone.getHeightMap() != null)) {
parentLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), parentZone);
parentGrid = parentZone.getHeightMap().getGridSquare(parentLoc);
} else parentGrid = new Vector2f(-1,-1);
} else
parentGrid = new Vector2f(-1, -1);
gridSquare = heightMap.getGridSquare(zoneLoc);
gridOffset = HeightMap.getGridOffset(gridSquare);
@ -184,8 +182,6 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -184,8 +182,6 @@ public class GetHeightCmd extends AbstractDevCmd {
realWorldAltitude = outsetALt;
}
}
@ -210,14 +206,11 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -210,14 +206,11 @@ public class GetHeightCmd extends AbstractDevCmd {
strMod -= .5f;
realWorldAltitude += strMod;
this.throwbackInfo(pc, "interpolated height with World: " + realWorldAltitude);
}
@Override

27
src/engine/devcmd/cmds/GetMemoryCmd.java

@ -19,19 +19,6 @@ public class GetMemoryCmd extends AbstractDevCmd { @@ -19,19 +19,6 @@ public class GetMemoryCmd extends AbstractDevCmd {
super("getmemory");
}
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
String hSize = getMemoryOutput(Runtime.getRuntime().totalMemory());
String mhSize = getMemoryOutput(Runtime.getRuntime().maxMemory());
String fhSize = getMemoryOutput(Runtime.getRuntime().freeMemory());
String out = "Heap Size: " + hSize + ", Max Heap Size: " + mhSize + ", Free Heap Size: " + fhSize;
throwbackInfo(pcSender, out);
}
public static String getMemoryOutput(long memory) {
String out = "";
if (memory > 1073741824)
@ -44,6 +31,20 @@ public class GetMemoryCmd extends AbstractDevCmd { @@ -44,6 +31,20 @@ public class GetMemoryCmd extends AbstractDevCmd {
return memory + "B";
}
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null)
return;
String hSize = getMemoryOutput(Runtime.getRuntime().totalMemory());
String mhSize = getMemoryOutput(Runtime.getRuntime().maxMemory());
String fhSize = getMemoryOutput(Runtime.getRuntime().freeMemory());
String out = "Heap Size: " + hSize + ", Max Heap Size: " + mhSize + ", Free Heap Size: " + fhSize;
throwbackInfo(pcSender, out);
}
@Override
protected String _getUsageString() {
return "' /getmemory'";

1
src/engine/devcmd/cmds/GetMobBaseLoot.java

@ -18,7 +18,6 @@ import engine.objects.PlayerCharacter; @@ -18,7 +18,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class GetMobBaseLoot extends AbstractDevCmd {

3
src/engine/devcmd/cmds/GetOffsetCmd.java

@ -24,7 +24,8 @@ public class GetOffsetCmd extends AbstractDevCmd { @@ -24,7 +24,8 @@ public class GetOffsetCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
Zone zone = null;
try {

3
src/engine/devcmd/cmds/GetRuneDropRateCmd.java

@ -23,7 +23,8 @@ public class GetRuneDropRateCmd extends AbstractDevCmd { @@ -23,7 +23,8 @@ public class GetRuneDropRateCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
String out = "Depracated";
throwbackInfo(pcSender, out);

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

@ -25,10 +25,12 @@ public class GetVaultCmd extends AbstractDevCmd { @@ -25,10 +25,12 @@ public class GetVaultCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
ClientConnection cc = SessionManager.getClientConnection(pcSender);
if (cc == null) return;
if (cc == null)
return;
VendorDialogMsg.getVault(pcSender, null, cc);
this.setTarget(pcSender); //for logging

3
src/engine/devcmd/cmds/GetZoneCmd.java

@ -26,7 +26,8 @@ public class GetZoneCmd extends AbstractDevCmd { @@ -26,7 +26,8 @@ public class GetZoneCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
if (words.length != 1) {
this.sendUsage(pcSender);

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

@ -25,13 +25,15 @@ public class GetZoneMobsCmd extends AbstractDevCmd { @@ -25,13 +25,15 @@ public class GetZoneMobsCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
int loadID = 0;
if (words.length == 1) {
try {
loadID = Integer.parseInt(words[0]);
} catch (Exception e) {}
} catch (Exception e) {
}
}
//find the zone

1
src/engine/devcmd/cmds/GotoBoundsCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;

1
src/engine/devcmd/cmds/GotoCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;

1
src/engine/devcmd/cmds/GotoObj.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum;

1
src/engine/devcmd/cmds/HeartbeatCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.ai.MobileFSMManager;

2
src/engine/devcmd/cmds/HotzoneCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@ -63,6 +62,7 @@ public class HotzoneCmd extends AbstractDevCmd { @@ -63,6 +62,7 @@ public class HotzoneCmd extends AbstractDevCmd {
return;
}
@Override
protected String _getHelpString() {
return "Use no arguments to see the current hotzone or \"random\" to change it randomly.";

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

@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap; @@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* @author
*
*/
public class InfoCmd extends AbstractDevCmd {
@ -426,8 +425,7 @@ public class InfoCmd extends AbstractDevCmd { @@ -426,8 +425,7 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
output += "enemy: " + targetMob.enemy.toString();
output += newline;
}
catch(Exception ex){
} catch (Exception ex) {
//who cares its info
}
output += "Spawn: (" + targetMob.getBindLoc().getX();
@ -439,7 +437,8 @@ public class InfoCmd extends AbstractDevCmd { @@ -439,7 +437,8 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
if (targetMob.isSummonedPet())
output += "isSummonedPet: true";
else output += "isSummonedPet: false";
else
output += "isSummonedPet: false";
PlayerCharacter owner = targetMob.getOwner();
if (owner != null)
output += " owner: " + owner.getObjectUUID();

2
src/engine/devcmd/cmds/MBDropCmd.java

@ -16,9 +16,7 @@ import engine.objects.LootTable; @@ -16,9 +16,7 @@ import engine.objects.LootTable;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class MBDropCmd extends AbstractDevCmd {

3
src/engine/devcmd/cmds/MakeBaneCmd.java

@ -23,7 +23,6 @@ import org.pmw.tinylog.Logger; @@ -23,7 +23,6 @@ import org.pmw.tinylog.Logger;
/**
* @author Eighty
*
*/
public class MakeBaneCmd extends AbstractDevCmd {
@ -78,8 +77,6 @@ public class MakeBaneCmd extends AbstractDevCmd { @@ -78,8 +77,6 @@ public class MakeBaneCmd extends AbstractDevCmd {
PlayerCharacter player = PlayerCharacter.getPlayerCharacter(attackerID);
if (player.getGuild().isEmptyGuild()) {
throwbackError(pc, "Errant's can not place banes");
return;

2
src/engine/devcmd/cmds/MakeItemCmd.java

@ -21,7 +21,6 @@ import java.util.ArrayList; @@ -21,7 +21,6 @@ import java.util.ArrayList;
/**
* @author Eighty
*
*/
public class MakeItemCmd extends AbstractDevCmd {
@ -70,7 +69,6 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -70,7 +69,6 @@ public class MakeItemCmd extends AbstractDevCmd {
}
//add item to inventory
pc.getCharItemManager().addItemToInventory(item);
}

42
src/engine/devcmd/cmds/NetDebugCmd.java

@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter; @@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
/**
* @author
* Summary: Devcmd to toggle logging of application protocol messages
*
* @author Summary: Devcmd to toggle logging of application protocol messages
*/
public class NetDebugCmd extends AbstractDevCmd {
@ -23,6 +21,23 @@ public class NetDebugCmd extends AbstractDevCmd { @@ -23,6 +21,23 @@ public class NetDebugCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
@ -58,29 +73,12 @@ public class NetDebugCmd extends AbstractDevCmd { @@ -58,29 +73,12 @@ public class NetDebugCmd extends AbstractDevCmd {
return "Toggles sending network messages to log";
}
// Class methods
@Override
protected String _getUsageString() {
return "/netdebug on|off";
}
// Class methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
}

3
src/engine/devcmd/cmds/PrintBonusesCmd.java

@ -73,8 +73,7 @@ public class PrintBonusesCmd extends AbstractDevCmd { @@ -73,8 +73,7 @@ public class PrintBonusesCmd extends AbstractDevCmd {
}
} else if (((AbstractCharacter) tar).getBonuses() != null) {
((AbstractCharacter) tar).getBonuses().printBonusesToClient(pc);
}
else
} else
throwbackInfo(pc, "Bonuses for " + type + ' ' + name + " not found");
}

3
src/engine/devcmd/cmds/PrintInventoryCmd.java

@ -83,7 +83,8 @@ public class PrintInventoryCmd extends AbstractDevCmd { @@ -83,7 +83,8 @@ public class PrintInventoryCmd extends AbstractDevCmd {
chargeInfo = " charges: " + charges + '/' + chargeMax;
}
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems() + chargeInfo);
} else goldCount += item.getNumOfItems();
} else
goldCount += item.getNumOfItems();
}
if (gold != null) {
goldCount += gold.getNumOfItems();

1
src/engine/devcmd/cmds/PrintLocationCmd.java

@ -16,7 +16,6 @@ import engine.objects.Regions; @@ -16,7 +16,6 @@ import engine.objects.Regions;
/**
* @author Eighty
*
*/
public class PrintLocationCmd extends AbstractDevCmd {

22
src/engine/devcmd/cmds/PrintStatsCmd.java

@ -25,6 +25,16 @@ public class PrintStatsCmd extends AbstractDevCmd { @@ -25,6 +25,16 @@ public class PrintStatsCmd extends AbstractDevCmd {
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
}
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
if (equip.containsKey(slot)) {
MobEquipment item = equip.get(slot);
if (item != null && item.getItemBase() != null) {
return item.getItemBase();
}
}
return null;
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
@ -71,7 +81,6 @@ public class PrintStatsCmd extends AbstractDevCmd { @@ -71,7 +81,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
return;
String newline = "\r\n ";
String out = "Server stats for Mob " + mb.getFirstName() + newline;
out += "Stats Base (Modified)" + newline;
@ -130,17 +139,6 @@ public class PrintStatsCmd extends AbstractDevCmd { @@ -130,17 +139,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
throwbackInfo(pc, out);
}
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
if (equip.containsKey(slot)) {
MobEquipment item = equip.get(slot);
if (item != null && item.getItemBase() != null) {
return item.getItemBase();
}
}
return null;
}
@Override
protected String _getHelpString() {
return "Returns the player's current stats";

76
src/engine/devcmd/cmds/PullCmd.java

@ -8,9 +8,7 @@ import engine.math.Vector3fImmutable; @@ -8,9 +8,7 @@ import engine.math.Vector3fImmutable;
import engine.objects.*;
/**
*
* @author
* Dev command to move mobile and it's spawn location
* @author Dev command to move mobile and it's spawn location
* to the player's current location
*/
public class PullCmd extends AbstractDevCmd {
@ -19,6 +17,42 @@ public class PullCmd extends AbstractDevCmd { @@ -19,6 +17,42 @@ public class PullCmd extends AbstractDevCmd {
super("pull");
}
private static void MoveMobile(Mob targetMobile, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.MobQueries.MOVE_MOB(targetMobile.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetMobile.setBindLoc(newLoc);
targetMobile.setLoc(newLoc);
targetMobile.refresh();
}
private static void MoveBuilding(Building targetBuilding, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.BuildingQueries.MOVE_BUILDING(targetBuilding.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetBuilding.setLoc(newLoc);
targetBuilding.getBounds().setBounds(targetBuilding);
targetBuilding.refresh(true);
}
private static void MoveNPC(NPC targetNPC, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.NPCQueries.MOVE_NPC(targetNPC.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetNPC.setBindLoc(newLoc);
targetNPC.setLoc(newLoc);
WorldGrid.updateObject(targetNPC, pcSender);
}
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
@ -65,40 +99,4 @@ public class PullCmd extends AbstractDevCmd { @@ -65,40 +99,4 @@ public class PullCmd extends AbstractDevCmd {
}
return true;
}
private static void MoveMobile(Mob targetMobile, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.MobQueries.MOVE_MOB(targetMobile.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetMobile.setBindLoc(newLoc);
targetMobile.setLoc(newLoc);
targetMobile.refresh();
}
private static void MoveBuilding(Building targetBuilding, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.BuildingQueries.MOVE_BUILDING(targetBuilding.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetBuilding.setLoc(newLoc);
targetBuilding.getBounds().setBounds(targetBuilding);
targetBuilding.refresh(true);
}
private static void MoveNPC(NPC targetNPC, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.NPCQueries.MOVE_NPC(targetNPC.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetNPC.setBindLoc(newLoc);
targetNPC.setLoc(newLoc);
WorldGrid.updateObject(targetNPC, pcSender);
}
}

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

@ -18,9 +18,8 @@ import java.util.concurrent.locks.ReadWriteLock; @@ -18,9 +18,8 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @author
* Summary: Game designer utility command to purge all
objects of a given type within a supplied range
* @author Summary: Game designer utility command to purge all
* objects of a given type within a supplied range
*/
public class PurgeObjectsCmd extends AbstractDevCmd {
@ -59,7 +58,6 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -59,7 +58,6 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
mobA = (Mob) ac;
if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
@ -100,6 +98,113 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -100,6 +98,113 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "npcmobmeshall";
// incorrect number of arguments test
if (userInput.length != 2)
return false;
// Test of game object type argument
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
if (stringIndex == -1)
return false;
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[1]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// User input passes validation
return true;
}
private static void removeBuilding(PlayerCharacter pc, Building building) {
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL))
return;
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
Shrine.RemoveShrineFromCacheByBuilding(building);
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false);
for (AbstractCharacter ac : building.getHirelings().keySet()) {
NPC npc = null;
Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC) ac;
else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob) ac;
if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(Enum.GameObjectType.NPC,
npc.getObjectUUID());
WorldGrid.RemoveWorldObject(npc);
} else if (mobA != null) {
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.MobQueries.DELETE_MOB(mobA);
DbManager.removeFromCache(Enum.GameObjectType.Mob,
mobA.getObjectUUID());
WorldGrid.RemoveWorldObject(mobA);
}
}
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
DbManager.removeFromCache(building);
WorldGrid.RemoveWorldObject(building);
WorldGrid.removeObject(building, pc);
}
private static void removeNPC(PlayerCharacter pc, NPC npc) {
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(npc);
WorldGrid.RemoveWorldObject(npc);
WorldGrid.removeObject(npc, pc);
}
// Class methods
private static void removeMob(PlayerCharacter pc, Mob mob) {
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
//mob.setHealth(-1, pc); //Kill it!
DbManager.MobQueries.DELETE_MOB(mob);
DbManager.removeFromCache(mob);
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
@ -174,38 +279,6 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -174,38 +279,6 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
return "/purge [npc|mob|mesh|all] [range <= 200]";
}
// Class methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "npcmobmeshall";
// incorrect number of arguments test
if (userInput.length != 2)
return false;
// Test of game object type argument
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
if (stringIndex == -1)
return false;
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[1]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
// User input passes validation
return true;
}
private void parseUserInput(String[] userInput) {
_targetMask = 0;
@ -236,80 +309,4 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -236,80 +309,4 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
_targetRange = Math.min(_targetRange, 200f);
}
private static void removeBuilding(PlayerCharacter pc, Building building) {
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL))
return;
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
Shrine.RemoveShrineFromCacheByBuilding(building);
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false);
for (AbstractCharacter ac: building.getHirelings().keySet()){
NPC npc = null;
Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC)ac;
else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob)ac;
if (npc != null){
for (Mob mob: npc.getSiegeMinionMap().keySet()){
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(Enum.GameObjectType.NPC,
npc.getObjectUUID());
WorldGrid.RemoveWorldObject(npc);
}else if (mobA != null){
for (Mob mob: mobA.getSiegeMinionMap().keySet()){
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.MobQueries.DELETE_MOB(mobA);
DbManager.removeFromCache(Enum.GameObjectType.Mob,
mobA.getObjectUUID());
WorldGrid.RemoveWorldObject(mobA);
}
}
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
DbManager.removeFromCache(building);
WorldGrid.RemoveWorldObject(building);
WorldGrid.removeObject(building, pc);
}
private static void removeNPC(PlayerCharacter pc, NPC npc) {
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(npc);
WorldGrid.RemoveWorldObject(npc);
WorldGrid.removeObject(npc, pc);
}
private static void removeMob(PlayerCharacter pc, Mob mob) {
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
//mob.setHealth(-1, pc); //Kill it!
DbManager.MobQueries.DELETE_MOB(mob);
DbManager.removeFromCache(mob);
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
}
}

1
src/engine/devcmd/cmds/RealmInfoCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;

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

@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter; @@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger;
/**
* @author
* Summary: Devcmd to reboot server
*
* @author Summary: Devcmd to reboot server
*/
public class RebootCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/RegionCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;

1
src/engine/devcmd/cmds/RemoveBaneCmd.java

@ -16,7 +16,6 @@ import engine.objects.*; @@ -16,7 +16,6 @@ import engine.objects.*;
/**
* @author Eighty
*
*/
public class RemoveBaneCmd extends AbstractDevCmd {

2
src/engine/devcmd/cmds/RenameCmd.java

@ -18,9 +18,7 @@ import engine.objects.NPC; @@ -18,9 +18,7 @@ import engine.objects.NPC;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class RenameCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/ResetLevelCmd.java

@ -32,5 +32,4 @@ public class ResetLevelCmd extends AbstractDevCmd { @@ -32,5 +32,4 @@ public class ResetLevelCmd extends AbstractDevCmd {
}
}

2
src/engine/devcmd/cmds/SetAICmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.ai.MobileFSMManager;
@ -19,7 +18,6 @@ import engine.server.MBServerStatics; @@ -19,7 +18,6 @@ import engine.server.MBServerStatics;
/**
* @author Steve
*
*/
public class SetAICmd extends AbstractDevCmd {

2
src/engine/devcmd/cmds/SetAdminRuneCmd.java

@ -17,9 +17,7 @@ import engine.objects.CharacterRune; @@ -17,9 +17,7 @@ import engine.objects.CharacterRune;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class SetAdminRuneCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/SetBaneActiveCmd.java

@ -15,7 +15,6 @@ import engine.objects.*; @@ -15,7 +15,6 @@ import engine.objects.*;
/**
* @author Eighty
*
*/
public class SetBaneActiveCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/SetBuildingAltitudeCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;

1
src/engine/devcmd/cmds/SetForceRenameCityCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;

8
src/engine/devcmd/cmds/SetGuildCmd.java

@ -10,9 +10,7 @@ import engine.objects.NPC; @@ -10,9 +10,7 @@ import engine.objects.NPC;
import engine.objects.PlayerCharacter;
/**
*
* @author
* Dev command to set the guild of targeted npc.
* @author Dev command to set the guild of targeted npc.
* Argument is a valid guild UID
*/
public class SetGuildCmd extends AbstractDevCmd {
@ -84,8 +82,8 @@ public class SetGuildCmd extends AbstractDevCmd { @@ -84,8 +82,8 @@ public class SetGuildCmd extends AbstractDevCmd {
// Argument must parse as a int.
try {
Integer.parseInt(userInput[0]); }
catch (NumberFormatException | NullPointerException e) {
Integer.parseInt(userInput[0]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}

1
src/engine/devcmd/cmds/SetHealthCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.DispatchChannel;

3
src/engine/devcmd/cmds/SetInvulCmd.java

@ -27,7 +27,8 @@ public class SetInvulCmd extends AbstractDevCmd { @@ -27,7 +27,8 @@ public class SetInvulCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
if (words.length != 1) {
this.sendUsage(pcSender);

1
src/engine/devcmd/cmds/SetMaintCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum;

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

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -21,6 +20,7 @@ import engine.objects.PlayerCharacter; @@ -21,6 +20,7 @@ import engine.objects.PlayerCharacter;
public class SetNpcEquipSetCmd extends AbstractDevCmd {
public static int lastEquipSetID = 0;
public SetNpcEquipSetCmd() {
super("setEquipSet");
this.addCmdString("equipset");
@ -68,7 +68,6 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd { @@ -68,7 +68,6 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
}
return;
}
@ -99,7 +98,6 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd { @@ -99,7 +98,6 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
}
return;
}

1
src/engine/devcmd/cmds/SetNpcMobbaseCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;

2
src/engine/devcmd/cmds/SetNpcNameCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -20,6 +19,7 @@ import engine.objects.PlayerCharacter; @@ -20,6 +19,7 @@ import engine.objects.PlayerCharacter;
public class SetNpcNameCmd extends AbstractDevCmd {
public static int lastEquipSetID = 0;
public SetNpcNameCmd() {
super("setNPCName");
this.addCmdString("npcname");

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

@ -8,9 +8,7 @@ import engine.objects.*; @@ -8,9 +8,7 @@ import engine.objects.*;
/**
*
* @author
* Dev command to set the owner of targeted building.
* @author Dev command to set the owner of targeted building.
* Argument is a valid guild UID
*/
public class SetOwnerCmd extends AbstractDevCmd {
@ -45,7 +43,8 @@ public class SetOwnerCmd extends AbstractDevCmd { @@ -45,7 +43,8 @@ public class SetOwnerCmd extends AbstractDevCmd {
if (city != null) {
city.claim(outOwner);
return; }
return;
}
}
_targetBuilding.setOwner(outOwner);
@ -89,8 +88,8 @@ public class SetOwnerCmd extends AbstractDevCmd { @@ -89,8 +88,8 @@ public class SetOwnerCmd extends AbstractDevCmd {
// Argument must parse to a long.
try {
Long.parseLong(userInput[0]); }
catch (NumberFormatException | NullPointerException e) {
Long.parseLong(userInput[0]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}

2
src/engine/devcmd/cmds/SetRankCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.InterestManagement.WorldGrid;
@ -126,7 +125,6 @@ public class SetRankCmd extends AbstractDevCmd { @@ -126,7 +125,6 @@ public class SetRankCmd extends AbstractDevCmd {
}
}
@Override

2
src/engine/devcmd/cmds/SetRuneCmd.java

@ -17,9 +17,7 @@ import engine.objects.CharacterRune; @@ -17,9 +17,7 @@ import engine.objects.CharacterRune;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class SetRuneCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/SetStaminaCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.DispatchChannel;

13
src/engine/devcmd/cmds/SetSubRaceCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
@ -79,7 +78,6 @@ public class SetSubRaceCmd extends AbstractDevCmd { @@ -79,7 +78,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
//pc.getCharItemManager().updateInventory();
// Mob mob = (Mob)target;
//
// if (mob == null)
@ -90,8 +88,6 @@ public class SetSubRaceCmd extends AbstractDevCmd { @@ -90,8 +88,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// mob.getCharItemManager().addItemToInventory(mobLoot);
// if (target.getObjectType() != GameObjectType.Building)
// return;
//
@ -155,13 +151,6 @@ public class SetSubRaceCmd extends AbstractDevCmd { @@ -155,13 +151,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// }
// for (EffectsBase eb : EffectsBase.getAllEffectsBase()){
// if (eb.getToken() == 0)
// continue;
@ -192,8 +181,6 @@ public class SetSubRaceCmd extends AbstractDevCmd { @@ -192,8 +181,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// }
}
@Override

1
src/engine/devcmd/cmds/ShowOffsetCmd.java

@ -53,5 +53,4 @@ public class ShowOffsetCmd extends AbstractDevCmd { @@ -53,5 +53,4 @@ public class ShowOffsetCmd extends AbstractDevCmd {
}
}

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

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;

77
src/engine/devcmd/cmds/SplatMobCmd.java

@ -12,8 +12,7 @@ import java.util.concurrent.locks.ReadWriteLock; @@ -12,8 +12,7 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @author
* Summary: Game designer utility command to create multiple
* @author Summary: Game designer utility command to create multiple
* mobiles of a given UUID within a supplied range
*/
@ -39,6 +38,41 @@ public class SplatMobCmd extends AbstractDevCmd { @@ -39,6 +38,41 @@ public class SplatMobCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
// incorrect number of arguments test
if (userInput.length != 3)
return false;
// Test for UUID conversion to int
try {
Integer.parseInt(userInput[0]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// Test for Number of Mobs conversion to int
try {
Integer.parseInt(userInput[1]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[2]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
return true;
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
@ -97,48 +131,13 @@ public class SplatMobCmd extends AbstractDevCmd { @@ -97,48 +131,13 @@ public class SplatMobCmd extends AbstractDevCmd {
return "Spawns multiple mobiles with a given range";
}
// Class methods
@Override
protected String _getUsageString() {
return "/splatmob UUID [Count <= 100] [range <= 1200]";
}
// Class methods
private static boolean validateUserInput(String[] userInput) {
// incorrect number of arguments test
if (userInput.length != 3)
return false;
// Test for UUID conversion to int
try {
Integer.parseInt(userInput[0]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
// Test for Number of Mobs conversion to int
try {
Integer.parseInt(userInput[1]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[2]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
return true;
}
private void parseUserInput(String[] userInput) {
// Clear previous values

42
src/engine/devcmd/cmds/SqlDebugCmd.java

@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter; @@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
/**
* @author
* Summary: Devcmd to toggle logging of mysql statements
*
* @author Summary: Devcmd to toggle logging of mysql statements
*/
public class SqlDebugCmd extends AbstractDevCmd {
@ -23,6 +21,23 @@ public class SqlDebugCmd extends AbstractDevCmd { @@ -23,6 +21,23 @@ public class SqlDebugCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
@ -58,29 +73,12 @@ public class SqlDebugCmd extends AbstractDevCmd { @@ -58,29 +73,12 @@ public class SqlDebugCmd extends AbstractDevCmd {
return "Toggles sending SQL statements to log";
}
// Class methods
@Override
protected String _getUsageString() {
return "/sqldebug on|off";
}
// Class methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
}

1
src/engine/devcmd/cmds/SummonCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;

1
src/engine/devcmd/cmds/UnloadFurnitureCmd.java

@ -21,7 +21,6 @@ import engine.objects.PlayerCharacter; @@ -21,7 +21,6 @@ import engine.objects.PlayerCharacter;
/**
* @author
*
*/
public class UnloadFurnitureCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/ZoneInfoCmd.java

@ -22,7 +22,6 @@ import java.util.ArrayList; @@ -22,7 +22,6 @@ import java.util.ArrayList;
/**
* @author
*
*/
public class ZoneInfoCmd extends AbstractDevCmd {

14
src/engine/devcmd/cmds/aiInfoCmd.java

@ -9,25 +9,19 @@ @@ -9,25 +9,19 @@
package engine.devcmd.cmds;
import engine.Enum.BuildingGroup;
import engine.Enum.GameObjectType;
import engine.Enum.TargetColor;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.BuildingManager;
import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.objects.*;
import engine.util.StringUtils;
import engine.objects.AbstractGameObject;
import engine.objects.Building;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author
*
*/
public class aiInfoCmd extends AbstractDevCmd {

3
src/engine/devcmd/cmds/convertLoc.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -44,8 +43,6 @@ public class convertLoc extends AbstractDevCmd { @@ -44,8 +43,6 @@ public class convertLoc extends AbstractDevCmd {
ChatManager.chatSystemInfo(pc, Vector3fImmutable.toString(convertedLoc));
}
@Override

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

@ -2,8 +2,10 @@ package engine.devcmd.cmds; @@ -2,8 +2,10 @@ package engine.devcmd.cmds;
import engine.Enum;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.*;
import engine.gameManager.BuildingManager;
import engine.gameManager.NPCManager;
import engine.objects.*;
import java.util.ArrayList;
public class simulateBootyCmd extends AbstractDevCmd {

5
src/engine/gameManager/BuildingManager.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.gameManager;
import engine.Enum;
@ -519,7 +518,8 @@ public enum BuildingManager { @@ -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;
@ -697,7 +697,6 @@ public enum BuildingManager { @@ -697,7 +697,6 @@ public enum BuildingManager {
return bindLoc;
}
}

1
src/engine/gameManager/ChatManager.java

@ -47,6 +47,7 @@ public enum ChatManager { @@ -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.
*/

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save