(orig): Allow moving origin to another country's origin. This is a

superset of the offset command.
(offs): Redundant, underdocumented, remove.

(orig): Allow deities to reset origin to absolute 0,0.
This commit is contained in:
Markus Armbruster 2006-01-04 14:36:21 +00:00
parent c13a592bf5
commit b69173eea4
6 changed files with 44 additions and 108 deletions

View file

@ -1,83 +0,0 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program 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
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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
*
* ---
*
* See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
* related information and legal notices. It is expected that any future
* projects/authors will amend these files as needed.
*
* ---
*
* offs.c: Diety set mapping offset.
*
* Known contributors to this file:
*
*/
#include <config.h>
#include <ctype.h>
#include <string.h>
#include "misc.h"
#include "player.h"
#include "file.h"
#include "nat.h"
#include "commands.h"
int
offs(void)
{
register int i;
struct natstr *natp;
coord xorg, yorg;
coord dx, dy;
s_char *cp;
struct natstr *np;
s_char buf[1024];
natp = getnatp(player->cnum);
xorg = natp->nat_xorg;
yorg = natp->nat_yorg;
if (!(cp = getstarg(player->argp[1], "sector or nation? ", buf)))
return RET_SYN;
if (strchr(cp, ',')) { /* x, y pair for offset */
if (!sarg_xy(cp, &dx, &dy)) {
pr("Bad sector designation.\n");
return RET_SYN;
}
xorg = dx;
yorg = dy;
} else {
/* actually nation name */
if ((i = natarg(cp, (s_char *)0)) < 0)
return RET_SYN;
np = getnatp(i);
xorg = np->nat_xorg;
yorg = np->nat_yorg;
}
np = getnatp(player->cnum);
/* NOTE: it's OK to use %d,%d here, because we want abs coords */
pr("Old offset was %d,%d\n", np->nat_xorg, np->nat_yorg);
np->nat_xorg = xorg;
np->nat_yorg = yorg;
putnat(np);
pr("New offset was %d,%d\n", xorg, yorg);
return RET_OK;
}

View file

@ -29,6 +29,7 @@
*
* Known contributors to this file:
* Shelley Louie, 1988
* Markus Armbruster, 2006
*/
#include <config.h>
@ -44,25 +45,46 @@
int
orig(void)
{
struct sctstr sect;
s_char *p;
coord x, y;
s_char buf[1024];
natid cnum;
struct natstr *np;
if ((p =
getstarg(player->argp[1], "New origin location : ", buf)) == 0) {
p = getstarg(player->argp[1], "New origin (sector or country) : ", buf);
if (!p)
return RET_SYN;
if (!isalpha(*p) && strchr(p, ',')) {
/* sector */
if (!sarg_xy(p, &x, &y)) {
pr("Bad sector designation.\n");
return RET_SYN;
}
} else if (*p == '~') {
/* reset */
if (!player->god) {
pr("Only deities can reset their origin.\n");
return RET_FAIL;
}
x = y = 0;
} else {
/* country */
cnum = natarg(p, NULL);
if (!(np = getnatp(cnum)))
return RET_SYN;
if (!player->god && player->cnum != cnum
&& getrel(np, player->cnum) != ALLIED) {
pr("Country %s is not allied with you!\n", np->nat_cnam);
return RET_FAIL;
}
x = np->nat_xorg;
y = np->nat_yorg;
}
if (!sarg_xy(p, &x, &y))
return RET_SYN;
if (!getsect(x, y, &sect))
return RET_SYN;
pr("Origin at %s (old system) is now at 0,0 (new system).\n",
xyas(sect.sct_x, sect.sct_y, player->cnum));
xyas(x, y, player->cnum));
np = getnatp(player->cnum);
np->nat_xorg = sect.sct_x;
np->nat_yorg = sect.sct_y;
np->nat_xorg = x;
np->nat_yorg = y;
putnat(np);
return RET_OK;
}

View file

@ -170,9 +170,8 @@ struct cmndstr player_coms[] = {
{"nuke <SECTS>", 0, nuke, 0, NORM},
{"offer <loan|treaty> <NAT> [<NUM> <DAYS> <IRATE>]", 1, offe, C_MOD,
NORM + MONEY + CAP},
{"offset <SECT|NAT>", 0, offs, C_MOD, GOD},
{"order <SHIPS> <c|s|r|d|l> ", 1, orde, C_MOD, NORM + CAP},
{"origin <SECT>", 1, orig, C_MOD, NORM},
{"origin <SECT|COUNTRY|~>", 1, orig, C_MOD, NORM},
{"paradrop <cargo-PLANES> <fighter-PLANES> <ap-SECT> <PATH|DESTINATION>", 3, para, C_MOD, NORM + MONEY + CAP},
{"path <SECT>", 0, path, 0, NORM},
{"payoff <SHIPS>", 0, payo, C_MOD, NORM},