Airlifting
Posted: Sat Jul 26, 2025 4:01 am
So I've been working on a fairly extensively modified custom ruleset. One of the things I wanted to fix was airlifting, because by default it's nonsensical, micromanage-y, and logistically annoying. The first part of my solution was to add cargo aircraft with the ability to carry other units, so units could be moved between cities by simply loading them onto a cargo plane and actually flying it to another city before unloading them, in the same way you sail Transports between cities.
This also let me get rid of the problematic Paratrooper teleportation ability. I simply gave Paratroopers (and Spies, presumably using a parachute with your nation's flag emblazoned on it) the ability to disembark from Air units in flight. If you want to deploy Paratroopers, you load them onto an actual plane, fly it to where you want them, and have them actually jump out. This means that you can't just teleport them past impenetrable enemy lines, but I see that as a feature, not a bug. If you can't get there with a plane, you shouldn't be able to drop Paratroopers there.
And this all worked fine, but I wanted to still be able to just voop a unit halfway around the world to that hut city my explorers discovered far from anywhere else I could land, or to a city completely surrounded by territory of Peaceful nations, Berlin Airlift-style.
So I figured I would remove the airlifting limit on Airports and make it so only Air units could be airlifted. That'd mean that instead of being limited by allowing only one flight per year through any given Airport, it would be limited by how many airplanes you actually had, and what you could airlift would be limited by how much of what those planes could actually carry.
At this point, I started running into problems. First off, the weird way airilftingstyle is configured means that there's no way to set it so that the destination Airport's capacity is unlimited without also allowing airlifting to cities that don't have Airports. So, okay, I just set it to SRC_UNLIMITED and raised the destination limit to 99, which should be enough for any reasonable purposes. Then I discovered that it wouldn't actually let me airlift anything that was transporting something, even if the unit (carrier, cargo, or both) would airlift fine on its own. So, okay, I poked through the action enablers, found the line that was disabling airlifting for Transporting units, and turned it off.
And then my ruleset wouldn't load, because there's a hard-coded check in the ruleset-loading code to make sure you haven't removed the first check from the ruleset. Well, I don't like it when computers tell me I can't do things, and I wanted to see what would happen, so I dug through the code and found that check, commented it out, recompiled, and tried again. Ruleset loaded this time, but my planes still wouldn't airlift while carrying things. So I went and dug through the code again and discovered that there's another hard-coded check in the actual airlifting code that directly prevents airlifting while transporting, regardless of what the ruleset says. So I commented that out too, recompiled again, and...
It works perfectly. Zero issues. Everything functions exactly as intended.
Now, I can see the potential for problems in some weird corner cases, like if an allied unit wanders onto one of your transport planes and you then airlift it to a city belonging to another ally, with which the first ally is not also allied... but that hardly seems like an issue that requires a hard-coded triple-redundant safety interlock to prevent anyone from ever airlifting a transporter under any circumstances. I just removed FROM_ALLIES and TO_ALLIES from my default configuration, which hardly matters, because the AI is too stupid to do it in the first place, and I never ally with the AIs, because AI allies are worse than useless.
If anyone wants it, here's a patch against 3.2.0 that disables the checks in the code. The one in the ruleset is left as an exercise for the modder, because there's a bunch of other stuff that needs to be changed in the ruleset to make it work anyway, like adding units that can actually do it in the first place.
This also let me get rid of the problematic Paratrooper teleportation ability. I simply gave Paratroopers (and Spies, presumably using a parachute with your nation's flag emblazoned on it) the ability to disembark from Air units in flight. If you want to deploy Paratroopers, you load them onto an actual plane, fly it to where you want them, and have them actually jump out. This means that you can't just teleport them past impenetrable enemy lines, but I see that as a feature, not a bug. If you can't get there with a plane, you shouldn't be able to drop Paratroopers there.
And this all worked fine, but I wanted to still be able to just voop a unit halfway around the world to that hut city my explorers discovered far from anywhere else I could land, or to a city completely surrounded by territory of Peaceful nations, Berlin Airlift-style.
So I figured I would remove the airlifting limit on Airports and make it so only Air units could be airlifted. That'd mean that instead of being limited by allowing only one flight per year through any given Airport, it would be limited by how many airplanes you actually had, and what you could airlift would be limited by how much of what those planes could actually carry.
At this point, I started running into problems. First off, the weird way airilftingstyle is configured means that there's no way to set it so that the destination Airport's capacity is unlimited without also allowing airlifting to cities that don't have Airports. So, okay, I just set it to SRC_UNLIMITED and raised the destination limit to 99, which should be enough for any reasonable purposes. Then I discovered that it wouldn't actually let me airlift anything that was transporting something, even if the unit (carrier, cargo, or both) would airlift fine on its own. So, okay, I poked through the action enablers, found the line that was disabling airlifting for Transporting units, and turned it off.
And then my ruleset wouldn't load, because there's a hard-coded check in the ruleset-loading code to make sure you haven't removed the first check from the ruleset. Well, I don't like it when computers tell me I can't do things, and I wanted to see what would happen, so I dug through the code and found that check, commented it out, recompiled, and tried again. Ruleset loaded this time, but my planes still wouldn't airlift while carrying things. So I went and dug through the code again and discovered that there's another hard-coded check in the actual airlifting code that directly prevents airlifting while transporting, regardless of what the ruleset says. So I commented that out too, recompiled again, and...
It works perfectly. Zero issues. Everything functions exactly as intended.
Now, I can see the potential for problems in some weird corner cases, like if an allied unit wanders onto one of your transport planes and you then airlift it to a city belonging to another ally, with which the first ally is not also allied... but that hardly seems like an issue that requires a hard-coded triple-redundant safety interlock to prevent anyone from ever airlifting a transporter under any circumstances. I just removed FROM_ALLIES and TO_ALLIES from my default configuration, which hardly matters, because the AI is too stupid to do it in the first place, and I never ally with the AIs, because AI allies are worse than useless.
If anyone wants it, here's a patch against 3.2.0 that disables the checks in the code. The one in the ruleset is left as an exercise for the modder, because there's a bunch of other stuff that needs to be changed in the ruleset to make it work anyway, like adding units that can actually do it in the first place.
Code: Select all
diff -u ../../freeciv-3.2.0/common/actions.c ./actions.c
--- ../../freeciv-3.2.0/common/actions.c 2025-07-17 05:14:19.000000000 -0400
+++ ./actions.c 2025-07-24 13:57:20.839903056 -0400
@@ -759,7 +759,7 @@
" another unit."),
ACTRES_PARADROP,
ACTRES_PARADROP_CONQUER,
- ACTRES_AIRLIFT,
+ //ACTRES_AIRLIFT,
ACTRES_NONE);
/* Why this is a hard requirement: sanity. */
diff -u ../../freeciv-3.2.0/common/unit.c ./unit.c
--- ../../freeciv-3.2.0/common/unit.c 2025-07-17 05:14:19.000000000 -0400
+++ ./unit.c 2025-07-24 13:55:44.932429405 -0400
@@ -98,10 +98,10 @@
return AR_WRONG_UNITTYPE;
}
- if (0 < get_transporter_occupancy(punit)) {
- /* Units with occupants can't be airlifted currently. */
- return AR_OCCUPIED;
- }
+// if (0 < get_transporter_occupancy(punit)) {
+// /* Units with occupants can't be airlifted currently. */
+// return AR_OCCUPIED;
+// }
if (NULL == psrc_city) {
/* No city there. */