[BtS SDK] Don't show units over cities

77alex77

Chieftain
Joined
Oct 25, 2007
Messages
91
Location
Somewhere beyond the sea
Hi there,
in CivIII there has been an option called "Show units over cities" or something like that. If it was disabled units located in cities were not shown on the map.
I know that there isn't such an option in CivIV but I wanted to have it more than ever, because it doesn't look good if a huge knight or whatever is standing on my city so that all the buildings cannot be seen properly.
I did some research in the SDK and found a simpel but 'suboptimal' solution:
I modified the function "updateCenterUnit()" in CvPlot.cpp:
Spoiler :
void CvPlot::updateCenterUnit()
{
if (!GC.IsGraphicsInitialized())
{
return;
}

if (!isActiveVisible(true))
{
setCenterUnit(NULL);
return;
}

setCenterUnit(getSelectedUnit());

// BEGIN 77alex77 don't show units over cities

//if this plot has a city and no unit is selected:
//set no center unit
if (getCenterUnit() == NULL && !(getPlotCity() == NULL))
{
return;
}

// END 77alex77 don't show units over cities

if (getCenterUnit() == NULL)
{
setCenterUnit(getBestDefender(GC.getGameINLINE().getActivePlayer(), NO_PLAYER, NULL, false, false, true));
}

if (getCenterUnit() == NULL)
{
setCenterUnit(getBestDefender(GC.getGameINLINE().getActivePlayer()));
}

if (getCenterUnit() == NULL)
{
setCenterUnit(getBestDefender(NO_PLAYER, GC.getGameINLINE().getActivePlayer(), gDLL->getInterfaceIFace()->getHeadSelectedUnit(), true));
}

if (getCenterUnit() == NULL)
{
setCenterUnit(getBestDefender(NO_PLAYER, GC.getGameINLINE().getActivePlayer(), gDLL->getInterfaceIFace()->getHeadSelectedUnit()));
}

if (getCenterUnit() == NULL)
{
setCenterUnit(getBestDefender(NO_PLAYER, GC.getGameINLINE().getActivePlayer()));
}
}

This solution is 'suboptimal' because units in cities cannot be selected the normal way (left mouse button) anymore.
They have to be selected via the context menu. The context menu for a tile can by default be accessed by "shift + left mouse button" or, if the respective option is activated (Civ4 options menu), by "right mouse button". Once a unit is selected, the usual plot list will appear and units can be selected as normal. It is also possible to select units in the city screen.
I will see if I can get this fixed. Perhaps someone knows a simple solution for this problem.

I don't know if there are other drawbacks. I played with this modification nearly half of a game and I had no problems. I also did some WB experiments to see if it effects bombing, nuking, etc. but it doesn't seem so.

I know that there might be not many civers who want such a 'feature', but I always missed this option and now it is 'really' possible to see all the city buildings on the world map.

I integrated my modification in the BtS 3.17 dll.

Installation instructions are included in the readme.
It is possible to start using this dll in the middle of a game.
So if you are interested, just have a look.
If you don't like it, just restore your old dll.


Don't show units over cities DLL (BtS 3.17):
Download here
 
Awesome!! Thankyou so much!! I was just asking about this the other day!!

I really missed this from civ3. Not so much because of the giants towering over the city, but because it obscures the city graphics.

Just curious, is it possible to use the CvGameCoreDLL.dll in a mod or custom assets rather than replacing the original?
 
[...]
Just curious, is it possible to use the CvGameCoreDLL.dll in a mod or custom assets rather than replacing the original?
I'm not sure if it can be placed in the custom assets folder. I read somewhere that this isn't possible as the dll will be ignored.

It is possible to install it as a mod but I didn't try it.
What you would have to do is to create the following folders:
.../Sid Meier's Civilization IV/Beyond the Sword/Mods/ModName
and
.../Sid Meier's Civilization IV/Beyond the Sword/Mods/ModName/Assets
The dll has to be placed in the .../ModName/Assets folder.
Then you should be able to load the mod called "ModName" as normal.
I'm not sure if a ModName.ini is also needed...will try it later.

I don't recommend to install it as a mod.
If you install it as described in the readme you can easily switch between the dlls (by renaming the files for example).
So if you are in the middel of a game and you think: "I want to see my glorious cities!" just use the provided dll and play on.
If you now play 50 turns and you think: "My citizens must feel unprotected if the garrison troops are not displayed." ;)
just switch back to your normal dll.
If it is installed as a mod you will have to start a new game to try it.
 
Ok, been trying this out and I can't live without it now. But I have a problem now, because there is another SDK mod I can't live without. I know nothing about programming but I'm extremely tempted to try my hand at merging the two since I see the code posted above, it makes it look easy. Exactly how difficult would it be for me to learn from scratch (no programming knowledge at all, other than some xml and doing a few Winmerge python merges) how to merge this with another SKD mod? Would it be a complex thing that I'd spend days of trial and error on, or something I could figure out and do in 4 or 5 hours of an evening?
 
I'm sure, as you have done some xml and python stuff already, that you will figure this out in less than 4 hours.
Of course you will need the complete source code of the SDK mod. Just open the file "CvPlot.cpp" and search for the function "updateCenterUnit()". The only thing you have to do is to insert that little code fragment given in the first post.
This one:
Spoiler :
// BEGIN 77alex77 don't show units over cities

//if this plot has a city and no unit is selected:
//set no center unit
if (getCenterUnit() == NULL && !(getPlotCity() == NULL))
{
return;
}

// END 77alex77 don't show units over cities

Be sure to insert it at the right place. So right after "setCenterUnit(getSelectedUnit());".

Now, that the merging is done, all you have to do is to compile the source code to get your "CvGameCoreDLL.dll".
This is also not difficult as there is an excellent tutorial.
If you follow the instructions step by step, nothing will go wrong.

I don't think so, but it might be possible that the merging will not work if...
...the other mod also modifies the "updateCenterUnit()" function. In this case you would have to figure out what it does there.
...the other mod uses the variable "centerUnit" for other purposes than to determine which unit of a stack should be displayed. But this is unlikely.

I hope this helped. Have fun!

alex
 
Top Bottom