From b69173eea4b90a4ad6c0a348a00166f94d87b7e9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 4 Jan 2006 14:36:21 +0000 Subject: [PATCH] (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. --- include/prototypes.h | 8 ++-- info/offset.t | 6 --- info/origin.t | 10 +++-- src/lib/commands/offs.c | 83 ----------------------------------------- src/lib/commands/orig.c | 42 ++++++++++++++++----- src/lib/player/empmod.c | 3 +- 6 files changed, 44 insertions(+), 108 deletions(-) delete mode 100644 info/offset.t delete mode 100644 src/lib/commands/offs.c diff --git a/include/prototypes.h b/include/prototypes.h index 31aec2083..c096c808d 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -79,6 +79,7 @@ extern s_char *prsub(struct shpstr *); extern int check_trade(void); extern int ontradingblock(int, int *); extern void trdswitchown(int, int *, int); +/* Commands */ int acce(void); int add(void); int anti(void); @@ -172,7 +173,6 @@ int newe(void); int news(void); int nuke(void); int offe(void); -int offs(void); int orde(void); int orig(void); int para(void); @@ -429,7 +429,7 @@ extern void log_last_commands(void); extern int gamedown(void); extern void daychange(time_t); extern int getminleft(time_t, int); -/* more in commands.h */ +/* more under Commands */ /* empmod.c */ /* init_nats.c */ extern int init_nats(void); @@ -444,7 +444,7 @@ extern char *praddr(struct player *); extern void player_main(struct player *); extern int match_user(char *, struct player *); extern int command(void); -/* more in commands.h */ +/* more under Commands */ /* recvclient.c */ extern int recvclient(char *, int); @@ -601,7 +601,7 @@ extern void pr(char *, ...) ATTRIBUTE((format (printf, 1, 2))); extern void uprnf(char *buf); extern void pr_id(struct player *, int, char *, ...) ATTRIBUTE((format (printf, 3, 4))); -extern void pr_flash(struct player *, char *format, ...) +extern void pr_flash(struct player *, char *, ...) ATTRIBUTE((format (printf, 2, 3))); extern void pr_inform(struct player *, char *, ...) ATTRIBUTE((format (printf, 2, 3))); diff --git a/info/offset.t b/info/offset.t deleted file mode 100644 index c6326e7f0..000000000 --- a/info/offset.t +++ /dev/null @@ -1,6 +0,0 @@ -.TH Command OFFSET -.NA offset "Temporarily change coordinate system" -.LV Expert -.SY "offset " -This should affect your maps. -.SA "Deity" diff --git a/info/origin.t b/info/origin.t index 3300d08a2..e800df363 100644 --- a/info/origin.t +++ b/info/origin.t @@ -1,9 +1,13 @@ .TH Command ORIGIN .NA origin "Change the origin of your country's coordinate system" .LV Expert -.SY "origin " -This command changes the origin of your coordinate system -(where 0,0 is located.) +.SY "origin " +This command moves the origin of your coordinate system +(where 0,0 is located). +.s1 +You can move it to another sector, or to the origin of an allied +country. Deities can also use a \*Q~\*U argument to move it to +absolute 0,0. .s1 This command does not change the location of your nation's capital, though its coordinates, like the coordinates of all other sectors, diff --git a/src/lib/commands/offs.c b/src/lib/commands/offs.c deleted file mode 100644 index f891e8ddb..000000000 --- a/src/lib/commands/offs.c +++ /dev/null @@ -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 - -#include -#include -#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; -} diff --git a/src/lib/commands/orig.c b/src/lib/commands/orig.c index d4fe88563..d5acc4fda 100644 --- a/src/lib/commands/orig.c +++ b/src/lib/commands/orig.c @@ -29,6 +29,7 @@ * * Known contributors to this file: * Shelley Louie, 1988 + * Markus Armbruster, 2006 */ #include @@ -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, §)) - 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; } diff --git a/src/lib/player/empmod.c b/src/lib/player/empmod.c index 2a8ea7b2f..6fd05c073 100644 --- a/src/lib/player/empmod.c +++ b/src/lib/player/empmod.c @@ -170,9 +170,8 @@ struct cmndstr player_coms[] = { {"nuke ", 0, nuke, 0, NORM}, {"offer [ ]", 1, offe, C_MOD, NORM + MONEY + CAP}, - {"offset ", 0, offs, C_MOD, GOD}, {"order ", 1, orde, C_MOD, NORM + CAP}, - {"origin ", 1, orig, C_MOD, NORM}, + {"origin ", 1, orig, C_MOD, NORM}, {"paradrop ", 3, para, C_MOD, NORM + MONEY + CAP}, {"path ", 0, path, 0, NORM}, {"payoff ", 0, payo, C_MOD, NORM}, -- 2.43.0