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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Planes and land units on ships are sold along with the ship, but trade
showed them only when SHOWPLANE was enabled. Show them always.
Planes on land units are not sold along with the land unit, but trade
showed them when SHOWPLANE was enabled. Don't.
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
* Plane range limit
* Land unit retreat orders and retreat percentage
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).
Use unit_drop_cargo() to drop a sold land unit's cargo.
Use unit_give_away() to transfer ownership. This fixes the following
bugs and misfeatures:
* Sold nuke wasn't taken off its plane. Could not happen before
commit 2e40a4bb, v4.3.3.
* Nuke on a plane wasn't sold along with the plane. Broken in commit
2e40a4bb, v4.3.3.
* Planes and land units on sold ships got their mobility zeroed.
* Planes on sold ships didn't get their wing reset.
Use unit_give_away() in gift(). This fixes a number of bugs:
* Nukes on planes weren't given away along with the plane.
* Likewise for land units on land units (can't happen in the stock
game).
* Mission was not cleared by unload land/plane, lunload land/plane,
and lload plane, except for planes on land units.
* Wing and army were never cleared.
It also happens to suppress information on planes given away along
with their land unit carriers. Shrug.
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.