Skip to content

Commit

Permalink
FIX: 1294 (#1295)
Browse files Browse the repository at this point in the history
* fix: (DAY) Fix issue where forced warping caused disappearing entities

* fix: (Day) Rename SendMapLayerChangedPacket
  • Loading branch information
AlexVild committed Jul 9, 2022
1 parent 5d31774 commit 9a7e7f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Intersect.Server/Admin/Actions/ActionProcessing.cs
Expand Up @@ -392,7 +392,8 @@ public static void ProcessAction(Player player, WarpMeToAction action)
var target = Player.FindOnline(action.Name);
if (target != null)
{
player.ForceInstanceChangeWarp(target.MapId, (byte)target.X, (byte)target.Y, target.MapInstanceId, target.InstanceType);
var forceInstanceChange = target.InstanceType != player.InstanceType;
player.AdminWarp(target.MapId, (byte)target.X, (byte)target.Y, target.MapInstanceId, target.InstanceType, forceInstanceChange);
PacketSender.SendChatMsg(player, Strings.Player.warpedto.ToString(target.Name), ChatMessageType.Admin);
PacketSender.SendChatMsg(
target, Strings.Player.warpedtoyou.ToString(player.Name), ChatMessageType.Notice
Expand Down Expand Up @@ -437,7 +438,9 @@ public static void ProcessAction(Player player, WarpToMeAction action)
}
else
{
target.ForceInstanceChangeWarp(player.MapId, (byte)player.X, (byte)player.Y, player.MapInstanceId, player.InstanceType);
var forceInstanceChange = target.InstanceType != player.InstanceType;

target.AdminWarp(player.MapId, (byte)player.X, (byte)player.Y, player.MapInstanceId, player.InstanceType, forceInstanceChange);
PacketSender.SendChatMsg(
player, Strings.Player.haswarpedto.ToString(target.Name), ChatMessageType.Admin, player.Name
);
Expand Down
6 changes: 3 additions & 3 deletions Intersect.Server/Entities/Player.cs
Expand Up @@ -1612,7 +1612,7 @@ public override void Warp(Guid newMapId, float newX, float newY, bool adminWarp
Warp(newMapId, newX, newY, (byte)Directions.Up, adminWarp, 0, false);
}

public void ForceInstanceChangeWarp(Guid newMapId, float newX, float newY, Guid newMapInstanceId, MapInstanceType instanceType, bool adminWarp = false)
public void AdminWarp(Guid newMapId, float newX, float newY, Guid newMapInstanceId, MapInstanceType instanceType, bool force)
{
PreviousMapInstanceId = MapInstanceId;
PreviousMapInstanceType = InstanceType;
Expand All @@ -1628,7 +1628,7 @@ public void ForceInstanceChangeWarp(Guid newMapId, float newX, float newY, Guid
{
PacketSender.SendChatMsg(this, Strings.Player.InstanceUpdate.ToString(PreviousMapInstanceId.ToString(), MapInstanceId.ToString()), ChatMessageType.Admin, CustomColors.Alerts.Info);
}
Warp(newMapId, newX, newY, (byte)Directions.Up, adminWarp, 0, false, false, null, false, true);
Warp(newMapId, newX, newY, (byte)Directions.Up, forceInstanceChange: force);
}

public override void Warp(
Expand Down Expand Up @@ -2006,7 +2006,7 @@ private void SendToNewMapInstance(MapController newMap)
// Get the entities from the old map - we need to clear them off the player's global entities on their client
if (oldMap != null && oldMap.TryGetInstance(PreviousMapInstanceId, out var oldMapInstance))
{
PacketSender.SendMapLayerChangedPacketTo(this, oldMap, PreviousMapInstanceId);
PacketSender.SendMapInstanceChangedPacket(this, oldMap, PreviousMapInstanceId);
oldMapInstance.ClearEntityTargetsOf(this); // Remove targets of this entity
}
// Clear events - we'll get them again from the map instance's event cache
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server/Networking/PacketSender.cs
Expand Up @@ -401,7 +401,7 @@ public static void SendMapEntitiesTo(Player player, ConcurrentDictionary<Guid, E
}
}

public static void SendMapLayerChangedPacketTo(Player player, MapController oldMap, Guid oldLayer)
public static void SendMapInstanceChangedPacket(Player player, MapController oldMap, Guid oldLayer)
{
// Sends a packet to the client telling it that the player has been warped to a new instance and that it should
// clear its local entities
Expand Down

0 comments on commit 9a7e7f3

Please sign in to comment.