Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Experimental] Server/Client Player Movement Desync Fix


balliztik1
 Share

Recommended Posts

Actually for those who want to wait for this to be much more stable, what i suggest is your sadscript a command like i did.

I made it so if u type /reset, the player is warped on the exact location he is (refresh the map which unfreezes the map)

Its easy just call ur map stuff like
Dim PlayerMap
Dim PlayerX
Dim PlayerY
PlayerMap = GetPlayerMap(index)
PlayerX = GetPlayerX(Index)
same for Y
then you do Call PlayerWarp(index, playermap, playerx, player)
as simple as that
Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

After looking through the code that handles map switching, I found a certain string that appears to only be sent when your on the edge of a map to switch maps, which is "requestnewmap". If you add a check on the server to see if the player is on the edge of a map when that string is received you can synchronize the player with the server without having to constantly synchronize every second or every time the player moves. The code for this is pretty simple: (Sample for EE2.7 Unedited)

1\. In modHandleData in the server, find the "Packet_RequestNewMap" sub.
2\. Replace the contents of the sub with
```
    If Dir < DIR_UP Or Dir > DIR_RIGHT Then
        Call HackingAttempt(Index, "Invalid Direction")
        Exit Sub
    End If
    Select Case GetPlayerDir(Index)
        Case DIR_UP
            If GetPlayerY(Index) > 0 And Map(GetPlayerMap(Index)).Up > 0 Then
                Call SendDataTo(Index, "notgettingmap" & SEP_CHAR & END_CHAR)
                Call SendPlayerXY(Index)
                Call PlayerMsg(Index, "Syncronized", 1)
                Exit Sub
            End If
        Case DIR_DOWN
            If GetPlayerY(Index) < MAX_MAPY And Map(GetPlayerMap(Index)).Down > 0 Then
                Call SendDataTo(Index, "notgettingmap" & SEP_CHAR & END_CHAR)
                Call SendPlayerXY(Index)
                Call PlayerMsg(Index, "Syncronized", 1)
                Exit Sub
            End If
        Case DIR_LEFT
            If GetPlayerX(Index) > 0 And Map(GetPlayerMap(Index)).Left > 0 Then
                Call SendDataTo(Index, "notgettingmap" & SEP_CHAR & END_CHAR)
                Call SendPlayerXY(Index)
                Call PlayerMsg(Index, "Syncronized", 1)
                Exit Sub
            End If
        Case DIR_RIGHT
            If GetPlayerX(Index) < MAX_MAPX And Map(GetPlayerMap(Index)).Right > 0 Then
                Call SendDataTo(Index, "notgettingmap" & SEP_CHAR & END_CHAR)
                Call SendPlayerXY(Index)
                Call PlayerMsg(Index, "Syncronized", 1)
                Exit Sub
            End If
    End Select
    Call PlayerMsg(Index, "Test!", 1)
    Call PlayerMove(Index, Dir, 1)
```3\. Open modHandleData in the client and add this at the bottom of Sub HandleData
```
    If casestring = "notgettingmap" Then
        GettingMap = False
    End If
```
And thats it!

If you want to test this, move your player to the center of the map, make sure the map has switchovers in all directions, and log out. Then open modClientTCP and find Sub PlayerMove. Replace```
Call SendData("playermove" & SEP_CHAR & GetPlayerDir(MyIndex) & SEP_CHAR & Player(MyIndex).Moving & END_CHAR)
```with```
'Call SendData("playermove" & SEP_CHAR & GetPlayerDir(MyIndex) & SEP_CHAR & Player(MyIndex).Moving & END_CHAR)
```
Then login and move to the each map corner and attempt to switch maps. Since the client is no longer sending the player movements to the server, the server still thinks you are in the center of the map so it will synchronize you :)
Link to comment
Share on other sites

~~just to let you guys know, the fix that raichu posted works much better then the one this topic is about.

sure , maybe its not as clean as robin or derrick would do it, but it works, not it will only sync on mapswitch, which will take out the warping back all the time, me like ^^

so, if you think you need a desync fix, i suggest this one.~~

this stil is not perfect, i am currently thinking about this… hmm

Damian666
Link to comment
Share on other sites

This isn't even really fixing the heart of the problem, your just covering up the original issue: The server cannot handle the clients consistent packets for each players location. I would suggest that the procedure would handle the amount of times the packet sends and the server receives, rather than spraying data all over the place. - Just my view on the matter

I'm going to fix this soon, as soon as I get the time.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...