Resource icon

C3X: EXE Mod including Bug Fixes, Stack Bombard, and Much More Release 23

About the so-called "houseboat bug":

This bug was frequently reported (and I ran into it myself several times) in the CCM succession games and in the CCM and RARR threads:
https://forums.civfanatics.com/search/162472298/?q=Houseboat+Bug&o=date&c[node]=67

This bug occurs, when the last city of a civ is conquered, but that civ still has one (or more settlers on board of a ship - this is why the succession game players have named that bug the houseboat bug). In that case the game is freezing. It can be triggered even by AI civs and even if these AI civs are not yet discovered by the human player in the game: https://forums.civfanatics.com/threads/rise-and-rule-revisited-epic-mod.549166/page-26#post-14686769

It seems, that this is no special bug of CCM or RARR, but a bug in the programming of Civ 3, that was fixed by Firaxis in Civ 3 Vanilla, but unfortunately later was reopened by them again in later versions of Civ 3. In the readme-file of the Civ 3 vanilla you can find the following entry: Fixed v1.21f: Fixed crash related to last settler dying on a transport.

Fixes v1.21f.jpg



It can be, that this is the same story, as it was with the submarine bug, that was fixed by Firaxis in Civ 3 Vanilla, too - but later reappeared in Civ 3 again.

After some reflections about that bug, I tried the following settings for the next versions of CCM 2.50 and RARR:

In the present CCM and RARR mods nearly all settlers need support. A civ without any cities is not able to generate gold (with the exception of goody huts or donations) and all remaining gold of the civ is plundered. If there is not enough gold for a civ, the unit with the greatest distance to the (no longer existing) capital will be eliminated in the interturn. In the next versions of the CCM and the RARR mods, I will set all settlers and transport ships to not needing any support. In my current testgames with these settings this very nasty bug did not appear - but this says nothing, as fortunately that bug does not appear in most games.

That bug doesn´t appear with a last (or the first) settler on land. It only appears when the last settler is on board of a ship.
 
Thanks for the info. This:
is exactly what I needed, a save I can load to get the crash. Because then I can run the game in a debugger, let it crash, and the debugger will point right to the problem area.

So here it is: an access violation by the instruction at 0x45A35F (in the GOG EXE). I don't have this function fully labeled, but here's the decompiled code leading up to that instruction:
Code:
iVar20 = leaders[(this->Body).CivID].CapitalID;
if ((((cities.Cities == NULL) || (iVar20 < 0)) || (cities.LastIndex < iVar20)) ||
   (cities.Cities[iVar20].City == NULL)) {
  capital = NULL;
}
else {
  capital = (City *)(cities.Cities[iVar20].City[-1].field_3A4 + 0x5a);
}
pTVar10 = Map::get_tile(&bic_data.Map,
                        (bic_data.Map.Width >> 1) * (uint)(ushort)(capital->Body).Y +
                        (uint)((ushort)(capital->Body).X >> 1) & 0xffff);
The instruction at 0x45A35F corresponds to the expression "(capital->Body).Y", which crashes because "capital" is null, which it will be whenever the civ's stored capital ID doesn't correspond to an actual city. I'll have to investigate this some more to figure out a good fix. I don't know yet what this function does but it's part of the unit AI, so I don't think the crash is related to settler maintenance, pop cost, etc. It's still a mystery why this crash was so hard to trigger, I set up a scenario where I could capture all of an AI's cities leaving it with only a settler on a galley and never got a crash so there's definitely some kind of subtlety to it.
 
Flintlock, it is great, that you are on the trail of the houseboat bug. :)

Here is another save file about the houseboat bug in the RARR thread:

https://forums.civfanatics.com/threads/rise-and-rule-revisited-epic-mod.549166/page-25#post-14686269

This time the bug was not triggered by the human player (in that case Germany) but by an AI civ. The American civ was not discovered by the human player and therefore there was no diplomatic control over the state of that civ. America was overrun by the Mongols and in that turn they captured the American capital Washington. The American "houseboat" is near the city of Riga ( https://forums.civfanatics.com/threads/rise-and-rule-revisited-epic-mod.549166/page-26#post-14686769 ).
 
I think the issue is with city capture. Each time you capture a city, it does a civ eliminated check. For some reason it doesn't see that when a settler is still alive. I only see it with CCM, so I think it is tied to using custom settlers. Civnator could explain the custom settlers better.
 
Does the AI not realize what units it has when they're loaded into ships? Or is it based off the AI using the units icon number to determine what is a settler and what isn't?
 
The houseboat bug is history. At first I thought this would take longer than one day but when I looked into that piece of code I posted above I realized I could fix the crash with a narrow surgical change. I went ahead and implemented that and it worked on the first try, which these kind of machine code patches usually don't so I am getting better at this. Unfortunately that means I haven't analyzed that function so I still can't say anything about what it does or why the houseboat bug appears when it does. Hopefully this fixes the bug completely but I've read conflicting reports about the nature of the bug so I'm not 100% sure.

Some more details about the fix: I overwrote the Map::get_tile function call with a call to a custom function that takes a pointer to a city object and, if it's not null, returns the tile the city is on like the original code, otherwise it returns a pointer to a special "null tile" object that already exists in the base game. This works because the capital city object is only used to get its tile and the tile object is only used (after the code I quoted) to get its continent ID, so this code replacement is possible without side effects.
This save file didn't load for me. Is it supposed to be compatible with the current version of RARR?
I think the issue is with city capture. Each time you capture a city, it does a civ eliminated check. For some reason it doesn't see that when a settler is still alive. I only see it with CCM, so I think it is tied to using custom settlers. Civnator could explain the custom settlers better.
I've read that the bug crashes the game immediately once the AI's last city is captured but I never saw that either in my tests or in the save Civinator linked me to. I suspect that the houseboat bug actually refers to two different but similar bugs. Both affect AIs with only a settler remaining on a transport but one crashes the game when the AI's last city is captured, and was patched back in vanilla, and the other was introduced in Conquests, causes crashes on the AI's turn, and is only triggered under some strange circumstances that I haven't been able to nail down.
Does the AI not realize what units it has when they're loaded into ships? Or is it based off the AI using the units icon number to determine what is a settler and what isn't?
The AI shouldn't be looking at icon numbers to ID units, and I haven't noticed it doing that, not that I've done a thorough investigation.
 
The houseboat bug is history

That is awesome. I am wondering, since you made it so your fixes are loaded through its own exe, would it be possible to run your exe for a few turns every time the houseboat bug appears and then revert back to normally loading up the game? Or would this cause too many issues? I was playing around with this idea should your changes ever not be able to be toggled (not a fan of the unlimited cities and units fixes since others have reported the game has memory corruption errors with too many cities and units).

Speak of unit AI, a request I'd like to add should you ever get around to it would be to the way the AI handles units with the hidden nationality ability. As it currently stands, the AI can see these units anywhere on the map even in the fog of war, and hunts them down relentlessly. They'll even declare war with friendly civs who won't let them pass through borders to hunt these HN units down. They also use HN units to attack friendly cities and manage to capture them - something the player cannot do without declaring war. They'll load up HN units into armies as well, and this creates other issues and crashes. In Vanilla, HN units weren't so highly prized by the AI. But in Conquests the AI loves to build them. So putting in HN units into your mod will just make them go crazy building them. Even in unmodded games, the AI will have a navy which is mostly privateers.

The AI shouldn't be looking at icon numbers to ID units, and I haven't noticed it doing that, not that I've done a thorough investigation.

Modding Q&A

Modding Q&A
 
I have never seen an army built and use by AI, do you know how to force it to do so?

One of those things where I've never understood but just have seen. I think it's more common in large games with more civs because of all the variables that come into play. However, it was my understanding that the AI will try to mimic player military so the more of something you build the more likely the AI is to build it. This particular case of the AI loading HN units into armies I've never seen, but have seen reports of in AthonyBoscia's 1989 thread.
 
I have never seen an army built and use by AI, do you know how to force it to do so?
As far as I can tell, the simplest way to get the AI to load Armies (and fight with them), is to mod the Army-unit: reduce the transport-capacity to only 1 unit, but give it a substantial HP-bonus (say, +8 HP) as partial compensation.

But getting the AI to build Armies...? To quote Han Solo: "Well, that's the real trick, isn't it?"

In the (rare!) event that the C3C-AI obtains a "Battle-Created Unit" (i.e. the MGL) in the epic game, and manages to retreat it safely to a nearby city, it then tends to 'prefer' to use that MGL to finish building improvements (including Great Wonders!). It rarely (if ever) converts MGLs to Armies — and when it does build an Army, it rarely (if ever) finishes filling it properly, so will not send it out to fight. Which means that it also rarely (and more likely never) has the option to build the Heroic Epic or Military Academy (both of which "Require a Victorious Army").

So the first thing I would do would be to give the MGL "All Terrain As Roads", so that it can be reasonably sure of reaching safety in the first place. I would also mod it so that it can only build Armies, thus preventing the AI (but also the human player) from doing anything else with it. AFAIK, the Firaxis Editor only allows the "Leader" AI-strategy to be checked if both the "Build Army" and "Finish improvement" special-action flags are checked, so this second change would have to be done with an alternative Editor (e.g. @Quintillus').

Another possibility would be to use autoproduction to 'give' MGLs (or Armies) to the AI (but also the human player) at regular intervals — but doing the latter will circumvent the "X cities per Army" limitation. So you'd probably better limit that facility, both in terms of a longish autoproduction-interval, and to a single building, ideally a Small Wonder (e.g. the Military Academy), which — if this is the only way that Armies will be built — should not require a victorious army as a prerequisite!
 
You can select another unit to be created by battle instead of a Leader. Though I have not fully tested how the AI handles this. The idea would be to give that custom unit only "build army" ability, but I'm still playing around with what AI to give them. It's one of those situations where the player can handle these just fine, the AI on the other hand...
 
In my mod, the AI builds tons of armies. Reasons are not entirely clear, maybe because I gave them a larger capacity or because I linked the possibility to build armies to several buildings, or because of both reasons, I do not know. I also have the AI build tons of transports and sending them all over the place, maybe because they're cheap and have a higher capacity as well.
 
I have found that the AI does use armies. They rarely have an optimal mix of units in the army and whenever the army gets to an enemy or neutral square in enemy territory, it wastes any improvements.

I find the AI's use of workers, roads and destroying them with army's to be in general problematic. The AI often has workers move through unimproved squares to improve a square somewhere else and then they have to go back through the unimproved square, this is an inefficient use of the worker.

When the AI is conquering territory, even through it is likely to soon be their territory, they destroy the improvement and will then have to rebuild, or more likely have a city with unimproved terrain.
 
When the AI is conquering territory, even through it is likely to soon be their territory, they destroy the improvement and will then have to rebuild, or more likely have a city with unimproved terrain.
Since the AI never alters existing improvements to anything more optimal, wanton AI-pillaging may not be such a bad thing in the long run.

I mean, how often have you seen AI-founded Plains-towns surrounded by mines and stunted for growth well into the game, because the founding tribe 'improved' that terrain early on, before it got access to freshwater?

Having a newly pillaged Plains-tile to work with might therefore give the conquering AI an opportunity to do what the first AI should have done, and irrigate that tile instead — and once the AI knows Electricity, it's nearly guaranteed to make the 'right' choice.
 
The houseboat bug is history.

Congratulations, if this is really working! :goodjob: :band:

Some more details about the fix: I overwrote the Map::get_tile function call with a call to a custom function that takes a pointer to a city object and, if it's not null, returns the tile the city is on like the original code, otherwise it returns a pointer to a special "null tile" object that already exists in the base game. This works because the capital city object is only used to get its tile and the tile object is only used (after the code I quoted) to get its continent ID, so this code replacement is possible without side effects.

Does this mean, that the 'houseboat' with the settler on board is continuing its journey in the next turn ?

This save file didn't load for me. Is it supposed to be compatible with the current version of RARR?

I tried to start that save and it is not compatible with the current version of RARR (1.7). To have a look at Izengrimm´s save file, the last version of RARR (1.6) must be installed. A still existing complete download of RARR 1.6 can be found here: https://www.civforum.de/showthread.php?97453-Rise-And-Rule-Revisited-(epic-mod)

RARR 1.6 is a self-extracting file, that must be extracted to the C3C scenarios folder. Before doing this, the current RARR folder in the C3C scenarios folder must be renamed to RARR-CCM (or something like that), otherwise some of the newer files will be overwritten by the installing of older files.

In that save, the game simply freezes after some messages about civs starting new wonder projects. The interesting in that save is, that in this case the AI triggered the freeze.

I've read that the bug crashes the game immediately once the AI's last city is captured but I never saw that either in my tests or in the save Civinator linked me to. I suspect that the houseboat bug actually refers to two different but similar bugs. Both affect AIs with only a settler remaining on a transport but one crashes the game when the AI's last city is captured, and was patched back in vanilla, and the other was introduced in Conquests, causes crashes on the AI's turn, and is only triggered under some strange circumstances that I haven't been able to nail down.

In all the cases I have seen the houseboat bug in C3C, it was not an immediate crash to desktop, but a freeze after the human player has finished his/her turn.
 
In all the cases I have seen the houseboat bug in C3C, it was not an immediate crash to desktop, but a freeze after the human player has finished his/her turn.

That's funny, I just realised, I have never had this houseboat bug in my mod. My settings there are very much the same as in vanilla. I am playing it many years and this situation when a settler or settlers are on a ship where the last city of a civilization just been conquered was always quite common and never had a crash or freeze because of that.

It did happen around 2-3 weeks ago when I was testing a new version of a mod, and again, there was no problem with it at all.
 
Last edited:
That is awesome. I am wondering, since you made it so your fixes are loaded through its own exe, would it be possible to run your exe for a few turns every time the houseboat bug appears and then revert back to normally loading up the game? Or would this cause too many issues? I was playing around with this idea should your changes ever not be able to be toggled (not a fan of the unlimited cities and units fixes since others have reported the game has memory corruption errors with too many cities and units).
It would be possible, my mod doesn't affect save games at all so you can switch freely between the modded and unmodded executables. I've never heard of memory corruption from unlimited units, and I digging around in the EXE I haven't seen any reason that would happen. As for removing the city limit, I know where & why that corrupts memory so if I ever implement that (and I intend to look into it eventually) I'll make sure to do it properly.
Speak of unit AI, a request I'd like to add should you ever get around to it would be to the way the AI handles units with the hidden nationality ability.
Added to the list. Making the AI less eager to hunt down every HN unit on the map would probably be difficult. Improving the AI's usage of MGLs and armies is something I was thinking of looking into before putting out the next version.
Interesting, so the icons are used in the upgrade logic at least. I had quick look through the unit upgrade code and found a reference to a field Antal called "IconID_2", so that checks out.
Does this mean, that the 'houseboat' with the settler on board is continuing its journey in the next turn ?
I don't think so, looking through the code for that function it looks like the unit will just fortify in place if it's not on the same continent as the capital. That should be the case with my fix since the null tile shouldn't be on the same continent as any real tile. I would have to observe the AI's behavior to be sure, however, because there might be some code elsewhere that causes the unit to do something different (but I doubt it). It occurs to me that the critical variable to trigger the houseboat bug might be whether or not the settler on a boat has any available location to settle. In my tests it always did, but in the one save I loaded that bugged out there was nothing close by, and it makes sense that if the AI can't find a place to settle it sends its settler back to its capital. Then the bug would just be that the code to do that doesn't first check if the AI actually has a capital. That still doesn't explain why it only applies to settlers on a boat, though.
I tried to start that save and it is not compatible with the current version of RARR (1.7). To have a look at Izengrimm´s save file, the last version of RARR (1.6) must be installed.
Alright, I'll install the old version and test that save file too.
 
FWIW, the primary problem with armies is that they won't load in units with a movement speed less than the army's current movement value.

So, they'll load a Knight (2 movement points) which will give the army 3 movement points so they won't load another Knight; they will however load Cavalry (loading 1 Cavalry will keep the army at 3 movement points so they will load a second) the end result being that the army will be slower than it could be if they'd used 3 Cavalry; if Cavalry or another 3-movement point unit is unavailable then they wouldn't add any more units whatsoever. A quick and easy fix would be instead to make them base their choice on whatever was already in the army and try to add more of the same.

On a related note, I've also read that the Increases Army Values flag for wonders does not work as advertised (or at all).
 
Back
Top Bottom