balliztik1 Posted June 21, 2009 Author Share Posted June 21, 2009 Current Status: Stable (Thanks to Robin's buffer system)The so-called "map freezing" bug, as Robin pointed out, has to do with the server and client becoming unsynchronized. This is due to the way Eclipse handles movement. The client tells the player that they have moved, then sends that data to the server. The problem with this is if there is a Spork in lag suddenly, the client may register a move or two, but the server won't be able to keep up, making the player's location, to the client, a space or two ahead of where they are really standing. To fix this problem, it's just a matter of sending the player their coordinates.**Warning: This fix is highly experimental and lacks extensive testing. I suggest you either back up the subs that we'll be replacing, or comment out the old code so you can revert to it later if need be.**Client first. Go into modGameLogic and find the CanMove function. Find this:```  If y < 0 Then```Replace that whole If-Elseif block with this:```  If X > MAX_MAPX Then    If Map(GetPlayerMap(MyIndex)).Right > 0 Then      Exit Function    Else      CanMove = False    End If  End If  If X < 0 Then    If Map(GetPlayerMap(MyIndex)).Left > 0 Then      Exit Function    Else      CanMove = False    End If  End If  If y > MAX_MAPY Then    If Map(GetPlayerMap(MyIndex)).Down > 0 Then      Exit Function    Else      CanMove = False    End If  End If  If y < 0 Then    If Map(GetPlayerMap(MyIndex)).Up > 0 Then      Exit Function    Else      CanMove = False    End If  End If```This will allow the player to trigger a move into spaces outside the map boundaries. Don't worry, the server will catch this. The problem before is that the server wasn't able to catch the difference because the client freezes itself when it hits the map edge. This way, the client sends the movement anyway, even if it's Radicchio. The server knows better.Next, head to the HandleData sub in modHandleData. Add this packet case:```  If (casestring = "playernewxy") Then    NewPosX = Val(parse(1))    NewPosY = Val(parse(2))    IsNewPos = True    Exit Sub  End If```In modGameLogic, find the GameLoop procedure and look for this:```Call CheckMovement```Paste this under it:```      ' Check if X and Y is the same      If Player(MyIndex).Moving > 0 Then        If IsNewPos = True Then          If Not GetPlayerX(MyIndex) = NewPosX Then SetPlayerX MyIndex, NewPosX          If Not GetPlayerY(MyIndex) = NewPosY Then SetPlayerY MyIndex, NewPosY          IsNewPos = False        End If      End If```Finally, open up modGlobals and add these variables:```' Position bufferPublic NewPosX As LongPublic NewPosY As LongPublic IsNewPos As Boolean```Now, open the server source. We'll need a sub to send that packet over. Create this in modServerTCP:```Sub SendPlayerNewXY(ByVal index As Long)  Call SendDataTo(index, "PLAYERNEWXY" & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & END_CHAR)End Sub```Now, all we do is call it. Simply find this line in the PlayerMove sub in modGameLogic:```    packet = "playermove" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR```It'll be in there 4 times in the default source. Paste this below that:```    Call SendPlayerNewXY(index)```That'll make sure to update the player's movements.And that should do it. Link to comment Share on other sites More sharing options...
Robin Posted June 21, 2009 Share Posted June 21, 2009 This will create a lot of movement lag for anyone who has over 50 latency.Keep the CanMove sub, allow the client to handle movement for itself, but when the server sends the movement packet to everyone else on the map, send a small packet to the player who moved telling it what X and Y the player has on the server. If it's not the same as in the client, simply modify the position of the player in their own client. Link to comment Share on other sites More sharing options...
balliztik1 Posted June 22, 2009 Author Share Posted June 22, 2009 Alright, thanks a ton, Robin. This looks a lot cleaner now. It took some modifying of the CanMove function to stop the client from loading the map, and a couple new packets, but it's much more efficient.I'll be modifying the code momentarily. Link to comment Share on other sites More sharing options...
dao Posted June 22, 2009 Share Posted June 22, 2009 uhh yea noob question what does this do? i know it does something with location but what xD Link to comment Share on other sites More sharing options...
balliztik1 Posted June 22, 2009 Author Share Posted June 22, 2009 @Zultar:> uhh yea noob question what does this do? i know it does something with location but what xDMakes sure the client and server are both using the same coordinates. They can become unsynced when there is lag. Link to comment Share on other sites More sharing options...
dao Posted June 22, 2009 Share Posted June 22, 2009 ahhh ok nice find xD Link to comment Share on other sites More sharing options...
Robin Posted June 22, 2009 Share Posted June 22, 2009 Replace:```  If (casestring = "playernewxy") Then    X = Val(parse(1))    y = Val(parse(2))    Call SetPlayerX(MyIndex, X)    Call SetPlayerY(MyIndex, y)    Exit Sub  End If```With:```  If (casestring = "playernewxy") Then    X = Val(parse(1))    Y = Val(parse(2))    If not GetPlayerX(index) = X then Call SetPlayerX(MyIndex, X)    If not GetPlayerY(index) = Y then Call SetPlayerY(MyIndex, Y)    Exit Sub  End If```Re-setting the X and Y is a waste if they're already the same. Link to comment Share on other sites More sharing options...
balliztik1 Posted June 22, 2009 Author Share Posted June 22, 2009 True. Added. Link to comment Share on other sites More sharing options...
Robin Posted June 22, 2009 Share Posted June 22, 2009 Good stuff. You've impressed me. I haven't seen many people willing to take the time to fix the small annoyances like this properly.pats you on the back.Keep it up. Link to comment Share on other sites More sharing options...
dao Posted June 22, 2009 Share Posted June 22, 2009 rob patted u xD lol id check ur back… might be a kick me sign or suminnice job tho like the 3rd annoying thing uve fixed Link to comment Share on other sites More sharing options...
damian666 Posted June 22, 2009 Share Posted June 22, 2009 oh finally ^^somebody has tackled this stupid bug :Pgreat job.Damian666 Link to comment Share on other sites More sharing options...
Robin Posted June 22, 2009 Share Posted June 22, 2009 @ZultarĂƒÂ¢Ă¢â‚¬Å¾Ă‚Â¢:> rob patted u xD lol id check ur back… might be a kick me sign or sumin> nice job tho like the 3rd annoying thing uve fixedsticks a note on Zultar's forehead. Link to comment Share on other sites More sharing options...
damian666 Posted June 22, 2009 Share Posted June 22, 2009 hmm… first it errors on compile, saying that index is not right, so, i dim it, and that solves it.but then whenever i try to walk, it errors too :/error code is "subscript out of range" aka rte 9any idea whats going on?Damian666btw, this error is only client sided, server runs as normal. Link to comment Share on other sites More sharing options...
Robin Posted June 22, 2009 Share Posted June 22, 2009 Dimming something that doesn't exist is a very stupid thing to do.The problem was in the code I posted, which is quite funny.```Â Â Â Â If not GetPlayerX(index) = X then Call SetPlayerX(MyIndex, X)Â Â Â Â If not GetPlayerY(index) = Y then Call SetPlayerY(MyIndex, Y)```Index should be MyIndex. Link to comment Share on other sites More sharing options...
damian666 Posted June 22, 2009 Share Posted June 22, 2009 aaah, so that was it huh, ill try right away ^^Damian666edit:yeah, that works ^^, although i must say it doesnt looks good, when you see your player jump a few spots, but hee, it beats the alternative :)Damian666 Link to comment Share on other sites More sharing options...
Tyr Posted June 22, 2009 Share Posted June 22, 2009 I just made the same code (well it does the same) some time ago, it works.The bug it self is irritating, for f.e. NPC talking / PvP.But trough this fix you get warped all the time with only a server ping of 60! I think this is pretty much more annoying then having to retype /refresh a few times.We were thinking of coding our server into C++ or Java, simply to build up the speed, as this is the only problem for this issue, any suggestions? Link to comment Share on other sites More sharing options...
Admiral Refuge Posted June 22, 2009 Share Posted June 22, 2009 @Tyr:> We were thinking of coding our server into C++ or Java, simply to build up the speed, as this is the only problem for this issue, any suggestions?Use Solar Eclipse when it comes out, since it's in Java? XD Link to comment Share on other sites More sharing options...
Tyr Posted June 22, 2009 Share Posted June 22, 2009 @Admiral:> Use Solar Eclipse when it comes out, since it's in Java? XDYou must be kidding Admiral, I'm not waiting for a new engine to come out or whatever Solar Eclipse is.Aura is already a very developped game with TONS of source edits.The question was if a Java/c++ server is going to fix this issue Link to comment Share on other sites More sharing options...
Admiral Refuge Posted June 22, 2009 Share Posted June 22, 2009 @Tyr:> You must be kidding Admiral, I'm not waiting for a new engine to come out or whatever Solar Eclipse is.> Aura is already a very developped game with TONS of source edits.> > The question was if a Java/c++ server is going to fix this issueNo worries mate (though, everything is virtually 100% compatible, from TE to EE2.8)But how can you turn down 3D?I think I remember HM saying that the reason the server is so laggy, is because of the datatype (does it use integer or something?) that it uses to send the packets, and he said that if you sent the packets as characters, it would reduce lag. Link to comment Share on other sites More sharing options...
Robin Posted June 22, 2009 Share Posted June 22, 2009 @Tyr:> I just made the same code (well it does the same) some time ago, it works.> > The bug it self is irritating, for f.e. NPC talking / PvP.> But trough this fix you get warped all the time with only a server ping of 60! I think this is pretty much more annoying then having to retype /refresh a few times.> > We were thinking of coding our server into C++ or Java, simply to build up the speed, as this is the only problem for this issue, any suggestions?Have you actually read the fix, or tried this code?It obviously doesn't warp you at all. It simply checks, after every step, that the client is synced properly. If not, it'll modify the position.Please read through the thing before making assumptions. Link to comment Share on other sites More sharing options...
Tyr Posted June 22, 2009 Share Posted June 22, 2009 Of course I did robin and yes i read it trough I know what it does, I even made this sort of fix before.I'm hopping around the screens like a bunny, let say it that way :)Server is for me around a 60-65 ping, which is pretty low for MMO's Link to comment Share on other sites More sharing options...
damian666 Posted June 22, 2009 Share Posted June 22, 2009 for me it does jump a bit to be honest…but after warp to next map, it jumps like 3 times max.i can live with that :pDamian666 Link to comment Share on other sites More sharing options...
Robin Posted June 22, 2009 Share Posted June 22, 2009 Eh, in that case I'll try it out.I can't see it being a problem in theory, but I'll have a look. Link to comment Share on other sites More sharing options...
Robin Posted June 22, 2009 Share Posted June 22, 2009 Jesus, this is terrible.Give me a few minutes, I'll sort it out. Link to comment Share on other sites More sharing options...
damian666 Posted June 22, 2009 Share Posted June 22, 2009 cool, and the weirdest part of it is, i am on the same computer, as my server.so, i should not have lag right?Damian666Warning - while you were typing a new reply has been posted. You may wish to review your post.damn ^^ 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