| Mirage Source http://miragesource.net/forums/ |
|
| PlayerData http://miragesource.net/forums/viewtopic.php?f=193&t=5356 |
Page 1 of 1 |
| Author: | Jacob [ Thu Apr 02, 2009 12:44 pm ] |
| Post subject: | PlayerData |
I've done this in MR and showed a few others a better way to do PlayerData. If you ever change what gets sent in the playerdata packet, you have change it in like 4 places. With this you would only change it in 1 place. I added it to modPlayer Code: Public Function PlayerData(ByVal Index As Long) As String PlayerData = SPlayerData & SEP_CHAR & Index & SEP_CHAR & GetPlayerName(Index) & SEP_CHAR & GetPlayerSprite(Index) & SEP_CHAR & GetPlayerMap(Index) & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & GetPlayerAccess(Index) & SEP_CHAR & GetPlayerPK(Index) & END_CHAR End Function An example Code: Public Sub SendJoinMap(ByVal Index As Long)
Dim Packet As String Dim i As Long ' Send all players on current map to index For i = 1 To High_Index If IsPlaying(i) Then If i <> Index Then If GetPlayerMap(i) = GetPlayerMap(Index) Then Call SendDataTo(Index, PlayerData(i)) End If End If End If Next ' Send index's player data to everyone on the map including himself Call SendDataToMap(GetPlayerMap(Index), PlayerData(Index)) End Sub |
|
| Author: | genusis [ Thu Apr 02, 2009 12:51 pm ] |
| Post subject: | Re: PlayerData |
hmm it looks good dugor. i should try it out when i get a chance. |
|
| Author: | GIAKEN [ Thu Apr 02, 2009 1:39 pm ] |
| Post subject: | Re: PlayerData |
You need to just make a SendPlayerData sub instead of just making a function that retrieves the string (which is probably slower than just putting the string in there, where as a sub that does it all might be faster). @genusis: What? |
|
| Author: | Jacob [ Thu Apr 02, 2009 1:44 pm ] |
| Post subject: | Re: PlayerData |
It may be a fraction slower not in lining the code, but it's much easier to maintain this way. If you wanted to be a bit more hardcore, you could 'cache' the player data and only update it when a value gets changed. |
|
| Author: | GIAKEN [ Thu Apr 02, 2009 1:45 pm ] |
| Post subject: | Re: PlayerData |
Yeah like how the maps are cached...it would be smart to cache everything. |
|
| Author: | genusis [ Thu Apr 02, 2009 1:58 pm ] |
| Post subject: | Re: PlayerData |
caching everything like that maps is a good idea. since it did speed the maps up. |
|
| Author: | Jacob [ Thu Apr 02, 2009 2:01 pm ] |
| Post subject: | Re: PlayerData |
It doesn't speed the maps up, it speeds up sending the data. You don't have to do all that string concoction when a player requests the data. |
|
| Author: | genusis [ Thu Apr 02, 2009 2:09 pm ] |
| Post subject: | Re: PlayerData |
speeding up the sending the data speeds up the maps. the faster the data is sent and collected the faster and better new stuff or information on the maps will work. so it did speed them up. |
|
| Author: | GIAKEN [ Thu Apr 02, 2009 2:14 pm ] |
| Post subject: | Re: PlayerData |
It didn't speed up the sending of them at all. They're still the same packet length, it just sped up the processing. |
|
| Author: | genusis [ Thu Apr 02, 2009 2:47 pm ] |
| Post subject: | Re: PlayerData |
Dugor wrote: it speeds up sending the data GIAKEN wrote: It didn't speed up the sending of them at all. They're still the same packet length, it just sped up the processing. HMMM? either way it speeds it up. |
|
| Author: | Matt [ Thu Apr 02, 2009 3:09 pm ] |
| Post subject: | Re: PlayerData |
genusis wrote: Dugor wrote: it speeds up sending the data GIAKEN wrote: It didn't speed up the sending of them at all. They're still the same packet length, it just sped up the processing. HMMM? either way it speeds it up. It speeds up the processing. By storing the maps in a cache, it doesn't have to build the packet each time. The packet is already built, so the server just grabs the packet from the cache and sends it on it's way. It's like prepackaged food. However, it doesn't speed up the sending of maps. It's just less processing on the server. |
|
| Author: | genusis [ Thu Apr 02, 2009 3:12 pm ] |
| Post subject: | Re: PlayerData |
couldn't we find a way to speed up the sending of maps and packets? |
|
| Author: | Matt [ Thu Apr 02, 2009 3:12 pm ] |
| Post subject: | Re: PlayerData |
genusis wrote: couldn't we find a way to speed up the sending of maps and packets? Yeah. Convert the packet system to a proper byte array system. |
|
| Author: | genusis [ Thu Apr 02, 2009 3:14 pm ] |
| Post subject: | Re: PlayerData |
why don't we do this also for all the packets? |
|
| Author: | Matt [ Thu Apr 02, 2009 3:19 pm ] |
| Post subject: | Re: PlayerData |
genusis wrote: why don't we do this also for all the packets? If you're directing that at my last post, I said packet SYSTEM. If it's directed at Dugor's original post, then you'll notice this is one of the more larger packets and it's used in a few different places. There's not many packets that are in different areas. |
|
| Author: | genusis [ Thu Apr 02, 2009 3:21 pm ] |
| Post subject: | Re: PlayerData |
ya i know packet system haha i been trying to make my post more simplified. well ya we really should try to get a proper byte array system going. i know William started on it and never finished it. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|