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.
The received packet script.
In the Step Event (only the relevant parts)
Thank you again!
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);
}
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
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);
}