[SDK] gDLL

Zebra 9

Emperor
Joined
May 17, 2006
Messages
1,554
Location
Middle of Cyberspace
I can't seem to figure out where gDLL is located. The reason I want to know is because I'm trying to make it possible to rename a civ/leader in game and I think this has something to do with this. So I would like to know where gDLL is (the file) and if I'm looking in the right spot (am I barking up the wrong tree?). Thanks.:goodjob:

P.S
I know C++ a little, I'm still learning.
 
I can't seem to figure out where gDLL is located. The reason I want to know is because I'm trying to make it possible to rename a civ/leader in game and I think this has something to do with this. So I would like to know where gDLL is (the file) and if I'm looking in the right spot (am I barking up the wrong tree?). Thanks.:goodjob:

P.S
I know C++ a little, I'm still learning.

You'll find the definition of gDLL at the end of CvGlobals.h..


Code:
//
// helper
//
#define GC CvGlobals::getInstance()
#ifndef _USRDLL
#define gDLL GC.getDLLIFaceNonInl()
#else
[B]#define gDLL GC.getDLLIFace()[/B]
#endif
#endif

So, gDLL is really just short-hand for...

Code:
CvGlobals::getInstance().getDLLIFace()

If you're not familiar with the Singleton pattern, you can google it. That should explain the getInstance() part. Basically, CvGlobals is not a static class, but instead whenever you call it it has one static member that will be initialized and used as the only instance of that class. So, CvGlobals::getInstance().getDLLIFace() calls the function getDLLIFace() on the only instance of the CvGlobals class.

CvGlobals::getDLLIFace() looks like this...

Code:
CvDLLUtilityIFaceBase* getDLLIFace() { return m_pDLL; }		// inlined for perf reasons, do not use outside of dll

...and m_pDLL is defined in CvGlobals.h as..

Code:
CvDLLUtilityIFaceBase* m_pDLL;

So, what this all means is that gDLL returns a pointer to a CvDLLUtilityIFaceBase. If you look at CvDLLUtilityIFaceBase.h, you'll see the class.

Now the bad news. All that file does is show the interface, that is, the functions that have to be declared by the actual class to be considered a CvDLLUtilityIFace class. The actual class and all it's code is implemented in the EXE, where they are close to impossible to modify.

Edit:

BTW, if you're looking to rename leaders, I believe that the name of the leader is actually found by calling CvPlayer::getName. You can probably just modify that to your hearts content.
 
Ok, I have been looking around the SDK. I have a good idea of what needs to be done and how to do it. So far I have a setName function:
Code:
void CvPlayer::setName(wchar name){
  szLeaderName = name
}
Now I haven't changed the getName but that should be simple enough, so I just need to know where my variable szLeaderName should go in the CvPlayer.cpp file, are there any other files that I should change (do I have to add something to the CvPlayer.h?), how do I open the setName function to python, will the game save the new name, and lastly how do I read from and use the information from the XML (not important). Sorry that I have so many questions. Now I think to open the setName to python I need to change the CvPlayerInterface file, am I right?
 
Ok, I have been looking around the SDK. I have a good idea of what needs to be done and how to do it. So far I have a setName function:
Code:
void CvPlayer::setName(wchar name){
  szLeaderName = name
}
Now I haven't changed the getName but that should be simple enough, so I just need to know where my variable szLeaderName should go in the CvPlayer.cpp file, are there any other files that I should change (do I have to add something to the CvPlayer.h?), how do I open the setName function to python, will the game save the new name, and lastly how do I read from and use the information from the XML (not important). Sorry that I have so many questions. Now I think to open the setName to python I need to change the CvPlayerInterface file, am I right?

If you have a new variable called szLeaderName that will be a member of the CvPlayer class, then you will need to add this code to the CvPlayer.h file...


Code:
CvString szLeaderName;

I'd recommend naming the variable m_szLeaderName instead, just to go along with the general convention of placing "m_" at the front of variables that will be members of the class (in this case, the CvPlayer class), so the code would be...

Code:
CvWString m_szLeaderName;

You'll want to put that somewhere in the private section of the class in CvPlayer.h. If you're not too picky, you can put it right below the line that says...

Code:
CvString m_szScriptData;

Also, you'll have to add the function declaration for the setLeaderName in the CvPlayer.h file.

There is a tutorial that shows how to make python functions callable from python, but here's a quick overview..

You will need to change CyPlayer.h, CyPlayer.cpp, and CyPlayerInterface.cpp. Take a look at how they do getUnitName and setUnitName for the unit, and it should be pretty similar.

Edit:

BTW, I almost forgot.

Because you're making a new variable, you'll probably want to make sure that it's saved when a player saves a game.

For this, you can pretty much add this line to CvPlayer::read(FDataStreamBase* pStream)...

Code:
pStream->ReadString(m_szLeaderName);

And this to CvPlayer::write(FDataStreamBase* pStream)...

Code:
pStream->WriteString(m_szLeaderName);

Make sure you put them in the same place, because the order in which data is read/written matters.
 
Ok, I think I followed the above instructions to the T. So I am wondeing if somone could compile this? If you want to check my code I commented the beginning and endings of the changed code with:
//Name Changer By Zebra 9
and
//End Name Changer By Zebra 9.:goodjob:
 

Attachments

Back
Top Bottom