🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How do the .dll's work?

Started by
0 comments, last by Peon 20 years, 10 months ago
I guess this is kind of off topic, but I was curious about how KHawk was able to use custom .dll''s written by us in C++ as a bot AI in the main program. I honestly pictured something more like a custom scripting language, not something in C++ (which worked out well, as it definetly lowers the learning curve) Can someone please explain how this works, or point me to other information? I really like the idea of these individual AI "modules".
Peon
Advertisement
Hi,

it is acutally quite simple. Your bot is derived from the abstract class (or interface if you will) IPlayer. Because both GDArena and the bot conform to this interface, they are able to communicate.

The class is actually exported from the dll by the QueryBotInterface() function which is in your bot's source code (generated by BotGen). This function is a normal C function like any other and is exported from the dll (like the winapi functions are exported from their dlls too).

If you look close at the definition of this function:

extern "C" int LINKAGE QueryBotInterface(const char *iid, IPlayer **iptr)

you'll notice the "LINKAGE" macro in front of it. Looking that up gives you:

#define LINKAGE __declspec(dllexport)

Which is a way of telling the VC++ compiler that the function needs to be exported from the dll.

I hope this helps.

If you have any more questions, just shoot

[edited by - Epidemi on August 29, 2003 3:23:38 AM]
--------------------Life after death? Is it like terminate and stay resident?

This topic is closed to new replies.

Advertisement