Buffer Problem

Imperial

Member
I keep getting this Error
Code:
___________________________________________
############################################################################################
ERROR in
action number 1
of Async Event: Networking
for object control_client:

Attempting to read from outside the buffer, returning 0
at gml_Script_client_message
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_client_message (line 0)
gml_Object_control_client_Other_68
this is the client_message Script:
Code:
var buffer = argument0;

while(buffer_tell(buffer) < buffer_get_size(buffer))
{
    var msg_id = buffer_read(buffer,buffer_u8);
    
    switch(msg_id)
    {
        case MESSAGE_MOVE:
        {
            var client = buffer_read(buffer,buffer_u8);
            var xx = buffer_read(buffer,buffer_u16);
            var yy = buffer_read(buffer,buffer_u16);
            
            if(ds_map_exists(clientmap,string(client)))
            {
                var client_object = clientmap[? string(client)];
                client_object.x = xx;
                client_object.y = yy;
            }
            else
            {
                var i = create(xx,yy,OtherClient);
                clientmap[? string(client)] = i;
            }
            
            with(server_client)
            {
                if(client_id != client_id_current)
                {
                    network_send_raw(self.socket_id,other.send_buffer,buffer_tell(other.send_buffer));
                }
            }
            
            break;
        }
    }
}
what It says Error in Line 0 ?
 

The-any-Key

Member
Line 0 may be something wrong with the debugger.

It's probably when you read the buffer.

Try run it in debug mode and check the buffer when the error occurs. I guess you lack one of the values in the buffer.
 

icuurd12b42

TMC Founder
GMC Elder
one of the buffer read is overrunning the buffer, likely one of these
var client = buffer_read(buffer,buffer_u8);
var xx = buffer_read(buffer,buffer_u16);
var yy = buffer_read(buffer,buffer_u16);

you probably dont have a matching set of data in the buffer, compare your buffer writing to the reading
 
Top