Commit graph

4090 commits

Author SHA1 Message Date
bd453cd821 Fix how empdump rejects attempt to split table sect
Split tables require the record index in the leftmost column.
defellipsis() correctly rejects "..." when the table doesn't have one.
It fails to reject it when it has one that is NSC_EXTRA, and thus not
permitted in a dump.  This is the case for table sect.  defellipsis()
happily succeeds, then chkflds() demands column "uid" if it's missing,
and rejects it if its present.
2011-06-25 16:50:05 +02:00
b40741dc5f empdump failed to catch some invalid column names
It missed those with more flags than just NSC_EXTRA set: table sect
name uid, table nat names passwd, xorg, yorg, contacts, rejects.
Since xundump() doesn't provide space for these, the bug could lead to
buffer overruns.  Fixes flawed commit 726a8e3d, v4.3.12.
2011-06-25 16:50:05 +02:00
7e95b52bce Fix empdump to check for truncation failure
xubody() neglected to check ef_truncate()'s return value.  Two failure
modes: invalid arguments, and ftruncate() failure.  The former
shouldn't happen, and the latter can happen only for file-backed
tables, hence only in empdump -i.
2011-06-25 16:49:58 +02:00
5cedc533f8 Make xundump report invalid record IDs
It failed silently before.
2011-06-25 16:49:57 +02:00
50070a8f9a Make xundump reject numbers that don't fit into integral field
Numbers are read into a double, then cast to the field type.  The cast
may change the value.  Flag that as error, except for floating-point
fields.
2011-06-25 16:49:57 +02:00
029d929b1b Restrict xundump to tables with a file name
Tables with a file name are: any game state, and any table that's
initialized from a .config file.

Tables that are no longer customizable: "updates" (customization had
no effect, because update_get_schedule() overwrote it), "table",
"meta" and the symbol tables (customization couldn't change them
anyway), and news-chr (customizing r_newsstory[] was kind of neat, but
unsafe because they are format strings for sprintf()).
2011-06-25 16:47:57 +02:00
573d3fe870 Fix xdump updates not to dump bogus extra updates
"xdump updates" believes there are always 15 (UPDATE_TIME_LEN - 1)
scheduled updates.  When fewer than 15 updates are scheduled, it shows
whatever crap update time happens to be in the unused part of
update_time[]: the initial zero or a previously scheduled update.

Root cause is that table EF_UPDATES has always UPDATE_TIME_LEN - 1
entries, which is incorrect when fewer updates are scheduled.  Only
xdump is affected, as the other users ignore the length and stop at
the sentinel.

Fix update_get_schedule() to resize table EF_UPDATES.
2011-06-25 16:45:31 +02:00
5b9d31a4b3 Check record uid comes first in split config tables
setnum() requires the record uid to come first, so we better ensure it
does.
2011-06-25 16:45:31 +02:00
cb3e35cb3a Don't stop checking xdump field headers when join field is missing
Also improve the error message a bit.
2011-06-25 16:45:31 +02:00
6e4772b175 A few comment fixes for nsc.[ch] file.[ch] 2011-06-25 16:45:31 +02:00
03a2c61de4 Better document how .config must match compiled-in UIDs 2011-06-25 16:45:29 +02:00
221268e0e1 Provide proper ca_table for carrier unit# selectors
Makes ef_verify() check carrier UIDs are sane.  Partially protects
unit_cargo_init(), which oopses on bad carriers.

This has become possible only since commit 64a53c90 (v4.3.17) set
their values to -1 in newly created units.  Before, they were zero in
units that had never been used, and a proper ca_table would have made
ef_verify() fail when unit#0 didn't exist.

The only unit# selectors left without a proper ca_table are ship's
follow, lost's id and trade's unitid.  Document why.
2011-06-25 16:44:04 +02:00
54fa510425 Update examples in doc/xdump to current server's output
The NSC_CONST flags added in commit fa63f87b have always been missing
here.  The previous commit changed xdump meta meta.  Other than that,
it's just different encodings.
2011-06-25 16:44:04 +02:00
b461cd3ae7 Provide proper ca_table for meta selector table
No idea why it was missing.
2011-06-25 16:44:04 +02:00
19215160f4 Refer to table names instead of C identifiers in .config
The C identifier permits looking up the table in the source.  The
table name permits lookup with xdump.

Coders should know how to go from table name to C identifier.  Deities
aren't all coders; we shouldn't ask them to guess table names from C
identifiers.
2011-06-06 19:24:13 +02:00
97f475b6c1 Oops in verify_row() when non-integral selector references a table 2011-06-06 19:24:13 +02:00
e1caa11733 Don't ignore non-virtual NSC_EXTRA columns in ef_verify.c
These are commonly timestamps (no verification implemented), or
aliases for a non-extra column (which gets verified).  Commit 49780e2c
(v4.3.12) added the exception: EF_SECTOR's uid.  Proof by example that
ignoring these columns is wrong.  Fix: ignore only virtual columns.
2011-06-06 19:24:13 +02:00
ed715061be Fix use-after-free when plane gets shot down or aborted by flak
ac_fireflak() dereferenced plp after ac_planedamage() freed it.
Broken in commit 16b16e34, v4.3.27.  Diagnosed with valgrind.
2011-06-06 19:21:09 +02:00
de9d7b011f Drop superfluous parameter vec[] of build_ship() & friends
All callers pass sp->sct_item.
2011-05-29 15:45:11 +02:00
6b0a70d3d1 Better diagnostics when build can't find suitable sectors
Report "No sectors" when there are no *owned* sectors, instead of "Bad
sector specification" when there are no sectors at all.
2011-05-29 15:45:11 +02:00
5fb330cfdd Clean up buil()'s variable declarations 2011-05-29 15:45:11 +02:00
c6137c7ba2 Make "build n" accept the optional tech argument
It has currently no real effect on the nuke built (nukes don't improve
with tech), but the special case is ugly, and is inconsistent with
info build.
2011-05-29 15:45:11 +02:00
61e00d5559 Simplify buil(): factor "can't build" handling out of switch cases 2011-05-29 15:45:03 +02:00
164b90760f Simplify buil(): factor getting third argument out of switch cases 2011-04-23 18:11:42 +02:00
98a9b53c0f Simplify buil(): replace a switch by a function pointer
To enable that, make build_ship() & friends all take the same int type
argument instead of each one its own pointer.  Passing pointers
triggered "may be used uninitialized" compiler warnings (the code was
safe despite the warnings).
2011-04-23 18:11:42 +02:00
8f6c4f18d7 Don't truncate research before multiplying with drnuke_const
For drnuke_const 0.33, research level 92.4 now suffices for a tech 280
nuke.  Before, you needed 93, which was inconsistent with what
version's promise "need 0.33 times the tech level in research".
2011-04-23 18:11:42 +02:00
316436bcfa Create nukes at the tech level permitted by research
The tech level is visible to players, but currently has no effect.
2011-04-23 18:11:42 +02:00
df07e45b70 Bridge building required 0.005 tech less than advertized, fix
Has been that way since bridge building required tech.
2011-04-23 18:11:42 +02:00
9ef7200406 Simplify build_bridge(): replace a switch by a function pointer 2011-04-23 18:11:42 +02:00
0ec19fe81e Factor bridge building out of buil()
Also avoids a "may be used uninitialized" compiler warning (the code
was safe despite the warning).
2011-04-23 18:11:38 +02:00
bc09ffde00 Move bridge building functions together, rename
Rename build_bridge() to build_bspan(), and build_tower() to
build_btower().
2011-04-23 18:09:38 +02:00
d7e0a7088c Check build's first argument before asking for the second 2011-04-23 18:09:05 +02:00
4c1f8ead27 Implement toggle techlists for show nuke
This was probably neglected when the techlists feature was added in
v4.0.0, because compiled-in nukes were sorted by tech, unlike ships,
planes and land units.  Customization can break that.
2011-04-23 07:04:42 +02:00
0846ebb440 Rewrite implementation of toggle techlists in show
To get rid of the ugly global variables.

Unlike before, the sort by tech is stable.
2011-04-23 07:04:42 +02:00
746aa60530 Fuse a few pr() in show_ship_stats() & friends
Also trim trailing space in output.
2011-04-23 07:04:42 +02:00
a474791e7b Belatedly clean up after commit 3b4de2fe Remove option FUEL 2011-04-23 07:04:42 +02:00
c15df51e27 Fix "show land s" to show columns xpl and lnd again
Broken in commit 3b4de2fe, v4.3.15.
2011-04-23 07:04:42 +02:00
02837d2b02 Factor show_load() out of show_ship_capab(), show_land_capab() 2011-04-23 07:04:42 +02:00
d4818ddb3b Simplify show_capab(), don't print trailing space 2011-04-23 07:04:42 +02:00
5f7b92e3ee Factor show_capab() out of show_ship_capab() & friends 2011-04-23 07:04:42 +02:00
6dd3097e78 Bump version to 4.3.28 2011-04-22 17:24:05 +02:00
Ron Koenderink
fc779dd47a Fix compile under Window MinGW environment
Switch to __int64 from _int64.  Change the constant
declaration to use LL instead of a cast.
2011-04-18 19:17:12 +02:00
61fa1c026b Clean up extra headline in info Bridges 2011-04-18 19:17:12 +02:00
4078c31713 Update info History and Overview to cover 1998-present 2011-04-18 19:17:11 +02:00
c1cdc7aa22 Clean up info Bugs
Add bug reporting instructions.

Drop the bugs documented as fixed.  File was last changed in Empire 2,
so these have been fixed for a while...

Remaining bugs:

    The classification scheme used by report is dumb.

It still is.

    You can make a sector temporarily useless by filling up all its
    fields with delivery and distribution information.  This is useful
    when an enemy is trying to capture the sector (his mil don't have
    room to move in :-) You have to halt some of the deliveries or
    distributions to make room for the military to move in.  (Mostly
    fixed by changing the number of available fields)

Fixed since 4.2.14 eliminated `variables'.  Delete.

    Warehouses can't distribute all commodities simultaneously, due to
    limited fields for this information.  This becomes a problem if
    you have a countrywide network of warehouses distributing to each
    other.  (Mostly fixed by changing the number of available fields)

Fixed since 4.2.14 eliminated `variables'.  Delete.

    You can sometimes move small quantities of certain items from
    warehouses at no mobility cost, even into mountains (this is my
    favorite bug, I'd hate to see it fixed :-)

Feature; delete.

    Guerrillas don't seem to carry the plague.

They still don't.

    You can sometimes trick someone into paying a huge price for
    commodities by changing the price suddenly.  Therefore one should
    always check prices when buying commodities.

You can't increase prices anymore.  Delete.

    When two countries are attacking each other simultaneously, you
    can sometimes move into a sector he is in the process of
    attacking.  If you get the timing right, he will take the sector
    but you will get it back, along with all his military.

Can't reproduce; delete.

    If a plane is out to trade, and gets shot down, it can still be
    bought until the next update.  If another country builds a new
    plane that gets the number of the plane that was shot down, the
    new plane will go on the trading market automatically.  Then if
    that plane is bought, the money goes to the country whose plane
    was shot down, not the country that built the plane.  I stole
    numerous planes (including nuclear missiles :-) this way (by
    deliberately putting low numbered planes up for trade, then having
    them shot down).

Planes on a trading block can't get shot down, because they can't fly.
They can get destroyed on the ground, though.  A new plane with the
same number still goes on the market automatically.  Same for ships,
land units and nukes.  check_trade() deletes a trade when the object's
owner changed.  Reword the paragraph accordingly.

    If a plane has negative mobility, then gets traded, mobility goes to 0.

Still correct.

    Firing on sectors with land-locked sunken ships does strange
    things.

Can't reproduce; delete.

    If two countries are cooperating, its possible to raid an enemy
    airport and steal the planes by putting them out to trade.

Still correct.

    You can also strip enemy sectors of commodities using "sell", if
    you have military control temporarily.

Requires mobility now.  Delete.

    One can make work go back to 100 everywhere in a country by moving
    all civil- ians in low-work sectors onto a bridge, then collapsing
    the bridge.  Work then goes to 100 at the next update, if you
    leave some mil in the vacated sectors.  Or you can move mil out
    too, letting the sector ownership change to the Deity, then move
    back in from a 100% working sector, and work goes immediately to
    100.

Feature; delete.

    Two cooperative countries can move commodities around at no
    mobility cost using the market.

Still correct.

    You can collapse enemy bridges by making a lightning raid on his
    bridgeheads and redesignating them, even if you only hold the
    bridgehead for a short time.  (In this games, bridges work
    differently, see info build, info bridges")

Still correct.  The parenthesis is cryptic, though; delete it.

    You can map out enemy territory by raiding his radar stations.

Feature; delete.

    Condition checking is very treacherous.  Global commands with
    conditions are unreliable.  I never figured out exactly what was
    wrong, although I think your method of putting conditions towards
    the front of the line helped sometimes.

Can't reproduce; delete.

    You can have more than 26 ships in a fleet, but only the first 26
    will move when you navigate the fleet (I think 26 is the right
    number, but I'm not cer- tain.  It might be 32).

Can't reproduce; delete.

    "Look" only spots subs (from destroyers) at a certain distance.
    If you are too close you won't see them (unless you are in the
    same sector).

Can't reproduce; delete.

    You can only fly as many planes on a mission as you can fit on the
    command line (so low numbered planes have an advantage this way).
    USE WINGS

The real issue here is truncation of long input lines.  Replace.

    When a sector has a visible ship, radar doesn't show whether the
    sector is land or sea, just the ship.  This has interesting
    possibilities for exploita- tion (like land-locking a battleship
    in your capital in order to deceive the enemy :-)

Feature; delete.

    I don't think you can land planes on a land-locked aircraft
    carrier anymore.

Yes, you can.  Is that good or bad?  Anyway, delete.

    Its common to mistakenly set the price of a plane or ship
    incorrectly so one should check trade after using set.

Pilot error; delete.

    The "must be accepted by" date on offered loans is bogus.

Why is it bogus?  The date looks good to me.  The offer expires at
that time.  Delete.

    "Turn off" doesn't stop updates.

Feature; delete.
2011-04-18 19:17:11 +02:00
631e55bf54 Update change log again for 4.3.27 2011-04-17 18:20:34 +02:00
ea7a741b32 Don't .ds <= and >=, use \(<= and \)>= directly
The symbols work fine even with CRT.MAC.  In fact, they've been used
by Food.t since Empire 2.
2011-04-17 17:52:31 +02:00
b42748001a Clarify info turn: turn off doesn't disable updates 2011-04-17 17:52:31 +02:00
eec6de50c8 Belatedly update designate's c_form
Commit 8227d8c8 (v4.3.12) removed its optional argument without
updating c_form.
2011-04-17 17:52:31 +02:00
c45a3bb923 Make option RAILWAYS disable rail infrastructure
Rail infrastructure isn't used with RAILWAYS.  Disable, to make the
improve command reject it.
2011-04-17 17:52:31 +02:00