Planes were not subject to air defense and flak over allied sectors.
Air defense was broken when Empire 2 changed it to happen after
spotting.
Flak was broken when 4.2.8 made ships and land units fire flak in
every sector, not just the target sector. Although an allied sector
doesn't fire flak, it may still contain hostile ships and land units.
Also makes use of ilist[] more robust: before, if relations somehow
went sour after unfriendly[] was initialized, the sector intercept
would run with an invalid interceptor list, and crash.
Chainsaw had missiles flying missions together with planes, and to
make that work, aircombat.c got code for coping with missiles. Since
Empire 2, missiles fly separately and don't go through aircombat.c
anymore. The missile code there has been useless for more than a
decade. Remove it.
This simplifies ac_encounter(), sam_intercept(), ac_intercept(),
ac_airtoair(), and gets rid of count_non_missiles(), all_missiles().
ac_encounter() passed MAXNOC instead of the sector owner to setcont(),
and setcont() does nothing for such an argument. Screwed up from the
start, in commit 144c7cb5, v4.2.22.
ac_encounter() lets all owners of ships and land units in the target
sector intercept, but not more than once.
Move the interception code behind reporting of both ships and land
units. Before, it was duplicated for ships and land units. Land
units didn't get reported when no bombers got through interception
triggered by ships.
Since the previous two commits, ac_encounter() checks its
mission_flags argument only for proper mission flags PM_R and PM_S,
not for plane flags P_A, P_S, P_I.
This makes the code to put plane flags into mission flags useless.
Remove it from bomb(), drop(), fly(), para(), reco(),
perform_mission(), mission_pln_arm(), air_defense(), pln_arm().
Much of that code was useless even before: P_X and P_H since Chainsaw
3 option STEALTHV became mandatory in Empire 2, and P_MINE since
commit cc0c3e4f (v4.3.0) cleaned up mine drops.
A reconnaissance patrol (recon and sweep) uses sonar when ASW planes
participate. ac_encounter() enabled sonar when P_A was in
mission_flags. These get computed by pln_arm() and callers. However,
they set P_A only when *all* planes were capable, including escorts.
Fix by checking actual plane capabilities instead. Closes#1389451.
A reconnaissance patrol (recon and sweep) reports much more detail
when spy planes participate. However, ac_encounter() didn't stop
doing that after all spy planes were shot down or aborted.
Fix by recalculating plane capabilities for every sector.
Remove the KillIdle thread. Add timeout to struct iop, initialized in
io_open(). Obey it in io_input() by passing it to empth_select(). If
empth_select() times out, report that back through io_input() to
recvclient() and player_login(). If player_login() receives a timeout
indication, print a message and terminate the session. If
recvclient() receives a timeout indication, flash a message to the
player and initiate a shut down the player's session.
Create WIN32 sys/time.h to define struct timeval. This creates some
conflicts with WIN32 windows.h definitions. Including windows.h in
show.c and info.c creates conflicts, so remove that. Modify service.c
to include sys/socket.h instead of windows.h to remove the conflict
with sys/time.h.
Remove the names for the bounce_empty, bounce_full and ctrl_c_event
events. The named events were being shared between all clients running
on a WIN32 machine which created the affect of disconnecting a client
when an input event occurred in another client. Broken in commit
f082ef9f (v4.3.11).
Add check to ensure a country by that name does not exist.
Ensure the length is not too long. Note this is a change
behaviour for edit and change commands which used to silently
truncate long names. Enforce that a country name can not have
control characters in it. Ensure that a country name is not
blank or just spaces.
The Chainsaw 3 feature to let you load/unload to a specific amount
through a negative amount argument created loopholes: it let you load
your ships in friendly sectors with the unload command, and unload
friendly ships with the load command. Likewise for land units, with
allied instead of friendly, of course.
Empire 4.0.0 fixed that for the case of loading a land unit from an
allied sector. Get rid of that check, and fix it for good in
load_comm_ok().
The game generally doesn't let you give away civilians. But the check
in load_comm_ok() for that compared the sector old owner to the player
instead of the ship's or land unit's owner, which is incorrect for
foreign ships or land units. Fix that.
Also make fix the message there not to assume that the civilians are
owned by the player. This can't currently happen, but will when these
commands support use by deities properly.
This is for consistency with load and unload.
Before, you could use lunload for allied land units and lload in
allied sectors, but the command failed when stuff was loaded in allied
sectors. Doing that with lload no longer fails the command, because
the check that does that in load_comm_land() is now masked by the new
checks in lload(). Note that loading with lunload still fails the
command; that inconsistency will be removed in a later commit.
load_plane_land() already refused to load planes from foreign sectors.
This commit makes that check redundant, so remove it. Functional
change: lload now refuses to load foreign planes silently, unless both
land unit and plane were named by number. This is consistent with
load.
load and unload work on foreign ships only when their argument
explicitely names them, i.e. you have to ask for them by number. When
any other syntax is used, load() ignores foreign ships. This makes
sense. Change lload() to work just like that.
The check for ship owner's relations to the player was backward: it
checked the player's relations to the ship's owner instead. Abusable:
you could load and unload any ship by declaring friendly to its owner.
Broken since Chainsaw let you load and unload friendly ships.
The check for land unit owner's relations to the player was similarly
backward, similarly abusable, and also broken since day one.
lload and lunload checked sector owner's relations to the land unit's
owner instead of to the player. Harmless, because the two must be the
same to reach the check.
The contents of the line was partly useless (repetition of the command
argument) and partly misleading (modification time of the formatted
info file, ifndef _WIN32).
Land units were erroneously charged the much lower raw path cost,
except when attacking high-mobility terrain (mountains). Broken in
commit 2673a258, v4.3.6.
Conditions comparing strings behaved rather erratically: while wing=m
was smartly interpreted as wing='m' (because m is ambiguous as plane
selector), wing=e was not so smartly interpreted as wing=effic
(because e unambiguously identifies effic; this was then rejected due
to incompatible types), and wing=g was even less smartly interpreted
as wing=group.
Address this by a redesign of the identifier resolution rules in
nstr_comp(): If the condition contains just one identifier, it names a
selector. If it contains two, try to intepret either as selector or,
if the other can be interpreted as selector, as value for that.
String selectors accept any identifier as value, numeric selectors
only the ones listed in their table.
Interpret both identifiers as selectors only if their types are
compatible (makes rpath=gu work for ships) and their tables, if any,
match (makes type=spy work for land units).
If more than one interpretation makes sense, drop any value
interpretations of identifiers that are unabbreviated selector names,
and selector interpretations of those that are not (makes wing=w work
for planes).
Change nstr_match_val() to accept any identifier as value for a string
selector. Replace nstr_mkselval() by nstr_resolve_val(), to resolve
string values in addition to symbolic ones. Remove resolution to
string from nstr_resolve_id(), drop its last parameter. Remove unused
nstr_string_ok(). New nstr_is_name_of_ca(), nstr_ca_comparable().
Examples for conditions that are now interpreted differently:
condition old interpretation new interpretation
wing=g wing=group wing='g'
w=g wing=group rejected as ambiguous (1)
w=e wing=effic (2) wing='e'
(1) because both wing='g' and 'w'=group make sense
(2) rejected as incomparable later on
Change nstr_mkselval() to generate values with promoted types only,
and replace nstr_coerce_val() by new and simpler nstr_optype() in
nstr_comp().
Replace the only remaining use of nstr_coerce_val() in surv() by
nstr_promote(), and remove nstr_coerce_val().
This loses one half of the unimplemented sketch of coercions to
NSC_STRING. Drop the other half from nstr_exec_val().
getsect() can fail here only when the coordinates are invalid. The
first check uses coordinates from a successful sarg_xy(), so they
can't be invalid. The second check uses coordinates of an object to
be put on the mission. If these are invalid, game state is corrupt,
and failing the mission command doesn't improve the situation a bit.
Before, the escort mission didn't support an op-area, and planes on
escort mission escorted anywhere. Change mission() to define the
op-area for escort missions as well. Show it in mission() and
show_mission(). Check it in find_escorts().