load tend: Avoid "may be used uninitialized" warnings c_load() initializes @ich only when @type is EF_SECTOR. It also uses it only then. Clang is cool with this, but GCC gets confused and warns "‘ich’ may be used uninitialized". Ron Koenderink reports Visual Studio 2019 even flags it as an error. Same for c_lload() and c_tend(). Time to clean this up. Rearrange the code to avoid the warning and also improve readability a bit. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
commands: Rename the command functions Command functions are traditionally named like the command shortened to four characters. When this name collides with a keyword or library function, we abbreviate more: brea(), rea(). A few are unabbreviated, e.g. execute(). A few have different names, e.g. explain(), not list(). Commit 23726b379 (v4.3.0) suppressed a GCC warning about carg() colliding with its built-in function. Ron Koenderink reported Microsoft Visual Studio 2019 fails to link: "_carg already defined in ucrtd.lib(ucrtbased.dll)". Time to clean this up: rename the functions to c_FOO(), where FOO is the unabbreviated name of the command. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load lload: Refuse to load satellites in space Doesn't affect the stock game, because none of its satellites are light, let alone x-light. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load: Move check for hardened plane into plane_loadable() This de-duplicates the check, and skips it when unloading. It never made sense there, and can't happen anymore since the previous commit. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load: Factor out plane_loadable(), land_loadable() load_plane_ship() and load_plane_land() duplicate code to check whether a plane can be loaded, except for the phrasing of one message. Factor out into plane_loadable(). tran_plane() has equivalent code, but wants different messages, which makes de-duplication unattractive. load_land_ship() and load_land_land() duplicate code to check whether a land unit can be loaded. Factor out into land_loadable(). Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Revert "Don't let trains load trains" This reverts commit b1a0ff2fbd87d3c332de1e0a41b3ddea133c77b1. Land units with capability heavy can't be loaded on anything, and land units carrying land units can't be loaded regardless of capabilities. Commit b1a0ff2fbd8 additionally outlawed loading of trains on land units, but not on ships. Bad idea, because it complicates matters for no good reason. Revert it. Doesn't affect the stock game, because its only train is heavy. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load unload: Don't treat unowned sectors specially load and unload silently skip unowned sectors, unlike lload and lunload. Probably goes back to Chainsaw option ALLYHARBOR. Drop that. Deities can now load and unload in unowned harbors and canals. Mortals are now notified they can't. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load lload unload lunload: Tweak suppression of error messages These commands suppress some error messages when ships, planes or land units involved aren't explicitly selected by UID. Without this, a command like "unload plane 80 *" would complain about every plane not on ship#80. Correct a few issues with this error suppression: 1. We don't suppress the error when we can't load/unload a ship or land unit because it's on the trading block. Do suppress it. 2. We suppress the error message when we can't load/unload due to foreign sector ownership in all but one places. Fix that place. 3. Messages about explicitly selected planes and land units to load are still suppressed when the carrier isn't selected explicitly. Change this to suppress regardless of the carrier. 3. We suppress the error when a carrier has no room. Don't, because it's a potentially confusing silent failure. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load: Drop dead recomputation of load_spy load_land_ship() recomputes load_spy "since [the carrier] may have changed". Has been that way since the feature was added in 4.2.0, but it's nonsense. Drop it. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load lload: Drop dead "cannot carry land units" checks load_land_ship() and load_land_land() fail for carriers that can't carry any land units before prompting for land units to load. They then iterate over land units to load, and fail when the carrrier has no room. They either report "cannot carry land units" or "doesn't have room for any more land units" then. The former cannot happen. Crept into load_land_ship() in Empire 2, blindly copied to load_land_land() in 4.0.0. load_plane_ship() and load_plane_land() don't have this issue. Drop the dead code. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
unload lunload: Fail early when carrier can't carry land units Attempting to unload land units from a carrier that can't carry any prompts for land units to unload, while attempting to unload planes or load land units or planes fails without prompting. Fix this inconsistency by making unload and lunload fail early for land units, just like they do for planes. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load unload lload lunload: Fix for areas starting with a digit load and lload skip foreign ships unless explicitly named, and suppress some error messages for ships not explicitly named. Makes sense, except the check for "explicitly named" is flawed: it checks whether the argument starts with a digit. Works as intended for lists like 1/2/3. Broken for areas that happen to start with a digit, such as 0:9,0:5. Visible in the load-tend test. Screwed up when the feature was added in Empire 2. Fix the obvious way: test for NS_LIST instead. While there, drop the p && *p guard, because it's always true after snxtitem(). Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
unload lunload: Say "Can't unload" instead of "Can't load" Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load: Replace variable load_unload by variable loading Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@redhat.com>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>