From 1c845e62e33ac9bfa19f15f6591a8d16f5ca72cf Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Sat, 16 Jan 2016 23:03:04 -0500 Subject: [PATCH] Implemented WeatherDirector , ZoneMaster, and WorldMaster in code. Zone objects has become the ZoneMaster actor object. --- .../FFXIVClassic Map Server.csproj | 10 ++-- FFXIVClassic Map Server/PacketProcessor.cs | 25 +++++++--- FFXIVClassic Map Server/actors/Actor.cs | 2 +- .../{ => actors/area}/Zone.cs | 46 +++++++++++++++-- FFXIVClassic Map Server/actors/debug/Debug.cs | 47 ++++++++++++++++++ .../actors/director/WeatherDirector.cs | 49 +++++++++++++++++++ .../actors/world/WorldMaster.cs | 44 +++++++++++++++++ FFXIVClassic Map Server/lua/LuaUtils.cs | 2 +- .../packets/send/Actor/SetActorNamePacket.cs | 2 +- 9 files changed, 209 insertions(+), 18 deletions(-) rename FFXIVClassic Map Server/{ => actors/area}/Zone.cs (73%) create mode 100644 FFXIVClassic Map Server/actors/debug/Debug.cs create mode 100644 FFXIVClassic Map Server/actors/director/WeatherDirector.cs create mode 100644 FFXIVClassic Map Server/actors/world/WorldMaster.cs diff --git a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj index 166a7102..e88c792d 100644 --- a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj +++ b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj @@ -67,8 +67,11 @@ + + + @@ -208,16 +211,13 @@ - + - - - - + diff --git a/FFXIVClassic Map Server/PacketProcessor.cs b/FFXIVClassic Map Server/PacketProcessor.cs index 67bfc4b9..bcf92323 100644 --- a/FFXIVClassic Map Server/PacketProcessor.cs +++ b/FFXIVClassic Map Server/PacketProcessor.cs @@ -34,6 +34,8 @@ using FFXIVClassic_Map_Server.dataobjects.actors; using FFXIVClassic_Map_Server.dataobjects.chara.npc; using FFXIVClassic_Map_Server.actors; using System.Net; +using FFXIVClassic_Map_Server.actors.debug; +using FFXIVClassic_Map_Server.actors.world; namespace FFXIVClassic_Lobby_Server { @@ -44,7 +46,10 @@ namespace FFXIVClassic_Lobby_Server List mConnections; StaticActors mStaticActors = new StaticActors(); - Zone inn = new Zone(); + + DebugProg debug = new DebugProg(); + WorldMaster worldMaster = new WorldMaster(); + Zone inn = new Zone(0xF4, "prv0Inn01", 0xD1, false, false, false, false); public PacketProcessor(Dictionary playerList, List connectionList) { @@ -182,16 +187,14 @@ namespace FFXIVClassic_Lobby_Server break; //Unknown case 0x0002: - BasePacket reply8 = new BasePacket("./packets/login/login8_data.bin"); //Debug, World Master, Director created - BasePacket reply9 = new BasePacket("./packets/login/login9_zonesetup.bin"); //Area Master, Bed, Book created + BasePacket reply9 = new BasePacket("./packets/login/login9_zonesetup.bin"); //Bed, Book created BasePacket reply10 = new BasePacket("./packets/login/login10.bin"); //Item Storage, Inn Door created BasePacket reply11 = new BasePacket("./packets/login/login11.bin"); //NPC Create ??? Final init #region replaceid //currancy.replaceActorID(player.actorID); //keyitems.replaceActorID(player.actorID); - - reply8.replaceActorID(player.actorID); + reply9.replaceActorID(player.actorID); reply10.replaceActorID(player.actorID); reply11.replaceActorID(player.actorID); @@ -290,12 +293,20 @@ namespace FFXIVClassic_Lobby_Server #endregion BasePacket tpacket = player.getActor().getInitPackets(player.actorID); - tpacket.debugPrintPacket(); + //tpacket.debugPrintPacket(); client.queuePacket(tpacket); inn.addActorToZone(player.getActor()); - client.queuePacket(reply8); + BasePacket innSpawn = inn.getSpawnPackets(player.actorID); + BasePacket debugSpawn = debug.getSpawnPackets(player.actorID); + BasePacket worldMasterSpawn = worldMaster.getSpawnPackets(player.actorID); + innSpawn.debugPrintPacket(); + + client.queuePacket(innSpawn); + client.queuePacket(debugSpawn); + client.queuePacket(worldMasterSpawn); + client.queuePacket(reply9); client.queuePacket(reply10); client.queuePacket(reply11); diff --git a/FFXIVClassic Map Server/actors/Actor.cs b/FFXIVClassic Map Server/actors/Actor.cs index d0dc2d5f..5084622f 100644 --- a/FFXIVClassic Map Server/actors/Actor.cs +++ b/FFXIVClassic Map Server/actors/Actor.cs @@ -24,7 +24,7 @@ namespace FFXIVClassic_Map_Server.dataobjects public ushort currentMainState = SetActorStatePacket.MAIN_STATE_PASSIVE; public ushort currentSubState = SetActorStatePacket.SUB_STATE_NONE; - public float positionX = SetActorPositionPacket.INNPOS_X, positionY = SetActorPositionPacket.INNPOS_Y, positionZ = SetActorPositionPacket.INNPOS_Z, rotation = SetActorPositionPacket.INNPOS_ROT; + public float positionX, positionY, positionZ, rotation; public float oldPositionX, oldPositionY, oldPositionZ, oldRotation; public ushort moveState, oldMoveState; diff --git a/FFXIVClassic Map Server/Zone.cs b/FFXIVClassic Map Server/actors/area/Zone.cs similarity index 73% rename from FFXIVClassic Map Server/Zone.cs rename to FFXIVClassic Map Server/actors/area/Zone.cs index b305e400..94a82191 100644 --- a/FFXIVClassic Map Server/Zone.cs +++ b/FFXIVClassic Map Server/actors/area/Zone.cs @@ -1,5 +1,8 @@ using FFXIVClassic_Lobby_Server.common; +using FFXIVClassic_Lobby_Server.packets; using FFXIVClassic_Map_Server.dataobjects; +using FFXIVClassic_Map_Server.lua; +using FFXIVClassic_Map_Server.packets.send.actor; using System; using System.Collections.Generic; using System.Linq; @@ -8,19 +11,36 @@ using System.Threading.Tasks; namespace FFXIVClassic_Map_Server { - class Zone + class Zone : Actor { - public uint mapId; + public string zoneName; + public ushort regionId; + public bool canStealth, isInn, canRideChocobo, isInstanceRaid; public ushort weatherNormal, weatherCommon, weatherRare; public ushort bgmDay, bgmNight, bgmBattle; + public int boundingGridSize = 50; public int minX = -100, minY = -100, maxX = 100, maxY = 100; private int numXBlocks, numYBlocks; private int halfWidth, halfHeight; private List[,] actorBlock; - public Zone() + public Zone(uint id, string zoneName, ushort regionId, bool canStealth, bool isInn, bool canRideChocobo, bool isInstanceRaid) : base(id) { + + this.zoneName = zoneName; + this.regionId = regionId; + this.canStealth = canStealth; + this.isInn = isInn; + this.canRideChocobo = canRideChocobo; + this.isInstanceRaid = isInstanceRaid; + + this.displayNameId = 0; + this.customDisplayName = "_areaMaster"; + this.actorName = String.Format("_areaMaster@{0:X5}",id<<8); + + this.className = "ZoneMasterPrvI0"; + numXBlocks = (maxX - minX) / boundingGridSize; numYBlocks = (maxY - minY) / boundingGridSize; actorBlock = new List[numXBlocks, numYBlocks]; @@ -37,6 +57,26 @@ namespace FFXIVClassic_Map_Server } + public override SubPacket createScriptBindPacket(uint playerActorId) + { + List lParams; + lParams = LuaUtils.createLuaParamList("/Area/Zone/ZoneMasterPrvI0", false, true, zoneName, "", 0xFFFFFFFF, false, false, canStealth, isInn, false, false, false, false, false, false); + return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams); + } + + public override BasePacket getSpawnPackets(uint playerActorId) + { + List subpackets = new List(); + subpackets.Add(createAddActorPacket(playerActorId)); + subpackets.Add(createSpeedPacket(playerActorId)); + subpackets.Add(createSpawnPositonPacket(playerActorId, 0x1)); + subpackets.Add(createNamePacket(playerActorId)); + subpackets.Add(createStatePacket(playerActorId)); + subpackets.Add(createIsZoneingPacket(playerActorId)); + subpackets.Add(createScriptBindPacket(playerActorId)); + return BasePacket.createPacket(subpackets, true, false); + } + #region Actor Management public void addActorToZone(Actor actor) diff --git a/FFXIVClassic Map Server/actors/debug/Debug.cs b/FFXIVClassic Map Server/actors/debug/Debug.cs new file mode 100644 index 00000000..13192ff4 --- /dev/null +++ b/FFXIVClassic Map Server/actors/debug/Debug.cs @@ -0,0 +1,47 @@ +using FFXIVClassic_Lobby_Server.packets; +using FFXIVClassic_Map_Server.dataobjects; +using FFXIVClassic_Map_Server.lua; +using FFXIVClassic_Map_Server.packets.send.actor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FFXIVClassic_Map_Server.actors.debug +{ + class DebugProg : Actor + { + + public DebugProg() + : base(0x5FF80002) + { + this.displayNameId = 0; + this.customDisplayName = "debug"; + + this.actorName = "debug"; + this.className = "Debug"; + } + + public override SubPacket createScriptBindPacket(uint playerActorId) + { + List lParams; + lParams = LuaUtils.createLuaParamList("/System/Debug.prog", false, false, false, false, true, 0xC51F, true, true); + return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams); + } + + public override BasePacket getSpawnPackets(uint playerActorId) + { + List subpackets = new List(); + subpackets.Add(createAddActorPacket(playerActorId)); + subpackets.Add(createSpeedPacket(playerActorId)); + subpackets.Add(createSpawnPositonPacket(playerActorId, 0x1)); + subpackets.Add(createNamePacket(playerActorId)); + subpackets.Add(createStatePacket(playerActorId)); + subpackets.Add(createIsZoneingPacket(playerActorId)); + subpackets.Add(createScriptBindPacket(playerActorId)); + return BasePacket.createPacket(subpackets, true, false); + } + + } +} diff --git a/FFXIVClassic Map Server/actors/director/WeatherDirector.cs b/FFXIVClassic Map Server/actors/director/WeatherDirector.cs new file mode 100644 index 00000000..7da80180 --- /dev/null +++ b/FFXIVClassic Map Server/actors/director/WeatherDirector.cs @@ -0,0 +1,49 @@ +using FFXIVClassic_Lobby_Server.packets; +using FFXIVClassic_Map_Server.dataobjects; +using FFXIVClassic_Map_Server.lua; +using FFXIVClassic_Map_Server.packets.send.actor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FFXIVClassic_Map_Server.actors.director +{ + class WeatherDirector : Actor + { + private uint weatherId; + + public WeatherDirector(uint weatherId, Zone zone) + : base(0x5FF80002) + { + this.weatherId = weatherId; + + this.displayNameId = 0; + this.customDisplayName = String.Format("weatherDire_{0}", zone.zoneName, zone.currentZoneId); + + this.actorName = String.Format("weatherDire_{0}@{0:04x}", zone.zoneName, zone.currentZoneId); + this.className = "Debug"; + } + + public override SubPacket createScriptBindPacket(uint playerActorId) + { + List lParams; + lParams = LuaUtils.createLuaParamList("/Director/Weather/WeatherDirector", false, false, false, false, weatherId); + return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams); + } + + public override BasePacket getSpawnPackets(uint playerActorId) + { + List subpackets = new List(); + subpackets.Add(createAddActorPacket(playerActorId)); + subpackets.Add(createSpeedPacket(playerActorId)); + subpackets.Add(createSpawnPositonPacket(playerActorId, 0x1)); + subpackets.Add(createNamePacket(playerActorId)); + subpackets.Add(createStatePacket(playerActorId)); + subpackets.Add(createIsZoneingPacket(playerActorId)); + subpackets.Add(createScriptBindPacket(playerActorId)); + return BasePacket.createPacket(subpackets, true, false); + } + } +} diff --git a/FFXIVClassic Map Server/actors/world/WorldMaster.cs b/FFXIVClassic Map Server/actors/world/WorldMaster.cs new file mode 100644 index 00000000..a5df2016 --- /dev/null +++ b/FFXIVClassic Map Server/actors/world/WorldMaster.cs @@ -0,0 +1,44 @@ +using FFXIVClassic_Lobby_Server.packets; +using FFXIVClassic_Map_Server.dataobjects; +using FFXIVClassic_Map_Server.lua; +using FFXIVClassic_Map_Server.packets.send.actor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FFXIVClassic_Map_Server.actors.world +{ + class WorldMaster : Actor + { + public WorldMaster() : base(0x5FF80001) + { + this.displayNameId = 0; + this.customDisplayName = "worldMaster"; + + this.actorName = "worldMaster"; + this.className = "WorldMaster"; + } + + public override SubPacket createScriptBindPacket(uint playerActorId) + { + List lParams; + lParams = LuaUtils.createLuaParamList("/World/WorldMaster_event", false, false, false, false, false, null); + return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams); + } + + public override BasePacket getSpawnPackets(uint playerActorId) + { + List subpackets = new List(); + subpackets.Add(createAddActorPacket(playerActorId)); + subpackets.Add(createSpeedPacket(playerActorId)); + subpackets.Add(createSpawnPositonPacket(playerActorId, 0x1)); + subpackets.Add(createNamePacket(playerActorId)); + subpackets.Add(createStatePacket(playerActorId)); + subpackets.Add(createIsZoneingPacket(playerActorId)); + subpackets.Add(createScriptBindPacket(playerActorId)); + return BasePacket.createPacket(subpackets, true, false); + } + } +} diff --git a/FFXIVClassic Map Server/lua/LuaUtils.cs b/FFXIVClassic Map Server/lua/LuaUtils.cs index 4281726b..c8c8a41c 100644 --- a/FFXIVClassic Map Server/lua/LuaUtils.cs +++ b/FFXIVClassic Map Server/lua/LuaUtils.cs @@ -195,7 +195,7 @@ namespace FFXIVClassic_Map_Server foreach (object o in list) { - if (o.GetType().IsArray) + if (o != null && o.GetType().IsArray) { Array arrayO = (Array)o; foreach (object o2 in arrayO) diff --git a/FFXIVClassic Map Server/packets/send/Actor/SetActorNamePacket.cs b/FFXIVClassic Map Server/packets/send/Actor/SetActorNamePacket.cs index b455d3a1..a26a4dd3 100644 --- a/FFXIVClassic Map Server/packets/send/Actor/SetActorNamePacket.cs +++ b/FFXIVClassic Map Server/packets/send/Actor/SetActorNamePacket.cs @@ -23,7 +23,7 @@ namespace FFXIVClassic_Map_Server.packets.send.actor { binWriter.Write((UInt32)displayNameID); - if (displayNameID == 0xFFFFFFFF) + if (displayNameID == 0 || displayNameID == 0xFFFFFFFF) { binWriter.Write(Encoding.ASCII.GetBytes(customName), 0, Encoding.ASCII.GetByteCount(customName) >= 0x20 ? 0x19 : Encoding.ASCII.GetByteCount(customName)); }