From ebd8ab0580ff7f1c790012bb8ae6cf730c5976e0 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Sat, 3 Dec 2016 13:23:32 -0500 Subject: [PATCH] Fixed random crashes when zoning. Was due to improper write of the SessionEndPacket. For extra safety db is locked until zone in happens. Added some logs. Seems to be all working! --- FFXIVClassic Map Server/PacketProcessor.cs | 9 +++++++-- FFXIVClassic Map Server/WorldManager.cs | 8 +++++--- .../actors/chara/player/Player.cs | 14 +++----------- FFXIVClassic Map Server/dataobjects/Session.cs | 2 +- .../Packets/WorldPackets/Send/SessionEndPacket.cs | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/FFXIVClassic Map Server/PacketProcessor.cs b/FFXIVClassic Map Server/PacketProcessor.cs index 7607e2e8..12b31425 100644 --- a/FFXIVClassic Map Server/PacketProcessor.cs +++ b/FFXIVClassic Map Server/PacketProcessor.cs @@ -49,7 +49,9 @@ namespace FFXIVClassic_Map_Server if (session.GetActor().destinationZone != 0) Server.GetWorldManager().DoZoneIn(session.GetActor(), false, session.GetActor().destinationSpawnType); - + + Program.Log.Info("{0} has been added to the session list.", session.GetActor().customDisplayName); + client.FlushQueuedSendPackets(); break; //World Server - Session End @@ -59,7 +61,10 @@ namespace FFXIVClassic_Map_Server if (endSessionPacket.destinationZoneId == 0) session.GetActor().CleanupAndSave(); else - session.GetActor().CleanupAndSave(endSessionPacket.destinationZoneId, endSessionPacket.destinationSpawnType, endSessionPacket.destinationX, endSessionPacket.destinationY, endSessionPacket.destinationZ, endSessionPacket.destinationRot); + session.GetActor().CleanupAndSave(endSessionPacket.destinationZoneId, endSessionPacket.destinationSpawnType, endSessionPacket.destinationX, endSessionPacket.destinationY, endSessionPacket.destinationZ, endSessionPacket.destinationRot); + + Server.GetServer().RemoveSession(session.id); + Program.Log.Info("{0} has been removed from the session list.", session.GetActor().customDisplayName); client.QueuePacket(SessionEndConfirmPacket.BuildPacket(session, endSessionPacket.destinationZoneId), true, false); client.FlushQueuedSendPackets(); diff --git a/FFXIVClassic Map Server/WorldManager.cs b/FFXIVClassic Map Server/WorldManager.cs index c330d99c..a9b03e08 100644 --- a/FFXIVClassic Map Server/WorldManager.cs +++ b/FFXIVClassic Map Server/WorldManager.cs @@ -468,12 +468,14 @@ namespace FFXIVClassic_Map_Server if (!isLogin) { player.playerSession.QueuePacket(DeleteAllActorsPacket.BuildPacket(player.actorId), true, false); - player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x0), true, false); - player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x0), true, false); + player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x2), true, false); + player.SendZoneInPackets(this, spawnType); } player.SendZoneInPackets(this, spawnType); - + + player.playerSession.LockUpdates(false); + LuaEngine.OnZoneIn(player); } diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 72e23282..9df7fe81 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -476,7 +476,7 @@ namespace FFXIVClassic_Map_Server.Actors QueuePacket(SetMapPacket.BuildPacket(actorId, zone.regionId, zone.actorId)); QueuePacket(GetSpawnPackets(actorId, spawnType)); - GetSpawnPackets(actorId, spawnType).DebugPrintPacket(); + //GetSpawnPackets(actorId, spawnType).DebugPrintPacket(); #region grouptest //Retainers @@ -660,11 +660,7 @@ namespace FFXIVClassic_Map_Server.Actors //Save Player Database.SavePlayerPlayTime(this); - Database.SavePlayerPosition(this); - - Server.GetServer().RemoveSession(playerSession.id); - - Program.Log.Info("{0} has been removed from the session list.", this.customDisplayName); + Database.SavePlayerPosition(this); } public void CleanupAndSave(uint destinationZone, ushort spawnType, float destinationX, float destinationY, float destinationZ, float destinationRot) @@ -684,11 +680,7 @@ namespace FFXIVClassic_Map_Server.Actors //Save Player Database.SavePlayerPlayTime(this); - Database.SavePlayerPosition(this); - - Server.GetServer().RemoveSession(playerSession.id); - - Program.Log.Info("{0} has been removed from the session list.", this.customDisplayName); + Database.SavePlayerPosition(this); } public Area GetZone() diff --git a/FFXIVClassic Map Server/dataobjects/Session.cs b/FFXIVClassic Map Server/dataobjects/Session.cs index 2e0c3ebb..0ea83806 100644 --- a/FFXIVClassic Map Server/dataobjects/Session.cs +++ b/FFXIVClassic Map Server/dataobjects/Session.cs @@ -20,7 +20,7 @@ namespace FFXIVClassic_Map_Server.dataobjects public uint languageCode = 1; private uint lastPingPacket = Utils.UnixTimeStampUTC(); - public bool isUpdatesLocked = false; + public bool isUpdatesLocked = true; public string errorMessage = ""; diff --git a/FFXIVClassic World Server/Packets/WorldPackets/Send/SessionEndPacket.cs b/FFXIVClassic World Server/Packets/WorldPackets/Send/SessionEndPacket.cs index 762ba91d..868f65bd 100644 --- a/FFXIVClassic World Server/Packets/WorldPackets/Send/SessionEndPacket.cs +++ b/FFXIVClassic World Server/Packets/WorldPackets/Send/SessionEndPacket.cs @@ -45,7 +45,7 @@ namespace FFXIVClassic_World_Server.Packets.WorldPackets.Send try { binWriter.Write((UInt32)destinationZoneId); - binWriter.Write((UInt32)spawnType); + binWriter.Write((UInt16)spawnType); binWriter.Write((Single)spawnX); binWriter.Write((Single)spawnY); binWriter.Write((Single)spawnZ);