I am trying to create an extension for tgf and having a bit of trouble. How would I call a dll in the pluin code? If I have a separate dll and I want to use the functions from it inside a function for my extension how would I go about doing that? I've been reading through all the documentation and I don't see how to do that. I assume it can be done as that is what dmc2 is basically doing. I'm not sure if anyone can help.
I also tried using the calldll extension and running it directly though tgf with no luck either. I read the articles on calldll and couldn't even get it to work with bass.dll. Now I'm not sure what I'm doing wrong here as I followed the article exactly and understand the principles behind it. I tried the old bass.dll as well as the new one and nothing seems to work. I tried a mulitude of different ways of using the calldll and it doesn't seem to do anything. When I run the app with calldll I get no feedback at all. Anyone familiar with extension creation for tgf?
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
turning myprocedure in a function? I'm not sure I fully understand this line and how it's being used. I get the loading of the dll. That makes sense. The rest I'm a little fuzzy on. I did some research on pointers to functions and your example is done a bit differently then what I had found. The first link you had posted did a straight typedef void functype(int);
I'm not sure I understand the typedef int(*some_proc)(int). Is that another way of doing the same thing or is that being setup differently? Thanks for the quick response.
GetProcAddress returns a FARPROC, which is the same as "int (__stdcall*)(void)". However myprocedure is an "int (__cdecl *)(int)", so to make them compatible you need to typecast it to that.
If you wanted you could do this:
// Declare a pointer to a function called myprocedure
int(*myprocedure)(int);
// Typecast the result of GetProcAddress to suit myprocedure
myprocedure = (int (__cdecl *)(int))GetProcAddress(some_dll,"_myprocedure@4");
using typedef is simply an easier method because it's shorter and easier to type (because you can use the same keyword in two places)
(sorry if this explanation isn't too good... i'm not very good at this myself, and most online tutorials are ugly. I suggest you just find your own way that works and stick with it)
Edit: remember that you're not converting to a function, you're only getting a pointer to its location in memory, then jumping to it
edit 2: I think "result = myprocedure(500);" should actually be "result = (*myprocedure)(500);"
Edited by the Author.
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
Alright...another question. I have a function to init my dll which works fine. It runs the functions it's suppose to and then I have a separate destroy function. The destroy function doesn't seem to be working when I end my application. I have an end game condition where I run the destroy function. It is not closing as it should. Is there separate function in the plugin code where I should add that code? Cause it does seem to close properly when I close out of tgf, but not my application. Any suggestions? Thanks again.
I've never actually made any TGF/MMF extensions (Can't stand that damn SDK) so you might be best asking someone like Marcello or Tigs. If you post some code though, I might be able to help
Edited by the Author.
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
Try freeing the DLLs in the Free() function (which runs when the extension is freed), if the external DLL is global to all instances of your object. (You would use Initialise() to initialise the DLL in this case.)
You might want to run a debugger over the DestroyRunObject function, because for me it runs when the application exits.