View Single Post
Solokiller
Senior Member
Join Date: Sep 2015
Old 10-18-2016 , 07:07   Re: Sven Co-op 5.0 gamedata thread
Reply With Quote #8

Well, you can't use its API to get that information. That's why i said you'll need to use some tricks; you'll have to get the library version used by SC (printed in the console on startup) and cast to the implementations of every interface to get to its data. It's not impossible, but unless you match up the right versions it will crash.

Getting the engine is a bit of work too, you'll need to create an entity that has a pointer to a function.
trigger_script has one, and i've got the source code for that entity if you need it. You'll be able to use that to find the offset (CTriggerScript is 228 bytes on Linux, the function is the last member, so + 224 from 'this').
Then you just cast edict_t::pvPrivateData to a byte pointer, offset to that function pointer, and dereference it to get the script function contained in it. (it's actually a pointer to a wrapper, the wrapper's layout is vtable then asIScriptFunction*)
Then you grab the engine pointer using asIScriptFunction::GetEngine.

Do be aware that if they find out you're hacking into their code like this, they will likely take some form of action.
Whether it involves shifting the trigger_script members around or changing how it stores the function entirely, i wouldn't put it past them to shoot themselves in the foot just to stop this.
If they won't share the information willingly, they won't allow you to get it through other means either.

That said, if they go through with Sniper's idea to reload Angelscript if a host error occurs, then you can just replace the Angelscript library that they'll be adding to do this. Implement asIScriptEngine and pass all methods through to the real engine.
Then you're basically given the address/offset and name of every API member on a silver platter. This also has the advantage of working for the client side when client side scripting is added, since they'll probably make that use the same code.
Solokiller is offline