mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Forgot the "SynchGroupWorkValuesPacket" and some merging stuff.
This commit is contained in:
		| @@ -136,6 +136,7 @@ | ||||
|     <Compile Include="packets\receive\ChatMessagePacket.cs" /> | ||||
|     <Compile Include="packets\receive\events\EventUpdatePacket.cs" /> | ||||
|     <Compile Include="packets\receive\events\EventStartPacket.cs" /> | ||||
|     <Compile Include="packets\receive\GroupCreatedPacket.cs" /> | ||||
|     <Compile Include="packets\receive\HandshakePacket.cs" /> | ||||
|     <Compile Include="packets\receive\LangaugeCodePacket.cs" /> | ||||
|     <Compile Include="packets\receive\ParameterDataRequestPacket.cs" /> | ||||
| @@ -211,6 +212,7 @@ | ||||
|     <Compile Include="packets\send\groups\GroupMembersX16Packet.cs" /> | ||||
|     <Compile Include="packets\send\groups\GroupMembersX32Packet.cs" /> | ||||
|     <Compile Include="packets\send\groups\GroupMembersX64Packet.cs" /> | ||||
|     <Compile Include="packets\send\groups\SynchGroupWorkValuesPacket.cs" /> | ||||
|     <Compile Include="packets\send\list\ListEntry.cs" /> | ||||
|     <Compile Include="packets\send\list\ListUtils.cs" /> | ||||
|     <Compile Include="packets\send\list\SetListPropertyPacket.cs" /> | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| using FFXIVClassic_Lobby_Server.common; | ||||
| using FFXIVClassic_Lobby_Server.packets; | ||||
| using FFXIVClassic.Common; | ||||
| using FFXIVClassic_Map_Server.Actors; | ||||
| using FFXIVClassic_Map_Server.packets.send.actor; | ||||
| using FFXIVClassic_Map_Server.packets.send.group; | ||||
| using FFXIVClassic_Map_Server.packets.send.groups; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| @@ -78,27 +78,27 @@ namespace FFXIVClassic_Map_Server.actors.group | ||||
|         { | ||||
|             ulong time = Utils.MilisUnixTimeStampUTC(); | ||||
|  | ||||
|             toPlayer.queuePacket(GroupHeaderPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this)); | ||||
|             toPlayer.queuePacket(GroupMembersBeginPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this)); | ||||
|             toPlayer.QueuePacket(GroupHeaderPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this)); | ||||
|             toPlayer.QueuePacket(GroupMembersBeginPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this)); | ||||
|  | ||||
|             int currentIndex = 0; | ||||
|  | ||||
|             while (true) | ||||
|             { | ||||
|                 if (members.Count - currentIndex >= 64) | ||||
|                     toPlayer.queuePacket(GroupMembersX64Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); | ||||
|                     toPlayer.QueuePacket(GroupMembersX64Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); | ||||
|                 else if (members.Count - currentIndex >= 32) | ||||
|                     toPlayer.queuePacket(GroupMembersX32Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); | ||||
|                     toPlayer.QueuePacket(GroupMembersX32Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); | ||||
|                 else if (members.Count - currentIndex >= 16) | ||||
|                     toPlayer.queuePacket(GroupMembersX16Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); | ||||
|                     toPlayer.QueuePacket(GroupMembersX16Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); | ||||
|                 else if (members.Count - currentIndex > 0) | ||||
|                     toPlayer.queuePacket(GroupMembersX08Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex));                | ||||
|                     toPlayer.QueuePacket(GroupMembersX08Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex));                | ||||
|                 else | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
|  | ||||
|             toPlayer.queuePacket(GroupMembersEndPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this));     | ||||
|             toPlayer.QueuePacket(GroupMembersEndPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this));     | ||||
|  | ||||
|         } | ||||
|  | ||||
| @@ -106,27 +106,27 @@ namespace FFXIVClassic_Map_Server.actors.group | ||||
|         {             | ||||
|             if (groupTypeId == PlayerPartyGroup) | ||||
|             { | ||||
|                 SetGroupWorkValuesPacket groupWork = new SetGroupWorkValuesPacket(groupId); | ||||
|                 SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupId); | ||||
|                 groupWork.addProperty(this, "partyGroupWork._globalTemp.owner"); | ||||
|                 groupWork.setTarget("/_init"); | ||||
|              | ||||
|                 SubPacket test = groupWork.buildPacket(player.actorId, player.actorId); | ||||
|                 player.queuePacket(test); | ||||
|                 player.QueuePacket(test); | ||||
|             } | ||||
|             else if (groupTypeId == GroupInvitationRelationGroup) | ||||
|             { | ||||
|                 SetGroupWorkValuesPacket groupWork = new SetGroupWorkValuesPacket(groupId); | ||||
|                 SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupId); | ||||
|                 groupWork.addProperty(this, "work._globalTemp.host"); | ||||
|                 groupWork.addProperty(this, "work._globalTemp.variableCommand"); | ||||
|                 groupWork.setTarget("/_init"); | ||||
|  | ||||
|                 SubPacket test = groupWork.buildPacket(player.actorId, player.actorId); | ||||
|                 test.debugPrintSubPacket(); | ||||
|                 player.queuePacket(test); | ||||
|                 test.DebugPrintSubPacket(); | ||||
|                 player.QueuePacket(test); | ||||
|             } | ||||
|             else if (groupTypeId == RetainerGroup) | ||||
|             { | ||||
|                 SetGroupWorkValuesPacket groupWork = new SetGroupWorkValuesPacket(groupId); | ||||
|                 SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupId); | ||||
|                 groupWork.addProperty(this, "work._memberSave[0].cdIDOffset"); | ||||
|                 groupWork.addProperty(this, "work._memberSave[0].placeName"); | ||||
|                 groupWork.addProperty(this, "work._memberSave[0].conditions"); | ||||
| @@ -134,7 +134,7 @@ namespace FFXIVClassic_Map_Server.actors.group | ||||
|                 groupWork.setTarget("/_init"); | ||||
|  | ||||
|                 SubPacket test = groupWork.buildPacket(player.actorId, player.actorId); | ||||
|                 player.queuePacket(test); | ||||
|                 player.QueuePacket(test); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| using FFXIVClassic_Lobby_Server.packets; | ||||
| using FFXIVClassic.Common; | ||||
| using FFXIVClassic_Map_Server.actors.group; | ||||
| using FFXIVClassic_Map_Server.dataobjects; | ||||
| using System; | ||||
|   | ||||
| @@ -0,0 +1,210 @@ | ||||
| using FFXIVClassic.Common; | ||||
| using FFXIVClassic_Map_Server.actors.group; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Reflection; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
|  | ||||
| namespace FFXIVClassic_Map_Server.packets.send.groups | ||||
| { | ||||
|     class SynchGroupWorkValuesPacket | ||||
|     { | ||||
|         public const ushort OPCODE = 0x017A; | ||||
|         public const uint PACKET_SIZE = 0xB0; | ||||
|  | ||||
|         private const ushort MAXBYTES = 0x98; | ||||
|  | ||||
|         private ushort runningByteTotal = 0; | ||||
|         private byte[] data = new byte[PACKET_SIZE - 0x20]; | ||||
|         private bool isMore = false; | ||||
|  | ||||
|         private MemoryStream mem; | ||||
|         private BinaryWriter binWriter; | ||||
|  | ||||
|         public SynchGroupWorkValuesPacket(ulong listId) | ||||
|         { | ||||
|             mem = new MemoryStream(data); | ||||
|             binWriter = new BinaryWriter(mem); | ||||
|             binWriter.Write((UInt64)listId); | ||||
|             binWriter.Seek(1, SeekOrigin.Current); | ||||
|         } | ||||
|  | ||||
|         public void closeStreams() | ||||
|         { | ||||
|             binWriter.Dispose(); | ||||
|             mem.Dispose(); | ||||
|         } | ||||
|  | ||||
|         public bool addByte(uint id, byte value) | ||||
|         { | ||||
|             if (runningByteTotal + 6 > MAXBYTES) | ||||
|                 return false; | ||||
|  | ||||
|             binWriter.Write((byte)1); | ||||
|             binWriter.Write((UInt32)id); | ||||
|             binWriter.Write((byte)value); | ||||
|             runningByteTotal += 6; | ||||
|  | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         public bool addShort(uint id, ushort value) | ||||
|         { | ||||
|             if (runningByteTotal + 7 > MAXBYTES) | ||||
|                 return false; | ||||
|  | ||||
|             binWriter.Write((byte)2); | ||||
|             binWriter.Write((UInt32)id); | ||||
|             binWriter.Write((UInt16)value); | ||||
|             runningByteTotal += 7; | ||||
|  | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         public bool addInt(uint id, uint value) | ||||
|         { | ||||
|             if (runningByteTotal + 9 > MAXBYTES) | ||||
|                 return false; | ||||
|  | ||||
|             binWriter.Write((byte)4); | ||||
|             binWriter.Write((UInt32)id); | ||||
|             binWriter.Write((UInt32)value); | ||||
|             runningByteTotal += 9; | ||||
|  | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         public bool addLong(uint id, ulong value) | ||||
|         { | ||||
|             if (runningByteTotal + 13 > MAXBYTES) | ||||
|                 return false; | ||||
|  | ||||
|             binWriter.Write((byte)8); | ||||
|             binWriter.Write((UInt32)id); | ||||
|             binWriter.Write((UInt64)value); | ||||
|             runningByteTotal += 13; | ||||
|  | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         public bool addBuffer(uint id, byte[] buffer) | ||||
|         { | ||||
|             if (runningByteTotal + 5 + buffer.Length > MAXBYTES) | ||||
|                 return false; | ||||
|  | ||||
|             binWriter.Write((byte)buffer.Length); | ||||
|             binWriter.Write((UInt32)id); | ||||
|             binWriter.Write(buffer); | ||||
|             runningByteTotal += (ushort)(5 + buffer.Length); | ||||
|  | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         public void addProperty(Group group, string name) | ||||
|         { | ||||
|             string[] split = name.Split('.'); | ||||
|             int arrayIndex = 0; | ||||
|  | ||||
|             if (!(split[0].Equals("work") || split[0].Equals("partyGroupWork"))) | ||||
|                 return; | ||||
|  | ||||
|             Object curObj = group; | ||||
|             for (int i = 0; i < split.Length; i++) | ||||
|             { | ||||
|                 //For arrays | ||||
|                 if (split[i].Contains('[')) | ||||
|                 { | ||||
|                     if (split[i].LastIndexOf(']') - split[i].IndexOf('[') <= 0) | ||||
|                         return; | ||||
|  | ||||
|                     arrayIndex = Convert.ToInt32(split[i].Substring(split[i].IndexOf('[') + 1, split[i].Length - split[i].LastIndexOf(']'))); | ||||
|  | ||||
|                     split[i] = split[i].Substring(0, split[i].IndexOf('[')); | ||||
|  | ||||
|                     if (i != split.Length - 1) | ||||
|                     { | ||||
|                         curObj = curObj.GetType().GetField(split[i]).GetValue(curObj); | ||||
|                         curObj = ((Array)curObj).GetValue(arrayIndex); | ||||
|                         i++; | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 FieldInfo field = curObj.GetType().GetField(split[i]); | ||||
|                 if (field == null) | ||||
|                     return; | ||||
|  | ||||
|                 curObj = field.GetValue(curObj); | ||||
|                 if (curObj == null) | ||||
|                     return; | ||||
|             } | ||||
|  | ||||
|             if (curObj == null) | ||||
|                 return; | ||||
|             else | ||||
|             { | ||||
|                 //Array, we actually care whats inside | ||||
|                 if (curObj.GetType().IsArray) | ||||
|                 { | ||||
|                     if (((Array)curObj).Length <= arrayIndex) | ||||
|                         return; | ||||
|                     curObj = ((Array)curObj).GetValue(arrayIndex); | ||||
|                 } | ||||
|  | ||||
|                 if (curObj == null) | ||||
|                     return; | ||||
|  | ||||
|                 //Cast to the proper object and add to packet | ||||
|                 uint id = Utils.MurmurHash2(name, 0); | ||||
|                 if (curObj is bool) | ||||
|                     addByte(id, (byte)(((bool)curObj) ? 1 : 0)); | ||||
|                 else if (curObj is byte) | ||||
|                     addByte(id, (byte)curObj); | ||||
|                 else if (curObj is ushort) | ||||
|                     addShort(id, (ushort)curObj); | ||||
|                 else if (curObj is short) | ||||
|                     addShort(id, (ushort)(short)curObj); | ||||
|                 else if (curObj is uint) | ||||
|                     addInt(id, (uint)curObj); | ||||
|                 else if (curObj is int) | ||||
|                     addInt(id, (uint)(int)curObj); | ||||
|                 else if (curObj is long) | ||||
|                     addLong(id, (ulong)(long)curObj); | ||||
|                 else if (curObj is ulong) | ||||
|                     addLong(id, (ulong)curObj); | ||||
|                 else if (curObj is float) | ||||
|                     addBuffer(id, BitConverter.GetBytes((float)curObj)); | ||||
|                 else | ||||
|                     return; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public void setIsMore(bool flag) | ||||
|         { | ||||
|             isMore = flag; | ||||
|         } | ||||
|  | ||||
|         public void setTarget(string target) | ||||
|         { | ||||
|             binWriter.Write((byte)(isMore ? 0x62 + target.Length : 0x82 + target.Length)); | ||||
|             binWriter.Write(Encoding.ASCII.GetBytes(target)); | ||||
|             runningByteTotal += (ushort)(1 + Encoding.ASCII.GetByteCount(target)); | ||||
|  | ||||
|         } | ||||
|  | ||||
|         public SubPacket buildPacket(uint playerActorID, uint actorID) | ||||
|         { | ||||
|             binWriter.Seek(0x8, SeekOrigin.Begin); | ||||
|             binWriter.Write((byte)runningByteTotal); | ||||
|  | ||||
|             closeStreams(); | ||||
|  | ||||
|             SubPacket packet = new SubPacket(OPCODE, playerActorID, actorID, data); | ||||
|             return packet; | ||||
|         } | ||||
|  | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user