Mirage Source http://miragesource.net/forums/ |
|
MS4 - Byte Array Packets [Incomplete] http://miragesource.net/forums/viewtopic.php?f=183&t=6360 |
Page 1 of 40 |
Author: | Jacob [ Wed Oct 28, 2009 12:16 pm ] |
Post subject: | MS4 - Byte Array Packets [Incomplete] |
This is not complete. I need to save what I've written so far. Packets In modEnumerations ENUM ServerPackets- Are for packets going from Server -> Client. ENUM ClientPackets- Are for packets going from Client -> Server. * MAKE SURE THE ENUMS ARE EXACTLY THE SAME BOTH SERVER AND CLIENT SIDE!!!! modHandleData Sub InitMessages Add your packet like the others. Example: Code: HandleDataSub(CMsgPlayerRevival) = GetAddress(AddressOf HandlePlayerRevival) ^ Is the ENUM ^ The sub for this packet HandleDataSub() is an array that will hold the memory address of a sub that deals with that packet. The following sub is how all the HandleData subs HAVE TO BE! Code: Private Sub Handle*(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.WriteBytes Data() End Sub * The name of the packet would go here. Writing a packet Example: Code: Sub SendPlayerInfoRequest(ByVal Name As String) Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.PreAllocate Len(Name) + 8 ' PreAllocate is not needed. If you can figure out the size of the packet before hand, do it. It will increase performance. Buffer.WriteInteger SMsgPlayerInfoRequest 'Our first long is the packet header. This is used so the handleData knows how to handle it. Buffer.WriteString Name ' This is just some data for this packet SendData Buffer.ToArray() ' Sends our data End Sub PreAllocate is not needed. If you can figure out the size of the packet before hand, do it. It will increase performance. When handling the data on the other end, you need to make sure to take the data out in the same order you put it in. The packet header does not count because it automatically gets taken care of. Example: Code: Private Sub HandlePlayerInfoRequest(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer Dim Name As String Dim n As Long, i As Long Set Buffer = New clsBuffer Buffer.WriteBytes Data() Name = Buffer.ReadString ' Other stuff here End sub |
Author: | GIAKEN [ Wed Oct 28, 2009 3:19 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Aren't byte array packets already in the engine? |
Author: | Jacob [ Wed Oct 28, 2009 3:38 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Yes, this is showing how to use them. |
Author: | GIAKEN [ Wed Oct 28, 2009 3:50 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Don't you need to Set Buffer = Nothing when finished to prevent memory leaks? |
Author: | wanai [ Sun Jan 09, 2022 12:34 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Econ |
Author: | wanai [ Sun Jan 09, 2022 12:35 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
126.3 |
Author: | wanai [ Sun Jan 09, 2022 12:36 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Bett |
Author: | wanai [ Sun Jan 09, 2022 12:38 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Bett |
Author: | wanai [ Sun Jan 09, 2022 12:39 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Shir |
Author: | wanai [ Sun Jan 09, 2022 12:40 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Shad |
Author: | wanai [ Sun Jan 09, 2022 12:41 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Jewe |
Author: | wanai [ Sun Jan 09, 2022 12:42 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Coch |
Author: | wanai [ Sun Jan 09, 2022 12:43 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Roma |
Author: | wanai [ Sun Jan 09, 2022 12:44 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Mich |
Author: | wanai [ Sun Jan 09, 2022 12:45 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Mill |
Author: | wanai [ Sun Jan 09, 2022 12:46 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Tesc |
Author: | wanai [ Sun Jan 09, 2022 12:48 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Citi |
Author: | wanai [ Sun Jan 09, 2022 12:49 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Orie |
Author: | wanai [ Sun Jan 09, 2022 12:50 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Judi |
Author: | wanai [ Sun Jan 09, 2022 12:51 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Rond |
Author: | wanai [ Sun Jan 09, 2022 12:52 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Jewe |
Author: | wanai [ Sun Jan 09, 2022 12:53 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Dorm |
Author: | wanai [ Sun Jan 09, 2022 12:54 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Thun |
Author: | wanai [ Sun Jan 09, 2022 12:55 pm ] |
Post subject: | Re: MS4 - Byte Array Packets [Incomplete] |
Lenn |
Page 1 of 40 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |