From 985ac03fbeaa4575cf78bed1d0f28b5c03a90564 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 23 Jan 2013 07:52:45 +0100 Subject: [PATCH] setsector setresource: Print effect for unowned sectors, too The "changed from" message has always been suppressed for unowned sectors. Makes no sense. Signed-off-by: Markus Armbruster --- src/lib/commands/setres.c | 15 +++++---------- src/lib/commands/setsect.c | 29 +++++++++++------------------ tests/actofgod/actofgod.xdump | 2 +- tests/actofgod/geninput.pl | 5 +++++ tests/actofgod/journal.log | 12 ++++++++++++ 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/lib/commands/setres.c b/src/lib/commands/setres.c index 6e66143a..7d479003 100644 --- a/src/lib/commands/setres.c +++ b/src/lib/commands/setres.c @@ -70,28 +70,23 @@ setres(void) return RET_FAIL; switch (char0) { case 'i': - if (sect.sct_own != 0) - resnoise(§, "Iron ore content", sect.sct_min, amt); + resnoise(§, "Iron ore content", sect.sct_min, amt); sect.sct_min = (unsigned char)amt; break; case 'g': - if (sect.sct_own != 0) - resnoise(§, "Gold content", sect.sct_gmin, amt); + resnoise(§, "Gold content", sect.sct_gmin, amt); sect.sct_gmin = (unsigned char)amt; break; case 'o': - if (sect.sct_own != 0) - resnoise(§, "Oil content", sect.sct_oil, amt); + resnoise(§, "Oil content", sect.sct_oil, amt); sect.sct_oil = (unsigned char)amt; break; case 'f': - if (sect.sct_own != 0) - resnoise(§, "Fertility content", sect.sct_fertil, amt); + resnoise(§, "Fertility content", sect.sct_fertil, amt); sect.sct_fertil = (unsigned char)amt; break; case 'u': - if (sect.sct_own != 0) - resnoise(§, "Uranium content", sect.sct_uran, amt); + resnoise(§, "Uranium content", sect.sct_uran, amt); sect.sct_uran = (unsigned char)amt; break; default: diff --git a/src/lib/commands/setsect.c b/src/lib/commands/setsect.c index 129d2230..c1490ab3 100644 --- a/src/lib/commands/setsect.c +++ b/src/lib/commands/setsect.c @@ -75,16 +75,14 @@ setsector(void) current = sect.sct_min; current += amt; current = LIMIT_TO(current, 0, 100); - if (sect.sct_own != 0) - resnoise(§, "Iron ore content", sect.sct_min, current); + resnoise(§, "Iron ore content", sect.sct_min, current); sect.sct_min = (unsigned char)current; break; case 'g': current = sect.sct_gmin; current += amt; current = LIMIT_TO(current, 0, 100); - if (sect.sct_own != 0) - resnoise(§, "Gold content", sect.sct_gmin, current); + resnoise(§, "Gold content", sect.sct_gmin, current); sect.sct_gmin = (unsigned char)current; break; case 'o': @@ -93,8 +91,7 @@ setsector(void) current = sect.sct_oil; current += amt; current = LIMIT_TO(current, 0, 100); - if (sect.sct_own != 0) - resnoise(§, "Oil content", sect.sct_oil, current); + resnoise(§, "Oil content", sect.sct_oil, current); sect.sct_oil = (unsigned char)current; break; case 'w': @@ -145,14 +142,12 @@ setsector(void) current = sect.sct_mines; current += amt; current = LIMIT_TO(current, 0, MINES_MAX); - 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); - } + 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': @@ -188,16 +183,14 @@ setsector(void) current = sect.sct_fertil; current += amt; current = LIMIT_TO(current, 0, 100); - if (sect.sct_own != 0) - resnoise(§, "Fertility content", sect.sct_fertil, current); + resnoise(§, "Fertility content", sect.sct_fertil, current); sect.sct_fertil = (unsigned char)current; break; case 'u': current = sect.sct_uran; current += amt; current = LIMIT_TO(current, 0, 100); - if (sect.sct_own != 0) - resnoise(§, "Uranium content", sect.sct_uran, current); + resnoise(§, "Uranium content", sect.sct_uran, current); sect.sct_uran = (unsigned char)current; break; default: diff --git a/tests/actofgod/actofgod.xdump b/tests/actofgod/actofgod.xdump index bb47fc25..343b92eb 100644 --- a/tests/actofgod/actofgod.xdump +++ b/tests/actofgod/actofgod.xdump @@ -191,7 +191,7 @@ owner xloc yloc des effic mobil off loyal terr0 terr1 terr2 terr3 dterr xdist yd 0 -7 -1 4 0 0 0 0 0 0 0 0 0 -7 -1 0 0 0 1 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 -5 -1 4 0 0 0 0 0 0 0 0 0 -5 -1 0 0 0 1 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 -3 -1 4 0 0 0 0 0 0 0 0 0 -3 -1 0 0 0 1 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 -1 -1 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 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 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 +0 -1 -1 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 1 0 50 50 50 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 /config config ship uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet xstart xend ystart yend cargostart(0) cargostart(1) cargostart(2) cargostart(3) cargostart(4) cargostart(5) cargoend(0) cargoend(1) cargoend(2) cargoend(3) cargoend(4) cargoend(5) amtstart(0) amtstart(1) amtstart(2) amtstart(3) amtstart(4) amtstart(5) amtend(0) amtend(1) amtend(2) amtend(3) amtend(4) amtend(5) autonav civil milit shell gun petrol iron dust bar food oil lcm hcm uw rad pstage ptime access mquota path follow name xbuilt ybuilt builder rflags rpath diff --git a/tests/actofgod/geninput.pl b/tests/actofgod/geninput.pl index 893505f3..1abc1bd1 100755 --- a/tests/actofgod/geninput.pl +++ b/tests/actofgod/geninput.pl @@ -190,6 +190,11 @@ sect_int( ['d', 0, 100], ); +# special case: unowned sector +edit('sect', '-1,-1', 'i', 50); +setres('-1,-1', 'g', 50); +setsect('-1,-1', 'f', 50); + # special case: mines in occupied sector setsect('1:3,-3', 'ol', 1); setsect('1,-3', 'mi', 1); diff --git a/tests/actofgod/journal.log b/tests/actofgod/journal.log index eed4ad35..5fe1e1dd 100644 --- a/tests/actofgod/journal.log +++ b/tests/actofgod/journal.log @@ -680,6 +680,18 @@ 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 edit l -1,-1 i 50 + Play#0 command edit + Play#0 output Play#0 1 Iron ore content of -1,-1 changed from 0 to 50 + Play#0 output Play#0 6 0 640 + Play#0 input setres g -1,-1 50 + Play#0 command setresource + Play#0 output Play#0 1 Gold content of -1,-1 changed from 0 to 50 + Play#0 output Play#0 6 0 640 + Play#0 input setsect f -1,-1 50 + Play#0 command setsector + Play#0 output Play#0 1 Fertility content of -1,-1 changed from 0 to 50 + 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).