2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * getvar.c: Routines for manipulating variable lists.
30 * Known contributors to this file:
40 getvar(int vtype, s_char *sp, int ptype)
47 if (ef_vars(ptype, sp, &nvp, &vtypep, &vamtp) < 0) {
48 logerror("getvar: ptype %d has no vars", ptype);
51 amt = vl_find(vtype, vtypep, vamtp, (int)*nvp);
53 logerror("getvar: vl_find returns %d, vtype %d", amt, vtype);
60 getvec(int class, int *vec, s_char *sp, int ptype)
67 if (ef_vars(ptype, sp, &nvp, &vtypep, &vamtp) < 0) {
68 logerror("getvec: ptype %d has no vars", ptype);
71 nv = vl_getvec(vtypep, vamtp, (int)*nvp, class, vec);
73 logerror("vl_getvec: returns %d, ptype %d\n", nv, ptype);
80 putvar(int vtype, int amt, s_char *sp, int ptype)
87 if (vtype < 0 || vtype > V_MAX) {
88 logerror("putvar: bad vtype %d\n", vtype);
91 if ((maxv = ef_vars(ptype, sp, &nvp, &vtypep, &vamtp)) < 0) {
92 logerror("putvar: ptype %d has no vars", ptype);
97 return vl_set(vtype, (u_int)amt, vtypep, vamtp, nvp, maxv);
101 putvec(int class, int *vec, s_char *sp, int ptype)
108 if ((maxv = ef_vars(ptype, sp, &nvp, &vtypep, &vamtp)) < 0) {
109 logerror("putvec: ptype %d has no vars", ptype);
112 for (x = 0; x < I_MAX; x++)
115 return vl_setvec(vtypep, vamtp, nvp, maxv, class, vec);