]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/tran.c
commands: Rename the command functions
[empserver] / src / lib / commands / tran.c
index 7dba719efcce7119a7bbaaac115344e53f8d8d93..d99538b914d10b0f044da499644b11c28053a5fe 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
- *     Markus Armbruster, 2006-2011
+ *     Markus Armbruster, 2006-2016
  */
 
 #include <config.h>
@@ -42,9 +42,10 @@ static int tran_pmap(coord, coord, char *, char *);
 static int tran_nmap(coord, coord, char *, char *);
 static int tran_nuke(void);
 static int tran_plane(void);
+static int pln_weight(struct plnstr *);
 
 int
-tran(void)
+c_transport(void)
 {
     char *what;
     char buf[1024];
@@ -147,7 +148,7 @@ tran_plane(void)
     coord dstx, dsty;
     int mcost;
     int weight, count;
-    int type, dam;
+    int dam;
     struct nstr_item nstr;
     struct plnstr plane;
     struct sctstr sect;
@@ -166,7 +167,6 @@ tran_plane(void)
     while (nxtitem(&nstr, &plane)) {
        if (!player->owner)
            continue;
-       type = plane.pln_type;
        if (plane.pln_ship >= 0) {
            pr("%s is stowed on ship #%d, and can't be transported\n",
               prplane(&plane), plane.pln_ship);
@@ -193,7 +193,7 @@ tran_plane(void)
                return RET_FAIL;
            }
        }
-       weight += plchr[type].pl_lcm + (plchr[type].pl_hcm * 2);
+       weight += pln_weight(&plane);
        ++count;
     }
     if (count == 0) {
@@ -241,6 +241,17 @@ tran_plane(void)
     return RET_OK;
 }
 
+static int
+pln_weight(struct plnstr *pp)
+{
+    int w, i;
+
+    w = 0;
+    for (i = I_NONE + 1; i <= I_MAX; i++)
+       w += plchr[pp->pln_type].pl_mat[i] * ichr[i].i_lbs;
+    return w;
+}
+
 /*
  * Pretty tacky, but it works.
  * If more commands start doing this, then