src/lib/commands/map.c

Go to the documentation of this file.
00001 /*
00002  *  Empire - A multi-player, client/server Internet based war game.
00003  *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
00004  *                           Ken Stevens, Steve McClure
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  *  ---
00021  *
00022  *  See files README, COPYING and CREDITS in the root of the source
00023  *  tree for related information and legal notices.  It is expected
00024  *  that future projects/authors will amend these files as needed.
00025  *
00026  *  ---
00027  *
00028  *  map.c: Display a map of sectors.
00029  * 
00030  *  Known contributors to this file:
00031  *     Dave Pare, 1986
00032  *     Ken Stevens, 1995
00033  */
00034 
00035 #include <config.h>
00036 
00037 #include "commands.h"
00038 #include "land.h"
00039 #include "map.h"
00040 #include "optlist.h"
00041 #include "ship.h"
00042 
00043 int
00044 map(void)
00045 {
00046     int unit_type = EF_BAD;
00047     int bmap = 0;
00048     char *str;
00049     char buf[1024];
00050     char prompt[128];
00051 
00052     if (**player->argp != 'm') {
00053         if (**player->argp == 'b')
00054             bmap = 'b';
00055         else if (**player->argp == 'n') {
00056             unit_type = EF_NUKE;
00057             if (player->argp[0][1] == 'b')
00058                 bmap = 'b';
00059             else
00060                 bmap = 'n';
00061         } else {
00062             if (**player->argp == 'l')
00063                 unit_type = EF_LAND;
00064             else if (**player->argp == 'p')
00065                 unit_type = EF_PLANE;
00066             else if (**player->argp == 's')
00067                 unit_type = EF_SHIP;
00068             else {
00069                 logerror("map: bad player->argp[0]");
00070                 return RET_SYN;
00071             }
00072             if (player->argp[0][1] == 'b')
00073                 bmap = 'b';
00074         }
00075     }
00076 
00077     if (player->argp[1] == NULL) {
00078         if (unit_type == EF_BAD) {
00079             str = getstring("(sects)? ", buf);
00080         } else {
00081             sprintf(prompt, "(sects, %s)? ", ef_nameof(unit_type));
00082             str = getstring(prompt, buf);
00083         }
00084 
00085         if (!str || !*str)
00086             return RET_SYN;
00087     } else
00088         str = player->argp[1];
00089 
00090     if (unit_type == EF_BAD)
00091         unit_type = EF_SHIP;
00092 
00093     return do_map(bmap, unit_type, str, player->argp[2]);
00094 }

Generated on Fri Mar 28 11:01:12 2008 for empserver by  doxygen 1.5.2