Post news RSS The pitfalls of a map twice as big - Big performance news

How having the biggest map ever in any March of the Eagles mod has impacted performance and how we've possibly resolved it.

Posted by on

Conflict of the Eagles has the BIGGEST map implementation in any instance of March of the Eagles. Some mods change the map and only have a handful of provinces. Most mods stick with the vanilla game's ~2,700 provinces. Conflict of the Eagles has around 5,000 provinces on the map.

Of course, this map was hand-crafted over the course of a year as the vanilla map was never going to be enough for any implementation. Not only did we ABSOLUTELY need a sliver of north america in the map as to put the USA in there, we also really wanted more to the south of the map. The Western Sahara conflict is now able to be fully represented, the entireties of Algeria, Libya, and Egypt are now in the mod. Saudi Arabia and (crucially) Iran are expanded without letting in Yemen, which would have been quite difficult to represent. Kazakhstan now also has an actual reason to be in the game, which is great.

Somehow, it worked, and 5,000 provinces seemed to be enough for the game to handle. However, there was something else, something more insidious lurking in the game's code that wouldn't rear its ugly head until later.

In Vanilla MOTE, some provinces are "cities" while other provinces are "attached" to these cities. It's almost exactly like in Victoria 2, where you cannot claim individual provinces in a peace deal, only regions. In MOTE, regions are defined by the region's city while other provinces have absolutely no value other than stepping stones for your armies.

In MOTE Enhanced, the practice was established to make every single province a city. This was done not only to make peace deals more entertaining, but also as a crucial necessity because of the implementation of civil wars. If somehow the regions started becoming broken up (as can happen during a civil war, as provinces are changing hands independently of peace deals), it can lead to individual provinces becoming out of sync with the regions and there will be some very glitchy bordergorey artifacts. Due to this, the "special" bonuses that cities enjoyed were stripped, and every province became a city.

This practice was carried over into Conflict of the Eagles for the same reason. It's been tested in other intermediate mods like the Libyan Civil War mod, and it works fine. In MOTE Enhanced, though, after the map modding work was complete, it became apparent that for some reason there was serious performance issues somehow attached with the map. Not only was the province density upped, meaning there was a lot more clutter, but zooming in and out also led to freezes. Couple this with the performance issues in my previous post and you can see how CotE alpha v0.1 was pretty terrible in terms of performance. AND it would crash a lot.

Performance and stability are linked. But even after removing event cache refreshing entirely and taking care of CPU-based slowdowns, we are still faced with some kind of GPU-based slowdown as an unoptimized game engine tries to draw *something* on all 5,000 provinces. And the game was STILL crashing. I was rapidly losing hope, having no motivation to keep working on the mod if it was somehow going to keep randomly crashing. It seemed to be linked to zooming up and down, as letting the run by itself would not crash, but zooming around while unpaused would eventually cause a crash. What in the world??? At this point, I was sure that it was just a limitation of the game engine and that putting 5,000 provinces was simply too much for the game to handle.

The revelation finally came as I really tried hard to minimize performance loss in an attempt to make the mod more stable. The first thing I targeted was the map icons for the units, because anytime I'd load the game I'd be faced with this:

Old Unit Map Icons

As you can see, the mapicons for the unit stay visible until a very high scroll level and clutter the screen to a very high degree. There's no way to change how high up they stay visible and they don't merge like in HOI4.

I tried simply removing their code in the files but as their code is referenced in-game, it resulted in a crash. Therefore, I rearranged the icons into a much smaller, much more compact position. To my surprise, it looks much better and reduced some of the lag, but not all of it:

Better Unit Icons

Although still considered "cluttered", this is LEAGUES better than what was there before. However, I still needed to figure out the freezing and stuttering, so I started re-constructing the mod file by file until the freeze re-appeared.

And it reappeared as soon as I made every single province a city. This made me understand that something about 5,000 cities was causing the freeze. Then I made the connection that the freeze was occuring when the city icons were being unloaded, at around half zoom level (They are unloaded earlier than the unit map icons).

To make a long story short, I was ultimately unable to remove the city icons from being loaded in the code. It seems like the executable directly calls on these exact buttons and windows, and if ANYTHING at all is altered (such as trying to stop it from loading in any graphic at all) the game will crash. This left me with only one viable option.

I had to remove all the cities.

The realization was a hard one, because having NONE of the provinces be cities would mean that countries would not be able to seize land in peace deals. This was actually OK, though, as expansion should be taken care of through in-game events. However, another quirk of the AI was that they would instantly be able to annex any country they were at war with if that country owned no cities. This was obviously completely unacceptable.

The only other possible alternative was to do what I had done in the Libyan Civil War mod. The map has no cities, but there are a bunch of off-screen provinces, each one of them forcibly isolated, and a city. There was one province per possible country tag, and each tag had their capital set to that isolated off-screen province. They could still fight and interact on the main map, but would not be able to annex each other as technically, they owned this province.

This also meant that all countries would exist constantly throughout the whole game. In some ways, this could boost stability, as it would stop countries from randomly being annexed, or winding up as an OPM outside of their cultural bounds, or appearing and disappearing, causing crashes. On the other hand, it created hurdles that were also unacceptable: No more use of "exists = yes" as a coding crutch, which was WIDELY used. Also no more change_tag = x, meaning you would never be able to peacefully change ideologies and therefore country names and flags.

Ultimately, though, I managed to do something even more crazy. I zapped all the cities away, and then I went into the code and found the chunk of .gui code that draws the button that can be clicked on to annex the country. By removing this small chunk of code, I actually did manage to simply delete the annex button from existence. What this meant was that neither the player nor the AI could annex countries anymore at all, which was perfect from the confines of the mod.

I also learned a lot about other performance tricks during these past few days and the current working build (alpha v0.5) actually runs INFINITELY better than before. First of all, no more annoying freezing when loading the bookmarks, because it turns out any bookmark causes a freeze. The temporary solution was to remove all bookmarks, meaning that you won't be able to have a cool description of the year 2005. This isn't a huge problem anyways as there's only one start date. Zooming in and out no longer lags (unless you have half the map as allies and all their armies are present, then zooming around might lag a small amount). The game plays much faster and I am hoping that this will lead to a huge reduction in crashing and a boost in performance.

Work to be continued and I'll keep you all updated.


This comment is currently awaiting admin approval, join now to view.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.