• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM [SOLVED] DS Grid problems...

S

Samus

Guest
So lately I've been working on an online networking game, and, surprisingly, the online Networking works just fine! The problem I'm having is actually much more basic, it's with DS Grids.

So (on the server side) I convert a DS_Grid to a String using DS_Grid_Write, and I save it as a variable "gridString". I then send that string from the server to the client. The client then uses DS_Grid_Read to read that string and turn it into a DS_Grid, which it uses to draw the different players at their given positions and stuff.

When I first press one of the arrow keys, the player moves to where it should go, but then the errors start going non-stop and it no longer reacts to key input (though the server receives it and broadcasts it):
"Grid 1, index out of bounds writing [2,-1] - size is [1,1]"

First of all, the size of the grid is larger that [1,1], it's usually [1,3] when I test it. Second of all, I have no clue where the [2,-1] comes from. I don't see anywhere in my Client's code that would ever make a negative number. Its probably something obvious that I just can't see. Any help is appreciated!

Code snippets:
In the Asynch Network Event.
Code:
///Recieve data from Server

//Handle the data
var buffer_serv = async_load[? "buffer"];
buffer_seek(buffer_serv, buffer_seek_start, 0);
scr_recieved_packet(buffer_serv);
if(message_id = "grid")
{
    if(player_grid != 0) ds_grid_destroy(player_grid);
    player_grid = ds_grid_create(1, 1);
    ds_grid_read(player_grid, mx);
}
The received packet script.
Code:
///scr_recieved_packet(buffer)

var buffer_serv =  argument[0];
message_id = buffer_read(buffer_serv, buffer_string); // 100, 120
mx = buffer_read(buffer_serv, buffer_string); //120
In the Step Event (only the relevant parts)
Code:
if(player_grid != 0)
{
    var gy = ds_grid_value_y(player_grid, 0, 0, 0, ds_grid_height(player_grid) - 1, global.name);
    x = ds_grid_get(player_grid, 1, gy);
    y = ds_grid_get(player_grid, 2, gy);
}
Thank you again!
 
S

Samus

Guest
Welp, I figured out how to stop the error... 15 minutes after I posted this.:D
I replaced my step event code with this:
Code:
//Move based on the grid
if(player_grid != 0)
{
    if(ds_grid_value_exists(player_grid, 0, 0, 0, ds_grid_height(player_grid), global.name))
    {
        var gy = ds_grid_value_y(player_grid, 0, 0, 0, ds_grid_height(player_grid) - 1, global.name);
        x = ds_grid_get(player_grid, 1, gy);
        y = ds_grid_get(player_grid, 2, gy);
    }
}
Now there is no error report, but the client doesn't react to the data the server is sending it. The problem is still there, whatever it is.
 
S

Samus

Guest
OK, Now I feel stupid.:confused:
The problem was actually on the server, and it was because of a typo. I put "buffer" where what I meant was "buffer_serv".o_O LOL!!
Anyhow, that fixed everything. How silly I am.
 
Top