-
Notifications
You must be signed in to change notification settings - Fork 1
Reading old encoded files
gnysek edited this page Aug 7, 2023
·
2 revisions
39dll
offered easy way to read files into buffer, and encode/decode them.
My networking example doesn't use this anymore, and all file functions are removed, however it's still possible to read old files, as GM have functions to load buffer into file and they are even better - there's no need to open file, read buffer and close - file is read into new buffer and closed instantly. This however implies need of copying newly created buffer to our default one, but that's why I've added seize_buffer()
(maaaaybe claim_buffer() would be better name for it...):
var _buff = buffer_load("filename");
seize_buffer(_buff); // copy to global.buffer
buffer_delete(_buff);
/// optionally decode
bufferdecrypt("secretcode"); // in fact bufferdecrypt and bufferencrypt does same, as it's kinda XOR function
/// you can now read data
// readbyte()...
// readint()...
// readstring()...
// etc..
You'll find bufferdecrypt()
and bufferencrypt()
function here:
https://gist.github.com/gnysek/b1a247af0d202af2f87ce4f5d84cee2f