From 221324cc1073b71ebda726b581ddeff1ea89a586 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 13 Sep 2008 15:27:42 -0400 Subject: [PATCH] Clean up rules on where you can scrap stuff You can now scrap ships in own or friendly, efficient harbors, planes in own or allied, efficient airfields, and land units in any own or allied sector. When something can't be scrapped because of these rules, print a suitable message. Before, you could scrap ships regardless of relations to sector owner (info claimed friendly was required), land units regardless of relations, but not while on ships, and planes even in friendly airfields (info claimed allied was required). When scrapping in a deity sector, scrap claimed it gave the cargo to POGO, which is somewhat bogus, as POGO can't own such stuff. --- info/scrap.t | 13 ++++--------- src/lib/commands/scra.c | 36 +++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/info/scrap.t b/info/scrap.t index da8a2f95..a73d31a3 100644 --- a/info/scrap.t +++ b/info/scrap.t @@ -1,23 +1,18 @@ .TH Command SCRAP -.NA scrap "Scrap a ship, plane, or unit" +.NA scrap "Scrap a ship, plane, or land unit" .LV Basic .SY "scrap " This command allows you to scrap planes/units/ships when you no longer need them. .s1 -Ships may only be scrapped friendly 60% harbours. -Planes may only be scrapped in 60% airfields. -Units may be scrapped in any sector. +Ships may only be scrapped in own or friendly 60% harbours. +Planes may only be scrapped in own or allied 60% airfields. +Land units may only be scrapped in own or allied sectors. .s1 When scrapping a unit, plane or ship, you receive materials equal to 2/3 the amount used to build it. The materials are put in the sector where the scrapping occurs. .s1 -When scrapping a unit, you also get the military that the unit represents -as mil in the sector. (Example: a unit that takes 100 mil to build is -at 50%, and is scrapped. 50 mil will be added to the sector) Units on -ships cannot be scrapped. -.s1 If you scrap a ship or unit that has planes on board, the planes will be transferred to the sector. .s1 diff --git a/src/lib/commands/scra.c b/src/lib/commands/scra.c index ccf4ecfa..e3ce6be3 100644 --- a/src/lib/commands/scra.c +++ b/src/lib/commands/scra.c @@ -134,28 +134,34 @@ scra(void) } } + getsect(item.gen.x, item.gen.y, §); if (type == EF_SHIP) { - getsect(item.ship.shp_x, item.ship.shp_y, §); - if (sect.sct_type != SCT_HARBR) - continue; - if (sect.sct_effic < 60 || sect.sct_own != player->cnum) - continue; - } else if (type == EF_LAND) { - if (item.land.lnd_ship >= 0) { - pr("%s is on a ship, and cannot be scrapped!\n", - prland(&item.land)); + if (!player->owner + && getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY) { + pr("%s is not in a friendly harbor!\n", + prship(&item.ship)); + continue; + } + if (sect.sct_type != SCT_HARBR || sect.sct_effic < 60) { + pr("%s is not in a 60%% efficient harbor!\n", + prship(&item.ship)); continue; } - getsect(item.land.lnd_x, item.land.lnd_y, §); } else { - getsect(item.plane.pln_x, item.plane.pln_y, §); - if (sect.sct_type != SCT_AIRPT) + if (!player->owner + && getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) { + pr("%s is not in an allied sector!\n", + obj_nameof(&item.gen)); continue; - if (sect.sct_effic < 60 || - (sect.sct_own != player->cnum && - getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY)) + } + if (type == EF_PLANE + && (sect.sct_type != SCT_AIRPT || sect.sct_effic < 60)) { + pr("%s is not in a 60%% efficient airfield!\n", + prplane(&item.plane)); continue; + } } + if (type == EF_SHIP) { eff = item.ship.shp_effic / 100.0; mp = &mchr[(int)item.ship.shp_type];