Resource icon

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

To me this is a bug, but it might be unique to me. Sometimes, and I am not sure why it happens (it doesn't happen that often), the game will no longer accept mouse input. I have to save from the keyboard and then load the game again.
 
I had it happen as well. It only happened twice, so I have no real idea as to how to replicate it. I suspect long sessions have something to do with it, but it is not the only factor. I know that the first time it happened after I left Civ on the background for a few hours as i had to go somewhere else, but the second happened while I was playing.

Not related, but I would love to have the option to have improvements be able to remove pop/building pollution fully. While a minor distraction in normal play, on scenarios that limit your ability to create workers it does get annoying (and far more problematic for the AI than myself). I saw the function labeled in Ghydra, but failed to find it on the steam version (I don't quite get how to use the search function)
 
Interesting you guys mention this now, I myself just recently stumbled over the hijacking of the L key while playing a game. I fixed it by making the unit load command take precedence over activating the city location highlighter. That fix will appear in R10 which is coming soon. Remapping the highlighter to O would work too but I like having it bound to L since it's supposed to be short for "location", as in AI city location. Similarly the P key binding is supposed to be short for "production". At first I wanted those key bindings to include shift, control, or alt, but that turned out to be surprisingly difficult since the game processes those key presses in some functions other than the ones I'm familiar with.

I'm happy for your fix to be the permanent solution to the problem Flintlock if it makes implementing it much easier for you. It was a suggestion I thought of as a work-around for the issue after I discovered it, but it sounds like your fix of the issue will be a better overall solution given it makes more sense for L to have multiple functions depending on context similar to how Ctrl+C does depending on whether your selected worker unit is standing on forest/jungle/marsh needing clearing, or pollution needing cleaning up. I agree that L for "location" is a more concise and accurate description for what the function is supposed to do, as opposed to using the O key for "overview", as overview could mean many different things, like looking in the city screen for an overview of its improvements, population work assignments, population mood etc.
 
To me this is a bug, but it might be unique to me. Sometimes, and I am not sure why it happens (it doesn't happen that often), the game will no longer accept mouse input. I have to save from the keyboard and then load the game again.
I've never had this happen to me. Sorry but I can't do anything about bugs that I can't reproduce.
Not related, but I would love to have the option to have improvements be able to remove pop/building pollution fully. While a minor distraction in normal play, on scenarios that limit your ability to create workers it does get annoying (and far more problematic for the AI than myself). I saw the function labeled in Ghydra, but failed to find it on the steam version (I don't quite get how to use the search function)
Added to the list. That function is probably not labelled in the Steam version. There are far more labeled functions, like 10 times as many at least, in the GOG version since that's where I do all my reverse engineering work. In the Steam version I only find & label what I need to port the mod over.
I'm happy for your fix to be the permanent solution to the problem Flintlock if it makes implementing it much easier for you. It was a suggestion I thought of as a work-around for the issue after I discovered it, but it sounds like your fix of the issue will be a better overall solution given it makes more sense for L to have multiple functions depending on context
Actually the easiest thing would have been to move the city location highlighter to a different key but I didn't even think of that at the time. I just like the idea of L for "location", though it doesn't really matter. Also when I was programming that in the first place I had forgotten about L to load units otherwise I probably would have picked a different key. I don't like how the game reuses hotkeys depending on context, there's one annoying overlap, Shift+D for both diplomacy and some worker function (auto clear pollution?), that always trips me up.
 
Not related, but I would love to have the option to have improvements be able to remove pop/building pollution fully.
Don't quote me, but I think this might already be possible using @Quintillus' Editor (it might even be possible using the original Firaxis Editor?)

If you can give an improvement(s) a sufficiently large negative pollution-value, you should be able to cancel out those last 2 pollution-icons which are left over after building a "Reduces population pollution"-improvement (= epic-game Mass-Transit, caps pop-pollution at 1 icon) and a "Reduces building pollution"-improvement (=epic-game Recycling Center, caps building-pollution at 1 icon).
I don't like how the game reuses hotkeys depending on context, there's one annoying overlap, Shift+D for both diplomacy and some worker function (auto clear pollution?), that always trips me up.
"B" being used for both "{B}uild(/join) city" and "{B}ombard" works fine in the epic-game -- but not in mods which include bombard-capable units which also have a population-cost.

Due to this hotkey-conflict, I "lost" several of my (autoproduced, unbuildable) Prospectors during my last playthough of EFZI Elite.

Not sure if it's possible to fix this, though...?
 
Last edited:
lurker's comment: I agree that Shift+D for Diplomacy and Clear Damage is annoying. The hotkey for clear damage is different in PTW; the conflict is only present in Conquests. I think it was changed to reflect that "damage" can include craters in Conquests, whereas it's only pollution in PTW. But due to the diplo overlap, I'm always sending workers off to clear damage when I want to initiate diplomacy.

tjs282's theory about negative pollution offsets allowing the canceling out of pollution sounds plausible, though I've never tried it myself. So long as Civ3 honors the -1 offset, it ought to work.

Edit: Checked and in PTW, Shift+P is (Automate) Clear Pollution.
 
Don't quote me, but I think this might already be possible using @Quintillus' Editor (it might even be possible using the original Firaxis Editor?)

If you can give an improvement(s) a sufficiently large negative pollution-value, you should be able to cancel out those last 2 pollution-icons which are left over after building a "Reduces population pollution"-improvement (= epic-game Mass-Transit, caps pop-pollution at 1 icon) and a "Reduces building pollution"-improvement (=epic-game Recycling Center, caps building-pollution at 1 icon).
This doesn't quite work. A building with the flag "Reduces population pollution" SETS population pollution at 1 (as long as city is a metropolis, 0 otherwise).
Reading the code, it seems that negative pollution is meaningless. From what I understood from the function, pollution generated by a building [ iVar1 ] is only counted if positive [ if (0 < iVar1) ]. Negative pollution goes to "return ret & (ret < 0) - 1;", returning 0. [ "value & value<0" returns 1 (true), 1-1 gives 0 ]. I'm unsure how 0 pollution is handled, but I assume the function is never called for that value.
I tried in game giving -100 pollution to a building with the flag "Reduces population pollution" to no effect. There are other permutations that I didn't try, but the evidence so far suggest that it doesn't work.

Code in question:
Spoiler :
Code:
   iVar1 = (this->Body).Improvements_Pollution;
   ret = iVar1;
   if (0 < iVar1) {
       i_improvement = 0;
       num_cleaning_improvs = 0;
       if (0 < bic_data.ImprovementsCount) {
           iVar3 = 0;
           do {
               bVar2 = has_improvement(this,i_improvement,true);
               if (bVar2 != false) {
                   id = *(int *)((int)(&(bic_data.Improvements)->CivilopediaEntry + 3) + iVar3 + 0x1c);
                   if (-1 < id) {
                       bVar2 = Leader::has_tech(leaders + (byte)(this->Body).CivID,id);
                       if (bVar2 != false) goto LAB_004b1bd3;
                   }
                   if ((*(byte *)((int)&(bic_data.Improvements)->ImprovementFlags + iVar3) & 0x40) != 0) {
                       num_cleaning_improvs = num_cleaning_improvs + 1;
                   }
               }
LAB_004b1bd3:
               i_improvement = i_improvement + 1;
               iVar3 = iVar3 + 0x110;
           } while (i_improvement < bic_data.ImprovementsCount);
           ret = 1;
           if (num_cleaning_improvs == 0) {
               ret = iVar1;
           }
       }
   }
   return ret & (ret < 0) - 1;
}
 
This doesn't quite work. A building with the flag "Reduces population pollution" SETS population pollution at 1 (as long as city is a metropolis, 0 otherwise).

:yup: Yes, that is why in the mod CCM there is no city size 3 (metropolis) - and this is working very well in the game.
 
If you can give an improvement(s) a sufficiently large negative pollution-value, you should be able to cancel out those last 2 pollution-icons which are left over after building a "Reduces population pollution"-improvement (= epic-game Mass-Transit, caps pop-pollution at 1 icon) and a "Reduces building pollution"-improvement (=epic-game Recycling Center, caps building-pollution at 1 icon).

The Antal exe reduced pollution to 0. This is a size 26 city with & without Mass Transit. Maybe Flintlock should look into what Antal changed on the pollution with the p4 exe.
no pollution.jpg
 
This doesn't quite work. A building with the flag "Reduces population pollution" SETS population pollution at 1 (as long as city is a metropolis, 0 otherwise).
Reading the code, it seems that negative pollution is meaningless. From what I understood from the function, pollution generated by a building [ iVar1 ] is only counted if positive [ if (0 < iVar1) ]. Negative pollution goes to "return ret & (ret < 0) - 1;", returning 0. [ "value & value<0" returns 1 (true), 1-1 gives 0 ]. I'm unsure how 0 pollution is handled, but I assume the function is never called for that value.
I tried in game giving -100 pollution to a building with the flag "Reduces population pollution" to no effect. There are other permutations that I didn't try, but the evidence so far suggest that it doesn't work.
Then maybe this would be the best and easiest way to fix it. Have the game treat negative pollution properly and allow buildings reduce city pollution (down to a minimum of 0, of course) with negative pollution output. Then buildings with the other flags could be given negative pollution in mods and that way negate it entirely.
 
The Antal exe reduced pollution to 0. This is a size 26 city with & without Mass Transit. Maybe Flintlock should look into what Antal changed on the pollution with the p4 exe.

Takeo, have you watched what happened with the population pollution in the next turns in that city with the Mass Transit in it ?
 
Takeo, have you watched what happened with the population pollution in the next turns in that city with the Mass Transit in it ?

Yes, nothing happens. Once the Mass Transit is built there is never any population pollution in that city again, no matter how big the city is.
 
Not sure if it's possible to fix this, though...?
I can't say for sure that it would be easy without having looked into it, but I can't imagine it would be difficult. The easiest thing would probably be to make the B key activate bombard instead of join city when both options are available. It should also be possible to move join city to another key like J, but to do a proper job of that you'd have to update the button tooltip and maybe other things as well.
What Antal did is change 4 "1" to 0. In specific, both the "Reduces population pollution" and the "Reduces building pollution" set their respective pollution to 0 rather than 1. However, it required to change it in 4 locations because civ3 has some duplicated code for whatever reason.
https://forums.civfanatics.com/thre...t-all-in-civ3-conquests.526144/#post-13221884
Thanks for the link, I didn't know Antal had already done this. I hadn't found that function he called class_City::Calculate_Pollution, which is at 0x4B1C10 in the GOG EXE and looks like it's used to compute the pollution amount to display in the city screen. It does contain a duplicate of the logic used when spawning pollution. Reducing the minimum pollution to zero would be simple using a few machine code edits like Antal describes. Actually what I would do is edit the two pollution computing functions used when spawning pollution then replace Calculate_Pollution with a small function that calls those two and sums the results.

I like the idea of enabling negative pollution since that feature could be enabled by default without changing the game rules. The problem is it would be necessary to change how pollution is calculated so that it could apply across categories. As it is, negative pollution should work, assuming the editor lets you set that, but only to cancel out pollution generated by buildings not population.
 
It should also be possible to move join city to another key like J
Not "J" please: this one's my preferred hotkey to activate stack-movement!

(Ctrl-J = move all units of the same type)

(IIRC, this does represent yet another duplicated hotkey-function, though: I think "[Ctrl-]X" activates stack-movement as well, even if I never use that one...)
Meanwhile, I implemented scenario configs like I described. Here's what it looks like:
View attachment 618914
This enables no-raze and limits railroad movement for the WW2 Pacific scenario. This file is loaded automatically along with the WW2 scenario and its settings are layered on top of the default config, which itself is layered on top of a hardcoded "base" config. I also added a mod info button which shows which config files are loaded. This is useful to verify that everything is working as expected. Here's what it looks like (note the button itself in the upper right):
View attachment 618915
OK, I must be doing something wrong.

Two weekends ago, I ditched C3X_R8 and installed C3X_R9, by deleting the old .exe, renaming the backup GOG-version, and then running the C3X_R9 Install.bat, and got a message saying it had successfully installed. As noted above, my "L" hotkey was also 'successfully' reassigned to show AI-city-location preference! ;)

A couple of days ago, I prepared a scenario config.ini file that looked just like your screenshot (I had Firefox open on the primary monitor and Notepad on the secondary, so I could copy/compare the text directly), and dropped it into my ../Conquests/Conquests/Napoleonic Europe scenario-folder (and also the WWII folder).

Then I fired up the game, only to discover 59 turns into my current run that monster AI-Austria has nonetheless gone ahead and razed 3 or 4 cities in western Russia (I also do not remember seeing the "C3X Info" button in my "Preferences" screen). So the scenario-specific config.ini is apparently not being consulted.

Any idea what I (still) need to do to get this working? Is there a switch I overlooked somewhere in the main config.ini, to tell the patch to look for scenario-specific .ini files?
 
Last edited:
Not "J" please: this one's my preferred hotkey to activate stack-movement!
I didn't know J was bound to stack move, I've always used X for that. The hotkeys in this game are quite a mess. Maybe I'll get around to sorting that out at some point, the ideal solution would be to make them all rebindable. But don't hold your breath for that, implementing that doesn't sound like much fun. In the mean time I'll try to look into swapping the priorities, like I did with the L key, so B prefers bombard over join city when both actions are available.
Then I fired up the game, only to discover 59 turns into my current run that monster AI-Austria has nonetheless gone ahead and razed 3 or 4 cities in western Russia (I also do not remember seeing the "C3X Info" button in my "Preferences" screen). So the scenario-specific config.ini is apparently not being consulted.
I guess that second image I posted is misleading. Even though it says "Version: 9", the per-scenario configs, info button, etc. are not present in the R9 version that's currently posted on CFC. I implemented that stuff then took the screenshot without bumping the mod version since the last release. Apologies for the confusion. The per-scenario configs will be in R10 or, if you really want it now, you could download the very latest version from my GitHub (https://github.com/maxpetul/C3X). It should work alright at the moment, but in general the latest GitHub version is incomplete and untested.
 
Flintlock updated C3X with a new update entry:

Release 10

New in this version:
- Scenario-specific mod configurations
- Mod info button
- Better logic for grouping units on right click menu
- Option to let units move after airdropping
- Fix phantom resource bug
- Fix air units losing a turn after being set to intercept
- L key loads unit over activating AI city loc highlighter

Read the rest of this update entry...



[Edit] Elaborating on some of the changes:
  • Scenario-specific mod configurations and mod info button: Scenarios may now include their own config files (named scenario.c3x_config.ini) in their folders which will be automatically applied by the modded EXE when the scenario is loaded. The scenario config settings will be layered on top of the default settings. There is also now a button on the top right of the prefs screen that tells the mod version and, more importantly, lists the loaded config files so you can check that the scenario config is loaded as you expect. See here for a demo: https://forums.civfanatics.com/thre...s-in-exe-modding.666881/page-28#post-16212316
  • Better logic for grouping units on right click menu: The full rules for unit grouping are here: https://forums.civfanatics.com/thre...s-in-exe-modding.666881/page-25#post-16187674. The important changes are that native & captured units will now be separated, units with different exp levels will be grouped together if they have no hit points, and units carrying a princess will be separated out.
  • Option to let units move after airdropping: When enabled, airdropping no longer ends a unit's turn, and in fact costs no movement.
  • Fix air units losing a turn after being set to intercept: In the base game, setting an air unit to intercept removes all of its remaining movement points. The lack of MP prevents it from intercepting during the next interturn. This fix simply preserves its MP.
There aren't many gameplay changes in this version because I wanted to get the per-scenario configs working first. I'm planning to do more gameplay stuff for the next version, I have in mind several suggestions that would be easy to make happen but would have been awkward to use without the per-scenario configs. Another thing I'd like to do is try again to improve the AI worker logic. I explored that back in November but it's not included in this version since I never got it working to my satisfaction.
 
Last edited:
:bounce: Flintlock one more time thank you very much for all your brilliant work! :thanx:
 
Top Bottom