]> git.pond.sub.org Git - empserver/commitdiff
(obj_nameof): New.
authorRon Koenderink <rkoenderink@yahoo.ca>
Mon, 10 Jul 2006 23:14:26 +0000 (23:14 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Mon, 10 Jul 2006 23:14:26 +0000 (23:14 +0000)
(nameofitem): Remove, switch callers to to obj_nameof().
(mission, show_mission): Convert functions to use obj_nameof()
instead of nameofitem().

include/empobj.h
include/prototypes.h
src/lib/commands/miss.c
src/lib/common/empobj.c [new file with mode: 0644]
src/lib/subs/mission.c

index 546ef46bde8b803206f9ed8bda1253f88c0a18ce..65b7a6152fcbfb20e8293650e19cfdc6d09f63b2 100644 (file)
@@ -84,6 +84,6 @@ union empobj_storage {
     struct trtstr treaty;
 };
 
-extern char * probjname(union empobj_storage *gp);
-#endif
+extern char *obj_nameof(struct empobj *gp);
 
+#endif
index 0ff66342e376ae2499a7bcde1412e39f804ec167..0bb5d1afe08e9927c7b0a77aaf0ba750cbdb1ac7 100644 (file)
@@ -488,7 +488,6 @@ extern int num_shipsatxy(coord, coord, int, int);
 extern int islist(char *);
 /* src/lib/subs/mission.c */
 extern char *mission_name(short);
-extern char *nameofitem(struct empobj *, int);
 extern int collateral_damage(coord, coord, int, struct emp_qelem *);
 extern int mission_pln_equip(struct plist *, struct ichrstr *, int, char);
 extern int ground_interdict(coord, coord, natid, char *);
index 2621602a01b14f9f594250e1af39c7f1969db191..88167b52966e4fb8568c0f52496d0d923e2e4768 100644 (file)
@@ -203,12 +203,12 @@ mission(void)
 
        if ((mission && (gp->mobil < mobused)) && mission_mob_cost) {
            pr("%s: not enough mobility! (needs %d)\n",
-              nameofitem(gp, type), mobused);
+              obj_nameof(gp), mobused);
            continue;
        }
        if (mission == MI_RESERVE && !lnd_can_attack((struct lndstr *)gp)) {
            pr("%s is not designed to fight ground troops\n",
-              prland((struct lndstr *)gp));
+              obj_nameof(gp));
            continue;
        }
        if (*p == '.') {
@@ -225,7 +225,7 @@ mission(void)
             mission == MI_AIR_DEFENSE) &&
            (oprange(gp, &radius) < dist)) {
            pr("%s: out of range! (range %d)\n",
-              nameofitem(gp, type), oprange(gp, &radius));
+              obj_nameof(gp), oprange(gp, &radius));
            continue;
        }
 
@@ -234,13 +234,13 @@ mission(void)
 
        if ((mission == MI_INTERDICT) && (type == EF_SHIP))
            if (mchr[(int)gp->type].m_frnge < 1) {
-               pr("%s: cannot fire at range!\n", nameofitem(gp, type));
+               pr("%s: cannot fire at range!\n", obj_nameof(gp));
                continue;
            }
 
        if ((mission == MI_INTERDICT) && (type == EF_LAND))
            if (lchr[(int)gp->type].l_frg < 1) {
-               pr("%s: cannot fire at range!\n", nameofitem(gp, type));
+               pr("%s: cannot fire at range!\n", obj_nameof(gp));
                continue;
            }
 
@@ -306,7 +306,7 @@ mission(void)
            mission == MI_DSUPPORT || mission == MI_INTERDICT ||
            mission == MI_AIR_DEFENSE) {
            pr("%s on %s mission, centered on %s, radius %d\n",
-              nameofitem(gp, type), mission_name(mission),
+              obj_nameof(gp), mission_name(mission),
               xyas(x, y, player->cnum), gp->radius);
        } else if (mission == MI_RESERVE) {
            int plus = 2;
@@ -322,9 +322,9 @@ mission(void)
            }
 
            pr("%s on %s mission with maximum reaction radius %d\n",
-              nameofitem(gp, type), mission_name(mission), plus);
+              obj_nameof(gp), mission_name(mission), plus);
        } else if (mission) {
-           pr("%s on %s mission\n", nameofitem(gp, type),
+           pr("%s on %s mission\n", obj_nameof(gp),
               mission_name(mission));
        }
 
diff --git a/src/lib/common/empobj.c b/src/lib/common/empobj.c
new file mode 100644 (file)
index 0000000..8254841
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  Empire - A multi-player, client/server Internet based war game.
+ *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                           Ken Stevens, Steve McClure
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  ---
+ *
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
+ *
+ *  ---
+ *
+ *  empobj.c: Common functions on struct empobj and
+ *            union empobj_storage
+ * 
+ *  Known contributors to this file:
+ *     Ron Koenderink, 2006
+ *     Markus Armbruster, 2006
+ */
+#include "empobj.h"
+
+
+char *
+obj_nameof(struct empobj *gp)
+{
+    switch (gp->ef_type) {
+    case EF_SHIP:
+       return prship((struct shpstr *)gp);
+    case EF_PLANE:
+       return prplane((struct plnstr *)gp);
+    case EF_LAND:
+       return prland((struct lndstr *)gp);
+    case EF_NUKE:
+       return prnuke((struct nukstr *)gp);
+    }
+    CANT_HAPPEN("unsupported TYPE");
+    return "";
+}
index 7f8b1e064c9edd4090096c01713174867e9f6fc3..4c733d3dacf49d0a286df0a2bd611ecd2f9dff75 100644 (file)
@@ -804,20 +804,6 @@ cando(int mission, int type)
     return 0;
 }
 
-char *
-nameofitem(struct empobj *gp, int type)
-{
-    switch (type) {
-    case EF_SHIP:
-       return prship((struct shpstr *)gp);
-    case EF_PLANE:
-       return prplane((struct plnstr *)gp);
-    case EF_LAND:
-       return prland((struct lndstr *)gp);
-    }
-    return NULL;
-}
-
 char *
 mission_name(short mission)
 {
@@ -858,7 +844,7 @@ show_mission(int type, struct nstr_item *np)
            pr("Thing                         x,y   op-sect rad mission\n");
            first = 0;
        }
-       pr("%-25s", nameofitem(gp, type));
+       pr("%-25s", obj_nameof(gp));
        prxy(" %3d,%-3d", gp->x, gp->y, player->cnum);
        if (gp->mission == MI_INTERDICT || gp->mission == MI_SUPPORT ||
            gp->mission == MI_OSUPPORT ||