External use of prod_materials_cost(), prod_resource_limit() went away
in commit 4a714a37d "production: Use update code instead of
duplicating it", v4.4.0.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Unused since commit beedf8dce "retreat: Rewrite automatic retreat code
to fix its many bugs", v4.3.33.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Commit 555de3100 (v4.3.0) added these macros so xdump tables loan and
treaty can share an agreement_statuses table. Treaties are gone since
commit a109de948 (v4.3.33). Drop the macros.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Portability issue: prototypes.h uses enum ns_seltype, defined in
nsc.h. GCC is fine with that; it supports incomplete enum types as an
extension. Broken in commit 157ae8ec2 "Clean up superfluous include
of nsc.h in prototypes.h", v4.3.27. Moving sarg.c stuff to nsc.h
fixes it.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
lwpSigWait() was designed to resemble sigwait(). It doesn't anymore.
Drop the awkward argument, and use the return value instead.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
LWP's use of sigset_t is problematic.
To iterate over a sigset_t, it uses NSIG, which is not portable: BSD
and System V provide it, but it's not POSIX.
To record signals caught, it updates a sigset_t variable from a signal
handler. The variable isn't volatile, because we'd have to cast away
volatile for sigaddset().
Replace sigset_t by an array of signal numbers terminated with 0.
Since lwpInitSigWait() needs to store the signal set for
lwpCatchAwaitedSig() anyway, there is no need to pass it to
lwpSigWait(). Drop its parameter.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Configuration tables product, sect-chr, ship-chr, plane-chr, land-chr,
nuke-chr have a bit of extra space deities can use for customizing
their games. Give them more: enlarge product from 23 to 31
entries (plus one sentinel), sect-chr from 39 to 63, ship-chr from 47
to 127, plane-chr from 47 to 127, land-chr from 31 to 127, and
nuke-chr from 20 to 63.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Macro SHP_TYPE_MAX is the largest possible ship type number. It is
only used to size mchr[], and we need + 2 there. Replace by MCHR_SZ
for simplicity.
Same for LND_TYPE_MAX, PLN_TYPE_MAX, P_MAX, and SCT_TYPE_MAX: replace
by LCHR_SZ, PLCHR_SZ, PCHR_SZ, and DCHR_SZ.
Same for N_MAXNUKE, except that one is more than the largest type
number. Replace by NCHR_SZ.
For consistency, define ICHR_SZ and INTRCHR_SZ for sizing ichr[] and
intrchr_sz[].
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>
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>
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>
Put the new function security_strength() next to military_control(),
because that one does a similar count.
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>
Assaulting a foreign sector with nothing but spies is special: the
spies sneak ashore. It is, however, more special than it should be:
the spies use no mobility and ignore landmines. They do use mobility
and hit landmines in other assaults. Assaulting your own sector with
nothing but spies is more costly and more risky than assaulting a
foreign one. This makes no sense. Has been that way since spies were
added in 4.0.0.
It's that way because sneaking ashore uses its own code to move the
spies instead of move_in_land() via att_move_in_off(). It can't use
move_in_land(), because that prints an unwanted "now occupies"
message, and destroys the list of assaulting units, which we still
need to catch and shoot spies.
Factor the code to move attacking land units to the target sector out
of move_in_land() into att_move_land(), and use that for sneaking
ashore. This makes the spies use mobility and hit landmines even when
they sneak.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
News reporting merges news items into recent items with same contents,
until their count reaches 127. Raise that limit to 65535, by making
struct nwsstr member nws_ntm unsigned short. Size of struct nwsstr
stays the same on all common machines.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Virtual selectors can't be used in xundump, since we lack a setter to
go with ca_get(). verify_ca() verifies they don't occur in tables
that can be xundumped.
When I restricted xundump to tables with a file name (commit 029d929,
v4.3.28), I neglected to update the test in verify_ca().
Factor out the correct test into xundumpable(). Use it to fix
verify_ca().
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
People in sectors get plagued, then taxed or paid, then fed. People
on ships and land units get paid, then fed, then plagued. Sectors
were messed up when Empire 3 made the update code work for budget.
Change sectors back to how they worked before Empire 3: move do_feed()
from produce_sect() to prepare_sects(), and delay do_plague() until
after do_feed(). People in sectors now get taxed, paid and fed even
when they die of the plague, just like they do on ships and land
units.
Because do_plague() now runs after populace(), the latter's handling
of people dying off doesn't cover plague anymore. Delay it to the
very end of prepare_sects().
Additionally, move feeding and plaguing from upd_ship(), upd_land() to
prep_ship(), prep_land(), for consistency with sectors.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>