![]() |
Re: Storing an array of function calls, and their params.....
Because, normal C++ is only fun when you do crazy things that either won't work or are a miracle when they do.
The crazy idea I had was to dynamically make a function that would call the other function with the appropriate parameters. Like... push ( b ) push ( a ) call ( MyCoolFunc ) pop ( eax ) pop ( eax ) ret Then set that little function as your function pointer, though since I don't know that much about assembly it's a little harder for me to get this working. Almost done though. |
Re: Storing an array of function calls, and their params.....
yep, I know such stuff ... jump to subroutines with the normal jump, to save a following 'return from subroutine' etc ... but normally I rather try to keep assembly and C/C++ separated. this had already positive effects when I had to ran a program on a non x86 machine at university :-)
|
Re: Storing an array of function calls, and their params.....
I'm coding for a game thats written in straight C, so virtual functions aren't available to me (easily anyway).
I'm creating a script system that is event based. The user can tell the game a bunch of different commands to execute when a certain event happens. What I was looking to do, is parse the file, then save off the commands that are linked to each event happening in a stack like the one we're talking about. Then, when the event happens, I can quickly execute the commands linked to that event, without reparsing anything, or working with strings. It seemed the quickest way to do what I needed to do. If theres a better way, I'd be happy to hear about it, I'm always open to learning more, especially if its faster, or more efficient. |
Re: Storing an array of function calls, and their params.....
There is probably a way to make the compiler do all the work but I haven't found it yet.
Not fun writing a function byte by byte though, calls fine now, just won't pop the stuff off the stack lol. *goes insane* |
Re: Storing an array of function calls, and their params.....
WARNING: Disgusting, hacked up code!
Code:
#define WIN32_LEAN_AND_MEAN |
Re: Storing an array of function calls, and their params.....
What Maleficus is doing right now IS portable. As long as all the functions have identical arguments, storing them in the struct is perfectly doable.
Code:
typedef struct Code:
// instancing If you want to call funcs that have variable types of arguments instead, you can do something like this: Code:
typedef struct Code:
// instancing |
Re: Storing an array of function calls, and their params.....
Quote:
Thanks for the help guys! :D |
All times are GMT +2. The time now is 20:43. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.