From 12491ffc168b86e4ffa5dc99d6b562e27569b3f7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Oct 2019 20:24:18 +0200 Subject: [PATCH] GIB 0 an Land kann alle Schiffe geben, auf Ozean nicht. --- res/translations/messages.en.po | 3 +++ scripts/tests/e2/ships.lua | 16 ++++++++++++++-- src/give.c | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index 135053782..659adee9f 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -2774,6 +2774,9 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Spells can only msgid "error326" msgstr "\"$unit($unit) in $region($region): '$order($command)' - These ships cannot form a convoy.\"" +msgid "error327" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit must keep at least one ship.\"" + msgid "error324" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is not one of ours.\"" diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 9286cc8f1..416677d26 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -203,8 +203,8 @@ function test_give_ship_same_ship() assert_not_equal(u1.ship, u2.ship) end -function test_give_ship_dont_give_all() - local r = region.create(1, 0, 'ocean') +function test_give_ship_all_on_ocean() + local r = region.create(0, 0, 'ocean') local f = faction.create("human") local u1 = unit.create(f, r, 1) u1.ship = ship.create(r, 'longboat') @@ -214,6 +214,18 @@ function test_give_ship_dont_give_all() assert_equal(2, u1.ship.number) end +function test_give_ship_all_on_land() + local r = region.create(0, 0, 'plain') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'longboat') + u1.ship.number = 2 + u1:add_order("GIB 0 2 SCHIFF") + process_orders() + assert_equal(nil, u1.ship) + assert_not_equal(nil, r.ships()) +end + function test_give_ship_no_boat() local r = region.create(1, 0, 'ocean') local f = faction.create("human") diff --git a/src/give.c b/src/give.c index ad157225a..47f472ec1 100644 --- a/src/give.c +++ b/src/give.c @@ -336,7 +336,7 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) return msg_error(u1, ord, 146); } if (u2 == NULL) { - if (n < u1->ship->number) { + if (fval(u1->region->terrain, LAND_REGION) || n < u1->ship->number) { ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); scale_ship(sh, 0); transfer_ships(u1->ship, sh, n);