Unlike tend, ltend does nothing silently when asked to tend zero
commodities. This may leave the player guessing why the command did
nothing. Report the reason and fail the command, just like tend does.
While there, improve the prompt to match tend's.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
We silently ignore target ships that can't take any more of the tended
commodity. This may leave the player guessing why the command did
nothing. Report the reason like this:
cs cargo ship (#150) can't hold more guns
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
We report
frg frigate (#170) cannot hold any uncompensated workers
only when tending from target to tender, not for the other direction.
Report it there, too.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Foreign target ships are silently ignored when tending civilians.
This may leave the player guessing why the command did nothing.
Report the reason similar to load does:
Your civilians refuse to board cs cargo ship (#162)!
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Target ships that can't be tended at all are silently ignored. This
may leave the player guessing why the command did nothing. Report
them, but only when explicitly named.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Tending to a dead ship destroys, and tending from a dead ship revives.
Has always been that way. Not actually a problem for ltend anymore,
because the dead can't carry or be carried since commit 64a53c90f0,
v4.3.17.
Fix by checking !own in addition to !player->owner
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
The bulletin reports the total amount tended to all ships so far.
Broken in commit 1de48e53da (v4.3.0), not fixed in commit 7cc14a2c9a
(v4.3.1). Fix the bulletin to report the amount tended to this ship.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Report the exact ship, like
frg frigate (#170) cannot hold any uncompensated workers
instead of reporting just the ship type, like
A frg frigate cannot hold any uncompensated workers
This is a bit more useful when tending to more than one ship.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Transferring commodities from tenders to targets continues with the
next tender when a target can't hold this kind of commodity.
Transferring them from targets to tenders fails (ltend) or stops
tending (tend) when a tender can't hold this kind of commodity. Has
always been that way.
Change the latter to continue with the next tender.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Transferring commodities from tenders to targets fails when a tender
doesn't have any. Transferring them from targets to tenders continues
with the next target when a target doesn't have any. Has always been
that way.
Change the former to continue with the next tender.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
We silently ignore foreign ships and land units. This may leave the
player guessing why the command did nothing. Report explicitly named
ones like this
You don't own ship #160!
except for tend's target ships. Nice reporting is a bit more involved
there, because you can tend to foreign target ships as long as they're
friendly. Left for later.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Land units not on the tender are silently ignored. This may leave the
player guessing why the command did nothing. Reporting them all would
be annoying; I just changed tend to report only explicitly named ones.
Make ltend behave the same.
This does add a related annoyance: ltend can complain "not on ship"
when tending explicitly selected land units from multiple ships.
Tolerable.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
The quickest way to tend all land units on a ship is to select all
land units with '*'. However, tend then prints a "not on ship"
message for every land unit not on the tender, as the load-tend test
demonstrates. Annoying. Suppress this message unless the land unit
was explictly selected by UID. Similar to how load and unload
suppress messages, only they get the condition wrong (to be fixed
soon).
A related annoyance remains, also visible in the load-tend test: tend
can still complain "not on ship" many times when tending explicitly
selected land units from multiple ships.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Each land unit is tended to each target ship in turn, and ends up on
the last one that can take it.. The load-tend test demonstrates this
with command "tend land 173 s 150/165":
spy infiltrator #320 transferred from sbc cargo submarine (#173) to cs cargo ship (#150)
spy infiltrator #320 transferred from sbc cargo submarine (#173) to ls landing ship (#165)
spy infiltrator #321 is not on sbc cargo submarine (#173)!
spy infiltrator #322 transferred from sbc cargo submarine (#173) to cs cargo ship (#150)
spy infiltrator #322 transferred from sbc cargo submarine (#173) to ls landing ship (#165)
Has been that way ever since Empire 2 added tending of land units.
Fix by breaking tend_land()'s loop over all target ships after a
successful transfer.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Exercise load, unload, lload, lunload, tend, and ltend.
Notable coverage gaps:
* Effect on land unit fortification
* Effect on mission and retreat orders
* Ships, land units and planes on sale (option MARKET 1)
* Transmission of plague (option NO_PLAGUE 0)
* Land units loading and unloading civilians (need a custom land unit
type capable of carrying civilians)
* load refusing to load x-light planes (need a custom ship type that
can carry helo but not x-light)
* load and lload refusing to load land units carrying land units, and
lload refusing to load land units onto land units that are being
carried (need a custom non-heavy land unit type that can carry land
units)
* tend refusing to tend non-light land units to non-supply ships, or
to supply ships without room (need custom a non-light assault land
unit type)
This test exposes bugs. They're marked "BUG:" in the test input.
There are also oddities marked "odd:", and usability issues marked
"usability:".
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
The edit command doesn't support editing plane fortification. Has
always been that way. Implement it as key 'F'.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Planes 7/8 aren't visible in output, because the test neglects to set
their owner. Messed up in commit commit efec441, v4.3.33. Correct
that oversight.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
The edit command doesn't support editing bars on ships and land units.
Has always been that way. The stock game's ships have always been
unable to load bars. Not the case for land units.
Unfortunately, the obvious key 'b' for bars was burned on plague time
in 4.0.17. Use key 'B' instead.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
The test covers only 'c' and 'l' with give, 'm' and 'g' with edit.
Cover the other item types, too.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
print_items() uses field widths between 3 and 5. They go back all the
way to Empire 1, and are fine for the stock game. Widen the narrower
ones to 5, because a consistent field width looks tidier, and can
avoid misaligned columns with customized ships and land units.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Fix the bug demonstrated by the previous commit:
take_casualties_from_lands() limits total casualties to @each. It
should limit each land unit's casualties, and only if !may_kill. This
can lead to fewer casualties than called for; oops in
take_casualties(). Broken in commit 025e9cc25, v4.4.0.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Tweak military in land units to demonstrate that
take_casualties_from_lands() can kill fewer military than it should.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Commit 35ecc008c fixed take_casualties() to destroy land units only
when casualties demand it. This test demonstrated the change: inf#29
no longer dies. Good. However, this lost coverage of land units
dying in a sucessful defense. Bad.
I could tweak inf#29 to get destroyed again, but that would lose
coverage of the bug fixed by commit 35ecc008c. Make linf#28 die
instead.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Since commit 1ec9b94, we derive the version number from git tags with
build-aux/git-version-gen. When a shallow clone doesn't include a
suitable tag, this fails, and make refuses to build anything. Since
Travis uses git-clone --depth=50, it'll break as soon as we've got
more than 50 commits since the last release.
Support arbitrarily shallow clones for limited purposes like testing
by falling back from a proper V.N-H version number to UNKNOWN-H.
To guard against use of such builds for other purposes, log a warning
on server startup, and print one on player login.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Commit 1ec9b94 normalized version numbers in test output to 4.3.34,
because that was thought to be the next version then. 4.3.34 has
become 4.4.0 meanwhile. Update the normalization just to avoid
mention of 4.3.34.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
The choice of "to minesweep" in "`d' to drop mines, and `m' to
minesweep" is obviously intentional. But saying it in standard
English instead is at least as clear, so do that.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Relations state is relatively bulky: it's a big chunk of struct
natstr, and adds 200 bytes per country to xdump nat.
Relations change rarely. Rewriting it to disk on every nation update
and retransmitting it in every xdump nat is wasteful.
To avoid this waste, move relations state to its own struct relatstr.
This is of course an xdump compatibility break. We're not maintaining
xdump compatibility in this release.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
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>
Reject state is relatively bulky: it's a big chunk of struct natstr,
and adds almost 200 bytes per country to xdump nat.
Reject state changes rarely. Rewriting it to disk on every nation
update and retransmitting it in every xdump nat is wasteful.
To avoid this waste, move reject state to its own struct rejectstr.
This is of course an xdump compatibility break. We're not maintaining
xdump compatibility in this release.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
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>
Contact state is relatively bulky: it's a big chunk of struct natstr,
and adds almost 200 bytes per country to xdump nat for deities.
Contact changes rarely. Since we avoid unnecessary updates, it
doesn't change at all unless option HIDDEN is enabled. Rewriting it
to disk on every nation update and retransmitting it in every deity
xdump nat is wasteful.
To avoid this waste, move contact state to its own struct contactstr.
This is of course an xdump compatibility break. We're not maintaining
xdump compatibility in this release.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
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>
A country must always be in contact of itself when option HIDDEN is
enabled. The code ensures this by establishing contact whenever a
player logs in, in init_nats(). This is not the proper place. Game
state should be initialized in empfile's oninit() callback, in this
case nat_oninit(). Do that, and drop the putcontact() from
init_nats().
Note that option LOSE_CONTACT only affects contact to other countries:
agecontact() doesn't age the country's contact to itself.
Use the opportunity to initialize contact so that getcontact() works
even when HIDDEN is disabled. Just cleanup, it isn't actually called
then.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Belatedly update fairland.xdump for commit f4f0482, v4.3.33.
The commit made empdump omit redundant data, shortening the
final.xdump. The matching manual update to fairland.xdump was
forgotten.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Land units with capability security get a combat bonus regardless of
efficiency. This lets players get the benefits of a security unit at
a discount: just don't build it beyond 10%.
Multiply the combat bonus by eff/100. Together with the previous
commit, this closes bug#64.
Note that the the strength of a security unit's commando raid is
already proportional to its efficiency.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Infrastructure requires lcms and hcms to build. The build materials
are exposed as infrastructure columns lcms, hcms (struct sctintrins
members in_lcms, in_hcms). They are per point of efficiency. In
contrast, sector and unit build materials are defined for 100%.
We want to define build materials for 100% now, for flexibility and
consistency, and we want to optionally support more build materials in
the future. Replace members in_lcms and in_hcms by array in_mat[],
and provide selectors l_build and h_build.
Additionally provide selectors for all other item types, with value
zero, to help clients prepare for future additional materials. Use
CA_DUMP_ONLY to keep them out of configuration tables until they
actually work.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Infrastructure build cost is defined by infra column dcost (struct
sctintrins member in_dcost). It's the cost per point of efficiency.
In contrast, sector and unit build cost is defined for 100%, by
sect-chr, ship-chr, plane-chr, land-chr, nuke-chr column cost.
Switch to build cost per 100%, for flexibility and consistency:
replace struct sctintrins member in_dcost by in_cost, and selector
dcost by cost.
With cost values that aren't multiple of 100, the build cost may have
to be rounded. Do this exactly like we round sector build cost: the
amount is limited to money * 100 / cost rounded down, but the money
charged is actual amount * money / 100 rounded randomly.
Do the same for mobility use: replace struct sctintrins member
in_mcost by in_bmobil, and selector mcost by bmobil, with similar
rounding.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Guerrilla are created loyal to the old owner. When the sector
converts, they switch their allegiance to POGO. This is a bit of a
hack.
When guerrilla win their fight for freedom in an old-owned sector, the
old-owner duly changes to POGO. However, the owner doesn't. Broken
in 4.2.6. The "Sector X,Y has been retaken!" message is still sent to
the "new" sector owner.
Simply restoring the owner change lost back then would restore a bug
that goes back to 2.3.7: takeover() doesn't run when an old-owned
sector is liberated. So fix the bug by making that unconditional.
Land units reported captured are actually destroyed, because POGO
can't own any. Oh well.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
take_casualties() first applies casualties without destroying land
units, and if any remain, applies them by destroying land units. This
is wrong, because the remaining casualties may not suffice to actually
kill. Has been that way since land units were added in Chainsaw 3.
Apply remaining casualties more carefully: destroy land units only
when efficiency falls below 10%.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>