]> git.pond.sub.org Git - empserver/commitdiff
Rename obj_nameof() to unit_nameof() and move to unitsub.c
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 21 May 2011 13:42:38 +0000 (15:42 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jun 2011 14:50:20 +0000 (16:50 +0200)
include/empobj.h
include/unit.h
src/lib/commands/load.c
src/lib/commands/miss.c
src/lib/commands/navi.c
src/lib/commands/rada.c
src/lib/commands/scra.c
src/lib/commands/scut.c
src/lib/subs/empobj.c
src/lib/subs/unitsub.c

index 3f6d181eb38efa4d8221a06dcd06b3054b6a7ccf..f0e6563be80c3609a0919a11ea6b5550534458d4 100644 (file)
@@ -98,7 +98,6 @@ struct empobj_chr;
 #define put_empobj(type, n, p) ef_write((type), (n), (p))
 #define get_empobjp(type, n) ((struct empobj *)ef_ptr((type), (n)))
 
-extern char *obj_nameof(struct empobj *gp);
 extern char *empobj_chr_name(struct empobj *gp);
 extern int get_empobj_mob_max(int type);
 
index 06d082f02bca1dcbb5e764006987a4be15576935..1eb5df24383cbc29b62132c90821d5a5dfb30e8d 100644 (file)
@@ -54,6 +54,7 @@ extern int unit_cargo_count(int, int, int);
 extern int unit_nplane(int, int, int *, int *, int *);
 extern void unit_onresize(int);
 
+extern char *unit_nameof(struct empobj *);
 extern void unit_list(struct emp_qelem *);
 extern void unit_put(struct emp_qelem *list, natid actor);
 extern char *unit_path(int, struct empobj *, char *);
index 8ab83e088ec5113af28a64282ede6a1ecd532fba..6b3886b52e2902d77b57a95c40c9c07fcf4f624b 100644 (file)
@@ -37,7 +37,6 @@
 
 #include <ctype.h>
 #include "commands.h"
-#include "empobj.h"
 #include "item.h"
 #include "land.h"
 #include "optlist.h"
@@ -363,7 +362,7 @@ void
 gift(natid givee, natid giver, void *ptr, char *mesg)
 {
     if (giver != givee)
-       wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(ptr), mesg);
+       wu(0, givee, "%s %s %s\n", cname(giver), unit_nameof(ptr), mesg);
     unit_give_away(ptr, givee, 0);
 }
 
index 6e795dec1de2aab410683690ca3979825d3fb830..93f96bb6b548fb1b0380a3e1872faa6fb4c2b96c 100644 (file)
 #include <config.h>
 
 #include "commands.h"
-#include "empobj.h"
 #include "mission.h"
 #include "optlist.h"
 #include "path.h"
+#include "unit.h"
 
 static int clear_mission(struct nstr_item *);
 static int show_mission(struct nstr_item *);
@@ -175,24 +175,24 @@ mission(void)
        if (mission == MI_RESERVE) {
            if (!lnd_can_attack((struct lndstr *)gp)) {
                pr("%s is not designed to fight ground troops\n",
-                  obj_nameof(gp));
+                  unit_nameof(gp));
                continue;
            }
            if (!lchr[gp->type].l_rad) {
-               pr("%s cannot react anywhere!\n", obj_nameof(gp));
+               pr("%s cannot react anywhere!\n", unit_nameof(gp));
                continue;
            }
        }
 
        if ((mission == MI_INTERDICT) && (type == EF_SHIP))
            if (mchr[(int)gp->type].m_glim == 0) {
-               pr("%s: cannot fire at range!\n", obj_nameof(gp));
+               pr("%s: cannot fire at range!\n", unit_nameof(gp));
                continue;
            }
 
        if ((mission == MI_INTERDICT) && (type == EF_LAND))
            if (lchr[(int)gp->type].l_dam == 0) {
-               pr("%s: cannot fire at range!\n", obj_nameof(gp));
+               pr("%s: cannot fire at range!\n", unit_nameof(gp));
                continue;
            }
 
@@ -247,7 +247,7 @@ mission(void)
 
        if (type == EF_PLANE && nuk_on_plane((struct plnstr *)gp) >= 0) {
            pr("%s can't perform a mission while it carries a nuclear weapon",
-              obj_nameof(gp));
+              unit_nameof(gp));
            continue;
        }
 
@@ -260,7 +260,7 @@ mission(void)
        range = oprange(gp);
        if (range < mapdist(gp->x, gp->y, x, y)) {
            pr("%s: out of range! (range %d)\n",
-              obj_nameof(gp), range);
+              unit_nameof(gp), range);
            continue;
        }
        gp->opx = x;
@@ -270,7 +270,7 @@ mission(void)
        num++;
 
        pr("%s on %s mission, centered on %s, radius %d\n",
-          obj_nameof(gp), mission_name(mission),
+          unit_nameof(gp), mission_name(mission),
           xyas(x, y, player->cnum), gp->radius);
     }
     if (num == 0) {
@@ -310,7 +310,7 @@ show_mission(struct nstr_item *np)
            pr("Thing                         x,y   op-sect rad mission\n");
            first = 0;
        }
-       pr("%-25s", obj_nameof(gp));
+       pr("%-25s", unit_nameof(gp));
        prxy(" %3d,%-3d", gp->x, gp->y);
        switch (gp->mission) {
        case MI_INTERDICT:
index 0ec8f6494f192e93ff26cecb52cf73c6bd42cca3..fec4bb8c0c75fa901d7e80c304d8a07e3960a119 100644 (file)
@@ -38,7 +38,6 @@
 #include "map.h"
 #include "optlist.h"
 #include "path.h"
-#include "empobj.h"
 #include "unit.h"
 
 static void pr_leader_change(struct empobj *leader);
@@ -89,7 +88,7 @@ do_unit_move(struct emp_qelem *ulist, int *together,
     type = leader->ef_type;
     pr("%s is %s\n",
        type == EF_SHIP ? "Flagship" : "Leader",
-       obj_nameof(leader));
+       unit_nameof(leader));
 
     if (player->argp[2]) {
        strcpy(buf, player->argp[2]);
@@ -335,7 +334,7 @@ pr_leader_change(struct empobj *leader)
 {
     pr("Changing %s to %s\n",
        leader->ef_type == EF_SHIP ? "flagship" : "leader",
-       obj_nameof(leader));
+       unit_nameof(leader));
 }
 
 static struct empobj *
index be0552cad9d50fa54735f2b2c0d8cc1ae485de8e..d21bbebb12e4cc91ba02d71e7fe60a9c9f8559c8 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "commands.h"
 #include "optlist.h"
-#include "empobj.h"
+#include "unit.h"
 
 int
 rada(void)
@@ -108,7 +108,7 @@ radar(int type)
                spy = lchr[item.land.lnd_type].l_spy;
            }
 
-           pr("%s at ", obj_nameof(&item.gen));
+           pr("%s at ", unit_nameof(&item.gen));
            radmap(item.gen.x, item.gen.y, item.gen.effic,
                   item.gen.tech, spy, tf);
        }
index 87a24d0ed200e120601ea907b9168fa154a55d7b..9bad64fca75a034d7a1375ca95e910644816b3ee 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <ctype.h>
 #include "commands.h"
-#include "empobj.h"
 #include "optlist.h"
 #include "unit.h"
 
@@ -159,7 +158,7 @@ scra(void)
            if (!player->owner
                && relations_with(sect.sct_own, player->cnum) != ALLIED) {
                pr("%s is not in an allied sector!\n",
-                  obj_nameof(&item.gen));
+                  unit_nameof(&item.gen));
                continue;
            }
            if (type == EF_PLANE
@@ -171,7 +170,7 @@ scra(void)
        }
 
        pr("%s scrapped in %s\n",
-          obj_nameof(&item.gen),
+          unit_nameof(&item.gen),
           xyas(item.gen.x, item.gen.y, player->cnum));
        unit_drop_cargo(&item.gen, sect.sct_own);
        if (type == EF_SHIP) {
index e2383f3ee3f691e9ef1bd94c6da6a98639ac752f..4e78b634609a30b41fdb515c393b9ccda1033ee2 100644 (file)
@@ -34,7 +34,6 @@
 
 #include <ctype.h>
 #include "commands.h"
-#include "empobj.h"
 #include "news.h"
 #include "optlist.h"
 #include "unit.h"
@@ -138,7 +137,7 @@ scut(void)
            }
        }
        pr("%s scuttled in %s\n",
-          obj_nameof(&item.gen),
+          unit_nameof(&item.gen),
           xyas(item.gen.x, item.gen.y, player->cnum));
        getsect(item.gen.x, item.gen.y, &sect);
        if (sect.sct_own == item.gen.own)
index fb38f739c98735b082eb8a8405d476cfc742a605..a43c7281ed91b222699b9de3d1be2adb053ac2d9 100644 (file)
 #include "empobj.h"
 #include "file.h"
 #include "optlist.h"
-#include "prototypes.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_REACH();
-    return "The Beast #666";
-}
 
 char *
 empobj_chr_name(struct empobj *gp)
index e2a2f9f71c2f2480bc3641974728eab9c2557b57..4e8e6c23c1346e991422082c7a023ce7ff26e486 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <config.h>
 
-#include "empobj.h"
 #include "file.h"
 #include "path.h"
 #include "player.h"
 #include "prototypes.h"
 #include "unit.h"
 
+char *
+unit_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_REACH();
+    return "The Beast #666";
+}
+
 void
 unit_list(struct emp_qelem *unit_list)
 {
@@ -115,7 +131,7 @@ unit_put(struct emp_qelem *list, natid actor)
                        && unit->ef_type != EF_SHIP))
            continue;
        if (actor) {
-           mpr(actor, "%s stopped at %s\n", obj_nameof(unit),
+           mpr(actor, "%s stopped at %s\n", unit_nameof(unit),
                xyas(unit->x, unit->y, actor));
            if (unit->ef_type == EF_LAND) {
                if (ulp->mobil < -127)
@@ -215,7 +231,7 @@ unit_view(struct emp_qelem *list)
            if (((struct mchrstr *)ulp->chrp)->m_flags & M_OIL)
                pr("[oil:%d] ", sect.sct_oil);
        }
-       pr("%s @ %s %d%% %s\n", obj_nameof(&ulp->unit.gen),
+       pr("%s @ %s %d%% %s\n", unit_nameof(&ulp->unit.gen),
           xyas(ulp->unit.gen.x, ulp->unit.gen.y, player->cnum),
           sect.sct_effic, dchr[sect.sct_type].d_name);
     }
@@ -239,7 +255,7 @@ unit_update_cargo(struct empobj *carrier)
        snxtitem_cargo(&ni, cargo_type, carrier->ef_type, carrier->uid);
        while (nxtitem(&ni, &obj)) {
            if (!carrier->own) {
-               mpr(obj.gen.own, "%s lost!\n", obj_nameof(&obj.gen));
+               mpr(obj.gen.own, "%s lost!\n", unit_nameof(&obj.gen));
                obj.gen.effic = 0;
            } else {
                /* mission op-area centered on the obj travels with it */
@@ -281,7 +297,7 @@ unit_drop_cargo(struct empobj *unit, natid newown)
                break;
            }
            mpr(cargo.gen.own, "%s transferred off %s %d to %s\n",
-               obj_nameof(&cargo.gen),
+               unit_nameof(&cargo.gen),
                ef_nameof(unit->ef_type), unit->uid,
                xyas(cargo.gen.x, cargo.gen.y, cargo.gen.own));
            if (newown)
@@ -309,9 +325,9 @@ unit_give_away(struct empobj *unit, natid recipient, natid giver)
 
     if (giver) {
        mpr(unit->own, "%s given to %s\n",
-           obj_nameof(unit), cname(recipient));
+           unit_nameof(unit), cname(recipient));
        mpr(recipient, "%s given to you by %s\n",
-           obj_nameof(unit), cname(giver));
+           unit_nameof(unit), cname(giver));
     }
 
     unit->own = recipient;