From c64c756eef35fc041befdd1dd385b903ef32a0c9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 29 Apr 2013 21:23:13 +0200 Subject: [PATCH] Fix xdump lost column type on big endian hosts Broken in commit 09248d0 (v4.3.8), which changed struct loststr member lost_type from char to short, but neglected to update the ca_type in lost_ca[]. On little endian hosts, the selector reads the least significant byte, with sign extension. Happens to work, because the type values are all sufficiently small integers. On big endian hosts, the selector reads the most signiciant byte, which is always zero (EF_SECTOR). Messes up xdump lost badly. Also breaks lost * ?type=..., but that's exotic. --- src/lib/common/nsc.c | 2 +- tests/smoke/smoke.out | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/common/nsc.c b/src/lib/common/nsc.c index bc50dcb1..c3c64356 100644 --- a/src/lib/common/nsc.c +++ b/src/lib/common/nsc.c @@ -487,7 +487,7 @@ struct castr lost_ca[] = { {"timestamp", fldoff(lost_timestamp), NSC_TIME, 0, NULL, EF_BAD, 0}, {"owner", fldoff(lost_owner), NSC_NATID, 0, NULL, EF_NATION, 0}, - {"type", fldoff(lost_type), NSC_CHAR, 0, NULL, EF_TABLE, 0}, + {"type", fldoff(lost_type), NSC_SHORT, 0, NULL, EF_TABLE, 0}, /* id's ca_table given by type, but can't express that: */ {"id", fldoff(lost_id), NSC_INT, 0, NULL, EF_BAD, 0}, {"x", fldoff(lost_x), NSC_XCOORD, 0, NULL, EF_BAD, 0}, diff --git a/tests/smoke/smoke.out b/tests/smoke/smoke.out index 6cc169fa..d6a24673 100644 --- a/tests/smoke/smoke.out +++ b/tests/smoke/smoke.out @@ -313,7 +313,7 @@ Player 00 Turn 00 starting [0:640] Command : XDUMP meta lost 0 "timestamp" 12 0 0 -1 "owner" 5 0 0 9 -"type" 4 0 0 27 +"type" 6 0 0 27 "id" 8 0 0 -1 "x" 9 0 0 -1 "y" 10 0 0 -1 @@ -1202,7 +1202,7 @@ CENSUS del dst [0:636] Command : XDUMP meta lost 0 "timestamp" 12 0 0 -1 "owner" 5 0 0 9 -"type" 4 0 0 27 +"type" 6 0 0 27 "id" 8 0 0 -1 "x" 9 0 0 -1 "y" 10 0 0 -1