]> git.pond.sub.org Git - empserver/commitdiff
Replace trade_check_item_ok() by check_obj_ok()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 1 Jul 2012 10:13:36 +0000 (12:13 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 13 Jul 2012 18:15:33 +0000 (20:15 +0200)
Relaxes the sanity check of the argument's ef_type.  Could be avoided,
but not worth the bother.

include/trade.h
src/lib/commands/set.c
src/lib/subs/trdsub.c

index d34f71ba31bb6cfdec8aeafb658776ceb69f7874..15b8c32a3ff7a14f37407f3c9095c1f57940ff92 100644 (file)
@@ -58,7 +58,6 @@ struct trdstr {
 };
 
 extern int trade_check_ok(struct trdstr *, union empobj_storage *);
-extern int trade_check_item_ok(union empobj_storage *);
 extern char *trade_nameof(struct trdstr *, union empobj_storage *);
 extern int trade_desc(struct trdstr *, union empobj_storage *);
 extern int trade_getitem(struct trdstr *, union empobj_storage *);
index 8a6537902d0e28c3e573f754c3093c023d3e9f2d..6cea604a215ccb90879ea62dc7e2fec961fa0693 100644 (file)
@@ -93,7 +93,7 @@ set(void)
                trade_nameof(&trade, &item), ni.cur);
        if (!(p = getstarg(player->argp[3], prompt, buf)))
            return RET_FAIL;
-       if (!trade_check_item_ok(&item))
+       if (!check_obj_ok(&item.gen))
            return RET_FAIL;
        if ((price = atoi(p)) < 0)
            continue;
index 36633a33bed549a448b19f41d25fbd78ef0850d1..590c489810df604e91df46dc18e8733df90acfac 100644 (file)
 int
 trade_check_ok(struct trdstr *tp, union empobj_storage *tgp)
 {
-    return check_trade_ok(tp) && trade_check_item_ok(tgp);
-}
-
-int
-trade_check_item_ok(union empobj_storage *tgp)
-{
-    if (tgp->gen.ef_type == EF_LAND)
-       return check_land_ok(&tgp->land);
-    if (tgp->gen.ef_type == EF_PLANE)
-       return check_plane_ok(&tgp->plane);
-    if (tgp->gen.ef_type == EF_SHIP)
-       return check_ship_ok(&tgp->ship);
-    if (tgp->gen.ef_type == EF_NUKE)
-       return check_nuke_ok(&tgp->nuke);
-    CANT_REACH();
-    pr("Trade lot went bad!\n");
-    return 0;
+    return check_trade_ok(tp) && check_obj_ok(&tgp->gen);
 }
 
 char *