Commit graph

32 commits

Author SHA1 Message Date
1713f2d303 Don't fix up dead planes stuck in the air
Missile interdiction leaves behind used up missiles with the
PLN_LAUNCHED flag set.  This can lead to a bogus warning from
pln_zap_transient_flags() on server restart.

Change pln_zap_transient_flags() to ignore dead planes.
(cherry picked from commit 7a06a58bec)
2008-07-13 07:58:09 -04:00
4e9e58bf6a Write planes fixed on game start to disk properly
When fixing planes stuck in the air, we fixed them only in memory, so
when a fixed plane wasn't written to disk for other reasons before the
next game start, it had to be fixed again.

Change pln_zap_transient_flags() to write them out.
2008-04-29 20:38:10 +02:00
7ca4f412b1 Fix tracking of planes flying a sortie
Planes normally sit in their base (sector or carrier), where they can
be spied, damaged, captured, loaded, unloaded, upgraded and so forth.
All this must not be possible while they fly.  There are two kinds of
flying planes: satellites in orbit, and planes flying a sortie.

Satellites in orbit have always been marked with flag PLN_LAUNCHED.
Works.  What didn't work was tracking planes flying a sortie.

If you look at one sortie in isolation, up to three groups of planes
can be flying at any point of time: the primary group, which carries
out the sortie's mission (bomb, transport, ...), their escorts, and a
group of hostile planes flying interception or air defense.

The old code attempted to track these planes by passing those groups
to the places that need to know whether a plane is flying.  This was
complex and incomplete, and broke down completely for the pin-bombing
command.

It was complex, because the plane code needs to keep track of all the
call chains that can lead to a place that needs to know whether a
plane flies, and pass the groups down the call chains.  This leads to
a rather ugly passing of plane groups all over the place.

It was incomplete, because it generally failed to pass the escorts.

And the whole scheme broke down for the pin-bombing command.  That's
because pin-bombing asks the player for targets while his planes are
loitering above the target sector.  This yields the processor and lets
other code run.  Which does not get the flying planes passed.

The new code marks planes and SAMs (but not other missiles) flying a
sortie with flag PLN_LAUNCHED (the previous commit laid the groundwork
for that), and does away with passing around groups of flying planes.

This fixes the following bugs:

* Many commands could interact with foreign planes flying for a
  pin-bombing command as if they were sitting in their base.  This
  includes spying, damaging, capturing, loading, or upgrading them,
  and even getting intercepted by them.  Any changes to those planes
  were wiped out when they landed.  Abusable.

* The bomb command could bomb its own escorts, directly (pin-bomb
  planes) or through collateral damage, strategic sector damage,
  collapsing bridges or nuke damage.  The damage to the escorts was
  wiped out when they landed.

* If you asked for a plane to fly both in the primary group and the
  escort group, you got charged fuel for two sorties instead of one.

* pln_put1() and pln_put() now recognize planes that didn't take off,
  and refrain from making them land.  Intercept (since commit
  c64e2149) and air defense can do that.  Making them land had no
  ill-effects, but it was still wrong.

There's one new problem: if PLN_LAUNCHED doesn't get reset properly,
due to game crash during flight or some other bug, the plane gets
stuck in the air.  Catch and fix that on game start in ef_verify().
2008-03-26 22:10:13 +01:00
0dd6702df1 Update known contributors comments 2008-03-14 20:25:44 +01:00
d1a193ff07 New nstr_mksymval() to create symbolic values 2008-03-14 20:25:41 +01:00
da8a1daeef Virtual selectors
Where ordinary selectors specify a value stored in some object,
virtual selectors specify a function to call to compute a value
associated with some object.

Use them to replace the special case xdump ver by new table
EF_VERSION.

Move configkeys[] to lib/common because nsc_init() needs it to
initialize empfile[EF_VERSION].cadef.
2008-03-14 20:25:41 +01:00
9b8683736b Make ef_verify() check ef_type and uid 2008-03-14 20:25:09 +01:00
db02dda32f Update copyright notice 2008-01-19 10:15:37 +01:00
454c6df5ef (verify_fail): Print index as it looks in input. 2007-08-24 17:23:26 +00:00
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +00:00
e42053d928 Break inclusion cycle: prototypes.h and commands.h included each
other.  Ensure headers in include/ can be included in any order
(except for econfig-spec.h, which is special).  New header types.h to
help avoid inclusion cycles.  Sort include directives.  Remove some
superflous includes.
2006-07-10 06:37:23 +00:00
5e66e5bdee (ef_verify): Check pchr[].p_level matches pchr[].p_type. 2006-06-08 20:22:58 +00:00
c432e3107d Symbolic names for table entries in conditionals, closes #928376:
(ef_elt_byname): New.
(nstr_match_val): Use it to generalize to arbitrary table with
uniquely named elements.  Use ca_type to find table, remove parameter
type.  Callers changed.
(nstr_mkselval): Adapt sanity check accordingly.
(NSC_TYPEID): No longer needed, remove, users changed to use
appropriate integer type instead.  This fixes signedness of sector
selectors des and newdes.
(meta_type): Remove entry for NSC_TYPEID.
(nstr_coerce_val): Can't detect typeid - integer mismatch anymore.
Was nice to have; perhaps revive it later.
2006-06-01 18:48:42 +00:00
cc1df4e88a (verify_fail): New parameter idx. Use it to print array index when
applicable.  Callers changed.
2006-05-24 18:32:13 +00:00
f576dd6694 (verify_row): uid check was too strict. 2006-04-05 18:47:02 +00:00
9559abb506 (verify_fail): New.
(verify_row): Use it.
2006-02-19 17:08:35 +00:00
8b97f10ea3 (verify_row): Passed uninitialized val->val_as.sym.len to nstr_exec_val(),
which broke NSC_STRINGY.
2006-02-14 19:54:08 +00:00
973da267eb (verify_row): Check all values against symbol tables, not just
non-negative ones.

(verify_row): Fix off by one in non-symbol table index check.
2006-02-06 07:57:04 +00:00
8ae71216d4 (verify_row): Check table references regardless of target table. Also
fixes the previous revision.
2006-02-06 07:53:42 +00:00
e71509b32f (verify_row): Check uid. 2006-02-05 19:59:08 +00:00
b121b58e91 (verify_row): NSC_BITS implies symbol_ca. Oops if violated. 2006-02-05 19:57:10 +00:00
afd93afbd3 (verify_row): Simplify control structure. No functional change. 2006-02-05 19:55:05 +00:00
1feb0c433d (verify_row): Fix for flags that don't fit into int. 2006-02-05 19:16:37 +00:00
1e17cc77cb (verify_row): if/else with negated condition is confusing. Negate
condition, swap conditional statements.
2006-02-05 19:13:58 +00:00
b11b81da8f (verify_row): Plug memory leak. 2006-02-05 19:08:49 +00:00
4515b84c59 COPYING duplicates information from README. Remove. Move GPL from
LICENSE to COPYING, because that's where it usually is.  Update all
the references to these files.
2006-01-21 19:48:41 +00:00
3e400c018c Update copyright notice. 2006-01-05 13:36:57 +00:00
Ron Koenderink
6f51053336 (verify_row): Add cast to an int for a call to sizeof().
This removes a warning.
2006-01-01 19:32:52 +00:00
3aebb68ee7 Include config.h. 2005-12-27 18:04:19 +00:00
e29f288289 Remove silly superflous parenthesis. 2005-12-03 21:14:26 +00:00
Ron Koenderink
65cda58286 (verify_row): Remove // comment.
Change %d to %ld when printing a long.
2005-12-01 00:39:05 +00:00
Ron Koenderink
40c821d28b (ef_init_srv): Add a call ef_verify() to verify game data and game
configuration consistency.

(ef_verify): New.  Verifies game data and game
configuration consistency.
2005-11-30 19:17:58 +00:00