From c900ef8f1eb2ee118b6eb5bd6d668d46bc1bc116 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 21 Jan 2013 21:44:51 +0100 Subject: [PATCH] setsector: Don't disclose number of landmines to occupier When the deity sets the number of mines with setsector, the sector owner (if any) is told the resulting number of mines. Even for occupied sectors, where mines belong to the old owner, and thus shouldn't be disclosed. Oops. Fix setsector not to tell the sector owner anything then. Signed-off-by: Markus Armbruster --- src/lib/commands/setsect.c | 10 ++++++++-- tests/actofgod/actofgod.xdump | 4 ++-- tests/actofgod/geninput.pl | 5 +++++ tests/actofgod/journal.log | 13 +++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/lib/commands/setsect.c b/src/lib/commands/setsect.c index d78e8c40..129d2230 100644 --- a/src/lib/commands/setsect.c +++ b/src/lib/commands/setsect.c @@ -145,8 +145,14 @@ setsector(void) current = sect.sct_mines; current += amt; current = LIMIT_TO(current, 0, MINES_MAX); - if (sect.sct_own != 0) - resnoise(§, "Mines", sect.sct_mines, current); + if (sect.sct_own != 0) { + if (sect.sct_own == sect.sct_oldown) + resnoise(§, "Mines", sect.sct_mines, current); + else + pr("Mines of %s changed from %d to %d\n", + xyas(sect.sct_x, sect.sct_y, player->cnum), + sect.sct_mines, current); + } sect.sct_mines = current; break; case 'o': diff --git a/tests/actofgod/actofgod.xdump b/tests/actofgod/actofgod.xdump index 6b77dc8f..bb47fc25 100644 --- a/tests/actofgod/actofgod.xdump +++ b/tests/actofgod/actofgod.xdump @@ -156,8 +156,8 @@ owner xloc yloc des effic mobil off loyal terr0 terr1 terr2 terr3 dterr xdist yd 0 -6 -4 4 0 0 0 0 0 0 0 0 0 -6 -4 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 0 -4 -4 4 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 3 7 -3 4 0 0 0 0 0 0 0 0 0 7 -3 0 0 100 0 4 0 0 0 0 0 3 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 3 9 -3 4 0 0 0 0 0 0 0 0 0 9 -3 0 0 100 0 4 0 0 0 0 0 3 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 diff --git a/tests/actofgod/geninput.pl b/tests/actofgod/geninput.pl index 7433b804..893505f3 100755 --- a/tests/actofgod/geninput.pl +++ b/tests/actofgod/geninput.pl @@ -190,6 +190,11 @@ sect_int( ['d', 0, 100], ); +# special case: mines in occupied sector +setsect('1:3,-3', 'ol', 1); +setsect('1,-3', 'mi', 1); +edit('sect', '3,-3', 'M', 1); + # dist edit('sect', '2,4', 'D', '4,4'); edit('sect', '4,4', 'D', '4,4'); diff --git a/tests/actofgod/journal.log b/tests/actofgod/journal.log index af7b1ca3..eed4ad35 100644 --- a/tests/actofgod/journal.log +++ b/tests/actofgod/journal.log @@ -680,6 +680,19 @@ Play#0 command edit Play#0 output Play#0 1 Defense percentage of 7,1 changed from 0 to 100 Play#0 output Play#0 6 0 640 + Play#0 input setsect ol 1:3,-3 1 + Play#0 command setsector + Play#0 output Play#0 1 Old owner of 1,-3 changed from 3 (#3) to 1 (#1). + Play#0 output Play#0 1 Old owner of 3,-3 changed from 3 (#3) to 1 (#1). + Play#0 output Play#0 6 0 640 + Play#0 input setsect mi 1,-3 1 + Play#0 command setsector + Play#0 output Play#0 1 Mines of 1,-3 changed from 0 to 1 + Play#0 output Play#0 6 0 640 + Play#0 input edit l 3,-3 M 1 + Play#0 command edit + Play#0 output Play#0 1 Mines changed to 1 + Play#0 output Play#0 6 0 640 Play#0 input edit l 2,4 D 4,4 Play#0 command edit Play#0 output Play#0 1 Distribution location for sector 2,4 changed from 2,4 to 4,4