]> git.pond.sub.org Git - empserver/commitdiff
Change encoding of `not in any group' from space to 0, because that's
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 27 May 2006 13:44:18 +0000 (13:44 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 27 May 2006 13:44:18 +0000 (13:44 +0000)
friendlier in conditionals:
(army, build_ship, build_land, build_plane, doship, doplane, dounit)
(flee, check_trade, wing, snxtitem_group, takeover_ship)
(takeover_land): Assign 0 instead of space.
(carg, lcarg, pr_ship, pr_plane, pr_land, ldump, land, pdump, plan)
(retr, lretr, sdump, shi, lnd_list, shp_list, ask_olist, att_prompt)
(ask_move_in): Update printing of group.

(takeover_plane): Failed to clear wing.

20 files changed:
include/nuke.h
src/lib/commands/army.c
src/lib/commands/buil.c
src/lib/commands/carg.c
src/lib/commands/edit.c
src/lib/commands/flee.c
src/lib/commands/land.c
src/lib/commands/ldump.c
src/lib/commands/pdump.c
src/lib/commands/plan.c
src/lib/commands/retr.c
src/lib/commands/sdump.c
src/lib/commands/shi.c
src/lib/commands/trad.c
src/lib/commands/wing.c
src/lib/subs/attsub.c
src/lib/subs/lndsub.c
src/lib/subs/shpsub.c
src/lib/subs/snxtitem.c
src/lib/subs/takeover.c

index 4c2eb0cc87cabc4f21c642e6c2cc97cff16bea1b..dc7059184fce08966387b99f1873648cacb6003f 100644 (file)
@@ -47,7 +47,7 @@ struct nukstr {
     signed char nuk_effic;     /* unused, always 100% */
     signed char nuk_mobil;     /* unused, always 0 */
     short nuk_tech;            /* nuke's tech level */
-    char nuk_stockpile;                /* group membership, unused, always ' ' */
+    char nuk_stockpile;                /* group membership, unused */
     coord nuk_opx, nuk_opy;    /* Op sector coords, unused */
     short nuk_mission;         /* mission code, unused */
     short nuk_radius;          /* mission radius, unused */
index c99f1f95e908a1b108cef6eabfaca09f62ccdc60..d17c7839d33f4f349511ed7c524dc71b902d979b 100644 (file)
@@ -62,7 +62,7 @@ army(void)
        return RET_SYN;
     }
     if (c == '~')
-       c = ' ';
+       c = 0;
     if (!snxtitem(&nstr, EF_LAND, player->argp[2]))
        return RET_SYN;
     count = 0;
index 909a0026ad49375d0165319ebb3172dc492fd946..d1495c63f57ed05f349b150c36e2a415ded155b8 100644 (file)
@@ -369,7 +369,7 @@ build_ship(struct sctstr *sp, struct mchrstr *mp, short *vec, int tlev)
     ship.shp_nland = 0;
     ship.shp_nxlight = 0;
     ship.shp_nchoppers = 0;
-    ship.shp_fleet = ' ';
+    ship.shp_fleet = 0;
     memset(ship.shp_item, 0, sizeof(ship.shp_item));
     ship.shp_pstage = PLG_HEALTHY;
     ship.shp_ptime = 0;
@@ -490,7 +490,7 @@ build_land(struct sctstr *sp, struct lchrstr *lp, short *vec, int tlev)
        land.lnd_mobil = 0;
     }
     land.lnd_uid = nstr.cur;
-    land.lnd_army = ' ';
+    land.lnd_army = 0;
     land.lnd_flags = 0;
     land.lnd_ship = -1;
     land.lnd_land = -1;
@@ -792,7 +792,7 @@ build_plane(struct sctstr *sp, struct plchrstr *pp, short *vec, int tlev)
     plane.pln_radius = 0;
     plane.pln_range = UCHAR_MAX; /* will be adjusted by pln_set_tech() */
     plane.pln_range_max = plane.pln_range;
-    plane.pln_wing = ' ';
+    plane.pln_wing = 0;
     plane.pln_ship = -1;
     plane.pln_land = -1;
     plane.pln_uid = nstr.cur;
index 787200974db3f9be0eed7a1faac29c5f22aa6fd8..ce2d0bd13ed46e2dfebb2596c56857273094f993 100644 (file)
@@ -63,7 +63,7 @@ carg(void)
        pr("%4d ", ni.cur);
        pr("%-4.4s ", mchr[(int)ship.shp_type].m_name);
        prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
-       pr("%c ", ship.shp_fleet);
+       pr("%1.1s", &ship.shp_fleet);
        pr("%4d%%", ship.shp_effic);
        pr("%4d", ship.shp_item[I_CIVIL]);
        pr("%4d", ship.shp_item[I_MILIT]);
@@ -112,7 +112,7 @@ lcarg(void)
        pr("%4d ", ni.cur);
        pr("%-4.4s ", lchr[(int)land.lnd_type].l_name);
        prxy("%4d,%-4d ", land.lnd_x, land.lnd_y, player->cnum);
-       pr("%c ", land.lnd_army);
+       pr("%1.1s ", &land.lnd_army);
        pr("%4d%%", land.lnd_effic);
        pr("%4d", land.lnd_item[I_CIVIL]);
        pr("%4d", land.lnd_item[I_MILIT]);
index d6edd0bff253bac28ac2f252ec6a90b5dca15a85..6856eea8af488189c3917404a28846b8c37cd58b 100644 (file)
@@ -329,7 +329,7 @@ pr_plane(struct plnstr *plane)
     pr("Efficiency <e>: %d\t", plane->pln_effic);
     pr("Mobility <m>: %d\n", plane->pln_mobil);
     pr("Tech <t>: %d\t\t", plane->pln_tech);
-    pr("Wing <w>: %c\n", plane->pln_wing);
+    pr("Wing <w>: %.1s\n", &plane->pln_wing);
     pr("Range <r>: %d\t\t", plane->pln_range);
     pr("Flags <f>: %d\n", plane->pln_flags);
     pr("Ship <s>: %d\t\t", plane->pln_ship);
@@ -346,7 +346,7 @@ pr_land(struct lndstr *land)
     pr("Efficiency <e>: %d\t", land->lnd_effic);
     pr("Mobility <M>: %d\n", land->lnd_mobil);
     pr("Tech <t>: %d\t\t", land->lnd_tech);
-    pr("Army <a>: %c\n", land->lnd_army);
+    pr("Army <a>: %.1s\n", &land->lnd_army);
     pr("Fortification <F>: %d\t", land->lnd_harden);
     pr("Fuel <B>: %d\n", land->lnd_fuel);
     pr("Land unit <Y>: %d\n", land->lnd_land);
@@ -387,7 +387,7 @@ pr_ship(struct shpstr *ship)
     pr("Tech <T>: %d\t\t\t", ship->shp_tech);
     pr("Efficiency <E>: %d\n", ship->shp_effic);
     pr("Mobility <M>: %d\t\t", ship->shp_mobil);
-    pr("Fleet <F>: %c\n", ship->shp_fleet);
+    pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
     /* could depend on opt_FUEL - but a deity might want to set this
        up before enabling the option */
     pr("Fuel <B>: %d\n", ship->shp_fuel);
@@ -834,7 +834,7 @@ doship(char op, int arg, char *p, struct shpstr *ship)
        break;
     case 'F':
        if (p[0] == '~')
-           ship->shp_fleet = ' ';
+           ship->shp_fleet = 0;
        else if (isalpha(p[0]))
            ship->shp_fleet = p[0];
        else {
@@ -948,7 +948,7 @@ dounit(char op, int arg, char *p, struct lndstr *land)
        break;
     case 'a':
        if (p[0] == '~')
-           land->lnd_army = ' ';
+           land->lnd_army = 0;
        else if (isalpha(p[0]))
            land->lnd_army = p[0];
        else {
@@ -1079,7 +1079,7 @@ doplane(char op, int arg, char *p, struct plnstr *plane)
        break;
     case 'w':
        if (p[0] == '~')
-           plane->pln_wing = ' ';
+           plane->pln_wing = 0;
        else if (isalpha(p[0]))
            plane->pln_wing = p[0];
        else {
index 50ea41db535b62e3bde4157760f8da10db87ec7c..07e3ad6adf828ab9d72d474f5636d4f9883109fa 100644 (file)
@@ -62,7 +62,7 @@ flee(void)
        return RET_SYN;
     }
     if (c == '~')
-       c = ' ';
+       c = 0;
     if (!snxtitem(&nstr, EF_SHIP, player->argp[2]))
        return RET_SYN;
     count = 0;
index a82a7d035849a425e23ef02376737842ca52bb72..1d4665d090e7715bd3aa323a3164b77f6781c744 100644 (file)
@@ -77,7 +77,7 @@ land(void)
        pr("%4d ", ni.cur);
        pr("%-15.15s", lchr[(int)land.lnd_type].l_name);
        prxy(" %4d,%-4d", land.lnd_x, land.lnd_y, player->cnum);
-       pr("%c", land.lnd_army);
+       pr("%1.1s", &land.lnd_army);
        pr("%4d%%", land.lnd_effic);
        pr("%4d", land.lnd_item[I_MILIT]);
        pr("%4d", land.lnd_harden);
index b6d9295cafa9e7d2d18eafb16257f2168f250984..78e3a2e9a181bb16d99aed1321f7aad263607ab1 100644 (file)
@@ -326,10 +326,7 @@ ldump(void)
                pr(" %d", yrel(np, land.lnd_y));
                break;
            case 4:
-               if (land.lnd_army == ' ')
-                   pr(" ~");
-               else
-                   pr(" %c", land.lnd_army);
+               pr(" %c ", land.lnd_army ? land.lnd_army : '~');
                break;
            case 5:
                pr(" %d", land.lnd_effic);
index ae2058dae86a345ca2c7b6f37b444a02d24a09a0..cdfd9e39edc3778c919e2a5d029cc76f28cabea2 100644 (file)
@@ -222,10 +222,7 @@ pdump(void)
                pr(" %d", yrel(natp, plane.pln_y));
                break;
            case 4:
-               if (plane.pln_wing == ' ')
-                   pr(" ~");
-               else
-                   pr(" %c", plane.pln_wing);
+               pr(" %c ", plane.pln_wing ? plane.pln_wing : '~');
                break;
            case 5:
                pr(" %d", plane.pln_effic);
index d3d9cd8df78e4ce97e2e50a07ae9a6428e0f7264..d1bfd05e1c1c65d77d4f3de5f9074ce0f9b708f3 100644 (file)
@@ -65,9 +65,8 @@ plan(void)
            pr("%3d ", plane.pln_own);
        pr("%4d %-19.19s ", np.cur, plchr[(int)plane.pln_type].pl_name);
        prxy("%4d,%-4d", plane.pln_x, plane.pln_y, player->cnum);
-       pr(" %c %3d%% %3d %3d %4d %3d  %3d",
-          plane.pln_wing, plane.pln_effic,
-          plane.pln_mobil,
+       pr(" %1.1s %3d%% %3d %3d %4d %3d  %3d",
+          &plane.pln_wing, plane.pln_effic, plane.pln_mobil,
           plane.pln_def, plane.pln_tech,
           plane.pln_range, plane.pln_harden);
        if (plane.pln_ship >= 0)
index 3d284758381563a545f7095019718af2f9aa82dd..2b3828c27a099d9894f299f8e79470b36609c998 100644 (file)
@@ -160,7 +160,7 @@ retr(void)
        pr("%4d ", ni.cur);
        pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
        prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
-       pr("%c", ship.shp_fleet);
+       pr("%1.1s", &ship.shp_fleet);
        pr(" %-11s", ship.shp_rpath);
        if (ship.shp_rflags & RET_GROUP)
            pr("Yes     ");
@@ -289,7 +289,7 @@ lretr(void)
        pr("%4d ", ni.cur);
        pr("%-16.16s ", lchr[(int)land.lnd_type].l_name);
        prxy("%4d,%-4d ", land.lnd_x, land.lnd_y, player->cnum);
-       pr("%c", land.lnd_army);
+       pr("%1.1s", &land.lnd_army);
        pr(" %-11s", land.lnd_rpath);
        if (land.lnd_rflags & RET_GROUP)
            pr("Yes      ");
index 3ecaadf6545286c7eff0e24861b75b729d4b491f..24d05b7b63ce525ffaddef0d915ea1351dd3bdde 100644 (file)
@@ -288,10 +288,7 @@ sdump(void)
                pr(" %d", yrel(np, ship.shp_y));
                break;
            case 4:
-               if (ship.shp_fleet == ' ')
-                   pr(" ~");
-               else
-                   pr(" %c", ship.shp_fleet);
+               pr(" %c ", ship.shp_fleet ? ship.shp_fleet : '~');
                break;
            case 5:
                pr(" %d", ship.shp_effic);
index e47e178c73c3a14cbf090892b34c664eb63989a1..12a79a29e4196bb6d88759344c2b16e80b15f90d 100644 (file)
@@ -75,7 +75,7 @@ shi(void)
        pr("%4d ", ni.cur);
        pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
        prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
-       pr("%c", ship.shp_fleet);
+       pr("%1.1s", &ship.shp_fleet);
        pr("%4d%%", ship.shp_effic);
 
        pr("%4d", ship.shp_item[I_CIVIL]);
index 1dfc4a94387e99864f4c78ef55cd15eb93e4d0ac..fc77d80e15622b3e5b66e3f1487a55a7ad1137a6 100644 (file)
@@ -398,7 +398,7 @@ check_trade(void)
            tg.pln.pln_own = trade.trd_maxbidder;
            makenotlost(EF_PLANE, tg.pln.pln_own, tg.pln.pln_uid,
                        tg.pln.pln_x, tg.pln.pln_y);
-           tg.pln.pln_wing = ' ';
+           tg.pln.pln_wing = 0;
            /* no cheap version of fly */
            if (opt_MOB_ACCESS) {
                tg.pln.pln_mobil = -(etu_per_update / sect_mob_neg_factor);
@@ -428,7 +428,7 @@ check_trade(void)
            tg.lnd.lnd_own = trade.trd_maxbidder;
            makenotlost(EF_LAND, tg.lnd.lnd_own, tg.lnd.lnd_uid,
                        tg.lnd.lnd_x, tg.lnd.lnd_y);
-           tg.lnd.lnd_army = ' ';
+           tg.lnd.lnd_army = 0;
            /* no cheap version of fly */
            if (opt_MOB_ACCESS) {
                tg.lnd.lnd_mobil = -(etu_per_update / sect_mob_neg_factor);
index 84e03dda29bfe14fcced747065d1e8c8a60bab2e..ba4419134ad93c1b687b81fb3a121eebd1e3b0a8 100644 (file)
@@ -60,7 +60,7 @@ wing(void)
        return RET_SYN;
     }
     if (c == '~')
-       c = ' ';
+       c = 0;
     if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
        return RET_SYN;
     count = 0;
index 22b7890b117af2467abec616a269f74862534b26..fca680d3f0e92ba2d012fc0087a4d7f470160123 100644 (file)
@@ -921,7 +921,7 @@ att_prompt(char *prompt, char army)
     char buf[1024];
     char *p;
 
-    if (army == ' ')
+    if (!army)
        army = '~';
     for (;;) {
        p = getstring(prompt, buf);
@@ -1051,7 +1051,7 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def,
                    att_mode[combat_mode],
                    prland(&land),
                    prcom(1, off),
-                   land.lnd_army == ' ' ? '~' : land.lnd_army,
+                   land.lnd_army ? land.lnd_army : '~',
                    land.lnd_effic);
            land_answer[(int)land.lnd_army] =
                att_prompt(prompt, land.lnd_army);
@@ -2293,7 +2293,7 @@ ask_move_in(struct combat *off, struct emp_qelem *olist,
                continue;
            sprintf(prompt, "Move in with %s (%c %d%%) [ynYNq?] ",
                    prland(&llp->land),
-                   llp->land.lnd_army == ' ' ? '~' : llp->land.lnd_army,
+                   llp->land.lnd_army ? llp->land.lnd_army :  '~',
                    llp->land.lnd_effic);
            *answerp = att_prompt(prompt, llp->land.lnd_army);
            if (player->aborted || att_get_combat(def, 0) < 0)
index c89e9b66784db5e4068e83c50fe4230f4d4a77db..3c1559bdd73a760f0225fd1ddd1d6ad3305b07d5 100644 (file)
@@ -765,7 +765,7 @@ lnd_list(struct emp_qelem *land_list)
        pr("%4d ", lnd->lnd_uid);
        pr("%-16.16s ", llp->lcp->l_name);
        prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->land.lnd_own);
-       pr("%c", lnd->lnd_army);
+       pr("%1.1s", &lnd->lnd_army);
        pr("%4d%%", lnd->lnd_effic);
        pr("%4d", lnd->lnd_item[I_SHELL]);
        pr("%4d", lnd->lnd_item[I_GUN]);
index bafa098a14a4712073f328b0863490462fd5be83..b6600a12ebd758ebfb00e73aac2e88721b2f2107 100644 (file)
@@ -333,7 +333,7 @@ shp_list(struct emp_qelem *ship_list)
        pr("%4d ", shp->shp_uid);
        pr("%-16.16s ", mlp->mcp->m_name);
        prxy("%4d,%-4d ", shp->shp_x, shp->shp_y, mlp->ship.shp_own);
-       pr("%c", shp->shp_fleet);
+       pr("%1.1s", &shp->shp_fleet);
        pr("%4d%%", shp->shp_effic);
        pr("%4d", shp->shp_item[I_MILIT]);
        pr("%4d", shp->shp_item[I_SHELL]);
index 992a01cef54fd5795fc1ef1b572579c582e8cba1..4b8e5a8db6f0850a5ddd525e574676009fe1d548 100644 (file)
@@ -45,6 +45,9 @@
  * can select on NS_ALL, NS_AREA, NS_DIST, and NS_LIST.
  * iterate thru the "condarg" string looking
  * for arguments to compile into the nstr.
+ * Using this function for anything but command arguments is usually
+ * incorrect, because it respects conditionals.  Use the snxtitem_FOO()
+ * instead.
  */
 int
 snxtitem(struct nstr_item *np, int type, char *str)
@@ -195,7 +198,7 @@ void
 snxtitem_group(struct nstr_item *np, int type, char group)
 {
     if (group == '~')
-       group = ' ';
+       group = 0;
     memset(np, 0, sizeof(*np));
     np->cur = -1;
     np->sel = NS_GROUP;
index 89b2734e0268930eaeaa995bcf3d83a6c82ed871..be1f802708332d6e857130560dc21651b25c1417 100644 (file)
@@ -206,6 +206,7 @@ takeover_plane(struct plnstr *pp, natid newown)
     pp->pln_own = newown;
     makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
     pp->pln_mission = 0;
+    pp->pln_wing = 0;
     putplane(pp->pln_uid, pp);
 }
 
@@ -224,7 +225,7 @@ takeover_ship(struct shpstr *sp, natid newown, int hostile)
     sp->shp_own = newown;
     makenotlost(EF_SHIP, sp->shp_own, sp->shp_uid, sp->shp_x, sp->shp_y);
     sp->shp_mission = 0;
-    sp->shp_fleet = ' ';
+    sp->shp_fleet = 0;
     sp->shp_rflags = 0;
     /* Keep track of when this was taken over */
     time(&sp->shp_access);
@@ -279,7 +280,7 @@ takeover_land(struct lndstr *landp, natid newown, int hostile)
        putland(landp->lnd_uid, landp);
        return;
     }
-    landp->lnd_army = ' ';
+    landp->lnd_army = 0;
     landp->lnd_mobil = 0;
     landp->lnd_harden = 0;
     /* Keep track of when this was taken over */