forked from MagicBane/Server
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c02564d7af | |||
| 945f85443d |
@@ -24,8 +24,3 @@
|
|||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
replay_pid*
|
replay_pid*
|
||||||
|
|
||||||
*.idea/
|
|
||||||
Server.iml
|
|
||||||
*.gitignore
|
|
||||||
prestonbane.iml
|
|
||||||
qodana.yaml
|
|
||||||
@@ -88,7 +88,7 @@ public enum MovementManager {
|
|||||||
|
|
||||||
// if (msg.getEndLat() < 0)
|
// if (msg.getEndLat() < 0)
|
||||||
// msg.setEndLat(0);
|
// msg.setEndLat(0);
|
||||||
//
|
//
|
||||||
// if (msg.getEndLon() > 0)
|
// if (msg.getEndLon() > 0)
|
||||||
// msg.setEndLon(0);
|
// msg.setEndLon(0);
|
||||||
|
|
||||||
@@ -216,16 +216,6 @@ 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()) {
|
if (toMove.getObjectType() == GameObjectType.PlayerCharacter && ((PlayerCharacter) toMove).isTeleportMode()) {
|
||||||
toMove.teleport(endLocation);
|
toMove.teleport(endLocation);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class Bounds {
|
|||||||
Bounds identityBounds = Bounds.borrow();
|
Bounds identityBounds = Bounds.borrow();
|
||||||
identityBounds.setBounds(location);
|
identityBounds.setBounds(location);
|
||||||
|
|
||||||
collisionState = collide(targetBounds, identityBounds, 0.1f);
|
collisionState = collide(targetBounds, identityBounds, 0.0f);
|
||||||
identityBounds.release();
|
identityBounds.release();
|
||||||
return collisionState;
|
return collisionState;
|
||||||
}
|
}
|
||||||
@@ -267,45 +267,6 @@ public class Bounds {
|
|||||||
return collidePoint;
|
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) {
|
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 denominator = ((x2 - x1) * (y4 - y3)) - ((y2 - y1) * (x4 - x3));
|
||||||
float numerator1 = ((y1 - y3) * (x4 - x3)) - ((x1 - x3) * (y4 - y3));
|
float numerator1 = ((y1 - y3) * (x4 - x3)) - ((x1 - x3) * (y4 - y3));
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import engine.Enum.GuildState;
|
|||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.gameManager.GuildManager;
|
||||||
import engine.gameManager.SessionManager;
|
import engine.gameManager.SessionManager;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
@@ -26,8 +27,6 @@ import engine.objects.Guild;
|
|||||||
import engine.objects.GuildStatusController;
|
import engine.objects.GuildStatusController;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
public AcceptSubInviteHandler() {
|
public AcceptSubInviteHandler() {
|
||||||
@@ -38,69 +37,74 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
|||||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
||||||
PlayerCharacter sourcePlayer;
|
PlayerCharacter playerCharacter;
|
||||||
Guild sourceGuild;
|
Guild protectorate;
|
||||||
Guild targetGuild;
|
Guild nation;
|
||||||
Dispatch dispatch;
|
Dispatch dispatch;
|
||||||
|
|
||||||
// get PlayerCharacter of person sending sub invite
|
// get PlayerCharacter of person sending sub invite
|
||||||
|
|
||||||
sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||||
|
|
||||||
if (sourcePlayer == null)
|
if (playerCharacter == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
sourceGuild = sourcePlayer.getGuild();
|
protectorate = playerCharacter.getGuild();
|
||||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
nation = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||||
|
|
||||||
//must be source guild to sub to
|
//must be source guild to sub to
|
||||||
|
|
||||||
if (targetGuild == null) {
|
if (nation == null) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sourceGuild == null) {
|
if (protectorate == null) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceGuild.equals(targetGuild))
|
if (protectorate.equals(nation))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus()) == false) {
|
||||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only a guild leader can accept fealty!");
|
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Only a guild leader can accept fealty!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//source guild is limited to 7 subs
|
//source guild is limited to 7 subs
|
||||||
//TODO this should be based on TOL rank
|
//TODO this should be based on TOL rank
|
||||||
|
|
||||||
if (!targetGuild.canSubAGuild(sourceGuild)) {
|
if (!nation.canSubAGuild(protectorate)) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//all tests passed, let's Handle code
|
//all tests passed, let's Handle code
|
||||||
//Update Target Guild State.
|
|
||||||
|
|
||||||
sourceGuild.upgradeGuildState(false);
|
// Update database
|
||||||
|
|
||||||
//Add sub so GuildMaster can Swear in.
|
if (!DbManager.GuildQueries.UPDATE_PARENT(protectorate.getObjectUUID(), nation.getObjectUUID())) {
|
||||||
|
ErrorPopupMsg.sendErrorMsg(playerCharacter, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<Guild> subs = targetGuild.getSubGuildList();
|
//update Guild states.
|
||||||
subs.add(sourceGuild);
|
|
||||||
|
|
||||||
targetGuild.setGuildState(GuildState.Nation);
|
protectorate.setNation(nation);
|
||||||
|
GuildManager.updateAllGuildTags(protectorate);
|
||||||
|
protectorate.upgradeGuildState(false);
|
||||||
|
|
||||||
|
if (nation.getGuildState() == GuildState.Sovereign)
|
||||||
|
nation.upgradeGuildState(true);
|
||||||
|
|
||||||
//Let's send the message back.
|
//Let's send the message back.
|
||||||
|
|
||||||
msg.setUnknown02(1);
|
msg.setUnknown02(1);
|
||||||
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
msg.setResponse("Your guild is now a " + protectorate.getGuildState().name() + '.');
|
||||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
ChatManager.chatSystemInfo(playerCharacter, "Your guild is now a " + protectorate.getGuildState().name() + '.');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import engine.job.JobScheduler;
|
|||||||
import engine.jobs.DeferredPowerJob;
|
import engine.jobs.DeferredPowerJob;
|
||||||
import engine.jobs.FinishSpireEffectJob;
|
import engine.jobs.FinishSpireEffectJob;
|
||||||
import engine.jobs.NoTimeJob;
|
import engine.jobs.NoTimeJob;
|
||||||
|
import engine.math.Bounds;
|
||||||
import engine.math.FastMath;
|
import engine.math.FastMath;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
@@ -268,6 +269,9 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
|
|
||||||
this.hash = rs.getString("hash");
|
this.hash = rs.getString("hash");
|
||||||
|
|
||||||
|
|
||||||
|
// For debugging skills
|
||||||
|
// CharacterSkill.printSkills(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Building getUpdatedBindBuilding(PlayerCharacter player) {
|
public static Building getUpdatedBindBuilding(PlayerCharacter player) {
|
||||||
@@ -4561,6 +4565,9 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
|
|
||||||
this.charItemManager = new CharacterItemManager(this);
|
this.charItemManager = new CharacterItemManager(this);
|
||||||
|
|
||||||
|
Bounds playerBounds = Bounds.borrow();
|
||||||
|
playerBounds.setBounds(this.getLoc());
|
||||||
|
this.setBounds(playerBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -5356,7 +5363,6 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
moveToMsg.setSourceType(GameObjectType.PlayerCharacter.ordinal());
|
moveToMsg.setSourceType(GameObjectType.PlayerCharacter.ordinal());
|
||||||
moveToMsg.setSourceID(this.getObjectUUID());
|
moveToMsg.setSourceID(this.getObjectUUID());
|
||||||
|
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(this, moveToMsg);
|
Dispatch dispatch = Dispatch.borrow(this, moveToMsg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user