Browse Source

Move to point message variable naming and handler cleanup

feature-workorder
FatBoy-DOTC 1 year ago
parent
commit
003b939d33
  1. 2
      src/engine/devcmd/cmds/SetSubRaceCmd.java
  2. 20
      src/engine/gameManager/MovementManager.java
  3. 6
      src/engine/mobileAI/utilities/MovementUtilities.java
  4. 2
      src/engine/net/client/ClientMessagePump.java
  5. 24
      src/engine/net/client/handlers/MoveToPointHandler.java
  6. 111
      src/engine/net/client/msg/MoveToPointMsg.java
  7. 2
      src/engine/objects/PlayerCharacter.java

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

@ -159,7 +159,7 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// pum.setEffectID(token); // pum.setEffectID(token);
// pum.setSourceType(pc.getObjectType().ordinal()); // pum.setSourceType(pc.getObjectType().ordinal());
// pum.setSourceID(pc.getObjectUUID()); // pum.setSourceID(pc.getObjectUUID());
// pum.setTargetType(pc.getObjectType().ordinal()); // pum.setStartLocType(pc.getObjectType().ordinal());
// pum.setTargetID(pc.getObjectUUID()); // pum.setTargetID(pc.getObjectUUID());
// pum.setNumTrains(40); // pum.setNumTrains(40);
// pum.setDuration(-1); // pum.setDuration(-1);

20
src/engine/gameManager/MovementManager.java

@ -116,8 +116,8 @@ public enum MovementManager {
// if inside a building, convert both locations from the building local reference frame to the world reference frame // if inside a building, convert both locations from the building local reference frame to the world reference frame
if (msg.getTargetID() > 0) { if (msg.getInBuildingUUID() > 0) {
Building building = BuildingManager.getBuildingFromCache(msg.getTargetID()); Building building = BuildingManager.getBuildingFromCache(msg.getInBuildingUUID());
if (building != null) { if (building != null) {
Vector3fImmutable convertLocEnd = new Vector3fImmutable(ZoneManager.convertLocalToWorld(building, endLocation)); Vector3fImmutable convertLocEnd = new Vector3fImmutable(ZoneManager.convertLocalToWorld(building, endLocation));
@ -128,8 +128,8 @@ public enum MovementManager {
// } // }
// else { // else {
toMove.setInBuilding(msg.getInBuilding()); toMove.setInBuilding(msg.getInBuilding());
toMove.setInFloorID(msg.getUnknown01()); toMove.setInFloorID(msg.getInBuildingFloor());
toMove.setInBuildingID(msg.getTargetID()); toMove.setInBuildingID(msg.getInBuildingUUID());
msg.setStartCoord(ZoneManager.convertWorldToLocal(building, toMove.getLoc())); msg.setStartCoord(ZoneManager.convertWorldToLocal(building, toMove.getLoc()));
if (toMove.getObjectType() == GameObjectType.PlayerCharacter) { if (toMove.getObjectType() == GameObjectType.PlayerCharacter) {
@ -174,9 +174,9 @@ public enum MovementManager {
msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc())); msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc()));
msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation)); msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation));
msg.setInBuilding(toMove.region.level); msg.setInBuilding(toMove.region.level);
msg.setUnknown01(toMove.region.room); msg.setInBuildingFloor(toMove.region.room);
msg.setTargetType(GameObjectType.Building.ordinal()); msg.setStartLocType(GameObjectType.Building.ordinal());
msg.setTargetID(regionBuilding.getObjectUUID()); msg.setInBuildingUUID(regionBuilding.getObjectUUID());
} }
} else { } else {
@ -185,8 +185,8 @@ public enum MovementManager {
toMove.setInBuilding(-1); toMove.setInBuilding(-1);
msg.setStartCoord(toMove.getLoc()); msg.setStartCoord(toMove.getLoc());
msg.setEndCoord(endLocation); msg.setEndCoord(endLocation);
msg.setTargetType(0); msg.setStartLocType(0);
msg.setTargetID(0); msg.setInBuildingUUID(0);
} }
//checks sync between character and server, if out of sync, teleport player to original position and return. //checks sync between character and server, if out of sync, teleport player to original position and return.
@ -233,7 +233,7 @@ public enum MovementManager {
toMove.cancelOnMove(); toMove.cancelOnMove();
//cancel any attacks for manual move. //cancel any attacks for manual move.
if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) && msg.getUnknown02() == 0) if ((toMove.getObjectType() == GameObjectType.PlayerCharacter) && msg.getInitiatedFromAttack() == 0)
toMove.setCombatTarget(null); toMove.setCombatTarget(null);

6
src/engine/mobileAI/utilities/MovementUtilities.java

@ -244,10 +244,10 @@ public class MovementUtilities {
msg.setSourceID(agent.getObjectUUID()); msg.setSourceID(agent.getObjectUUID());
msg.setStartCoord(startLoc); msg.setStartCoord(startLoc);
msg.setEndCoord(endLoc); msg.setEndCoord(endLoc);
msg.setUnknown01(-1); msg.setInBuildingFloor(-1);
msg.setInBuilding(-1); msg.setInBuilding(-1);
msg.setTargetType(0); msg.setStartLocType(0);
msg.setTargetID(0); msg.setInBuildingUUID(0);
try { try {

2
src/engine/net/client/ClientMessagePump.java

@ -643,7 +643,7 @@ public class ClientMessagePump implements NetMsgHandler {
moveMsg.setStartCoord(sourcePlayer.getLoc()); moveMsg.setStartCoord(sourcePlayer.getLoc());
moveMsg.setEndCoord(sourcePlayer.getLoc()); moveMsg.setEndCoord(sourcePlayer.getLoc());
moveMsg.setInBuilding(-1); moveMsg.setInBuilding(-1);
moveMsg.setUnknown01(-1); moveMsg.setInBuildingFloor(-1);
dispatch = Dispatch.borrow(sourcePlayer, moveMsg); dispatch = Dispatch.borrow(sourcePlayer, moveMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);

24
src/engine/net/client/handlers/MoveToPointHandler.java

@ -32,37 +32,31 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null; PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null;
if (pc == null) if (pc == null)
return false; return false;
if (msg.getInitiatedFromAttack() == 1) {
if(pc.combatTarget == null){ //move message was initiated by an attack message
MovementManager.movement(msg, pc);
return true;
} else{
Enum.GameObjectType combatTargetType = pc.combatTarget.getObjectType(); Enum.GameObjectType combatTargetType = pc.combatTarget.getObjectType();
if (combatTargetType.equals(Enum.GameObjectType.NPC)) { if (combatTargetType.equals(Enum.GameObjectType.NPC)) {
msg.clearTarget(); msg.clearTarget();
pc.setCombatTarget(null); pc.setCombatTarget(null);
origin.sendMsg(msg); origin.sendMsg(msg);
}
if(combatTargetType.equals(Enum.GameObjectType.Mob) || combatTargetType.equals(Enum.GameObjectType.PlayerCharacter)){
MovementManager.movement(msg, pc);
return true;
} else if (combatTargetType.equals(Enum.GameObjectType.Building)) { } else if (combatTargetType.equals(Enum.GameObjectType.Building)) {
Building targetBuilding = BuildingManager.getBuilding(pc.combatTarget.getObjectUUID()); Building targetBuilding = BuildingManager.getBuilding(pc.combatTarget.getObjectUUID());
if (targetBuilding != null) { if (targetBuilding != null) {
if (targetBuilding.isVulnerable() && targetBuilding.getRank() > -1) { if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0) {
MovementManager.movement(msg, pc);
return true;
} else{
msg.clearTarget(); msg.clearTarget();
pc.setCombatTarget(null); pc.setCombatTarget(null);
origin.sendMsg(msg); origin.sendMsg(msg);
} }
} }
} }
}
msg.setEndCoord(pc.loc); msg.setEndCoord(pc.loc);
origin.sendMsg(msg); origin.sendMsg(msg);
return true; return true;
} }
MovementManager.movement(msg, pc);
return true;
}
} }

111
src/engine/net/client/msg/MoveToPointMsg.java

@ -10,6 +10,7 @@
package engine.net.client.msg; package engine.net.client.msg;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.gameManager.BuildingManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.net.AbstractConnection; import engine.net.AbstractConnection;
@ -21,19 +22,19 @@ import engine.objects.Building;
public class MoveToPointMsg extends ClientNetMsg { public class MoveToPointMsg extends ClientNetMsg {
private int sourceType; private int sourceType; //ordinal of the character type that sent this message 54=PlayerCharacter
private int sourceID; private int sourceID; // uuid of the source character of this message
private float startLat; private float startLat; //start loc of move message (offset if inside a building not world loc)
private float startLon; private float startLon; //start loc of move message (offset if inside a building not world loc)
private float startAlt; private float startAlt; //start loc of move message (offset if inside a building not world loc)
private float endLat; private float endLat; //end loc of move message (offset if inside a building not world loc)
private float endLon; private float endLon; //end loc of move message (offset if inside a building not world loc)
private float endAlt; private float endAlt; //end loc of move message (offset if inside a building not world loc)
private int targetType; private int startLocType; // enum ordinal of the object player is inside 0=nothing 8=building
private int targetID; private int inBuildingUUID; // uuid of the building character is currently inside
private int inBuilding; // 0=true, -1=false 0/1/2 = floor you are on private int inBuilding; // is inside a building 0=true -1=false
private int unknown01; private int inBuildingFloor; // floor of building character is currently in -1=not inside building 0/1/2/3 = floor number
private byte unknown02; private byte initiatedByAttack; // move message sent as a result of move to target to attack 0=false 1=true
private byte unknown03; private byte unknown03;
/** /**
@ -54,11 +55,11 @@ public class MoveToPointMsg extends ClientNetMsg {
this.endLat = msg.endLat; this.endLat = msg.endLat;
this.endLon = msg.endLon; this.endLon = msg.endLon;
this.endAlt = msg.endAlt; this.endAlt = msg.endAlt;
this.targetType = msg.targetType; this.startLocType = msg.startLocType;
this.targetID = msg.targetID; this.inBuildingUUID = msg.inBuildingUUID;
this.inBuilding = msg.inBuilding; this.inBuilding = msg.inBuilding;
this.unknown01 = msg.unknown01; this.inBuildingFloor = msg.inBuildingFloor;
this.unknown02 = msg.unknown02; this.initiatedByAttack = msg.initiatedByAttack;
this.unknown03 = msg.unknown03; this.unknown03 = msg.unknown03;
} }
@ -73,11 +74,11 @@ public class MoveToPointMsg extends ClientNetMsg {
this.endLat = building.getLoc().x; this.endLat = building.getLoc().x;
this.endLon = building.getLoc().z; this.endLon = building.getLoc().z;
this.endAlt = building.getLoc().y; this.endAlt = building.getLoc().y;
this.targetType = 0; this.startLocType = 0;
this.targetID = 0; this.inBuildingUUID = 0;
this.inBuilding = -1; this.inBuilding = -1;
this.unknown01 = -1; this.inBuildingFloor = -1;
this.unknown02 = 0; this.initiatedByAttack = 0;
this.unknown03 = 0; this.unknown03 = 0;
} }
@ -108,11 +109,11 @@ public class MoveToPointMsg extends ClientNetMsg {
writer.putFloat(this.endAlt); writer.putFloat(this.endAlt);
writer.putFloat(this.endLon); writer.putFloat(this.endLon);
writer.putInt(this.targetType); writer.putInt(this.startLocType);
writer.putInt(this.targetID); writer.putInt(this.inBuildingUUID);
writer.putInt(this.inBuilding); writer.putInt(this.inBuilding);
writer.putInt(this.unknown01); writer.putInt(this.inBuildingFloor);
writer.put((byte) 0); writer.put((byte) 0);
writer.put((byte) 0); writer.put((byte) 0);
@ -135,13 +136,13 @@ public class MoveToPointMsg extends ClientNetMsg {
this.endAlt = reader.getFloat(); this.endAlt = reader.getFloat();
this.endLon = reader.getFloat(); this.endLon = reader.getFloat();
this.targetType = reader.getInt(); this.startLocType = reader.getInt();
this.targetID = reader.getInt(); this.inBuildingUUID = reader.getInt();
this.inBuilding = reader.getInt(); this.inBuilding = reader.getInt();
this.unknown01 = reader.getInt(); this.inBuildingFloor = reader.getInt();
this.unknown02 = reader.get(); this.initiatedByAttack = reader.get();
this.unknown03 = reader.get(); this.unknown03 = reader.get();
} }
@ -209,20 +210,20 @@ public class MoveToPointMsg extends ClientNetMsg {
this.endAlt = value; this.endAlt = value;
} }
public int getTargetType() { public int getStartLocType() {
return this.targetType; return this.startLocType;
} }
public void setTargetType(int value) { public void setStartLocType(int value) {
this.targetType = value; this.startLocType = value;
} }
public int getTargetID() { public int getInBuildingUUID() {
return this.targetID; return this.inBuildingUUID;
} }
public void setTargetID(int value) { public void setInBuildingUUID(int value) {
this.targetID = value; this.inBuildingUUID = value;
} }
public int getInBuilding() { public int getInBuilding() {
@ -233,12 +234,8 @@ public class MoveToPointMsg extends ClientNetMsg {
this.inBuilding = value; this.inBuilding = value;
} }
public int getUnknown01() { public void setInBuildingFloor(int value) {
return this.unknown01; this.inBuildingFloor = value;
}
public void setUnknown01(int value) {
this.unknown01 = value;
} }
public void setStartCoord(Vector3fImmutable value) { public void setStartCoord(Vector3fImmutable value) {
@ -254,8 +251,8 @@ public class MoveToPointMsg extends ClientNetMsg {
} }
public void clearTarget() { public void clearTarget() {
this.targetType = 0; this.startLocType = 0;
this.targetID = 0; this.inBuildingUUID = 0;
} }
public void setPlayer(AbstractCharacter ac) { public void setPlayer(AbstractCharacter ac) {
@ -263,10 +260,10 @@ public class MoveToPointMsg extends ClientNetMsg {
this.sourceID = ac.getObjectUUID(); this.sourceID = ac.getObjectUUID();
this.setStartCoord(ac.getLoc()); this.setStartCoord(ac.getLoc());
this.setEndCoord(ac.getEndLoc()); this.setEndCoord(ac.getEndLoc());
this.targetType = 0; this.startLocType = 0;
this.targetID = 0; this.inBuildingUUID = 0;
this.inBuilding = ac.getInBuilding(); this.inBuilding = ac.getInBuilding();
this.unknown01 = ac.getInFloorID(); this.inBuildingFloor = ac.getInFloorID();
} }
@ -274,10 +271,10 @@ public class MoveToPointMsg extends ClientNetMsg {
if (target == null) { if (target == null) {
this.setStartCoord(ac.getLoc()); this.setStartCoord(ac.getLoc());
this.setEndCoord(ac.getEndLoc()); this.setEndCoord(ac.getEndLoc());
this.targetType = 0; this.startLocType = 0;
this.targetID = 0; this.inBuildingUUID = 0;
this.inBuilding = -1; this.inBuilding = -1;
this.unknown01 = -1; this.inBuildingFloor = -1;
} else { } else {
Vector3fImmutable convertLocStart = ZoneManager.convertWorldToLocal(target, ac.getLoc()); Vector3fImmutable convertLocStart = ZoneManager.convertWorldToLocal(target, ac.getLoc());
Vector3fImmutable convertLocEnd = convertLocStart; Vector3fImmutable convertLocEnd = convertLocStart;
@ -286,10 +283,10 @@ public class MoveToPointMsg extends ClientNetMsg {
this.setStartCoord(convertLocStart); this.setStartCoord(convertLocStart);
this.setEndCoord(convertLocEnd); this.setEndCoord(convertLocEnd);
this.targetType = GameObjectType.Building.ordinal(); this.startLocType = GameObjectType.Building.ordinal();
this.targetID = target.getObjectUUID(); this.inBuildingUUID = target.getObjectUUID();
this.inBuilding = ac.getInBuilding(); this.inBuilding = ac.getInBuilding();
this.unknown01 = ac.getInFloorID(); this.inBuildingFloor = ac.getInFloorID();
} }
} }
@ -298,7 +295,11 @@ public class MoveToPointMsg extends ClientNetMsg {
return unknown03; return unknown03;
} }
public int getUnknown02() { public int getInitiatedFromAttack() {
return unknown02; return initiatedByAttack;
}
public int getInBuildingFloor() {
return this.inBuildingFloor;
} }
} }

2
src/engine/objects/PlayerCharacter.java

@ -5353,7 +5353,7 @@ public class PlayerCharacter extends AbstractCharacter {
moveToMsg.setStartCoord(this.getLoc()); moveToMsg.setStartCoord(this.getLoc());
moveToMsg.setEndCoord(endLoc); moveToMsg.setEndCoord(endLoc);
moveToMsg.setInBuilding(-1); moveToMsg.setInBuilding(-1);
moveToMsg.setUnknown01(-1); moveToMsg.setInBuildingFloor(-1);
moveToMsg.setSourceType(GameObjectType.PlayerCharacter.ordinal()); moveToMsg.setSourceType(GameObjectType.PlayerCharacter.ordinal());
moveToMsg.setSourceID(this.getObjectUUID()); moveToMsg.setSourceID(this.getObjectUUID());

Loading…
Cancel
Save