/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
return RET_OK;
}
-static void
-warn_deprecated_arg(char *what, char *arg, char *use)
-{
- pr("%s '%s' is deprecated and will go away in a future release.\n"
- "Use %s instead.\n",
- what, arg, use);
-}
-
static int
parse_map_flags(int bmap, char *str)
{
int map_flags;
char *p;
- int tflags = 0;
- char *tp = NULL;
switch (bmap) {
default: CANT_REACH();
if (bmap != 'b')
goto bad_flag;
map_flags |= MAP_ALT;
- /*
- * Flags following 't' used to be ignored. That breaks
- * perfectly sensible "ts". Try to continue, but save
- * state for when a bad flag is found.
- */
- if (!tflags) {
- tflags = map_flags;
- tp = p;
- }
break;
- case 'r':
- if (bmap != 'b' || tflags)
- goto bad_flag;
- warn_deprecated_arg("Map flag", "r", "argument 'revert'");
- return MAP_BMAP_REVERT;
default:
bad_flag:
- if (tflags) {
- /* ignore bad flags following 't' */
- warn_deprecated_arg("Argument", tp, "map flag 't'");
- return tflags;
- }
pr("Bad flag %c!\n", *p);
return -1;
}
}
/*
- * Return character to use in maps for sector type TYPE owned by OWN.
- * If OWNER_OR_GOD, the map is for the sector's owner or a deity.
+ * Return character to use in maps for sector type @type owned by @own.
+ * If @owner_or_god, the map is for the sector's owner or a deity.
*/
static char
map_char(int type, natid own, int owner_or_god)
return draw_map(origin, map_flags, &ns);
}
+int
+nav_map(int x, int y, int show_designations)
+{
+ char *ptr;
+ struct nstr_sect ns;
+ struct sctstr sect;
+ int i;
+ /* Note this is not re-entrant anyway, so we keep the buffers
+ around */
+ static char *wmapbuf = NULL;
+ static char **wmap = NULL;
+ int changed = 0;
+
+ if (!wmapbuf)
+ wmapbuf = malloc(WORLD_Y * MAPWIDTH(1));
+ if (!wmap) {
+ wmap = malloc(WORLD_Y * sizeof(*wmap));
+ if (wmap && wmapbuf) {
+ for (i = 0; i < WORLD_Y; i++)
+ wmap[i] = &wmapbuf[MAPWIDTH(1) * i];
+ } else if (wmap) {
+ free(wmap);
+ wmap = NULL;
+ }
+ }
+ if (!wmapbuf || !wmap) {
+ pr("Memory error, tell the deity.\n");
+ logerror("malloc failed in navi\n");
+ return RET_FAIL;
+ }
+ snxtsct_dist(&ns, x, y, 1);
+ blankfill(wmapbuf, &ns.range, 1);
+ while (nxtsct(&ns, §)) {
+ ptr = &wmap[ns.dy][ns.dx];
+ *ptr = dchr[sect.sct_type].d_mnem;
+ if (!show_designations &&
+ sect.sct_own != player->cnum &&
+ sect.sct_type != SCT_WATER &&
+ sect.sct_type != SCT_BSPAN && sect.sct_type != SCT_HARBR)
+ *ptr = '?';
+ changed += map_set(player->cnum, sect.sct_x, sect.sct_y, *ptr, 0);
+ /*
+ * We do it this way so that 'x' and 'X'
+ * bdesignations will show up. This can
+ * be used to mark mined sectors. So, the
+ * player will see the current des, UNLESS
+ * they've marked the sector 'x' or 'X',
+ * in which case they'll see that.
+ * --ts
+ */
+ *ptr = player->bmap[sect.sct_uid];
+ }
+ if (changed)
+ writemap(player->cnum);
+ for (i = 0; i < ns.range.height; i++)
+ pr("%s\n", wmap[i]);
+ return RET_OK;
+}
+
int
bmaps_intersect(natid a, natid b)
{