Rob Janes Posted December 4, 2012 Author Share Posted December 4, 2012 I created a SendData() debugger form for both the client and server, which prints out the header of each packet being sent, and how often it's being sent. The were two major client side packets being sent. 1\. Movement, 2\. SendPlayerDir. When a player walks up against a blocked tile, it does collision testing, SendPlayerDir was being sent a ridicious amount of times, it would litterally send this packet every few miliseconds while doing collision testing against a blocked tile (while the player's keys were down). This is WAY too much network traffic for the same check that could be performed once and send only one packet versus hundreds. To fix this. Add a global variable in modGlobals (client side) called```Public Last_Dir as Long```In your modGameLogic, sub CanMoveYou should notice that your code where it checks DirUp, DirDown, DirLeft, DirRight it will read this:```'*********************'******MOVE DOWN******'*********************If DirDown Then Call SetPlayerDir(MyIndex, DIR_DOWN) ' Check to see if they are trying to go out of bounds If GetPlayerY(MyIndex) < Map.MaxY Then If CheckDirection(DIR_DOWN) Then CanMove = False Call SendPlayerDir Exit Function End If Else'************* REST OF CODE HERE```What we want to do is remove the Call SendPlayerDir after it does CheckDirection(DIR_DOWN) and rather add the following line to the top just after the SetPlayerDir(MyIndex, X) piece of the code.If Last_Dir <> GetPlayerDir(MyIndex) ThenCall SendPlayerDirLast_Dir = GetPlayerDir(MyIndex)End IfSo it should resemble.```'*********************'******MOVE DOWN******'*********************If DirDown Then Call SetPlayerDir(MyIndex, DIR_DOWN) If Last_Dir <> GetPlayerDir(MyIndex) Then Call SendPlayerDir Last_Dir = GetPlayerDir(MyIndex) End If ' Check to see if they are trying to go out of bounds If GetPlayerY(MyIndex) < Map.MaxY Then If CheckDirection(DIR_DOWN) Then CanMove = False Exit Function End If Else'******** REST OF CODE HERE```What this does it now it only calls the SendPlayerDir if we have changed direction from however we were previously facing, but still sets the CanMoveFlag during the Directional Checking. Link to comment Share on other sites More sharing options...
teamokell Posted December 4, 2012 Share Posted December 4, 2012 I love u Rob Janes. Nice job. Link to comment Share on other sites More sharing options...
JohnPony Posted December 4, 2012 Share Posted December 4, 2012 Nice find. Link to comment Share on other sites More sharing options...
abhi2011 Posted December 4, 2012 Share Posted December 4, 2012 But wat if an admin walks about to a blocked tile trys to move and then warps to another tile and then move the same direction as before? Would the packet be sent? Link to comment Share on other sites More sharing options...
Alerd Posted December 4, 2012 Share Posted December 4, 2012 change to all move? etc right left up and down? or only down ? Link to comment Share on other sites More sharing options...
abhi2011 Posted December 4, 2012 Share Posted December 4, 2012 All Link to comment Share on other sites More sharing options...
Alerd Posted December 4, 2012 Share Posted December 4, 2012 I do not see the changes: d Link to comment Share on other sites More sharing options...
JohnPony Posted December 4, 2012 Share Posted December 4, 2012 You're not going to see the changes right away, this is more of a back end performance fix. Link to comment Share on other sites More sharing options...
Ryo Posted December 10, 2012 Share Posted December 10, 2012 Why did you make a public variable,A dim would be enough. Link to comment Share on other sites More sharing options...
abhi2011 Posted December 11, 2012 Share Posted December 11, 2012 Dim is Module-Level/Form LevelPublic is project level. Link to comment Share on other sites More sharing options...
Growlith1223 Posted December 11, 2012 Share Posted December 11, 2012 He means why put the Public variable in modGlobals..I will have to agree on that, why put a new global var that will only be called in one Module. A dim would be a more reasonable type as it's only being called in the PlayerMovement. Link to comment Share on other sites More sharing options...
iraasta Posted December 11, 2012 Share Posted December 11, 2012 Nice. Does it have big difference in CPS? Link to comment Share on other sites More sharing options...
Growlith1223 Posted December 11, 2012 Share Posted December 11, 2012 > Nice. Does it have big difference in CPS?This does because it makes more space to send to the client and vice versa, it does improve it but not a lot. Link to comment Share on other sites More sharing options...
Valentine90 Posted December 11, 2012 Share Posted December 11, 2012 Very good, love it, it's always good to improve eclipse origins, avoid sending unnecessary things, congratulations, this tutorial is more valuable than many systems that have bugs around and the newbies love him. Link to comment Share on other sites More sharing options...
JohnPony Posted December 12, 2012 Share Posted December 12, 2012 > He means why put the Public variable in modGlobals..I will have to agree on that, why put a new global var that will only be called in one Module. A dim would be a more reasonable type as it's only being called in the PlayerMovement.You do know dims only last the lifetime of the method they are called in..I could however understand him making this a private variable declared in this module. Link to comment Share on other sites More sharing options...
Rob Janes Posted December 12, 2012 Author Share Posted December 12, 2012 Dimming the Last_Dir here would be useless as the CanMove sub is called through ProcessMovement which is called on the GameLoop. You'd need to store it globally else the Last_Dir would reset to 0 each time around. Link to comment Share on other sites More sharing options...
JohnPony Posted December 12, 2012 Share Posted December 12, 2012 > Dimming the Last_Dir here would be useless as the CanMove sub is called through ProcessMovement which is called on the GameLoop. You'd need to store it globally else the Last_Dir would reset to 0 each time around.Exactly my point ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png) Link to comment Share on other sites More sharing options...
Alerd Posted December 18, 2012 Share Posted December 18, 2012 Can someone write if I have to replace?```'*********************'******MOVE DOWN******'*********************If DirDown Then Call SetPlayerDir(MyIndex, DIR_DOWN) ' Check to see if they are trying to go out of bounds If GetPlayerY(MyIndex) < Map.MaxY Then If CheckDirection(DIR_DOWN) Then CanMove = False Call SendPlayerDir Exit Function End If Else'************* REST OF CODE HERE```to```'*********************'******MOVE DOWN******'*********************If DirDown Then Call SetPlayerDir(MyIndex, DIR_DOWN) If Last_Dir <> GetPlayerDir(MyIndex) Then Call SendPlayerDir Last_Dir = GetPlayerDir(MyIndex) End If ' Check to see if they are trying to go out of bounds If GetPlayerY(MyIndex) < Map.MaxY Then If CheckDirection(DIR_DOWN) Then CanMove = False Exit Function End If Else'******** REST OF CODE HERE``` Link to comment Share on other sites More sharing options...
Valentine90 Posted January 3, 2013 Share Posted January 3, 2013 Hello, I analyzed the original **Eclipse Origins v2** here and **SendPlayerDir** is not sent when the player collides with a locked position, ie not being sent in excess. Link to comment Share on other sites More sharing options...
Rob Janes Posted January 3, 2013 Author Share Posted January 3, 2013 Origins v2 has it's own similar code included where it checks for d <> the new direction, this code applies for 3.0 / Nightly etc. Link to comment Share on other sites More sharing options...
zerohero Posted January 6, 2013 Share Posted January 6, 2013 Good job identifying this Rob, its small optimisations like this that make a huge difference! Link to comment Share on other sites More sharing options...
Helladen Posted January 6, 2013 Share Posted January 6, 2013 SendPlayerData is used way too much, you should probably make more packets for sending data. It is a waste of bandwidth and the player jumps around a lot when you do that. I optimized all the packets/variables of my source code of Origins, but I didn't finish upgrading it to what Jscinder did to the source. I moved on by, then. ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) Link to comment Share on other sites More sharing options...
Mal Posted January 6, 2013 Share Posted January 6, 2013 > SendPlayerData is used way too much, you should probably make more packets for sending data. It is a waste of bandwidth and the player jumps around a lot when you do that. I optimized all the packets/variables of my source code of Origins, but I didn't finish upgrading it to what Sekaru did to the source. I moved on by, then. ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)Not to mention it's a synchronous, blocking socket to begin with. Link to comment Share on other sites More sharing options...
Guest Posted January 6, 2013 Share Posted January 6, 2013 > but I didn't finish upgrading it to what Sekaru did to the sourceWhat? I haven't even worked on EO. Link to comment Share on other sites More sharing options...
Helladen Posted January 6, 2013 Share Posted January 6, 2013 > What? I haven't even worked on EO.Corrected. ![:wub:](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wub.png) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now