mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Packet refactoring.
This commit is contained in:
		| @@ -21,7 +21,6 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>. | ||||
|  | ||||
| using System; | ||||
| using System.IO; | ||||
| using System.Text; | ||||
|  | ||||
| using Meteor.Common; | ||||
|  | ||||
| @@ -32,7 +31,7 @@ namespace Meteor.Map.packets.send.events | ||||
|         public const ushort OPCODE = 0x0131; | ||||
|         public const uint PACKET_SIZE = 0x50; | ||||
|  | ||||
|         public static SubPacket BuildPacket(uint sourcePlayerActorId, uint eventOwnerActorID, string eventStarter) | ||||
|         public static SubPacket BuildPacket(uint sourcePlayerActorId, uint eventOwnerActorID, string eventName, byte eventType) | ||||
|         { | ||||
|             byte[] data = new byte[PACKET_SIZE - 0x20]; | ||||
|             int maxBodySize = data.Length - 0x80; | ||||
| @@ -43,8 +42,8 @@ namespace Meteor.Map.packets.send.events | ||||
|                 { | ||||
|                     binWriter.Write((UInt32)sourcePlayerActorId); | ||||
|                     binWriter.Write((UInt32)0); | ||||
|                     binWriter.Write((Byte)1); | ||||
|                     binWriter.Write(Encoding.ASCII.GetBytes(eventStarter), 0, Encoding.ASCII.GetByteCount(eventStarter) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(eventStarter)); | ||||
|                     binWriter.Write((Byte)eventType); | ||||
|                     Utils.WriteNullTermString(binWriter, eventName); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -34,7 +34,7 @@ namespace Meteor.Map.packets.send.events | ||||
|         public const ushort OPCODE = 0x012F; | ||||
|         public const uint PACKET_SIZE = 0x90; | ||||
|  | ||||
|         public static SubPacket BuildPacket(uint sourcePlayerActorId, uint targetEventActorId, uint unknown, string conditionName, List<LuaParam> luaParams) | ||||
|         public static SubPacket BuildPacket(uint triggerActorId, uint ownerActorId, string eventName, byte eventType, List<LuaParam> luaParams) | ||||
|         { | ||||
|             byte[] data = new byte[PACKET_SIZE - 0x20]; | ||||
|  | ||||
| @@ -42,11 +42,13 @@ namespace Meteor.Map.packets.send.events | ||||
|             { | ||||
|                 using (BinaryWriter binWriter = new BinaryWriter(mem)) | ||||
|                 { | ||||
|                     binWriter.Write((UInt32)sourcePlayerActorId); | ||||
|                     binWriter.Write((UInt32)targetEventActorId); | ||||
|                     binWriter.Write((UInt32)unknown); | ||||
|                     binWriter.Write((UInt32)0x30400000); | ||||
|                     binWriter.Write(Encoding.ASCII.GetBytes(conditionName), 0, Encoding.ASCII.GetByteCount(conditionName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(conditionName)); | ||||
|                     binWriter.Write((UInt32)triggerActorId); | ||||
|                     binWriter.Write((UInt32)ownerActorId); | ||||
|                     binWriter.Write((Byte)eventType); | ||||
|                     binWriter.Write((Byte)0x17); //? | ||||
|                     binWriter.Write((UInt16)0x75DC); //? | ||||
|                     binWriter.Write((UInt32)0x30400000); //ServerCodes | ||||
|                     Utils.WriteNullTermString(binWriter, eventName); | ||||
|  | ||||
|                     binWriter.Seek(0x30, SeekOrigin.Begin); | ||||
|  | ||||
| @@ -54,7 +56,7 @@ namespace Meteor.Map.packets.send.events | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return new SubPacket(OPCODE, sourcePlayerActorId, data); | ||||
|             return new SubPacket(OPCODE, triggerActorId, data); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -34,7 +34,7 @@ namespace Meteor.Map.packets.send.events | ||||
|         public const ushort OPCODE = 0x0130; | ||||
|         public const uint PACKET_SIZE = 0x2B8; | ||||
|  | ||||
|         public static SubPacket BuildPacket(uint sourcePlayerActorId, uint eventOwnerActorID, string eventStarter, string callFunction, List<LuaParam> luaParams) | ||||
|         public static SubPacket BuildPacket(uint triggerActorID, uint ownerActorID, string eventName, byte eventType, string functionName, List<LuaParam> luaParams) | ||||
|         { | ||||
|             byte[] data = new byte[PACKET_SIZE - 0x20]; | ||||
|             int maxBodySize = data.Length - 0x80; | ||||
| @@ -43,19 +43,19 @@ namespace Meteor.Map.packets.send.events | ||||
|             { | ||||
|                 using (BinaryWriter binWriter = new BinaryWriter(mem)) | ||||
|                 { | ||||
|                     binWriter.Write((UInt32)sourcePlayerActorId); | ||||
|                     binWriter.Write((UInt32)eventOwnerActorID); | ||||
|                     binWriter.Write((Byte)5); | ||||
|                     binWriter.Write(Encoding.ASCII.GetBytes(eventStarter), 0, Encoding.ASCII.GetByteCount(eventStarter) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(eventStarter)); | ||||
|                     binWriter.Seek(0x29, SeekOrigin.Begin); | ||||
|                     binWriter.Write(Encoding.ASCII.GetBytes(callFunction), 0, Encoding.ASCII.GetByteCount(callFunction) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(callFunction)); | ||||
|                     binWriter.Write((UInt32)triggerActorID); | ||||
|                     binWriter.Write((UInt32)ownerActorID); | ||||
|                     binWriter.Write((Byte)eventType); | ||||
|                     Utils.WriteNullTermString(binWriter, eventName); | ||||
|                     binWriter.Seek(0x29, SeekOrigin.Begin);                 | ||||
|                     Utils.WriteNullTermString(binWriter, functionName); | ||||
|                     binWriter.Seek(0x49, SeekOrigin.Begin); | ||||
|  | ||||
|                     LuaUtils.WriteLuaParams(binWriter, luaParams); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return new SubPacket(OPCODE, sourcePlayerActorId, data); | ||||
|             return new SubPacket(OPCODE, triggerActorID, data); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -61,7 +61,7 @@ namespace Meteor.Map.packets.send.player | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return new SubPacket(OPCODE, sourceActorId, data);             | ||||
|             return new SubPacket(OPCODE, sourceActorId, data); | ||||
|         } | ||||
|          | ||||
|     } | ||||
|   | ||||
| @@ -25,7 +25,6 @@ namespace Meteor.Map.packets.send.player | ||||
| { | ||||
|     class SetCurrentMountGoobbuePacket | ||||
|     { | ||||
|  | ||||
|         public const ushort OPCODE = 0x01a0; | ||||
|         public const uint PACKET_SIZE = 0x28; | ||||
|  | ||||
|   | ||||
| @@ -105,8 +105,7 @@ namespace Meteor.Map.packets.send.player | ||||
|                         Program.Log.Error("Failed making SetCutsceneBook packet. Bin Stream was too big!"); | ||||
|  | ||||
|                     binWriter.Seek(0x109, SeekOrigin.Begin); | ||||
|                     binWriter.Write(Encoding.ASCII.GetBytes(sNpcName), 0, Encoding.ASCII.GetByteCount(sNpcName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sNpcName)); | ||||
|  | ||||
|                     Utils.WriteNullTermString(binWriter, sNpcName); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -21,6 +21,7 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>. | ||||
|  | ||||
| using Meteor.Common; | ||||
| using System; | ||||
| using System.IO; | ||||
|  | ||||
| namespace Meteor.Map.packets.send.player | ||||
| { | ||||
| @@ -31,8 +32,18 @@ namespace Meteor.Map.packets.send.player | ||||
|  | ||||
|         public static SubPacket BuildPacket(uint sourceActorId, uint dreamID) | ||||
|         { | ||||
|             dreamID += 0x20E; | ||||
|             return new SubPacket(OPCODE, sourceActorId, BitConverter.GetBytes((uint)dreamID)); | ||||
|             dreamID = 0x0216; | ||||
|             byte[] data = new byte[PACKET_SIZE - 0x20]; | ||||
|  | ||||
|             using (MemoryStream mem = new MemoryStream(data)) | ||||
|             { | ||||
|                 using (BinaryWriter binWriter = new BinaryWriter(mem)) | ||||
|                 { | ||||
|                     binWriter.Write((Int32)0x216); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return new SubPacket(OPCODE, sourceActorId, data); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user