Remove option TREATIES

TREATIES has issues:

* Treaties can cover attack, assault, paradrop, board, lboard, fire,
  build (s|p|l|n) and enlist, but not bomb, launch, torpedo and
  enlistment centers.

* Usability is very poor.  While a treaty is in effect, every player
  action that violates a treaty condition triggers a prompt like this:

    This action is in contravention of  treaty #0 (with Curmudgeon)
    Do you wish to go ahead anyway? [yn]

  If you decline, the action is not executed.  If you accept, it is.
  In both cases, your decision is reported in the news.

  You cannot get rid of these prompts until the treaty expires.

* Virtually nobody uses them.

* Virtually unused code is buggy code.  There is at least one race
  condition: multifire() reads the firing sector, ship or land unit
  before the treaty prompt, and writes it back after, triggering a
  generation oops.  Any updates made by other threads while trechk()
  waits for input are wiped out, triggering a seqno mismatch oops.

* The treaty prompts could confuse smart clients that aren't prepared
  for them.  WinACE isn't, but is reported to work anyway at least
  common usage.  Ron Koenderink (the WinACE maintainer) suspects there
  could be a few situations where it will fail.

This feature is not earning its keep.  Remove it.  Drop command
treaty, consider treaty, offer treaty, xdump treaty, reject treaties.
Output of accept changed, obviously.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-01-11 18:02:53 +01:00
parent b2090ed34f
commit a109de948b
60 changed files with 415 additions and 1300 deletions

View file

@ -639,14 +639,10 @@ att_approach(struct combat *off, struct combat *def)
/* The attack is valid. Tell the attacker about what they're going to hit */
int
void
att_show(struct combat *def)
{
/* Note that we tell the player about the treaty BEFORE we tell them
about the item. If we didn't, then they gain free information */
if (def->type == EF_SECTOR) {
if (!trechk(player->cnum, def->own, LANATT))
return abort_attack();
pr("%s is a %d%% %s %s with approximately %d military.\n",
xyas(def->x, def->y, player->cnum),
roundintby((int)def->eff, 10),
@ -655,19 +651,10 @@ att_show(struct combat *def)
if (map_set(player->cnum, def->x, def->y, def->sct_dcp->d_mnem, 0))
writemap(player->cnum);
} else if (def->type == EF_SHIP || def->type == EF_LAND) {
if (def->type == EF_SHIP) {
if (!trechk(player->cnum, def->own, SEAATT))
return abort_attack();
} else {
if (!trechk(player->cnum, def->own, LNDATT))
return abort_attack();
}
pr("%s is about %d%% efficient and has approximately %d mil on board.\n",
prcom(0, def), roundintby((int)def->eff, 10),
roundintby(def->troops, 10));
}
/* Ok, everything is fine */
return 0;
}
/* Attack and assault ask the user which kind of support they want */

View file

@ -38,9 +38,6 @@
* some kind of payment plan...like house payments
* and such, where the bucks just get paid up each
* update or so.
*
* I'd have made this more like treaty if I weren't
* so disgusted with how it works.
*/
#include <config.h>

View file

@ -1,86 +0,0 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2014, 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.
*
* ---
*
* distrea.c: Display treaty information
*
* Known contributors to this file:
*
*/
#include <config.h>
#include "file.h"
#include "nat.h"
#include "nsc.h"
#include "player.h"
#include "prototypes.h"
#include "treaty.h"
int
distrea(int n, struct trtstr *tp)
{
int i;
int acond, bcond, cond;
time_t now;
if (tp->trt_status == TS_FREE)
return 0;
if (tp->trt_cna != player->cnum &&
tp->trt_cnb != player->cnum && !player->god)
return 0;
(void)time(&now);
if (now > tp->trt_exp) {
tp->trt_status = TS_FREE;
if (!puttre(n, tp)) {
pr("Couldn't save treaty; get help!\n");
return 0;
}
pr("Treaty #%d expired %s", n, ctime(&tp->trt_exp));
return 0;
}
pr("\n * * * Empire Treaty #%d * * *\n", n);
if (tp->trt_status == TS_PROPOSED)
pr("(proposed)\n");
pr("between %s and ", cname(tp->trt_cna));
pr("%s expires %s", cname(tp->trt_cnb), ctime(&tp->trt_exp));
pr("%24.24s terms", cname(tp->trt_cna));
pr(" - %s terms\n", cname(tp->trt_cnb));
for (i = 0; 0 != (cond = treaty_flags[i].value); i++) {
acond = tp->trt_acond & cond;
bcond = tp->trt_bcond & cond;
if (acond | bcond) {
if (acond)
pr("%30s", treaty_flags[i].name);
else
pr("%30s", "");
if (bcond)
pr(" - %s\n", treaty_flags[i].name);
else
pr(" -\n");
}
}
return 1;
}

View file

@ -102,7 +102,6 @@ ef_open_srv(void)
failed |= !ef_open(EF_GAME, EFF_MEM);
failed |= !ef_open(EF_NEWS, 0);
failed |= !ef_open(EF_LOAN, 0);
failed |= !ef_open(EF_TREATY, 0);
failed |= !ef_open(EF_NUKE, EFF_MEM);
failed |= !ef_open(EF_POWER, 0);
failed |= !ef_open(EF_TRADE, 0);
@ -131,7 +130,6 @@ ef_close_srv(void)
ef_close(EF_GAME);
ef_close(EF_NEWS);
ef_close(EF_LOAN);
ef_close(EF_TREATY);
ef_close(EF_NUKE);
ef_close(EF_POWER);
ef_close(EF_TRADE);

View file

@ -1,132 +0,0 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2014, 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.
*
* ---
*
* trechk.c: Check to see if an actor has violated a treaty.
*
* Known contributors to this file:
* Steve McClure, 1998-1999
*/
/*
* Check to see if an actor has a treaty forbidding a given action,
* and if so, see if the actor wishes to break the treaty.
* All applicable treaties are checked. All treaties must be broken
* if the action is to be allowed. Propsed treaties are warned about,
* but no mention of broken pending treaties are made in the news.
*/
#include <config.h>
#include "file.h"
#include "nat.h"
#include "news.h"
#include "optlist.h"
#include "prototypes.h"
#include "treaty.h"
int
trechk(natid actor, natid victim, int provision)
{
natid cn;
char buf[1024];
int news_verb;
int involved[MAXNOC];
struct trtstr treaty;
time_t now;
int conditions;
natid other;
int broken;
int applied;
struct nstr_item nstr;
if (!opt_TREATIES)
return 1;
(void)time(&now);
broken = 0;
applied = 0;
for (cn = 0; cn < MAXNOC; cn++)
involved[cn] = 0;
snxtitem_all(&nstr, EF_TREATY);
while (nxtitem(&nstr, &treaty)) {
if (treaty.trt_status == TS_FREE)
continue;
if (treaty.trt_exp < now)
continue;
if (actor == treaty.trt_cna) {
conditions = treaty.trt_acond;
other = treaty.trt_cnb;
} else if (actor == treaty.trt_cnb) {
conditions = treaty.trt_bcond;
other = treaty.trt_cna;
} else
continue;
if ((conditions & provision) == 0)
continue;
if (victim != other) {
switch (provision) {
/* These are violations no matter who the victim is */
case NEWSHP:
case NEWLND:
case NEWNUK:
case NEWPLN:
case TRTENL:
break;
default:
/* The rest are only violations against the victim */
continue;
}
}
/* treaty applies to actor */
applied++;
pr("This action is in contravention of ");
if (treaty.trt_status == TS_PROPOSED)
pr("pending ");
pr(" treaty #%d (with %s)\n", nstr.cur, cname(other));
getstring("Do you wish to go ahead anyway? [yn] ", buf);
if (*buf == 'n' || *buf == 'N')
broken = 0;
else
broken = 1;
if (treaty.trt_status == TS_SIGNED)
involved[other]++;
}
if (applied > 0) {
news_verb = N_HONOR_TRE;
if (broken > 0)
news_verb = N_VIOL_TRE;
for (cn = 0; cn < MAXNOC; cn++)
if (involved[cn] > 0)
nreport(actor, news_verb, cn, 1);
}
if (applied && !broken) {
/*
* if any treaty applied, and none were broken
* the intended action is NOT performed.
*/
return 0;
}
return 1;
}