Mirage Source

Free ORPG making software.
It is currently Fri May 10, 2024 3:05 pm

All times are UTC




Post new topic Reply to topic  [ 16 posts ] 
Author Message
 Post subject: PlayerData
PostPosted: Thu Apr 02, 2009 12:44 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
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


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 12:51 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
hmm it looks good dugor. i should try it out when i get a chance.

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Last edited by genusis on Thu Apr 02, 2009 1:58 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 1:39 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
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?

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 1:44 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
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.


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 1:45 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Yeah like how the maps are cached...it would be smart to cache everything.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 1:58 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
caching everything like that maps is a good idea. since it did speed the maps up.

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 2:01 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
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.


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 2:09 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
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.

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 2:14 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
It didn't speed up the sending of them at all. They're still the same packet length, it just sped up the processing.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 2:47 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
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.

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 3:09 pm 
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.


Top
  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 3:12 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
couldn't we find a way to speed up the sending of maps and packets?

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 3:12 pm 
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.


Top
  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 3:14 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
why don't we do this also for all the packets?

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Top
 Profile  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 3:19 pm 
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.


Top
  
 
 Post subject: Re: PlayerData
PostPosted: Thu Apr 02, 2009 3:21 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Feb 02, 2007 4:50 am
Posts: 263
Location: usa michigan centriville
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.

_________________
Fuck? I really joined in 2006.
Spirea, Chat Rooms, Discussions, Help. everything you need in one spot.
http://spirean.com
I love my computer, you never ask for more, you can be my princess or be my whore


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group