]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/trdsub.c
Update copyright notice
[empserver] / src / lib / subs / trdsub.c
index 93391497c9b0f30a8fcb0cd85af01465d41cc428..e7b6d93dcd992f7ce4480a814112cfd88f6cd6f5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -48,6 +48,7 @@
 #include "sect.h"
 #include "ship.h"
 #include "trade.h"
+#include "unit.h"
 #include "xy.h"
 
 int
@@ -171,6 +172,38 @@ trade_desc(struct empobj *tgp)
     return 1;
 }
 
+int
+trade_has_unsalable_cargo(struct empobj *tgp, int noisy)
+{
+    int ret, i, type;
+    short *item;
+    struct nstr_item ni;
+    union empobj_storage cargo;
+
+    ret = 0;
+    if (tgp->ef_type == EF_SHIP || tgp->ef_type == EF_LAND) {
+       item = tgp->ef_type == EF_SHIP
+           ? ((struct shpstr *)tgp)->shp_item
+           : ((struct lndstr *)tgp)->lnd_item;
+       for (i = I_NONE + 1; i <= I_MAX; i++) {
+           if (item[i] && !ichr[i].i_sell) {
+               if (noisy)
+                   pr("%s carries %s, which you can't sell.\n",
+                      unit_nameof(tgp), ichr[i].i_name);
+               ret = 1;
+           }
+       }
+    }
+
+    for (type = EF_PLANE; type <= EF_NUKE; type++) {
+       snxtitem_cargo(&ni, type, tgp->ef_type, tgp->uid);
+       while (nxtitem(&ni, &cargo))
+           ret |= trade_has_unsalable_cargo(&cargo.gen, noisy);
+    }
+
+    return ret;
+}
+
 int
 trade_getitem(struct trdstr *tp, union empobj_storage *tgp)
 {