Commit graph

2808 commits

Author SHA1 Message Date
d4ac7d94b2 Generalize ef_extend() to non-file-backed tables
ef_extend() extended the file bypassing the cache, which screws up the
cache if it's EFF_MEM.  It fixed that by closing and reopening the
table.  Cheesy, and worked only for file-backed tables.

Rewrite ef_extend() to remap the cache properly for EFF_MEM.  While
there, simplify the !EFF_MEM case: steal a cache slot instead of
allocating a buffer.

Factor cache mapping out of ef_open() and ef_extend() into new
ef_remap_cache().
2008-02-24 08:40:05 +01:00
642c11eb64 Replace EFF_RDONLY by EFF_PRIVATE
Read-only was a bit of a misnomer: you could write to the table by
obtaining a pointer into it from ef_ptr(), you just couldn't write to
the backing file.

Semantic changes:

* ef_flush() is now allowed when the table is file-backed or privately
  mapped.  Before, it had to be file-backed.  Flushing a privately
  mapped table does nothing, just like flushing a read-only table did.

* ef_write() is now allowed when the table is file-backed or fully
  cached.  Before, it had to be file-backed and not read-only.
  Writing to a privately mapped file-backed table doesn't write to the
  file.

* ef_extend() is not implemented for privately mapped tables, just
  like it wasn't implemented for read-only tables.
2008-02-21 21:05:16 +01:00
53bcf04664 Remove obsolete comment
Obsolete since ef_open() locks the file (commit de124108).
2008-02-19 20:27:01 +01:00
8d4b959a0c Define and use NATID_BAD instead of literal 255 2008-02-19 20:25:08 +01:00
00bb086d2a Fix spelling of symbol PLN_AIRBURST in plane_flags[] 2008-02-17 19:54:41 +01:00
e58d3206bb Clean up trailing whitespace-space in manual pages 2008-02-17 19:50:38 +01:00
1f4d483b78 Consider only wilderness for randomly placed sanctuaries
Before, any non-sea sector was acceptable.  Placing sanctuaries on
mountains, plains or bridges doesn't seem such a bright idea, though.
2008-02-17 09:01:29 +01:00
d3a3aa4306 Don't recompute sct_coastal in desi(), just use it
No need to recompute it since sct_coastal was redesigned to be
reliable in 4.3.0 (commit 7b947943),
2008-02-17 08:56:14 +01:00
44f6656e2f Remove unused check_cost() 2008-02-17 08:47:51 +01:00
8227d8c8ef Don't let designate check total cost before doing anything
desi() ran the designate code twice, first for adding up the cost,
then for changing designation.  However, the checking pass already
changed the sector when that cost nothing.  The checking pass also
suppressed messages.  There was at least one message that never got
printed because it was suppressed in the checking pass, and the
condition for it was no longer true in the changing pass, due to the
premature sector change: when a deity changed a non-coastal sector to
harbor or bridge head.

The total cost check is of limited value: designate costing money is a
bad idea, and the stock game has no such sectors.  Not enough value to
justify keeping and fixing this disgusting mess.  Remove it instead.
2008-02-17 08:47:23 +01:00
6110da1ef4 Fix mobility cost for marines assaulting from non-landing ships
Always charge land units at least as much mobility for assaulting from
non-landing ships as for landing ships.  Before, marines lost all
mobility when assaulting from a non-landing ship, which could be less
than what the same assault costs from a landing ship (half an update's
worth).
2008-02-17 06:56:46 +01:00
f0cd142fa3 Remove thoroughly obsolete info on estimated odds
The code to estimate odds and ask for confirmation was disabled in
4.0.0, and removed for good in 4.3.4.
2008-02-16 20:57:39 +01:00
74dc4b9e3a Simplify take_move_in_mob()
Actually, this isn't just simplification.  When mobility gain per
update was configured to be greater than 128, mobility could go from 1
to less than -127 when assaulting from a landing ship, and thus
overflow.  Make it saturate at -127.  Note that you can expect plenty
of trouble elsewhere with such a silly configuration.
2008-02-16 20:57:39 +01:00
5c2f7646e1 Fix LWP's stack initialization for -s
With -s, LWP initializes thread stacks to track stack use.  It did
that after makecontext(), with disastrous results on systems where
makecontext() writes something to the stack that swapcontext() expects
to find there.  Makes FreeBSD 6.2 crash in swapcontext().

Factor stack allocation out of lwpNewContext() into lwpNewStack().
Move call of lwpStackCheckInit() into lwpNewStack().
2008-02-16 20:57:38 +01:00
40eb78eb74 Fix confused and buggy bridge splashing code
A bridge (span or tower) must be splashed when it gets damaged below
SCT_MINEFF.  Likewise when its last supporting sector (bridge head or
tower) gets damaged below SCT_MINEFF, unless EASY_BRIDGES is enabled.
We need to check this whenever a bridge head, span or tower gets
damaged.  This is done in three places, and all of them screw up:

* checksect() ignores damage to bridge heads.  It also leaves writing
  back the sector it checks to the caller, which never happens when
  it's called from sct_postread().

  Note that checksect() drowns all planes on bridges it splashes.
  Functions that need to exempt flying planes from such a fate have to
  splash bridges themselves.

* sect_damage() ignores damage to bridge towers, and damage to bridge
  spans unless EASY_BRIDGES is enabled.  It then runs checksect(),
  which compensates for these omissions, but happily drowns the planes
  sect_damage() attempts to protect.

* eff_bomb() ignores damage to bridge heads.  Collateral damage makes
  sect_damage() run, which compensates for the omission.

This causes the following bugs:

* Efficiency damage going through sect_damage() can drown planes it
  shouldn't.  This affects pinpoint bombing when collateral damage
  splashes a bridge, and strategic bombing.  The drowned planes then
  crash and burn when they attempt to land at their (just splashed)
  base.

* Efficiency damage to bridge heads not going through sect_damage()
  fails to collapse unsupported bridges.  This affects pin-bombing
  efficiency without collateral damage, and ground combat.  Also deity
  commands edit, setsector and add, but that could be regarded as a
  feature.

* If the sector file somehow ends up with an inefficient bridge span,
  it collapses on every read again and again, until it collapses on a
  write.  Related problems exist with other actions of checksect(),
  and they're not addressed here.

* If the sector file somehow ends up with adjacent inefficient bridge
  towers, checksect() on any of them recurses infinitely:

  - checksect() inefficient tower T1
    - knockdown() T1, but don't write that back to the sector file
    - bridgefall() T1; this reads all adjacent sectors, including
      inefficient towert T2
      - checksect() T2
        - knockdown() T2, but don't write that back to the sector file
	- bridgefall() T1; this reads adjacent sectors including T1
	  - checksect() T1
	    ...

This commit creates a new function bridge_damaged() to splash any
bridges that became inefficient or unsupported after damage to a
sector.  To avoid the inifinite recursion, we call it in
sct_prewrite() instead of checksect().

No uses knockdown() outside bridgefall.c remain, so give it internal
linkage.
2008-02-16 20:57:38 +01:00
Ron Koenderink
13cca55a9d Added Remove_Repository to supported command list
This feature was added in commit 70c03561bb but was
not added to the list of supported commands at the top
of file.  No functional change just a documentation
correction.
2008-02-16 11:15:10 -06:00
Ron Koenderink
ffee7cd10d Apply the patches using git apply instead of patch
Need to be in the empserver directory before applying
the "git apply" command, move the "cd empserver" to the
clone step. This change also fixes a bug when using
with an existing repository not being the correct
directory when executing the "git pull" command.
Fixes commit acd768e5e2 as it used git diff format.
2008-02-16 11:09:19 -06:00
Ron Koenderink
5461c86994 Remove unused local variables 2008-02-10 12:56:56 +01:00
Ron Koenderink
acd768e5e2 Update nightly build for recent changes to path.c.in
The three previous commits touching path.c.in broke mingw.patch: the
relative vs absolute paths changes moved the initializers to be
patched to new variables, and the telfil removal messed up the
context.
2008-02-10 12:56:49 +01:00
Ron Koenderink
83f7839d22 Remove the initialization for builtindir, not required
Fixes commit 4bb23dd1.
2008-02-10 11:48:25 +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
3290e87576 Get rid of the need to fix up lchr[].
Mil are not required for building units since 4.0.0.  l_mil was still
initialized to l_item[I_MILIT], and used instead of that in a couple
of places.  Fix those, and remove the initialization.
2008-02-07 08:01:54 +01:00
91eefc3f3a Fix initialization of configdir
Windows code leaked memory (result of _fullpath()).

POSIX code passed a null buffer to getcwd(), which is not portable,
and failed to check for errors.
2008-02-07 08:01:54 +01:00
b76e5a5eed Make conftab.c independent of the current directory
read_builtin_tables() wanted to run in builtindir, and
read_custom_tables() wanted to run in configdir.  Bothersome.  Use new
fopenat() to relax those requirements.

The chdir() satisfying them are now superflous, remove them.
2008-02-07 08:01:54 +01:00
4bb23dd1a6 Make econfig keys data and info work for relative names
File names in econfig need to be interpreted relative to configdir.
This wasn't the case everywhere for keys data and info.

Fix this by changing variables gamedir and infodir to hold absolute
names.  Change builtindir likewise, for consistency.  Store the values
from econfig in gamedir_conf, infodir_conf and builtindir_conf.

Uses new fnameat() to derive absolute names from possibly relative
ones.
2008-02-07 08:01:54 +01:00
7379041d26 Fix title and section header in manual pages
Commit 530deef2 failed to update .TH of fairland(6), files(6) and
pconfig(6).

Commit 530deef2 failed to update .TH of empire(6).

Commit eeb9d3cb created empsched(6) with the wrong .TH.
2008-02-07 08:01:54 +01:00
a38fad4229 Make utility programs abort on internal error
Until now, they tried to recover and continue (debug off).  That's
appropriate only for the server.  The server could be told to abort
instead (debug on, selected by option -d), but not the utility
programs.

Change debug to be on by default, and switch it off early in the
server's main().  No functional change for the server.
2008-02-07 08:01:53 +01:00
a573f44960 Fix unintentionally broad patterns in .gitignore
The patterns intended to match exactly weren't anchored.  In
particular, pattern lib make anything below src/lib/ invisible.
Anchor them all.
2008-02-07 08:01:53 +01:00
Ron Koenderink
70c03561bb Switch nightlybuilds to git
Create a local git repository on the SuSE nightly build machine.
Update local git repository from the Markus's public repository
at the beginnning of the nightlybuilds for SuSE and WIN32.
For the SuSE and WIN32 nightlybuilds drawn from the local
git repository on SuSE machine.
2008-02-04 20:26:46 -06:00
77e95bd788 Clean up library dependencies
Move stuff to untangle the ugly cyclic dependencies between the
archives built for selected subdirectories of src/lib/:

* Move common/io.c to empthread/ because it requires empthread stuff

* Move parts of subs/nstr.c to common/nstreval.c to satisfy
  common/ef_verify.o

* Move getstarg.c getstring.c onearg.c from gen/ to subs/ because they
  require stuff from there

* Move bridgefall.c check.c damage.c empobj.c journal.c maps.c
  sectdamage.c from common/ to subs/ because they require stuff from
  there

* Move cnumb.c from subs/ to common/ to satisfy common/type.o

* Move log.c fsize.c from common/ to gen/ because they really belong
  there

* Move emp_config.c mapdist.c from gen/ to common/ because they really
  belong there, and require stuff from libglobal.a

Also package as/ as libas.a to satisfy common/path.o.

Remaining dependencies:

    lib             needs
    --------------------------------------------
    libas.a         libglobal.a
    libcommon.a     libas.a libglobal.a libgen.a
    libgen.a
    libglobal.a
    liblwp.a        libgen.a
    libw32.a[*]     libgen.a

    [*] Except for service.o, which can only be linked into the server

Link order now: liblwp.a libcommon.a libas.a libgen.a libglobal.a
libw32.a.  The position of libw32.a is not quite right, but works
anyway.
2008-02-03 08:11:13 +01:00
1cbb37d4fb Get rid of src/lib/gen/copy.c
The function that gave its name to this file is long gone, the file's
description is bogus, and it contains just one definition.  Move that
to ../subs/border.c, and delete the file.
2008-02-03 07:44:20 +01:00
3d2518a724 Get rid of src/lib/common/land.c
There are several files with land unit subroutines.  This one is in an
awkward place: it depends on stuff from ../subs, which contributes to
libcommon.a's ugly dependencies.  Move its contents to logical places
(use internal linkage where possible), and remove it.
2008-02-03 07:37:16 +01:00
312e6d4c5b Document econfig key info setting for running without installing 2008-02-02 16:15:40 +01:00
b58bc70d07 Remove telfil, use teldir instead. 2008-02-02 09:22:10 +01:00
f80af5c7da Belatedly update c_form of of show command
It lacked item and news since 4.3.0.
2008-02-02 07:56:49 +01:00
b8a9136242 Trim extra newline from documentation of econfig key update_demand 2008-02-02 07:53:19 +01:00
4fb5f76326 Remove unused non-terminal <VAR> from output of list command
It's been unused since commit 5dec30d6, and its explanation was bogus
before.
2008-02-02 07:50:26 +01:00
Ron Koenderink
eb473a6a24 Add missing expansion island
The number of islands was off by one.  The last island was
created, but not actually placed on the map.
2008-01-27 14:20:51 +01:00
36044a0534 Fix empsched's name in its manual page 2008-01-19 10:32:02 +01:00
db02dda32f Update copyright notice 2008-01-19 10:15:37 +01:00
c297edfb0f Remove bogus comment 2008-01-19 09:00:32 +01:00
d1ebdec5a9 Note generator script in output 2008-01-17 22:12:55 +01:00
853b29dd43 Fix bogus file names in error messages 2008-01-13 11:25:32 +01:00
bcdcbab19c Replace .cvsignore files by .gitignore files 2008-01-13 11:22:33 +01:00
35db407da0 Convert the build process from CVS to git
Detect .git instead of CVS.  Use git-ls-files with git, else
$(srcdir)/sources.mk.  info/findsubj.pl now gets the info files as
arguments rather than from sources.mk.

Remaking info subjects doesn't quite work, but it was broken similarly
before.
2008-01-13 11:17:26 +01:00
544612ed8c 4.3.11 late changes. 2008-01-01 19:22:59 +00:00
e424baab8b (player_coms): Clean up c_form of announce, break, bye and list. 2008-01-01 19:09:38 +00:00
Ron Koenderink
353cb3209b Add HTML links.
Improve description for Autotrading.
2008-01-01 16:26:58 +00:00
Ron Koenderink
20a8cceb0e Add HTML link for info pages. 2008-01-01 16:22:41 +00:00