Advertisement

Compile to file?

Started by April 05, 2007 11:55 AM
3 comments, last by MrPotatoes 17 years, 7 months ago
i thought i read it within your feature list but i'm confused because i didn't see a tutorial/example of it on the site. i'm looking to see if i can get the angelscript files and then compile them into a single file. what i wanted to do is then take that compiled file and read it into memory and use it by my game engine. i need to do this because all the game information (styles, types, rules) would be in the scripts and i don't want to have those freely available to edit because that cheats the idea of the game. is it possible to do this with angel script? if i'm not being clear enough i can clear it up. ------------- ok, i thought of something to make it more clear. i want to compile it to a game package. it will contain all the information for a game type. i'll compiile it to say a shared object or a Dynamic Link Library. from there i can save it to memory and read from it there like an exe. or just read the information. either way i wanted to write script files (not within the code) and then you compile it to a package and i get the information from there. i hope that is better. [Edited by - MrPotatoes on April 5, 2007 12:25:44 PM]
After you create your engine and build a script file, you can save it to file by calling the SaveByteCode method. Use LoadByteCode to load it back in.

Check out the docs related to int asIScriptEngine::SaveByteCode(const char *module, asIBinaryStream *out)
Advertisement
midnite already told you what you need to know. You can also take a peek at test_saveload.cpp in test_feature, though it was by no means written as a tutorial.

I normally do not recommend using the save/load feature unless you need the extra load performance. AngelScript is not able to validate the pre-compiled bytecodes to make sure they are safe (in regards to out-of-bounds access, null pointers, etc). You'll have to do that validation yourself by making sure nobody has tampered with the bytecode you compiled, e.g. through checksums, etc.

If you're only interesting in hiding the script code, then a simple obfuscation or even encryption might be better, as then the code will not be freely available and it will still go through all the validation done by the script compiler.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Or you could leave it open, but checksum it. This would allow your players to make modifications ('mods'), but not cheat - you just only allow players to play together if they all have the same checksum, or you make everything run on the server and ignore the scripts on the client side.
i know what i'm going to do. thank you all for responding :)

This topic is closed to new replies.

Advertisement