diff --git a/FFXIVClassic Map Server/Program.cs b/FFXIVClassic Map Server/Program.cs index 5eb5aef6..d350ce99 100644 --- a/FFXIVClassic Map Server/Program.cs +++ b/FFXIVClassic Map Server/Program.cs @@ -74,6 +74,20 @@ namespace FFXIVClassic_Lobby_Server String input = Console.ReadLine(); String[] split = input.Split(' '); + if (split.Length >= 1) + { + if (split[0].Equals("mypos")) + { + try + { + server.printPos(); + } + catch (Exception e) + { + Log.error("Could not load packet: " + e); + } + } + } if (split.Length >= 2) { if (split[0].Equals("sendpacket")) @@ -98,6 +112,10 @@ namespace FFXIVClassic_Lobby_Server Log.error("Could not change music: " + e); } } + else if (split[0].Equals("warp")) + { + server.doWarp(split[1]); + } } if (split.Length >= 3) { diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index f07d0b1a..00feb077 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -14,6 +14,7 @@ using FFXIVClassic_Map_Server.packets.send.actor; using FFXIVClassic_Map_Server; using FFXIVClassic_Map_Server.actors; using FFXIVClassic_Map_Server.packets.send; +using FFXIVClassic_Map_Server.dataobjects.chara; namespace FFXIVClassic_Lobby_Server { @@ -38,6 +39,7 @@ namespace FFXIVClassic_Lobby_Server { mWorldManager = new WorldManager(this); mWorldManager.LoadZoneList(); + mWorldManager.LoadZoneEntranceList(); IPEndPoint serverEndPoint = new System.Net.IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), FFXIV_MAP_PORT); @@ -283,6 +285,26 @@ namespace FFXIVClassic_Lobby_Server } } + public void doWarp(string entranceId) + { + uint id; + + if (entranceId.ToLower().StartsWith("0x")) + id = Convert.ToUInt32(entranceId, 16); + else + id = Convert.ToUInt32(entranceId); + + FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id); + + if (ze == null) + return; + + foreach (KeyValuePair entry in mConnectedPlayerList) + { + mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); + } + } + public void doWarp(string map, string sx, string sy, string sz) { uint mapId; @@ -299,8 +321,6 @@ namespace FFXIVClassic_Lobby_Server foreach (KeyValuePair entry in mConnectedPlayerList) { - BasePacket e2Packet = BasePacket.createPacket(_0xE2Packet.buildPacket(0x6c, 0xF), true, false); - entry.Value.queuePacket(e2Packet); mWorldManager.DoZoneChange(entry.Value.getActor(), mapId, 0x2, x, y, z, 0.0f); } } @@ -310,6 +330,15 @@ namespace FFXIVClassic_Lobby_Server return mWorldManager; } + + public void printPos() + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + Log.info(String.Format("{0} position: {1}, {2}, {3}, {4}", p.customDisplayName, p.positionX, p.positionY, p.positionZ, p.rotation)); + } + } } } diff --git a/FFXIVClassic Map Server/WorldManager.cs b/FFXIVClassic Map Server/WorldManager.cs index d968ea5b..ad30ee90 100644 --- a/FFXIVClassic Map Server/WorldManager.cs +++ b/FFXIVClassic Map Server/WorldManager.cs @@ -7,6 +7,7 @@ using FFXIVClassic_Map_Server.common.EfficientHashTables; using FFXIVClassic_Map_Server.dataobjects; using FFXIVClassic_Map_Server.dataobjects.chara; using FFXIVClassic_Map_Server.packets.send; +using FFXIVClassic_Map_Server.packets.send.login; using MySql.Data.MySqlClient; using System; using System.Collections.Generic; @@ -187,7 +188,8 @@ namespace FFXIVClassic_Map_Server player.rotation = spawnRotation; //Send packets - player.sendZoneInPackets(this); + player.playerSession.queuePacket(_0xE2Packet.buildPacket(0x6c, 0xF), true, false); + player.sendZoneInPackets(this, spawnType); } //Login Zone In @@ -205,7 +207,8 @@ namespace FFXIVClassic_Map_Server zone.addActorToZone(player); //Send packets - player.sendZoneInPackets(this); + player.playerSession.queuePacket(_0x2Packet.buildPacket(player.actorId), true, false); + player.sendZoneInPackets(this, 0x1); } public Player GetPCInWorld(string name) @@ -265,6 +268,13 @@ namespace FFXIVClassic_Map_Server } } + public ZoneEntrance getZoneEntrance(uint entranceId) + { + if (zoneEntranceList.ContainsKey(entranceId)) + return zoneEntranceList[entranceId]; + else + return null; + } } } diff --git a/FFXIVClassic Map Server/actors/Actor.cs b/FFXIVClassic Map Server/actors/Actor.cs index 96257569..48b9301f 100644 --- a/FFXIVClassic Map Server/actors/Actor.cs +++ b/FFXIVClassic Map Server/actors/Actor.cs @@ -69,7 +69,7 @@ namespace FFXIVClassic_Map_Server.dataobjects { SubPacket spawnPacket; if (!spawnedFirstTime && playerActorId == actorId) - spawnPacket = SetActorPositionPacket.buildPacket(actorId, playerActorId, 0, positionX, positionY, positionZ, rotation, spawnType, false); + spawnPacket = SetActorPositionPacket.buildPacket(actorId, playerActorId, 0, positionX, positionY, positionZ, rotation, 0x1, false); else if (playerActorId == actorId) spawnPacket = SetActorPositionPacket.buildPacket(actorId, playerActorId, 0xFFFFFFFF, positionX, positionY, positionZ, rotation, spawnType, true); else @@ -101,11 +101,16 @@ namespace FFXIVClassic_Map_Server.dataobjects } public virtual BasePacket getSpawnPackets(uint playerActorId) + { + return getSpawnPackets(playerActorId, 0x1); + } + + public virtual BasePacket getSpawnPackets(uint playerActorId, uint spawnType) { List subpackets = new List(); subpackets.Add(createAddActorPacket(playerActorId)); subpackets.Add(createSpeedPacket(playerActorId)); - subpackets.Add(createSpawnPositonPacket(playerActorId, 0x1)); + subpackets.Add(createSpawnPositonPacket(playerActorId, spawnType)); subpackets.Add(createNamePacket(playerActorId)); subpackets.Add(createStatePacket(playerActorId)); subpackets.Add(createIsZoneingPacket(playerActorId)); diff --git a/FFXIVClassic Map Server/actors/area/Zone.cs b/FFXIVClassic Map Server/actors/area/Zone.cs index 6339e278..a8c7caf2 100644 --- a/FFXIVClassic Map Server/actors/area/Zone.cs +++ b/FFXIVClassic Map Server/actors/area/Zone.cs @@ -89,7 +89,8 @@ namespace FFXIVClassic_Map_Server public void addActorToZone(Actor actor) { - mActorList.Add(actor.actorId, actor); + if (!mActorList.ContainsKey(actor.actorId)) + mActorList.Add(actor.actorId, actor); int gridX = (int)actor.positionX / boundingGridSize; int gridY = (int)actor.positionZ / boundingGridSize; diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index c6f09aaa..8859c249 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -145,14 +145,14 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams); } - public override BasePacket getSpawnPackets(uint playerActorId) + public override BasePacket getSpawnPackets(uint playerActorId, uint spawnType) { List subpackets = new List(); subpackets.Add(createAddActorPacket(playerActorId)); if (isMyPlayer(playerActorId)) subpackets.AddRange(create0x132Packets(playerActorId)); subpackets.Add(createSpeedPacket(playerActorId)); - subpackets.Add(createSpawnPositonPacket(playerActorId, 0x1)); + subpackets.Add(createSpawnPositonPacket(playerActorId, spawnType)); subpackets.Add(createAppearancePacket(playerActorId)); subpackets.Add(createNamePacket(playerActorId)); subpackets.Add(_0xFPacket.buildPacket(playerActorId, playerActorId)); @@ -363,14 +363,13 @@ namespace FFXIVClassic_Map_Server.dataobjects.chara return propPacketUtil.done(); } - public void sendZoneInPackets(WorldManager world) + public void sendZoneInPackets(WorldManager world, ushort spawnType) { - playerSession.queuePacket(SetMapPacket.buildPacket(actorId, zone.regionId, zone.actorId), true, false); - playerSession.queuePacket(_0x2Packet.buildPacket(actorId), true, false); - playerSession.queuePacket(SetMusicPacket.buildPacket(actorId, 0x3D, 0x01), true, false); + playerSession.queuePacket(SetMapPacket.buildPacket(actorId, zone.regionId, zone.actorId), true, false); + playerSession.queuePacket(SetMusicPacket.buildPacket(actorId, zone.bgmDay, 0x01), true, false); playerSession.queuePacket(SetWeatherPacket.buildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR), true, false); - playerSession.queuePacket(getSpawnPackets(actorId)); + playerSession.queuePacket(getSpawnPackets(actorId, spawnType)); #region grouptest //Retainers diff --git a/FFXIVClassic Map Server/dataobjects/ConnectedPlayer.cs b/FFXIVClassic Map Server/dataobjects/ConnectedPlayer.cs index c4ee21b1..a53e35b8 100644 --- a/FFXIVClassic Map Server/dataobjects/ConnectedPlayer.cs +++ b/FFXIVClassic Map Server/dataobjects/ConnectedPlayer.cs @@ -73,13 +73,13 @@ namespace FFXIVClassic_Map_Server.dataobjects public void updatePlayerActorPosition(float x, float y, float z, float rot, ushort moveState) { - /* + playerActor.positionX = x; playerActor.positionY = y; playerActor.positionZ = z; playerActor.rotation = rot; playerActor.moveState = moveState; - */ + } public void sendMotd()