Modmodding Q&A Thread

As a follow up/tangent, I think I've narrowed down a cause of the big speedbump I was encountering just by the process of guess and check - the updatePlotGroup() call in CvPlot::setImprovementType() seems to cause a major lag spike when a fort is added/removed in certain cases. While I'm not 100% sure about the contributing factors, it seems if the fort is on a trade connection the lag spike is worse. I don't know much about plot groups, but I wonder if there's a way to optimize that. I've found that in my modmod(mod) (which has substantially diverged from base DoC to be fair), late game turn times might have an appreciable amount of time devoted to fort plot group recalculations.
 
Does anyone know how to use Microsoft Visual C++ 2010 Express' profiler? I've checked the official documentation and any online posts I could find, but couldn't find details on the 2010 profiler. I can tell it's possible, as there's a build configuration called "Profile" in the CvGameCoreDLL project, and many calls to the PROFILE_FUNC() define scattered among the code.

I've implemented some new features in the DLL and want to see if can optimize them. Thanks!
I haven't used the VS profiler, but you can compile a profile DLL and then use another tool like VerySleepy to monitor it. It's not the most informative result anyway though.

As a follow up/tangent, I think I've narrowed down a cause of the big speedbump I was encountering just by the process of guess and check - the updatePlotGroup() call in CvPlot::setImprovementType() seems to cause a major lag spike when a fort is added/removed in certain cases. While I'm not 100% sure about the contributing factors, it seems if the fort is on a trade connection the lag spike is worse. I don't know much about plot groups, but I wonder if there's a way to optimize that. I've found that in my modmod(mod) (which has substantially diverged from base DoC to be fair), late game turn times might have an appreciable amount of time devoted to fort plot group recalculations.
Plot group is the game's term for a group of tiles that is connected, i.e. by roads etc. Since forts act like cities, they have a huge impact on connections between previous unconnected plot groups that is non-trivial to compute. The plot group logic probably has a lot of potential to be improved on, but also probably has already seen a lot of improvement in mods focused on performance, e.g. Advanced Civ. So I would look there instead of trying to redo it.
 
After a discussion on a previous thread, I've become intrigued by the idea of multiple units being able to attack the same tile at once. Is it even possible to mod Civ IV in this way, or is that aspect of the game hard-coded?
 
First you would need to define what it means for multiple units to attack the same tile at once.
 
Of course, and maybe I should rephrase it: I would like multiple units to be able to attack the same unit simultaneously. As in, if I have a stack of 4 Musketeers, and I ordered the stack onto a tile with a single enemy unit, then the combat strength of all 4 Musketeers would be added and compared against the strength of the single unit. And similarly, if I order the stack onto a tile with 2 enemy units in a stack, then the combat would be the strength of all 4 Musketeers against the strength of both enemy units. As things are now, units fight each other one at a time.
 
With enough effort you could do that, but I don't think it would be a good idea because it would empower stacking even more.
 
IIRC there's a Caveman2Cosmos mechanic where you can merge or split similar units into bigger or smaller groups with corresponding strength, that's probably the closest thing to what you ask for.
 
It's not a good sign when your idea is in C2C but maybe that's just me.
 
Yeah after thinking about it some more, I think I agree with you that stacking doesn't need to be buffed. Have you given any further thought to the idea of supply limits for tiles? I don't know much about coding so for all I know it could be a lot more trouble than it's worth. But if it were easy to do it might be a neat idea.
 
You could do this and there are mods that have tried this, but I don't think it ever worked satisfyingly. The issue is not to implement the new game rule, it is to structure the AI and game balance around it.

Units being the primary object moving around the map as part of stacks is a fundamental principle that the entire game is designed around. You can change it but it's likely that the rest of the game won't fit anymore.

This topic arose out of the discussion of 1upt in another thread - part of the reason that I think this change was ill conceived is that the devs never thought through what the knock on effects on the rest of the game would be. For example, if you have 1upt there can be fewer units in the game overall, because otherwise there is not enough space for them. To achieve this you need to increase unit costs by a lot. That knocks the cost relationship between units and buildings out of balance, and imo also makes the game (especially the early game) a lot more boring because you are waiting for units to be built. Plus combat results become a lot more swingy.

Supply limits are a compromise between this and stacks but the same questions would need to be answered. Also, you should always ask yourself what problem you are trying to solve. What is bad in the game that is improved by limiting stack sizes. Sure you cannot be overrun by a larger stack anymore. But what is the real difference between your enemy having one 50 unit stack or five 10 unit stacks, and is one really less survivable than the other? It seems the problem in that situation is having fewer units than your opponent in the first place, regardless of how they are allowed to move across the map.
 
A very interesting perspective, it hadn't actually occurred to me all of the negative ramifications of the 1 UPT rule. And after giving it some more thought and reading what you had to say, I think that while supply limits work well in a Paradox Studios game, they don't seem to be necessary in DoC, or Civ IV for that matter.
 
Yeah. And I'm not even sure if supply limits actually work well in e.g. EU4 either. They seem to be the source of a lot of AI cheese.
 
Hello all! I made an account to ask this question. I've started tinkering with a 'performance' version of DOC on a smaller map, and am running into crashes seemingly involving AI settlers. No crashes occur when the SettlerMaps are made all 20s (I suppose because no one is building settlers), and from MPLog.txt I've found they always occur after an AI moves a settler and its protective unit. I can prevent the crash by playing as the AI which 'caused' it, but eventually a different AI causes a crash for the same reason. I don't believe this is explicitly to do with city founding as I've seen it happening with units moving to tiles adjacent to a preexisting city. I understand there have been unit AI crashes in the past; is there a chance someone has a suggestion on what might be causing this issue? Thank you!

This is on 1.17.4 from Github. The last lines of the log always look something like this:

Player 0 Turn ON
Player 0 Unit 49156 (TXT_KEY_LEADER_RAMESSES's Settler) moving from 60:21 to 59:21
Player 0 Unit 24577 (TXT_KEY_LEADER_RAMESSES's Militia) moving from 60:21 to 59:21

There are no error messages on the crash, and I haven't been able to get anything out of the dump files.

I've confirmed my Settlermaps are the correct dimension too.
 
Last edited:
I want to add a UHV to my civ that's similar to the Moors, except instead of adding food from orchards it'd give production from water tiles.

Do you know where in the DLL I could edit that?
 
CvPlot::calculateNatureYield
 
I've successfully implemented the UHV, but right now I'm having a weird problem, possibly as a consequence, where the Moai Statues no longer need the 20 water tiles and now Carthage keeps building them...

I'm not if it was the DLL edit, or adding a wonder that caused the problem...
 
Yeah I think I figured it out, I accidentally forgot to add the wonder to the DLL which subtly messed things up.
 
Do you know where I could find specialist yields in the DLL? (eg. change the yield of a specialist under specific conditions)
 
There is no dynamic function that determines specialist yields you could edit. Specialist yields are applied in the CvCity::processSpecialist() function, but it uses XML values directly. Still, if you want to make a change, that is probably the best place to start.
 
There is no dynamic function that determines specialist yields you could edit. Specialist yields are applied in the CvCity::processSpecialist() function, but it uses XML values directly. Still, if you want to make a change, that is probably the best place to start.
Yeah, I was trying to do this to add a UP to one of my civs, but ultimately I came up with another UP which is more fitting anyways, so it's fine.
 
Back
Top Bottom