Compare commits

..

8 Commits

13 changed files with 147 additions and 149 deletions
+5 -2
View File
@@ -24,5 +24,8 @@
hs_err_pid*
replay_pid*
.idea/
*.iml
*.idea/
Server.iml
*.gitignore
prestonbane.iml
qodana.yaml
+3 -4
View File
@@ -14,7 +14,6 @@ import engine.gameManager.ChatManager;
import engine.objects.AbstractGameObject;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
/**
* @author Eighty
@@ -47,10 +46,10 @@ public class AddGoldCmd extends AbstractDevCmd {
throwbackError(pc, "Quantity must be a number, " + words[0] + " is invalid");
return;
}
if (amt < 1 || amt > MBServerStatics.PLAYER_GOLD_LIMIT) {
throwbackError(pc, "Quantity must be between 1 and " + MBServerStatics.PLAYER_GOLD_LIMIT);
if (amt < 1 || amt > 10000000) {
throwbackError(pc, "Quantity must be between 1 and 10000000 (10 million)");
return;
} else if ((curAmt + amt) > MBServerStatics.PLAYER_GOLD_LIMIT) {
} else if ((curAmt + amt) > 10000000) {
throwbackError(pc, "This would place your inventory over 10,000,000 gold.");
return;
}
+16 -52
View File
@@ -16,7 +16,6 @@ import engine.devcmd.AbstractDevCmd;
import engine.gameManager.DbManager;
import engine.objects.*;
import engine.powers.EffectsBase;
import engine.server.MBServerStatics;
import java.util.ArrayList;
@@ -32,82 +31,47 @@ public class MakeItemCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if (words[0].equals("resources")) {
int resourceAmount = 1000;
if (words.length > 1) {
try {
resourceAmount = Integer.parseInt(words[1]);
} catch (NumberFormatException e) {
throwbackError(pc, "Resource amount must be a number.");
return;
}
}
if (resourceAmount < 1)
resourceAmount = 1;
resourceAmount = Math.min(
resourceAmount,
MBServerStatics.RESOURCE_STACK_LIMIT
);
for (int ibID : Warehouse.getMaxResources().keySet()) {
if (ibID == 7)
continue;
ItemBase ib = ItemBase.getItemBase(ibID);
if (ib == null)
continue;
short weight = ib.getWeight();
if (!pc.getCharItemManager().hasRoomInventory(weight)) {
throwbackError(pc, "Not enough room in inventory for any more resources.");
throwbackError(pc, "Not enough room in inventory for any more of this item");
pc.getCharItemManager().updateInventory();
return;
}
Item item = new Item(
ib,
pc.getObjectUUID(),
OwnerType.PlayerCharacter,
(byte) 0,
(byte) 0,
(short) ib.getDurability(),
(short) ib.getDurability(),
true,
false,
ItemContainerType.INVENTORY,
(byte) 0,
new ArrayList<>(),
""
);
boolean worked = false;
Item item = new Item(ib, pc.getObjectUUID(),
OwnerType.PlayerCharacter, (byte) 0, (byte) 0, (short) ib.getDurability(), (short) ib.getDurability(),
true, false, ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(), "");
item.setNumOfItems(resourceAmount);
item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
worked = true;
} catch (Exception e) {
throwbackError(
pc,
"Unable to create resource " + ib.getName() + ": " + e.getMessage()
);
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage());
return;
}
if (item == null) {
throwbackError(pc, "Unable to create resource " + ib.getName() + ".");
if (item == null || !worked) {
throwbackError(pc, "DB error 2: Unable to create item.");
return;
}
//add item to inventory
pc.getCharItemManager().addItemToInventory(item);
}
pc.getCharItemManager().updateInventory();
return;
}
if (words.length < 3 || words.length > 5) {
@@ -136,7 +100,7 @@ public class MakeItemCmd extends AbstractDevCmd {
return;
}
numItems = (numItems < 1) ? 1 : numItems;
numItems = Math.min(numItems, MBServerStatics.RESOURCE_STACK_LIMIT);
numItems = (numItems > 5000) ? 5000 : numItems;
}
int itembaseID;
-7
View File
@@ -39,13 +39,6 @@ public class SlotTestCmd extends AbstractDevCmd {
Building building = (Building) target;
outString += "Rank: " + building.getRank() + "\r\n";
outString += "MaxSlots: " + building.getBlueprint().getMaxSlots() + "\r\n";
outString += "SlotsForRank: "
+ building.getBlueprint().getSlotsForRank(building.getRank())
+ "\r\n";
outString += "Hireling Count: " + building.getHirelings().size() + "\r\n\r\n";
buildingLocations = BuildingManager._slotLocations.get(building.meshUUID);
if (buildingLocations == null) {
+11 -1
View File
@@ -88,7 +88,7 @@ public enum MovementManager {
// if (msg.getEndLat() < 0)
// msg.setEndLat(0);
//
//
// if (msg.getEndLon() > 0)
// msg.setEndLon(0);
@@ -216,6 +216,16 @@ public enum MovementManager {
}
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
Vector3fImmutable playerCollidePoint = Bounds.PlayerCollisionPoint((PlayerCharacter) toMove, toMove.getLoc(), endLocation);
if (playerCollidePoint != null) {
msg.setEndCoord(playerCollidePoint);
endLocation = playerCollidePoint;
collide = true;
}
}
if (toMove.getObjectType() == GameObjectType.PlayerCharacter && ((PlayerCharacter) toMove).isTeleportMode()) {
toMove.teleport(endLocation);
return;
+40 -1
View File
@@ -81,7 +81,7 @@ public class Bounds {
Bounds identityBounds = Bounds.borrow();
identityBounds.setBounds(location);
collisionState = collide(targetBounds, identityBounds, 0.0f);
collisionState = collide(targetBounds, identityBounds, 0.1f);
identityBounds.release();
return collisionState;
}
@@ -267,6 +267,45 @@ public class Bounds {
return collidePoint;
}
public static Vector3fImmutable PlayerCollisionPoint(PlayerCharacter player, Vector3fImmutable start, Vector3fImmutable end) {
Vector3fImmutable collidePoint = null;
float distance = player.getLoc().distance2D(end);
// Check for building collisions first
collidePoint = PlayerBuildingCollisionPoint(player, start, end);
if (collidePoint != null) {
return collidePoint;
}
// Now check for player collisions
HashSet<AbstractWorldObject> nearbyPlayers = WorldGrid.getObjectsInRangePartial(player, distance + 2, MBServerStatics.MASK_PLAYER);
float minDistance = 5.0f; // Minimum distance between players
for (AbstractWorldObject awo : nearbyPlayers) {
PlayerCharacter otherPlayer = (PlayerCharacter) awo;
if (otherPlayer == player) continue;
Vector3fImmutable otherLoc = otherPlayer.getLoc();
Vector3fImmutable closestPoint = getClosestPointOnLine(start, end, otherLoc);
if (closestPoint.distance2D(otherLoc) < minDistance) {
// Collision detected, adjust end point
Vector3fImmutable pushVector = closestPoint.subtract(otherLoc).normalize();
collidePoint = closestPoint.add(pushVector.scaleAdd(minDistance, Vector3fImmutable.ZERO));
break;
}
}
return collidePoint != null ? collidePoint : end;
}
private static Vector3fImmutable getClosestPointOnLine(Vector3fImmutable lineStart, Vector3fImmutable lineEnd, Vector3fImmutable point) {
Vector3fImmutable line = lineEnd.subtract(lineStart);
float t = point.subtract(lineStart).dot(line) / line.dot(line);
t = Math.max(0, Math.min(1, t));
return lineStart.add(line.scaleAdd(t, Vector3fImmutable.ZERO));
}
public static boolean linesTouching(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
float denominator = ((x2 - x1) * (y4 - y3)) - ((y2 - y1) * (x4 - x3));
float numerator1 = ((y1 - y3) * (x4 - x3)) - ((x1 - x3) * (y4 - y3));
+1 -1
View File
@@ -1259,7 +1259,7 @@ public class ClientMessagePump implements NetMsgHandler {
cost *= profit;
if (gold.getNumOfItems() + cost > MBServerStatics.PLAYER_GOLD_LIMIT) {
if (gold.getNumOfItems() + cost > 10000000) {
return;
}
+1 -1
View File
@@ -335,7 +335,7 @@ public class Blueprint {
availableSlots = 3;
break;
case 8:
availableSlots = Math.min(3, this.maxSlots);
availableSlots = 1;
break;
default:
availableSlots = 0;
+3 -2
View File
@@ -2335,14 +2335,15 @@ public class CharacterItemManager {
}
if (this.getGoldInventory().getNumOfItems() + goldFrom2 > MBServerStatics.PLAYER_GOLD_LIMIT) {
if (this.getGoldInventory().getNumOfItems() + goldFrom2 > 10000000) {
PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
if (pc.getClientConnection() != null)
ErrorPopupMsg.sendErrorPopup(pc, 202);
return false;
}
if (tradingWith.getGoldInventory().getNumOfItems() + goldFrom1 > MBServerStatics.PLAYER_GOLD_LIMIT) {
if (tradingWith.getGoldInventory().getNumOfItems() + goldFrom1 > 10000000) {
PlayerCharacter pc = (PlayerCharacter) tradingWith.absCharacter;
if (pc.getClientConnection() != null)
ErrorPopupMsg.sendErrorPopup(pc, 202);
+40 -39
View File
@@ -674,6 +674,46 @@ public class Item extends AbstractWorldObject {
public static Item newGoldItem(AbstractWorldObject awo, ItemBase ib, Enum.ItemContainerType containerType) {
return newGoldItem(awo, ib, containerType, true);
}
//used for vault!
public static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType) {
return newGoldItem(accountID, ib, containerType, true);
}
private static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) {
int ownerID;
OwnerType ownerType;
ownerID = accountID;
ownerType = OwnerType.Account;
Item newGold = new Item(ib, ownerID, ownerType,
(byte) 0, (byte) 0, (short) 0, (short) 0, true, false, containerType, (byte) 0,
new ArrayList<>(), "");
synchronized (newGold) {
newGold.numberOfItems = 0;
}
if (persist) {
try {
newGold = DbManager.ItemQueries.ADD_ITEM(newGold);
if (newGold != null) {
synchronized (newGold) {
newGold.numberOfItems = 0;
}
}
} catch (Exception e) {
Logger.error(e);
}
DbManager.ItemQueries.ZERO_ITEM_STACK(newGold);
}
return newGold;
}
private static Item newGoldItem(AbstractWorldObject awo, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) {
int ownerID;
@@ -731,49 +771,10 @@ public class Item extends AbstractWorldObject {
}
DbManager.ItemQueries.ZERO_ITEM_STACK(newGold);
}
newGold.containerType = containerType;
return newGold;
}
//used for vault!
public static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType) {
return newGoldItem(accountID, ib, containerType, true);
}
private static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) {
int ownerID;
OwnerType ownerType;
ownerID = accountID;
ownerType = OwnerType.Account;
Item newGold = new Item(ib, ownerID, ownerType,
(byte) 0, (byte) 0, (short) 0, (short) 0, true, false, containerType, (byte) 0,
new ArrayList<>(), "");
synchronized (newGold) {
newGold.numberOfItems = 0;
}
if (persist) {
try {
newGold = DbManager.ItemQueries.ADD_ITEM(newGold);
if (newGold != null) {
synchronized (newGold) {
newGold.numberOfItems = 0;
}
}
} catch (Exception e) {
Logger.error(e);
}
DbManager.ItemQueries.ZERO_ITEM_STACK(newGold);
}
return newGold;
}
// This is to be used for trades - the new item is not stored in the database
public static Item newGoldItemTemp(AbstractWorldObject awo, ItemBase ib) {
+2 -13
View File
@@ -26,7 +26,6 @@ import engine.job.JobScheduler;
import engine.jobs.DeferredPowerJob;
import engine.jobs.FinishSpireEffectJob;
import engine.jobs.NoTimeJob;
import engine.math.Bounds;
import engine.math.FastMath;
import engine.math.Vector3fImmutable;
import engine.net.ByteBufferWriter;
@@ -269,9 +268,6 @@ public class PlayerCharacter extends AbstractCharacter {
this.hash = rs.getString("hash");
// For debugging skills
// CharacterSkill.printSkills(this);
}
public static Building getUpdatedBindBuilding(PlayerCharacter player) {
@@ -1239,17 +1235,12 @@ public class PlayerCharacter extends AbstractCharacter {
playerCharacter.deactivateCharacter();
return null;
}
// Ebonreach: give new characters starter gold.
Item starterGold = Item.newGoldItem(playerCharacter, ItemBase.getItemBase(7), Enum.ItemContainerType.INVENTORY);
if (starterGold != null)
DbManager.ItemQueries.UPDATE_GOLD(starterGold, 10000);
// Get any new skills that belong to the player
playerCharacter.calculateSkills();
a.setLastCharacter(playerCharacter.getObjectUUID());
playerCharacter.getCharItemManager().load();
playerCharacter.charItemManager.load();
playerCharacter.activateCharacter();
@@ -4570,9 +4561,6 @@ public class PlayerCharacter extends AbstractCharacter {
this.charItemManager = new CharacterItemManager(this);
Bounds playerBounds = Bounds.borrow();
playerBounds.setBounds(this.getLoc());
this.setBounds(playerBounds);
}
@Override
@@ -5368,6 +5356,7 @@ public class PlayerCharacter extends AbstractCharacter {
moveToMsg.setSourceType(GameObjectType.PlayerCharacter.ordinal());
moveToMsg.setSourceID(this.getObjectUUID());
Dispatch dispatch = Dispatch.borrow(this, moveToMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
+23 -23
View File
@@ -99,29 +99,29 @@ public class Warehouse extends AbstractWorldObject {
public static ConcurrentHashMap<Integer, Integer> getMaxResources() {
if (maxResources.size() != 23) {
maxResources.put(7, 1000000000);
maxResources.put(1580000, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580001, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580002, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580003, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580004, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580005, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580006, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580007, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580008, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580009, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580010, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580011, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580012, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580013, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580014, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580015, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580016, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580017, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580018, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580019, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580020, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580021, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(7, 100000000);
maxResources.put(1580000, 10000);
maxResources.put(1580001, 2000);
maxResources.put(1580002, 2000);
maxResources.put(1580003, 1000);
maxResources.put(1580004, 10000);
maxResources.put(1580005, 3000);
maxResources.put(1580006, 3000);
maxResources.put(1580007, 1000);
maxResources.put(1580008, 3000);
maxResources.put(1580009, 2000);
maxResources.put(1580010, 2000);
maxResources.put(1580011, 1000);
maxResources.put(1580012, 2000);
maxResources.put(1580013, 3000);
maxResources.put(1580014, 1000);
maxResources.put(1580015, 1000);
maxResources.put(1580016, 1000);
maxResources.put(1580017, 500);
maxResources.put(1580018, 500);
maxResources.put(1580019, 500);
maxResources.put(1580020, 500);
maxResources.put(1580021, 500);
}
return maxResources;
+2 -3
View File
@@ -33,16 +33,15 @@ public class MBServerStatics {
// hit box
// calcs
public static final boolean PRINT_INCOMING_OPCODES = false; // print
public static final int BANK_GOLD_LIMIT = 1000000000;
public static final int BANK_GOLD_LIMIT = 25000000;
// incoming
// opcodes to
// console
public static final int PLAYER_GOLD_LIMIT = 500000000;
public static final int PLAYER_GOLD_LIMIT = 10000000;
// buildings, npcs
/*
* Login cache flags
*/
public static final int RESOURCE_STACK_LIMIT = 1000000000;
public static final boolean SKIP_CACHE_LOGIN = false; // skip caching // login server
public static final boolean SKIP_CACHE_LOGIN_PLAYER = false; // skip caching // on login
public static final boolean SKIP_CACHE_LOGIN_ITEM = false; // skip caching