[C++] What is gDLL?

Drawmeus

Emperor
Joined
Jul 25, 2007
Messages
1,213
I see it everywhere, and I've even done some work with it, but I don't really understand it.

When I've tried to find the methods that it's being used for - for example:
Code:
gDLL->sendMinorGiftGold(eMinor, iNumGold);

nothing appears.

I'm not really a programmer - a competent scripter who can follow C++ logic, yes, but not a software engineer. I've had no luck figuring this out. Would anyone be able to explain it to me?

I gather it's (at least part of) the interface between this code and other aspects of the game, but with game logic (e.g. sendMinorGiftGold) apparently included in it, it seems like something I need a fairly thorough understanding of if I'm going to do any serious implementation in the DLL.
 
At a simple level it's

Code:
#define gDLL GC.getDLLIFace()

see CvGlobals.h

At a more complex level it's "a pointer to the stuff we're not allowed to play with"

If you look in the main Civ5 directory there are (at least) 6 Civ related code libraries - Civ5GDF.dll, CvGameCore, CvGameDatabase, CvLocalization and CivilizationV.exe, as well as numerous 3rd party support libraries (eg lua51, ssleay, zlib1)

Of those 6 Civ code libraries we can only "play" with one - CvGameCore - the other 5 are "off-limits". gDLL (and UIDLL) is how you have to call code in those other libraries - you just have to take it on trust that it a) works and b) does what you expect.

While working with the dll code you have to keep in mind that everything is set up for multi-player, and single player is really just a multi-player game with only one human player. So when you give a gift of gold to a CS not only does the CS have to know about it, but every other player has to know about it as well.

W
 
The network code will in turn call functions in CvDllNetMessageHandler.cpp, which we do have access to. In the example used it will call CvDllNetMessageHandler::ResponseMinorCivGiftGold.
 
So then, would it have been impossible to code city-states if they weren't already provided for us? I.e. things like gold gifting would just not be doable?
 
You don't have to use this system. The downside of not doing it is you lose MP compatibility. Which right now is no loss at all since mods don't work in MP.

I don't know how moddable it is. I don't think you could add your own net messages in civ 4 but there was an onModNetMessage function that could be used. I don't see any such function in civ 5 but we have access to more of the source, and may be able to add our own functions. We'll see once someone tries to do it.

Worst case scenario we have to (ab)use existing functions. It won't look pretty but there's nothing stopping us from doing it.
 
So then, would it have been impossible to code city-states if they weren't already provided for us? I.e. things like gold gifting would just not be doable?

If you're willing to accept that such extensive mods will never work in multi-player games, it won't be an issue.

We tend to think in terms of "I'll give some gold to a CS, my treasury goes down, but my standing with the CS goes up" style logic. But that is not what happens with a network enabled game.

It's more "I'll give some gold to a CS, send a message to that effect". Followed by "I've received a message that someone (it could be yourself) gave gold to a CS, decrease how much gold they have but increase their standing with the CS".

You can code the first (single player) approach as it's all within the single game state on your computer. You can't code/extend the second (multi-player) approach as we don't have access to the network message sending code.

W
 
I'm very comfortable working with network concepts (I spent 5 years as a game systems/combat designer on a AAA quality MMORPG) - I just didn't realize that's the thing that I don't have access to.

I guess I'll be coding for single player, then. And if they ever expose the necessary stuff for MP (I rather doubt they will unless they do a real "THIS IS MULTIPLAYER!" expansion), well, I'll probably ask for better programmers than myself to help work it out >.>

Thanks for the responses, this was very helpful, as usual.
 
any way for us to figure out what all we can do with the stuff we're not supposed to play with? :p

Apart from documenting all occurences of gDLL, that is.
 
Top Bottom