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

[EO] Server crashed (try on gravity-code)


Sealbreaker
 Share

Recommended Posts

I recently have a problem with my server… So i tried myself on adding gravity to EO and added a sub in my game-loop (client-sided) which calls sendgravity:
```
Public Sub SendGravity(ByVal Index As Long)
    Dim Buffer As clsBuffer
    Set Buffer = New clsBuffer
    Buffer.WriteLong CGravity
    SendData Buffer.ToArray()
    Set Buffer = Nothing
End Sub
```
and serverside the place where the server reacts and which also is the part that causes my server to crash (btw, it crashes WITHOUT giving me the chance to debug or any further information):

```
' :::::::::::::::::::
' :: Gravity Packet ::
' :::::::::::::::::::
Sub HandleGravity(ByVal Index As Long)
    Dim n As Long
    Dim Buffer As clsBuffer
    Set Buffer = New clsBuffer

    If Index = 0 Or Index > MAX_PLAYERS Then Exit Sub

    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_PLATFORM Then
    Call SendPlayerXY(Index)
    Exit Sub
    End If

    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type <> TILE_TYPE_PLATFORM Then
  Call SetPlayerY(Index, GetPlayerY(Index) + 1)
  SendPlayerXY (Index)
  End If
  End If
    Set Buffer = Nothing
End Sub
```
SO, i need any help i can get to get my server and this code working…
(i had this sort of topic before with a "subscript out of range" error i had within the gravity-code (serverside again) which i fixed with help of robin and which i changed a bit... The new problem (crash) seems to me to be caused through the if-check for the index being higher than max_players...

-seal
Link to comment
Share on other sites

When is Index ever set? Is there a portion of the code that sets it? If not, you need to have the client send MyIndex, and then have the handle code read it, and set Index to it, or have the client send the player's name, and use```
FindPlayer(Name)
```, after setting the variable name to the received data.

I may be wrong, as I have been lately, but since nobody else has tried anything…And it's the only thing I can see that could possibly be screwing it up.
~Urame
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...