Fix make dist in a separate build directory without git
In that case, make copied the sources.mk from $srcdir, but unless it
existed already, the peculiar workings of VPATH did us in: make
searched for the target, found it in $srcdir, and the dependency
became circular.
Fix by keeping sources.mk in $srcdir always. We can build it there,
because its contents depends only on git state, not on anything in the
build tree. This avoids the need to copy sources.mk alltogether.
Don't let ships double-retreat first on 'i' and then on 'h'
When a ship is shelled, retreat condition 'i' (injured) applies. When
there's no return fire, 'h' (helpless) applies as well. Ships
retreated twice in that case. Fix that.
Ron Koenderink [Sun, 16 Nov 2008 14:42:42 +0000 (08:42 -0600)]
Log out player when time per day is exceeded
Commit 3da4030 already changed player_main() to log out the player
when m_m_p_d was exceeded in command(). This crept in accidentally.
Complete the job by changing status() to log out the player instead of
downgrading him to visitor status.
Also, change player_main(), command() and status() to apply the time
limit to countries in sanctuary in addition to active countries.
Leave visitors alone, because those are shared logins. Make the
disconnect message to a player consistent for all situations.
Note that commit 875a80d1 already changed player_main() to apply the
time limit only to active countries instead of all, just like status()
does, but neglected to document that.
Capital obliteration failed to charge money and report news
Commit 221e88f1 (v4.3.15) made caploss() expect the new owner in
sct_own, so it can distinguish between sack and obliteration. Commit 0d139ee1 (v4.3.17) broke that in sct_prewrite(): it moved zapping the
sector owner after caploss(), and passed 0 instead of the old owner to
caploss(). Because of that, obliterating a capital didn't make the
news and didn't cost the victim money. Fix that.
Ron Koenderink [Sat, 15 Nov 2008 19:08:19 +0000 (13:08 -0600)]
Rewrite accounting of play time
Replace daychange() and gettimeleft() by update_timeused_login(),
update_timeused() and enforce_minimum_session_time(). The new
code doesn't assume the day is always 24 hours long which can
occur when transitioning into or out of DST and such. Logging
in after more a multiple of 128 days now resets nat_timeused
properly.
Fix nat_timeused calculation on midnight rollover to include
the time since midnight.
struct natstr member nat_dayno and struct player member timeleft
are now unused, remove them.
Ron Koenderink [Mon, 10 Nov 2008 00:06:51 +0000 (18:06 -0600)]
Fix parsing of 24:00 in game_hours and update_demandtimes
daytime() rejects 24:00 as invalid. This makes daytime_range()
fail, is_daytime_allowed() ignore this and later ranges silently.
Broken in commit acdee1e3, v4.2.15.
With RAILWAYS, highway-like sectors double as rail. They need to be
at least 5% efficient to be operational, and then they additionally
extend rail into adjacent sectors that are at least 60% efficient.
New opt_RAILWAYS, SCT_HAS_RAIL(), sct_rail_track(). Update
sector_mcost(), bp_neighbors(), lnd_mar_one_sector() for RAILWAYS
mobility rules. Update sinfra(), spyline(), satdisp_sect() to show
rail track instead of rail infrastructure for RAILWAYS.
New virtual sector selector track, implemented by nsc_sct_track().
We don't want to starve tiny populations, because that would require
players to move trivial amounts of food after explore and such.
growfood() used to simply grow at least 1f when a sector was about to
starve. That food is almost never eaten by a tiny population, so we
effectively got some production without work. Fix by taking away that
free food after people ate, in do_feed().
A sector type's terrain (struct dchrstr member d_terrain) is the
sector type of its underlying terrain. Sector types occuring in
d_terrain are terrain types, and must have their own type in
d_terrain. Players can change sector types only to those with the
same terrain.
The builtin configuration defines terrain types sea, mountain,
wasteland, wilderness and plains. It gives bridge span and tower
terrain sea, and everything else terrain wilderness. Hence, the stock
game remains unchanged.
Deities can use terrain to create sector types that can be developed
only in limited ways.
Ron Koenderink [Tue, 28 Oct 2008 14:48:25 +0000 (08:48 -0600)]
Represent logged in time in seconds rather than minutes
This simplifies things. In particular, it gets rid of random rounding
in getcommand(), which created a variation in the nightly build
depending on whether the update starts before or after the deity logs
out.
Replace struct natstr member nat_minused by nat_timeused, and update
cou_ca[] accordingly (this affects xdump nat). Replace player member
minleft by timeleft, and getminleft() by gettimeleft(). Update
getcommand(), daychange(), player_main(), status() accordingly, taking
care not to change player output. Change edit country key 'u' to work
in seconds.
Ron Koenderink [Sun, 26 Oct 2008 21:56:04 +0000 (15:56 -0600)]
Add more tests to nightly builds
Add Player 02 as an ally for Player 01.
Add tests for telegrams, wall, announce, relationships,
land units, wire, fire, attack, planes, autofish and autooil.
Ron Koenderink [Wed, 8 Oct 2008 13:52:10 +0000 (07:52 -0600)]
Add land units tests to nightly builds and improve economy
Up the bar production. Start education and tech for player 08
Improve the general economy for player 08. Add land units building
tests to player 01, including ensuring the tech is high to build.
Ron Koenderink [Mon, 6 Oct 2008 23:58:59 +0000 (17:58 -0600)]
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.
Ron Koenderink [Sun, 28 Sep 2008 15:03:50 +0000 (09:03 -0600)]
Add xdump tests to nightly builds
Add xdump meta test to Turn 00 Player 02 to verify player visibility.
Add xdump test to Turn 99 Player 00 to verify xdump output.
Add xdump test to Turn 99 Player 01 to player's version of xdump
output.
Ron Koenderink [Sat, 27 Sep 2008 01:47:16 +0000 (19:47 -0600)]
Move test scripts from nightlybuild.sh to separate files
The test scripts are now in nightly/tests/TURN/PLAYER. For each turn,
the update script is executed first (except for turn 00), and then all
the player scripts in the appropriate turn directory. This runs
runfeed() in different directories; change it to accomodate for that.
The update script runs "report *" on all updates. Before, it ran only
on some of them.
Ron Koenderink [Fri, 26 Sep 2008 03:12:24 +0000 (21:12 -0600)]
Correction for Ubuntu Conversion
Change nightlybuild.sh to allow the setting of the pthread
option for ./configure. Remove the incorrectly added xml
header line from the ubuntu-pthread.i386.config file.
Disable incorrect autmatic supply in load and lload
load_land_ship() and load_land_land() automatically resupply the land
units they load. This can draw supplies from the sector where the
land units are. When load() and lload() later update the sector, they
wipe out the update made for drawing supplies, and we get a seqno
mismatch oops. Highly abusable. Disable for now.
Make unit_give_away() immune to infinite recursion
Put the unit before recursing into its cargo. This breaks cycles in
the "is loaded on" relations. Such cycles exist only in a corrupt
game state. Mildly inefficient, because callers typically put the
unit again.
Wipe orders when ship, plane, land unit or nuke changes owner
Use new unit_wipe_orders() for violent takeover (takeover_unit() on
behalf of assault, attack, board, lboard, paradrop and pboard), and
peaceful takeover (unit_give_away() on behalf of arm, disarm, load,
unload, lload, lunload, scrap, scuttle, tend, trade).
Before, takeover_unit() cleared only group, mission and ship retreat
orders, and unit_give_away() only group and mission. Orders that
weren't cleared:
* Mission op area (visible in xdump)
* Ship autonav orders
* Ship sail path including ship to follow and mobility quota
Factor new takeover_unit() out of takeover_ship(), takeover_plane(),
takeover_land(). This fixes the following bugs in assault, attack,
board, lboard, paradrop and pboard:
* When the "land unit loaded on land unit" relation had a cycle,
takeover_land() went into an infinite recursion. Such cycles exist
only in a corrupt game state.
* Nukes armed on planes weren't taken over along with their plane.
Broken in commit 2e40a4bb, v4.3.3.
* Taking over land units with negative mobility increased mobility to
zero. Ditto planes embarked on ships or land units.
* Taking over planes embarked on ships or land units didn't clear
their wing.
* Taking over planes and land units updated their MOB_ACCESS timestamp
(pln_access, lnd_access), except for planes not embarked on
anything. This had no effect.
Trade code can't quite decide whether negative trd_unitid or zero
trd_owner marks unused slots. The former is a bad idea, because blank
slots have a zero trd_unitid.
Make sure to zero trd_owner when setting trd_unitid to negative value
in trad() and check_trade(). This fixes recognition of unused slots
in set (broken in commit e16e38df, v4.2.18) and xdump (never worked).
When giving away cargo by scrapping or scuttling its carrier, the
cargo's cargo wasn't given away. Happened for instance when a ship
carrying a land unit carrying a SAM got scrapped.
Also, wing, army and mission weren't cleared.
To fix, create unit_give_away() and use it in unit_drop_cargo().
Factor unit_drop_cargo() out of scra(), scuttle_ship(),
scuttle_land(), fix it up:
* Some messages were sent as bulletins instead of printing them.
* Nukes were always destroyed. They're now treated exactly like other
cargo.
* scuttle destroyed some cargo silently, and listed other cargo as
"scuttled". It now simply lets unit_update_cargo() running from
carrier prewrite callbacks list all cargo "lost".
Simplify its callers. scuttle_ship() and scuttle_land() are now
trivial, inline and remove.
When called from the scuttle command, scuttle_tradeship() asks for
confirmation when scuttling doesn't pay. When called from the autonav
code, it can't ask. Change it to fail then, and use that in
nav_ship() to avoid scuttle where it doesn't pay. Also simplify some.
Fix when scuttle_tradeship() asks for confirmation
Fix scuttle to ask for confirmation when scuttling a tradeship in an
unsuitable sector even when the tradeship is pirated. Broken when
commit a99bc3be (v4.2.13) suppressed that for pirated tradeships
wholesale because it let pirates ferret out where the ship was built.
You can now scrap ships in own or friendly, efficient harbors, planes
in own or allied, efficient airfields, and land units in any own or
allied sector.
When something can't be scrapped because of these rules, print a
suitable message.
Before, you could scrap ships regardless of relations to sector owner
(info claimed friendly was required), land units regardless of
relations, but not while on ships, and planes even in friendly
airfields (info claimed allied was required).
When scrapping in a deity sector, scrap claimed it gave the cargo to
POGO, which is somewhat bogus, as POGO can't own such stuff.
Fix scrap and scuttle output when there's output about cargo
scra() and scut() printed their "scrapped in" / "scuttled in" message
in two parts. Messages for scrapped / scuttled cargo were printed
between the parts. Fix by printing in one go, after the cargo
messages.
Until commit 3e370da5, dead planes had to be explicitely taken off
their carrier to update load counters. This is no longer necessary;
simplify pln_put1() and scut(). scut() got it wrong, by the way: it
failed to take planes off land units.
EF_PLANE is closed before EF_LAND: if a land unit carries a plane, the
plane goes away before its carrier, and unit_onresize() oopses. Fix
by not checking cargo list consistency there when the file is already
gone.
unit_cargo_init() has a similar issue, at least theoretically: it
rebuilds cargo lists one after the other. Zap them all first.
Ron Koenderink [Sat, 13 Sep 2008 23:33:24 +0000 (17:33 -0600)]
Do not update player's bank balance when the change is zero
Hackish work around for a race condition in the nightly build's
regression tests: sometimes the update starts right after the
force command yields, sometimes a bit later. If it is late, we
use one random number here, for the bye, and throwing off the
random sequence.
Treat zero owner just like efficiency below minimum. Before, cargo
was taken off carriers only when efficiency fell below minimum, not
when owner changed to zero.
Run item_prewrite() unconditionally, for simplicity.
Ron Koenderink [Sat, 13 Sep 2008 21:18:29 +0000 (15:18 -0600)]
Allow any length thread names for WIN32
Dynamically allocate the string space for thread
name in WIN32 (ntthread.c) thread space. This
makes the WIN32 more consistent with the other
environments. It also addresses WIN32 issue of
the print width of 17 being used and only having
space for 16 characters in the fixed allocation.
Use new snxtitem_cargo() to simplify a couple of loops
Change snxtitem_all() loops that skip everything but a carrier's cargo
to use snxtitem_cargo() in scra(), scuttle_ship(), scuttle_land(),
takeover_ship(), takeover_land(), trade_desc(), feed_ship().
Rewrite the broken code to move cargo with its carrier
The old code did not move a carrier's cargo (planes, land units,
nukes) when the carrier moved. Instead, it fixed up the location in
the postread callback. Anything not going through ef_read(), in
particular the update, saw it in its old, incorrect location, until a
fixed up copy got written back.
Moreover, the timestamp did not change when cargo moved, so
incremental dumps did not pick up the movement.
The new code moves the cargo along with the carrier.
New unit_update_cargo() moves or destroys a carrier's cargo (planes,
land units, nukes) along with the carrier. Call it from
shp_prewrite(), pln_prewrite() and lnd_prewrite() when the carrier
moves or gets destroyed.
Remove the code to destroy cargo from shp_prewrite(), pln_prewrite(),
lnd_prewrite().
Remove the code to fix up cargo location from pln_postread(),
lnd_postread(), nuk_postread().
This changes the message for ship and land unit cargo getting
destroyed from "sunk" and "MIA" to "lost".
Make the item iterator capable of iterating over a cargo list
New snxtitem_cargo() initializes an iterator for a cargo list, with
new enum ns_seltype member NS_GROUP and new struct nstr_item member
next. Extend nxtitem() and nxtitemp() to step through the list.
Zap next uid in clink_rem(), check it in clink_add()
The former ensures that next links are valid even for uids not on any
list. The latter oopses on adding an uid to a list when it is already
on a list, unless it is at the tail.
Ron Koenderink [Fri, 12 Sep 2008 01:06:10 +0000 (19:06 -0600)]
Ensure the empth_sleep() always yields for WIN32
The WIN32 version did not block when the sleep was
already reached by the time empth_sleep() did the
time remaining calculation. The other versions
of empth_sleep() do always yield.
Ron Koenderink [Thu, 11 Sep 2008 20:58:32 +0000 (14:58 -0600)]
Use empty schedule file for the nightly build
This ensures that no unplanned updates occur
during the nightly build sequence. Remove
unnecesary enables and disables from the script.
Remove unnecessary argument for force command.
Instead of counting the load with lnd_nland() / lnd_nxlight(), check
whether there's at least one loaded with lnd_first_on_land() /
pln_first_on_land().