Commit graph

69 commits

Author SHA1 Message Date
5e45859979 New macro ARRAY_SIZE()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
4a1ec06364 Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 10:41:28 +01:00
d111522fe8 Update copyright notice
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2018-04-29 10:33:19 +02:00
afe5001a23 Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-07 09:38:32 +02:00
de24545963 relations: Create EF_RELAT table of struct relatstr
New struct relatstr is basically empty so far.  The next commit will
move relations state from struct natstr to struct relatstr.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 20:09:21 +02:00
f35f16c0a2 reject: Create EF_REJECT table of struct rejectstr
New struct rejectstr is basically empty so far.  The next commit will
move reject state from struct natstr to struct rejectstr.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 20:09:21 +02:00
4b4df53485 contact: Create EF_CONTACT table of struct contactstr
New struct contactstr is basically empty so far.  The next commit will
move contact state from struct natstr to struct contactstr.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 20:09:20 +02:00
549561ff03 Include "file.h" where it's needed
Several headers define macros that use ef_ptr() without including
"file.h".  Fix that.  Drop redundant inclusions elsewhere.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-08-06 20:08:31 +02:00
bae3f5447e Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-07-02 17:45:44 +02:00
b14f5276ab Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-02-28 16:21:34 +01:00
a109de948b Remove option TREATIES
TREATIES has issues:

* Treaties can cover attack, assault, paradrop, board, lboard, fire,
  build (s|p|l|n) and enlist, but not bomb, launch, torpedo and
  enlistment centers.

* Usability is very poor.  While a treaty is in effect, every player
  action that violates a treaty condition triggers a prompt like this:

    This action is in contravention of  treaty #0 (with Curmudgeon)
    Do you wish to go ahead anyway? [yn]

  If you decline, the action is not executed.  If you accept, it is.
  In both cases, your decision is reported in the news.

  You cannot get rid of these prompts until the treaty expires.

* Virtually nobody uses them.

* Virtually unused code is buggy code.  There is at least one race
  condition: multifire() reads the firing sector, ship or land unit
  before the treaty prompt, and writes it back after, triggering a
  generation oops.  Any updates made by other threads while trechk()
  waits for input are wiped out, triggering a seqno mismatch oops.

* The treaty prompts could confuse smart clients that aren't prepared
  for them.  WinACE isn't, but is reported to work anyway at least
  common usage.  Ron Koenderink (the WinACE maintainer) suspects there
  could be a few situations where it will fail.

This feature is not earning its keep.  Remove it.  Drop command
treaty, consider treaty, offer treaty, xdump treaty, reject treaties.
Output of accept changed, obviously.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:44:14 +01:00
bb467c335d Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-02 14:33:48 +01:00
df4925d696 Update copyright notice 2013-01-12 17:45:01 +01:00
1118f1c0ca Update copyright notice 2012-06-10 10:52:22 +02:00
c6d3f68bbb New server option -F to force start even when state looks bad
Risks crashes and further corruption, but gives deities a chance to
fix up a bad game state with edit commands and such.
2011-07-10 21:17:01 +02:00
d63b0e1a7b Split ef_verify() into ef_verify_config(), ef_verify_state() 2011-07-10 21:17:01 +02:00
6eec001050 Fix empdump not to touch plane file when import fails
pln_zap_transient_flags() fixes up planes stuck in the air (commit
7ca4f412, v4.3.12).  Since commit 4e9e58bf (v4.3.14), it writes back
the fixed planes.  This is wrong for empdump.

empdump should touch data only on successful import.  When it fails
because ef_verify() fails, and any planes are found stuck in the air,
the plane file gets rewritten.

Make parameter ef_verify() take parameter may_put to let empdump
suppress the plane write-back.  The plane file still get written out
on successful import, along with the other imported game state.
2011-06-25 17:05:12 +02:00
31b9ff08f3 Move pln_oninit(), lnd_oninit(), nuk_oninit() to filetable.c
They set up invariants, and thus should be always active, not just in
the server.  Since ef_blank() isn't used for these files outside the
server right now, this isn't a bug fix, just cleanup.
2011-06-25 16:50:06 +02:00
0fcd935999 Clean up how game state file sizes are checked
New struct empfile member nent replaces ef_open() parameter nelt.
Cleaner, because the expected size is a property of the file, not of
how it's used.  Also fixes empdump to check file sizes.

Complication: with EFF_CREATE, ef_open() creates an empty file, to be
extended to the correct size.  Callers passed nelt argument -1 along
with EFF_CREATE, to make ef_open() accept the empty file.  Can't do
the same for empfile member nent.  Instead, make ef_open() not check
the (zero) size then.

Replaces commit 5750107b, v4.3.15.
2011-06-25 16:50:06 +02:00
44f97c3297 Clean up how a view's base table is defined
New struct empfile member base replaces ef_open_view() parameter base.
Cleaner, because the base table is a property of the view, not of how
it's used.

Use it to clean up verify_fail()'s base table access, and for extra
sanity checks in ef_open() and ef_open_view().
2011-06-25 16:50:06 +02:00
a485084777 Change struct empfile callback onresize() to return void
ef_open() handles onresize() failing incorrectly.  Instead of fixing
that, drop the failure mode.  It's not really used: unit_onresize()
fails only when used incorrectly.  It isn't.  If it ever is, ignoring
the failure is safe.
2011-06-25 16:50:05 +02:00
7e2008e7f4 License upgrade to GPL version 3 or later
Why upgrade?  I'm not a lawyer, but here's my take on the differences
to version 2:

* Software patents: better protection against abuse of patents to
  prevent users from exercising the rights under the GPL.  I doubt
  we'll get hit with a patent suit, but it's a good move just on
  general principles.

* License compatibility: compatible with more free licenses, i.e. can
  "steal" more free software for use in Empire.  I don't expect to steal
  much, but it's nice to have the option.

* Definition of "source code": modernization of some details for today's
  networked world, to make it easier to distribute the software.  Not
  really relevant to us now, as we normally distribute full source code.

* Tivoization: this is about putting GPL-licensed software in hardware,
  then make the hardware refuse to run modified software.  "Neat" trick
  to effectively deny its users their rights under the GPL.  Abuse was
  "pioneered" by TiVo (popular digital video recorders).  GPLv3 forbids
  it.  Unlikely to become a problem for us.

* Internationalization: more careful wording, to harden the license
  outside the US.  The lawyers tell us it better be done that way.

* License violations: friendlier way to deal with license violations.
  This has come out of past experience enforcing the GPL.

* Additional permissions: Probably not relevant to us.

Also include myself in the list of principal authors.
2011-04-12 21:20:58 +02:00
73e25ff21e Update copyright notice 2010-01-19 08:40:17 +01:00
35ef345ecb Update copyright notice 2009-02-08 09:33:18 +01:00
Ron Koenderink
f180712625 Fix initialization of new elements in plane, land and nuke tables
ef_init_srv() neglected to set struct empfile callback oninit.  This
made unit_carrier_change() crash or oops on freshly initialized
planes, land units and nukes, i.e. when build used an uid that hadn't
been used before.  Oops recovery worked.

Broken in commit 64a53c90, v4.3.17.
2008-10-18 10:53:42 -04:00
d702068457 Fix trailing whitespace 2008-09-17 21:31:40 -04:00
64a53c90f0 Cargo lists storing lists of cargo for each carrier
Persistent game state encodes "who carries what" by storing the
carrier uid in the cargo.  Cargo lists augment that: they store lists
of cargo for each carrier.  They are not persistent.

New unit_cargo_init() to compute the cargo lists from game state.
Call it in ef_init_srv() and at the end of update_main().

New unit_onresize() to resize the cargo list data structure.
Installed as units' struct empfile callback onresize to make them
resize automatically with the unit files.

New unit_carrier_change() to update cargo lists when carriers change
in game state.  Convenience wrappers pln_carrier_change(),
lnd_carrier_change() and nuk_carrier_change().  Call them from
prewrite callbacks to keep cargo lists in sync with game state.

To make that work, unused units must not point to a carrier.  Add new
pln_oninit(), lnd_oninit() and nuk_oninit() take care of newly created
units.  Change lnd_prewrite() and nuk_prewrite() to take dead land
units and nukes off their carrier.  pln_prewrite() did that already.

New unit_cargo_first(), unit_cargo_next() to traverse cargo lists.
Convenience wrappers lnd_first_on_ship(), lnd_first_on_land(),
lnd_next_on_unit(), pln_first_on_ship(), pln_first_on_land(),
pln_next_on_unit() and nuk_on_plane().  The latter is disabled for now
because it clashes with an existing function.
2008-09-08 21:30:39 -04:00
c5482e4bfb Pass old element to empfile callback prewrite()
Change sct_prewrite(), shp_prewrite(), pln_prewrite(), lnd_prewrite(),
nuk_prewrite() accordingly.  New argument isn't used for anything,
yet.
2008-09-08 21:26:40 -04:00
62076fbed7 Move view open/close into src/lib/common/file.c
Really belongs there, because it manipulates empfile[].

New ef_open_view() to replace ef_init_view().  Make ef_close() cope
with views, and remove ef_fina_view().  Make ef_extend() and
ef_truncate() oops on views.
2008-09-03 21:17:46 -04:00
bf436a4498 Change empfile members postread() and prewrite() to return void
Callers ignore the value, and callees always return 1.  Pointless.
2008-09-03 20:43:13 -04:00
8d85979a82 Update known contributors comments 2008-05-18 10:59:04 +02:00
5750107b65 Make server check game state file sizes on startup
Certain tables have a fixed size depending on configuration: EF_SECTOR
has WORLD_SZ() elements, EF_NATION, EF_MAP and EF_BMAP have MAXNOC
elements, and EF_REALM has MAXNOC * MAXNOR elements.  Bad things
happen if the files backing them are shorter.

Pass expected size to ef_open(), and make it fail when the actual size
differs.
2008-05-17 17:00:57 +02:00
a71f01585f empfile's init callback is now unused, remove 2008-03-05 22:48:24 +01:00
6b89127d5b shp_init(), lnd_init(), pln_init(), nuk_init() are now empty, remove 2008-03-05 22:48:24 +01:00
400df7be82 Clean up initialization of nat_ca[]
Factor it out of ef_init_srv() and put it into new nsc_init(), next to
nat_ca[].
2008-02-10 11:40:57 +01:00
55ff4f8e3a Clean up initialization of empfile[]
Split ef_init() into two functions: empfile_init() for initialization,
and empfile_fixup() to fix it up for configuration.  Put them next to
empfile[].  Move the call to empfile_init() from behind emp_config()
to before it.
2008-02-10 11:40:57 +01:00
db02dda32f Update copyright notice 2008-01-19 10:15:37 +01:00
9868e1b76f (ef_init_srv): Rev. 1.27 set NSC_CONST in all nat_ca[] instead of
cou_ca[] as before.  Fix by not setting it at all.
2007-10-27 17:07:09 +00:00
654335c621 New Empire table game, to be used for global stuff:
(gamestr, EF_GAME, game_ca): New.
(empfile): Declare the table.
(ef_open_srv, ef_close_srv): Open and close it.
(main): Create it.
(empobj_storage): New member game.

(EF_DYNMAX): New.
(EF_IS_GAME_STATE): Use it.
2007-07-14 14:49:58 +00:00
d62355e76d (ef_open_srv, start_server): Journal must not be written before
empth_init(), because writing calls empth_self().  Move call of
journal_startup().
(ef_close_srv, finish_server, panic): Move call of journal_shutdown()
for symmetry.
2007-01-21 17:58:01 +00:00
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +00:00
1ca0b5cb2b Finally merge the journal patch:
(keep_journal): New econfig key.
(player_main): Log player login and logout.
(recvclient): Log player input.
(ef_open_srv, ef_close_srv): Log startup and shutdown.
(update_main): Log update.

Support the common SIGHUP log rotation idiom:
(empth_wait_for_shutdown, empth_wait_for_signal): Rename.
[EMPTH_LWP, EMPTH_POSIX] (empth_init, empth_wait_for_signal): Wait for
SIGHUP as well.
(main) [SIGHUP]: Reopen journal when empth_wait_for_signal() returns
SIGHUP.
2006-06-08 20:11:26 +00:00
93b6a54356 (nat_ca, cou_ca, ef_init_srv, xdvisible): Plug major information leak:
nat_ca[] was designed for visibility to the owner only, while cou_ca[]
was designed for the public.  xdvisible() implemented that for xdump.
But selectors don't care for that!  Since nat_ca[] applies to
EF_NATION, it must be for public visibility.  Broken in 4.2.21.  Fix
by exchanging contents of nat_ca[] and and cou_ca[].  This breaks
clients relying on xdump.
2006-05-22 20:59:11 +00:00
13cd9081da Minimize redundancy between (mortal's) xdump nation and xdump country:
(ef_init_srv): Make NSC_DEITY in cou_ca mirror ~NSC_EXTRA in nat_ca,
except for cnum, which may not have either flag in either table.
(nat_ca): Make selectors stat, cname, passwd, xorg, yorg, relations,
contacts and rejects NSC_EXTRA.
2006-05-22 19:58:44 +00:00
35d14c3e73 (cou_ca, nat_ca, ef_init_srv): Make selectors relations and rejects
visible to mortals in cou_ca[].
2006-05-18 19:20:16 +00:00
f5a9284867 Update known contributors comment. 2006-02-24 21:35:27 +00:00
bd65a84eb5 New way to read configuration tables:
(config_tables): New econfig key.
(read_config_tables): New, implements config_tables.
(main): Call it.  Need to call ef_init() and chdir(configdir) first.
(ef_init_srv): Don't call ef_init(), since main() did it already.

Remove old way to do the same:
(ef_load): Remove, along with calls.
(empfile): Set configuration tables' member file back to NULL.
2006-02-18 13:57:52 +00:00
58f67c8e19 Change xdump nat to show only own country, and xdump cou to show to
deities what xdump nat used to show:
(cou_ca): Remove initializer.
(ef_init_srv): Initialize cou_ca[] from nat_ca[].
(xdvisible): Change case EF_NATION to return true only for owner
even for deities.
2006-02-17 18:38:50 +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
cb32ec38d6 (ef_open_srv): Intialize views only if all is well, so they can assume
the underlying file is open.
2006-01-21 18:35:26 +00:00