#include "plague.h"
#include "ship.h"
-static int can_tend_to(struct shpstr *, struct shpstr *);
+static int can_tend_to(struct shpstr *, int, struct shpstr *, int);
static void expose_ship(struct shpstr *s1, struct shpstr *s2);
-static int tend_land(struct shpstr *tenderp, char *units);
+static int tend_land(struct shpstr *tenderp, int, char *units);
int
tend(void)
continue;
if (!check_ship_ok(&tender))
return RET_SYN;
- if (0 != (retval = tend_land(&tender, p)))
+ retval = tend_land(&tender, tenders.sel == NS_LIST, p);
+ if (retval)
return retval;
continue;
}
return RET_SYN;
total = 0;
while (nxtitem(&targets, &target)) {
- if (ip->i_uid == I_CIVIL && tender.shp_own != target.shp_own)
- continue;
if (amt < 0) {
/* take from target and give to tender */
- if (!player->owner)
+ if (!player->owner) {
+ if (targets.sel == NS_LIST)
+ pr("You don't own ship #%d!\n", target.shp_uid);
continue;
- if (!can_tend_to(&target, &tender))
+ }
+ if (!can_tend_to(&target, targets.sel == NS_LIST,
+ &tender, tenders.sel == NS_LIST))
continue;
ontarget = target.shp_item[ip->i_uid];
if (ontarget == 0) {
total += transfer;
} else {
/* give to target from tender */
- if (!can_tend_to(&tender, &target))
+ if (!can_tend_to(&tender, tenders.sel == NS_LIST,
+ &target, targets.sel == NS_LIST))
+ continue;
+ if (ip->i_uid == I_CIVIL && tender.shp_own != target.shp_own)
continue;
ontarget = target.shp_item[ip->i_uid];
vbase = &mchr[(int)target.shp_type];
}
static int
-can_tend_to(struct shpstr *from, struct shpstr *to)
+can_tend_to(struct shpstr *from, int noisy_from,
+ struct shpstr *to, int noisy_to)
{
- if (!to->shp_own)
+ /*
+ * Careful: error messages must not disclose anything on foreign
+ * @to the player doesn't already know, or could trivially learn.
+ */
+ if (!to->shp_own) {
+ if (noisy_to)
+ pr("You don't own ship #%d!\n", to->shp_uid);
return 0;
- if (to->shp_own != player->cnum && !player->god
- && relations_with(to->shp_own, player->cnum) < FRIENDLY)
+ }
+ if (from->shp_uid == to->shp_uid) {
+ if (noisy_from && noisy_to)
+ pr("%s won't tend to itself\n", prship(from));
return 0;
- if (from->shp_uid == to->shp_uid)
+ }
+ if (from->shp_x != to->shp_x || from->shp_y != to->shp_y) {
+ if (noisy_from && noisy_to) {
+ /* Don't disclose foreign @to exists elsewhere */
+ if (player->god || to->shp_own == player->cnum)
+ pr("%s is not in the same sector as %s\n",
+ prship(to), prship(from));
+ else
+ pr("You don't own ship #%d!\n", to->shp_uid);
+ }
return 0;
- if (from->shp_x != to->shp_x || from->shp_y != to->shp_y)
+ }
+ if (!player->god && to->shp_own != player->cnum
+ && relations_with(to->shp_own, player->cnum) < FRIENDLY) {
+ if (noisy_to) {
+ /*
+ * Don't disclose unfriendly @to exists here unless
+ * lookout from @from would see it.
+ */
+ if ((mchr[from->shp_type].m_flags & M_SUB)
+ || (mchr[to->shp_type].m_flags & M_SUB))
+ pr("You don't own ship #%d!\n", from->shp_uid);
+ else
+ pr("You are not on friendly terms with"
+ " the owner of ship #%d!\n",
+ to->shp_uid);
+ }
return 0;
+ }
return 1;
}
}
static int
-tend_land(struct shpstr *tenderp, char *units)
+tend_land(struct shpstr *tenderp, int noisy, char *units)
{
struct nstr_item lni;
struct nstr_item targets;
if (!check_ship_ok(tenderp) || !check_land_ok(&land))
return RET_SYN;
while (nxtitem(&targets, &target)) {
- if (!can_tend_to(tenderp, &target))
+ if (!can_tend_to(tenderp, noisy,
+ &target, targets.sel == NS_LIST))
continue;
/* Fit unit on ship */
Play#1 output Play#1 6 0 420
Play#1 input tend f 150 1 150
Play#1 command tend
+ Play#1 output Play#1 1 cs cargo ship (#150) won't tend to itself
Play#1 output Play#1 1 0 total food transferred off of cs cargo ship (#150)
Play#1 output Play#1 6 0 419
Play#1 input tend f 150 1 0
Play#1 command tend
+ Play#1 output Play#1 1 ls landing ship (#0) is not in the same sector as cs cargo ship (#150)
Play#1 output Play#1 1 0 total food transferred off of cs cargo ship (#150)
Play#1 output Play#1 6 0 418
Play#1 input tend m 150/151 1 t
Play#1 output Play#1 6 0 415
Play#1 input tend f 166 1 160/162/163/164
Play#1 command tend
+ Play#1 output Play#1 1 You don't own ship #160!
+ Play#1 output Play#1 1 You are not on friendly terms with the owner of ship #164!
Play#1 output Play#1 1 2 total food transferred off of cs cargo ship (#166)
Play#1 output Play#1 6 0 414
Play#1 input tend f 166 1 u
Play#1 output Play#1 6 0 410
Play#1 input tend c 166 1 160/162/163/164
Play#1 command tend
+ Play#1 output Play#1 1 You don't own ship #160!
+ Play#1 output Play#1 1 You are not on friendly terms with the owner of ship #164!
Play#1 output Play#1 1 0 total civilians transferred off of cs cargo ship (#166)
Play#1 output Play#1 6 0 409
Play#1 input tend f 160/162/163/164 -1 166
Play#1 output Play#1 6 0 408
Play#1 input tend f 166 -1 160/162/163/164
Play#1 command tend
+ Play#1 output Play#1 1 You don't own ship #160!
+ Play#1 output Play#1 1 You don't own ship #162!
+ Play#1 output Play#1 1 You don't own ship #163!
+ Play#1 output Play#1 1 You don't own ship #164!
Play#1 output Play#1 1 0 total food transferred to cs cargo ship (#166)
Play#1 output Play#1 6 0 407
Play#1 input tend h 170/171 1 150
Play#1 output Play#1 6 0 392
Play#1 input tend land 151 301 151
Play#1 command tend
+ Play#1 output Play#1 1 cs cargo ship (#151) won't tend to itself
Play#1 output Play#1 6 0 391
Play#1 input tend land 166 330 164
Play#1 command tend
+ Play#1 output Play#1 1 You are not on friendly terms with the owner of ship #164!
Play#1 output Play#1 6 0 390
Play#1 input tend land 151 301 0
Play#1 command tend
+ Play#1 output Play#1 1 ls landing ship (#0) is not in the same sector as cs cargo ship (#151)
Play#1 output Play#1 6 0 389
Play#1 input tend land 150 n 151
Play#1 command tend
Play#0 output Play#0 6 0 639
Play#0 input tend f 166 1 160/164
Play#0 command tend
+ Play#0 output Play#0 1 You don't own ship #160!
Play#0 output Play#0 1 1 total food transferred off of cs cargo ship (#166)
Play#0 output Play#0 6 0 638
Play#0 input tend c 160/164 1 166
Play#0 output Play#0 6 0 637
Play#0 input tend c 166 1 160/164
Play#0 command tend
+ Play#0 output Play#0 1 You don't own ship #160!
Play#0 output Play#0 1 0 total civilians transferred off of cs cargo ship (#166)
Play#0 output Play#0 6 0 636
Play#0 input tend land 163/164 313/314 166
Play#0 output Play#0 6 0 635
Play#0 input tend land 162 312 160
Play#0 command tend
+ Play#0 output Play#0 1 You don't own ship #160!
Play#0 output Play#0 6 0 634
Play#0 input ctld
Play#0 output Play#0 1 Bye-bye