edit: Report sector loss and gain properly for key 'L'

Send bulletin to owner and report news exactly like for key 'o'.

Also print a "sector duplicated" message, just for consistency with
other keys.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2013-01-26 08:58:14 +01:00
parent a41c74967d
commit fec5ad692d
6 changed files with 136 additions and 15 deletions

42
include/actofgod.h Normal file
View file

@ -0,0 +1,42 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire 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 3 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, see <http://www.gnu.org/licenses/>.
*
* ---
*
* See files README, COPYING and CREDITS in the root of the source
* tree for related information and legal notices. It is expected
* that future projects/authors will amend these files as needed.
*
* ---
*
* actofgod.h: Deity meddling
*
* Known contributors to this file:
* Markus Armbruster, 2013
*/
#ifndef ACTOFGOD_H
#define ACTOFGOD_H
#include "item.h"
#include "nat.h"
extern void report_god_takes(char *, char *, natid);
extern void report_god_gives(char *, char *, natid);
#endif

View file

@ -384,6 +384,8 @@ extern void stop_service(void);
/*
* src/lib/subs/ *.c
*/
/* actofgod.c */
/* in actofgod.h */
/* askyn.c */
extern int confirm(char *);
extern int askyn(char *);

View file

@ -38,6 +38,7 @@
#include <ctype.h>
#include <limits.h>
#include "actofgod.h"
#include "commands.h"
#include "item.h"
#include "land.h"
@ -421,6 +422,7 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
{
coord newx, newy;
int new;
struct sctstr newsect;
switch (*key) {
case 'o':
@ -431,21 +433,13 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
prnatid(sect->sct_own), prnatid(arg));
if (arg == sect->sct_own)
break;
if (sect->sct_own && sect->sct_own != player->cnum) {
wu(0, sect->sct_own,
"Sector %s taken from you by an act of %s!\n",
report_god_takes("Sector ",
xyas(sect->sct_x, sect->sct_y, sect->sct_own),
cname(player->cnum));
}
benefit(sect->sct_own, -1);
sect->sct_own = arg;
if (arg && arg != player->cnum) {
wu(0, arg,
"Sector %s given to you by an act of %s!\n",
sect->sct_own);
report_god_gives("Sector ",
xyas(sect->sct_x, sect->sct_y, arg),
cname(player->cnum));
}
benefit(arg, 1);
arg);
sect->sct_own = arg;
break;
case 'O':
if (arg < 0 || arg >= MAXNOC)
@ -553,6 +547,14 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
case 'L':
if (!sarg_xy(p, &newx, &newy))
return RET_SYN;
getsect(newx, newy, &newsect);
pr("Sector %s duplicated to %s\n",
xyas(sect->sct_x, sect->sct_y, player->cnum),
xyas(newx, newy, player->cnum));
report_god_takes("Sector ", xyas(newx, newy, newsect.sct_own),
newsect.sct_own);
report_god_gives("Sector ", xyas(newx, newy, sect->sct_own),
sect->sct_own);
sect->sct_x = newx;
sect->sct_y = newy;
ef_set_uid(EF_SECTOR, &sect, XYOFFSET(newx, newy));

67
src/lib/subs/actofgod.c Normal file
View file

@ -0,0 +1,67 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire 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 3 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, see <http://www.gnu.org/licenses/>.
*
* ---
*
* See files README, COPYING and CREDITS in the root of the source
* tree for related information and legal notices. It is expected
* that future projects/authors will amend these files as needed.
*
* ---
*
* actofgod.c: Deity meddling subroutines
*
* Known contributors to this file:
* Markus Armbruster, 2013
*/
#include <config.h>
#include "actofgod.h"
#include "file.h"
#include "news.h"
#include "optlist.h"
#include "player.h"
#include "prototypes.h"
static void
nreport_divine_aid(natid whom, int goodness)
{
if (opt_GODNEWS && getnatp(whom)->nat_stat != STAT_GOD && goodness)
nreport(player->cnum, goodness > 0 ? N_AIDS : N_HURTS, whom, 1);
}
void
report_god_takes(char *prefix, char *what, natid from)
{
if (from && from != player->cnum) {
wu(0, from, "%s%s taken from you by an act of %s!\n",
prefix, what, cname(player->cnum));
nreport_divine_aid(from, -1);
}
}
void
report_god_gives(char *prefix, char *what, natid to)
{
if (to && to != player->cnum) {
wu(0, to, "%s%s given to you by an act of %s!\n",
prefix, what, cname(player->cnum));
nreport_divine_aid(to, 1);
}
}

View file

@ -360,12 +360,15 @@ actor action victim times duration time
0 42 3 49 0 0
0 42 2 38 0 0
0 42 1 39 0 0
0 44 3 1 0 0
0 43 3 1 0 0
0 44 1 19 0 0
0 43 2 1 0 0
0 44 3 2 0 0
0 43 3 2 0 0
0 43 1 54 0 0
0 42 1 4 0 0
1 45 0 1 0 0
0 43 3 1 0 0
/config
config treaty
uid cna cnb status acond bcond exp

View file

@ -127,9 +127,11 @@
Play#0 output Play#0 6 0 640
Play#0 input edit l 1,7 L 1,-7
Play#0 command edit
Play#0 output Play#0 1 Sector 1,7 duplicated to 1,-7
Play#0 output Play#0 6 0 640
Play#0 input edit l 3,-7 L 3,-7 L 1,0
Play#0 command edit
Play#0 output Play#0 1 Sector 3,-7 duplicated to 3,-7
Play#0 output Play#0 1 Usage: edit <country|land|ship|plane|unit> <NAT|SECT|SHIP|PLANE|LAND> [<KEY> <VALUE>]...
Play#0 output Play#0 6 0 640
Play#0 input edit l 1,1 e 0
@ -1595,6 +1597,9 @@
Play#0 command read
Play#0 output Play#0 1
Play#0 output Play#0 1 > BULLETIN from POGO, (#0) dated Thu Jan 1 00:00:00 1970
Play#0 output Play#0 1 Sector 1,-7 taken from you by an act of POGO!
Play#0 output Play#0 1 Sector 3,-7 taken from you by an act of POGO!
Play#0 output Play#0 1 Sector 3,-7 given to you by an act of POGO!
Play#0 output Play#0 1 cs cargo ship (#0) taken from you by an act of POGO!
Play#0 output Play#0 1 cs cargo ship (#1) taken from you by an act of POGO!
Play#0 output Play#0 1 cs cargo ship (#2) taken from you by an act of POGO!