]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/type.c
Update copyright notice
[empserver] / src / lib / common / type.c
index a7b9941a80c443c82d43b8b2181b5f4e7572b6a2..6c4253e747862dad772c5025a2857a1297e1e35f 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2020, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire 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
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  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
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
  *  ---
  *
  *  type.c: typename to array offset translation
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1989
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2004-2011
  */
 
 #include <config.h>
 
-#include <stddef.h>
-#include <string.h>
-#include "misc.h"
-#include "ship.h"
+#include "item.h"
 #include "land.h"
+#include "match.h"
+#include "nsc.h"
+#include "nuke.h"
 #include "plane.h"
+#include "product.h"
+#include "prototypes.h"
 #include "sect.h"
-#include "nuke.h"
-#include "file.h"
-#include "common.h"
-#include "match.h"
+#include "ship.h"
 
 /*
- * Return index of sector called NAME in dchr[], or M_NOTFOUND.
+ * Return index of sector called @name in dchr[], or M_NOTFOUND.
  */
 int
 sct_typematch(char *name)
@@ -62,7 +61,8 @@ sct_typematch(char *name)
 }
 
 /*
- * Search table TYPE for an element matching NAME, return its index.
+ * Search table @type for an element matching @name, return its index.
+ * Accepts EF_BAD, but of course never finds anything then.
  * Return M_NOTFOUND if there are no matches, M_NOTUNIQUE if there are
  * several.
  */
@@ -70,6 +70,8 @@ int
 ef_elt_byname(int type, char *name)
 {
     switch (type) {
+    case EF_BAD:
+       return M_NOTFOUND;
     case EF_NATION:
        return cnumb(name);
     case EF_SECTOR_CHR:
@@ -95,9 +97,9 @@ ef_elt_byname(int type, char *name)
                      offsetof(struct ichrstr, i_name),
                      sizeof(ichr[0]));
     case EF_PRODUCT:
-       return 1 + stmtch(name, pchr + 1,
-                         offsetof(struct pchrstr, p_sname),
-                         sizeof(pchr[0]));
+       return stmtch(name, pchr,
+                     offsetof(struct pchrstr, p_sname),
+                     sizeof(pchr[0]));
     case EF_TABLE:
        return stmtch(name, empfile,
                      offsetof(struct empfile, name),