buffer_create_fix for GMS1
A downloadable extension
Versions: GameMaker: Studio
Platforms: Windows, Windows (YYC)
In GMS1, calling buffer_create with size of 0 throws an error like this one:
ERROR!!! :: ############################################################################################ FATAL ERROR in action number 1 of PreCreate Event for object <name>: buffer_create: Illegal size 0 ############################################################################################
Consequently, this also means that if a game receives a network_send* packet with size of 0, it will crash - with nothing that you can do about this.
This extension fixes that by monkey-patching the implementation of buffer_create to allow 0-sized buffers like GMS2 does.
How to use:
1. Import the extension to your project (drag and drop onto GMS1 IDE or right-click on "Extensions" in resource panel ➜ "Import extension").
2. Call the function on game start once:
buffer_create_fix();
You can verify that it works by doing the following:
socket = network_create_server(network_socket_udp, 5000, 1);
buffer = buffer_create(1, buffer_grow, 1);
network_send_udp(socket, "127.0.0.1", 5000, buffer, 0);
 
var b = buffer_create(0, buffer_grow, 1);
show_debug_message("size of zero-sized buffer(): " + string(buffer_get_size(b)));
Special thanks to Pelican Police for funding development of this extension.
| Status | Released | 
| Category | Assets | 
| Author | YellowAfterlife | 
| Tags | GameMaker | 
Download
Click download now to get access to the following files:

Comments
Log in with itch.io to leave a comment.
Now that's handy.