fmttime2822() prints long with format %d, and passes long to abs().
Harmless, because both int and long are 32 bits in the Windows API.
Clean it up anyway.
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>
Most uses of getrel() have been replaced by the safer relations_with()
in commit 0c60e57..67b9135, v4.3.27. Eliminate the remaining ones:
* Convert rela() to use relations_with(). The case of relations to
self, where the two differ, doesn't occur. The code becomes more
easier to understand, even.
* relations_with() is then getrel()'s last user. Inline.
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>
All callers of getrejects() also check whether the sender is a deity.
Factor out the common code into nat_accepts(), and drop getrejects().
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Communications from deities can't be rejected, but the accept command
fails to consider that detail. Should not normally matter, because
the reject command doesn't let you reject deities. Fix it anyway.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
When sending a telegram, typed_wu() checks whether the recipient is
rejecting telegrams. The check tacitly assumes from == player->cnum.
Happens to be the case, but clean it up anyway.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Announcement rejection is completely broken for deities.
Additionally, deity announcements aren't exempted from rejection, but
that should not normally matter, because the reject command doesn't
let you reject deities.
Broken when announcements were separated from telegrams in Empire 3.
Fix to test the sender's instead of the player's divinity.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Bulletins notifying on a relations change can be rejected just like a
telegram from the country initiating the change, except for one
inconsistency: telegrams from deities are exempt, but bulletins on a
relation change by a deity aren't. Inconsistent since rejecting was
added in Merc Empire.
Change setrel() to treat relation change bulletins the same as tele()
treats telegrams.
Should not normally matter, because the reject command doesn't let you
reject deities.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Fix do_loan() to check !player->god instead of player->cnum != 0.
Screwed up when rejecting was added in Merc Empire.
Should not normally matter, because the reject command doesn't let you
reject deities.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Instead of enumerating all eight combinations of the three flags in a
table, simply print each flag on its own, and drop the table. The old
table depends on the flag encoding, the new code doesn't.
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>
The next commit will create a contact file, and the macro to get a
contact entry will be named getcontact(). Rename the existing
getcontact() out of the way.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Make setcont() update the nation only when it actually changes the
contact value. For added benefit, map all non-zero values to one when
option LOSE_CONTACT is disabled.
This saves I/O, in particular xdump bandwidth.
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>
When option LOSE_CONTACT is enabled, contact is lost after a few
updates. The remaining number of updates is to be decremented by one
each update. However, it's actually decremented every time an active
nation is updated. This makes countries lose contact much too fast,
typically every update. Broken in commit ac25058, v4.3.0.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Interactive edit shows what can be edited, with edit keys and current
values. When option HIDDEN is enabled, "edit c" additionally shows
contact information like "Countries contacted: 1(6) 2(6) 4(5) ".
Lists the numbers of contacted countries and, in parenthesis, how many
updates contact is going to last if option LOSE_CONTACT is enabled.
The line was added along with option HIDDEN in Empire 2. As long as
editing contact isn't implemented, it doesn't belong here. Drop it.
If deities need contact information, we'll have to show it elsewhere.
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>
Grant land units with security capability the same bonus as in convert
and shoot: multiply by (1 + eff/100).
military_control()'s code to count military is now functionally
equivalent to security_strength(), except it has no use for its second
parameter. Change security_strength() to permit a null argument, and
reuse it in military_control().
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Moving stuff out of an occupied sector generally requires "military
control", i.e. you need at least one military for every ten civilians.
Military in land units count. Even when the land unit is loaded on a
ship or land unit. Questionable, because unload need not be possible.
Checking whether unload would be possible is not worth the trouble
here, simply ignore embarked land units.
This affects commands move, explore, sell, set and transport, as well
as the update's distribution and delivery.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Convert and shoot put land units to work regardless of ownership.
Clearly wrong for foreign, non-allied land units trapped in the
sector.
They also happily use land units loaded on ships or land units, unlike
most other commands. Questionable, because unload need not be
possible.
Checking for ownership and load status was neglected when land units
were added in Chainsaw 3. Non-allied land units became possible in
4.0.0.
Checking relations and whether unload would be possible is not worth
the trouble here, simply ignore all foreign and embarked land units.
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>
Land units with capability security reduce the mobility cost and have
their military count double, regardless of efficiency. This lets
players get the benefits of a security unit at a discount: just don't
build it beyond 10%.
Count security unit's military times 1 + eff/100 instead of double.
Change the mobility bonus term from number of security units to sum of
security unit efficiency / 100. Partial fix for bug#64.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>