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

@ -24,7 +24,7 @@
*
* ---
*
* acce.c: Report rejection status of telegrams/treaties/annos/loans
* acce.c: Report rejection status of telegrams/annos/loans
*
* Known contributors to this file:
*
@ -35,7 +35,7 @@
#include "commands.h"
/*
* report rejection status of telegrams and treaties.
* report rejection status
* Optional argument reports staus from the
* viewpoint of another country
*/
@ -44,22 +44,14 @@ acce(void)
{
static char *rejects[] = {
/* must follow reject flags defined in nat.h */
" YES YES YES YES",
" NO YES YES YES",
" YES NO YES YES",
" NO NO YES YES",
" YES YES NO YES",
" NO YES NO YES",
" YES NO NO YES",
" NO NO NO YES",
" YES YES YES NO ",
" NO YES YES NO ",
" YES NO YES NO ",
" NO NO YES NO ",
" YES YES NO NO ",
" NO YES NO NO ",
" YES NO NO NO ",
" NO NO NO NO "
" YES YES YES",
" NO YES YES",
" YES NO YES",
" NO NO YES",
" YES YES NO ",
" NO YES NO ",
" YES NO NO ",
" NO NO NO ",
};
struct natstr *natp;
struct natstr *np;
@ -75,9 +67,9 @@ acce(void)
as = natp->nat_cnum;
pr("\t%s Acceptance Status Report\t", cname(as));
prdate();
pr("\n Acceptance status %5s theirs\n",
player->cnum == as ? "yours" : " his");
pr(" tel trty anno loan tel trty anno loan\n");
pr("\n Acceptance status %s theirs\n",
player->cnum == as ? "yours" : " his ");
pr(" tel anno loan tel anno loan\n");
for (cn = 0; cn < MAXNOC; cn++) {
if (cn == as)
continue;

View file

@ -89,10 +89,8 @@ assa(void)
return RET_OK;
}
/* Show what we're assaulting, and check treaties */
if (att_show(def))
return RET_FAIL;
/* Show what we're assaulting */
att_show(def);
/* Ask about offensive support */

View file

@ -72,10 +72,8 @@ atta(void)
if (att_abort(A_ATTACK, NULL, def))
return RET_FAIL;
/* Show what we're attacking, and check treaties */
if (att_show(def))
return RET_FAIL;
/* Show what we're attacking */
att_show(def);
/* Ask about offensive support */

View file

@ -122,10 +122,8 @@ boar(void)
return RET_OK;
}
/* Show what we're boarding, and check treaties */
if (att_show(def))
return RET_FAIL;
/* Show what we're boarding */
att_show(def);
/* Ask the player what he wants to board with */

View file

@ -46,7 +46,6 @@
#include "plague.h"
#include "plane.h"
#include "ship.h"
#include "treaty.h"
#include "unit.h"
static int build_ship(struct sctstr *sp, int type, int tlev);
@ -240,10 +239,6 @@ build_ship(struct sctstr *sp, int type, int tlev)
cost = mp->m_cost * SHIP_MINEFF / 100.0;
if (!build_can_afford(cost, mp->m_name))
return 0;
if (!trechk(player->cnum, 0, NEWSHP))
return 0;
if (!check_sect_ok(sp))
return 0;
sp->sct_avail -= avail;
player->dolcost += cost;
ef_blank(EF_SHIP, pick_unused_unit_uid(EF_SHIP), &ship);
@ -331,10 +326,6 @@ build_land(struct sctstr *sp, int type, int tlev)
return 0;
}
#endif
if (!trechk(player->cnum, 0, NEWLND))
return 0;
if (!check_sect_ok(sp))
return 0;
avail = (LND_BLD_WORK(lp->l_lcm, lp->l_hcm) * LAND_MINEFF + 99) / 100;
if (sp->sct_avail < avail) {
pr("Not enough available work in %s to build a %s\n",
@ -421,10 +412,6 @@ build_nuke(struct sctstr *sp, int type, int tlev)
pr(" (%d available work required)\n", avail);
return 0;
}
if (!trechk(player->cnum, 0, NEWNUK))
return 0;
if (!check_sect_ok(sp))
return 0;
sp->sct_avail -= avail;
player->dolcost += np->n_cost;
ef_blank(EF_NUKE, pick_unused_unit_uid(EF_NUKE), &nuke);
@ -494,10 +481,6 @@ build_plane(struct sctstr *sp, int type, int tlev)
xyas(sp->sct_x, sp->sct_y, player->cnum));
return 0;
}
if (!trechk(player->cnum, 0, NEWPLN))
return 0;
if (!check_sect_ok(sp))
return 0;
sp->sct_avail -= avail;
player->dolcost += cost;
ef_blank(EF_PLANE, pick_unused_unit_uid(EF_PLANE), &plane);

View file

@ -24,7 +24,7 @@
*
* ---
*
* cons.c: Consider a loan or treaty
* cons.c: Consider a loan
*
* Known contributors to this file:
* Markus Armbruster, 2004-2014
@ -36,23 +36,18 @@
#include "loan.h"
#include "news.h"
#include "optlist.h"
#include "treaty.h"
/*
* Things common to a loan or treaty.
*/
struct ltcomstr {
int type; /* EF_LOAN or EF_TREATY */
int type; /* currently always EF_LOAN */
int num; /* number */
char *name; /* "loan" or "treaty" */
char *Name; /* "Loan" or "Treaty" */
char *name; /* "loan" */
char *Name; /* "Loan" */
natid proposer; /* country offering */
natid proposee; /* country offered to */
natid mailee; /* who gets mail about it */
char op; /* 'a', 'd', or 'p' */
union {
struct lonstr l; /* the loan */
struct trtstr t; /* the treaty */
} u;
};
@ -61,8 +56,6 @@ static int cons_display(struct ltcomstr *ltcp);
static int cons_accept(struct ltcomstr *ltcp);
static int cons_decline(struct ltcomstr *ltcp);
static int cons_postpone(struct ltcomstr *ltcp);
static int treaty_accept(struct ltcomstr *ltcp);
static int treaty_decline(struct ltcomstr *ltcp);
static int loan_accept(struct ltcomstr *ltcp);
static int loan_decline(struct ltcomstr *ltcp);
static void accpt(struct ltcomstr *ltcp);
@ -95,32 +88,22 @@ cons(void)
/*
* Choose whether we want to accept, decline, or postpone a
* loan or treaty. Put all the goodies in ltcp, and return
* loan. Put all the goodies in ltcp, and return
* RET_OK if all goes well, and anything else on error.
*/
static int
cons_choose(struct ltcomstr *ltcp)
{
static int lon_or_trt[] = { EF_LOAN, EF_TREATY, EF_BAD };
static int lon_or_trt[] = { EF_LOAN, EF_BAD };
char *p;
struct lonstr *lp;
struct trtstr *tp;
char prompt[128];
char buf[1024];
memset(ltcp, 0, sizeof(*ltcp));
if (!getstarg(player->argp[1], "loan or treaty? ", buf))
return RET_SYN;
ltcp->type = ef_byname_from(buf, lon_or_trt);
p = player->argp[1] ? player->argp[1] : "loan";
ltcp->type = ef_byname_from(p, lon_or_trt);
switch (ltcp->type) {
case EF_TREATY:
if (!opt_TREATIES) {
pr("Treaties are not enabled.\n");
return RET_FAIL;
}
ltcp->name = "treaty";
ltcp->Name = "Treaty";
break;
case EF_LOAN:
if (!opt_LOANS) {
pr("Loans are not enabled.\n");
@ -130,7 +113,7 @@ cons_choose(struct ltcomstr *ltcp)
ltcp->Name = "Loan";
break;
default:
pr("You must specify \"loan\" or \"treaty\".\n");
pr("You must specify \"loan\".\n");
return RET_SYN;
}
sprintf(prompt, "%s number? ", ltcp->Name);
@ -150,15 +133,6 @@ cons_choose(struct ltcomstr *ltcp)
ltcp->proposer = lp->l_loner;
ltcp->proposee = lp->l_lonee;
break;
case EF_TREATY:
tp = &ltcp->u.t;
if (tp->trt_status == TS_SIGNED) {
pr("That treaty has already been accepted!\n");
return RET_FAIL;
}
ltcp->proposer = tp->trt_cna;
ltcp->proposee = tp->trt_cnb;
break;
}
ltcp->mailee = (ltcp->proposer == player->cnum)
? ltcp->proposee : ltcp->proposer;
@ -175,8 +149,6 @@ cons_display(struct ltcomstr *ltcp)
switch (ltcp->type) {
case EF_LOAN:
return disloan(ltcp->num, &ltcp->u.l);
case EF_TREATY:
return distrea(ltcp->num, &ltcp->u.t);
default:
CANT_REACH();
return 0;
@ -189,8 +161,6 @@ cons_accept(struct ltcomstr *ltcp)
switch (ltcp->type) {
case EF_LOAN:
return loan_accept(ltcp);
case EF_TREATY:
return treaty_accept(ltcp);
default:
CANT_REACH();
return RET_FAIL;
@ -203,17 +173,12 @@ cons_decline(struct ltcomstr *ltcp)
switch (ltcp->type) {
case EF_LOAN:
return loan_decline(ltcp);
case EF_TREATY:
return treaty_decline(ltcp);
default:
CANT_REACH();
return RET_FAIL;
}
}
/*
* Postpone a treaty; always succeeds.
*/
static int
cons_postpone(struct ltcomstr *ltcp)
{
@ -318,74 +283,8 @@ loan_decline(struct ltcomstr *ltcp)
}
/*
* Accept a treaty. Return RET_OK on success, anything else on error.
*/
static int
treaty_accept(struct ltcomstr *ltcp)
{
struct trtstr *tp;
tp = &ltcp->u.t;
if (ltcp->proposee != player->cnum) {
pr("%s %d is still pending.\n", ltcp->Name, ltcp->num);
return RET_OK;
}
if (!gettre(ltcp->num, tp)) {
pr("treaty_accept: can't read treaty");
pr("can't read treaty; get help!\n");
return RET_FAIL;
}
if (tp->trt_status == TS_FREE) { /* treaty offer withdrawn */
late(ltcp);
return RET_OK;
}
if (tp->trt_status == TS_SIGNED) { /* somehow got accepted */
prev_signed(ltcp);
return RET_OK;
}
tp->trt_status = TS_SIGNED;
if (!puttre(ltcp->num, tp)) {
pr("treaty_accept: can't write treaty");
pr("Problem saving treaty; get help!\n");
return RET_FAIL;
}
accpt(ltcp);
pr("Treaty in effect until %s", ctime(&tp->trt_exp));
return RET_OK;
}
/*
* Decline a treaty. Return RET_OK on success, anything else on error.
*/
static int
treaty_decline(struct ltcomstr *ltcp)
{
struct trtstr *tp;
tp = &ltcp->u.t;
if (!gettre(ltcp->num, tp)) {
logerror("treaty_decline: can't read treaty");
pr("can't read treaty; get help!\n");
return RET_FAIL;
}
/* treaty got signed somehow between now and last time we read it */
if (tp->trt_status == TS_SIGNED) {
late(ltcp);
return RET_OK;
}
tp->trt_status = TS_FREE;
if (!puttre(ltcp->num, tp)) {
logerror("treaty_decline: can't write treaty");
pr("Problem saving treaty; get help!\n");
return RET_FAIL;
}
decline(ltcp);
return RET_OK;
}
/*
* Somebody tried to accept a loan/treaty that was retracted,
* or to decline a loan/treaty they already signed.
* Somebody tried to accept a loan that was retracted,
* or to decline a loan they already signed.
*/
static void
late(struct ltcomstr *ltcp)
@ -396,7 +295,7 @@ late(struct ltcomstr *ltcp)
}
/*
* Loan or treaty was previously signed.
* Loan was previously signed.
*/
static void
prev_signed(struct ltcomstr *ltcp)
@ -405,7 +304,7 @@ prev_signed(struct ltcomstr *ltcp)
}
/*
* Post-processing after successful declination of loan or treaty.
* Post-processing after successful declination of loan.
* Notify the folks involved.
*/
static void
@ -424,7 +323,7 @@ decline(struct ltcomstr *ltcp)
}
/*
* Post-processing after successful acceptance of loan or treaty.
* Post-processing after successful acceptance of loan.
* Notify the press, and the folks involved.
* (Weird spelling is to avoid accept(2)).
*/
@ -435,9 +334,6 @@ accpt(struct ltcomstr *ltcp)
case EF_LOAN:
nreport(ltcp->proposer, N_MAKE_LOAN, player->cnum, 1);
break;
case EF_TREATY:
nreport(player->cnum, N_SIGN_TRE, ltcp->mailee, 1);
break;
default:
CANT_REACH();
}

View file

@ -34,7 +34,6 @@
#include "chance.h"
#include "commands.h"
#include "treaty.h"
int
enli(void)
@ -55,8 +54,6 @@ enli(void)
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;
if (!trechk(player->cnum, 0, TRTENL))
return RET_FAIL;
natp = getnatp(player->cnum);
newmil = 500;
sprintf(prompt, "Number to enlist (max %d) : ", newmil);

View file

@ -94,9 +94,7 @@ lboa(void)
}
/* Show what we're boarding */
if (att_show(def))
return RET_FAIL;
att_show(def);
/* Ask the player what he wants to board with */

View file

@ -367,22 +367,6 @@ multifire(void)
}
continue;
}
switch (target) {
case targ_ship:
if (!trechk(player->cnum, vict, SEAFIR))
continue;
break;
case targ_sub:
if (!trechk(player->cnum, vict, SUBFIR))
continue;
break;
case targ_land:
if (!trechk(player->cnum, vict, LANFIR))
continue;
break;
default:
break;
}
nfiring++;
switch (target) {

View file

@ -24,7 +24,7 @@
*
* ---
*
* offe.c: Offer a loan or treaty
* offe.c: Offer a loan
*
* Known contributors to this file:
* Pat Loney, 1992
@ -36,21 +36,15 @@
#include "commands.h"
#include "loan.h"
#include "optlist.h"
#include "treaty.h"
static int do_treaty(void);
static int do_loan(void);
int
offe(void)
{
char *cp;
char buf[1024];
cp = getstarg(player->argp[1], "loan or treaty? ", buf);
if (!cp || !*cp)
return RET_SYN;
cp = player->argp[1] ? player->argp[1] : "loan";
switch (*cp) {
case 'l':
if (!opt_LOANS) {
@ -58,100 +52,12 @@ offe(void)
return RET_FAIL;
}
return do_loan();
case 't':
if (!opt_TREATIES) {
pr("Treaties are not enabled.\n");
return RET_FAIL;
}
return do_treaty();
default:
pr("You must specify \"loan\" as there are no treaties.\n");
pr("You must specify \"loan\".\n");
return RET_SYN;
}
}
static int
do_treaty(void)
{
char *cp;
int ourcond, theircond;
struct symbol *tfp;
struct trtstr trty;
struct nstr_item nstr;
natid recipient;
time_t now;
int j, n;
struct natstr *natp;
char prompt[128];
char buf[1024];
if ((n = natarg(player->argp[2], "Treaty offered to? ")) < 0)
return RET_SYN;
recipient = n;
if (recipient == player->cnum) {
pr("You can't sign a treaty with yourself!\n");
return RET_FAIL;
}
natp = getnatp(recipient);
if (player->cnum && (getrejects(player->cnum, natp) & REJ_TREA)) {
pr("%s is rejecting your treaties.\n", cname(recipient));
return RET_SYN;
}
pr("Terms for %s:\n", cname(recipient));
theircond = 0;
for (tfp = treaty_flags; tfp && tfp->name; tfp++) {
sprintf(prompt, "%s? ", tfp->name);
if (!(cp = getstring(prompt, buf)))
return RET_FAIL;
if (*cp == 'y')
theircond |= tfp->value;
}
pr("Terms for you:\n");
ourcond = 0;
for (tfp = treaty_flags; tfp && tfp->name; tfp++) {
sprintf(prompt, "%s? ", tfp->name);
if (!(cp = getstring(prompt, buf)))
return RET_FAIL;
if (*cp == 'y')
ourcond |= tfp->value;
}
if (ourcond == 0 && theircond == 0) {
pr("Treaties with no clauses aren't very useful, boss!\n");
return RET_SYN;
}
cp = getstring("Proposed treaty duration? (days) ", buf);
if (!cp)
return RET_FAIL;
j = atoi(cp);
if (j <= 0) {
pr("Bad treaty duration.\n");
return RET_SYN;
}
(void)time(&now);
snxtitem_all(&nstr, EF_TREATY);
while (nxtitem(&nstr, &trty)) {
if (trty.trt_status == TS_FREE) {
break;
}
}
ef_blank(EF_TREATY, nstr.cur, &trty);
trty.trt_acond = ourcond;
trty.trt_bcond = theircond;
trty.trt_status = TS_PROPOSED;
trty.trt_cna = player->cnum;
trty.trt_cnb = recipient;
trty.trt_exp = j * SECS_PER_DAY + now;
if (!puttre(nstr.cur, &trty)) {
logerror("do_treaty: can't write treaty");
pr("Couldn't save treaty; get help.\n");
return RET_FAIL;
}
wu(0, recipient, "Treaty #%d proposed to you by %s\n",
nstr.cur, cname(player->cnum));
pr("You have proposed treaty #%d\n", nstr.cur);
return RET_OK;
}
static int
do_loan(void)
{

View file

@ -130,10 +130,8 @@ paradrop(struct emp_qelem *list, coord x, coord y)
if (att_abort(A_PARA, NULL, def))
return RET_FAIL;
/* Show what we're air-assaulting, and check treaties */
if (att_show(def))
return RET_FAIL;
/* Show what we're air-assaulting */
att_show(def);
/* set what we're air-assaulting with */

View file

@ -24,7 +24,7 @@
*
* ---
*
* reje.c: Refuse telegrams/annos/treaties/loans from countries
* reje.c: Refuse telegrams/annos/loans from countries
*
* Known contributors to this file:
*
@ -58,7 +58,7 @@ reje(void)
return RET_SYN;
}
p = getstarg(player->argp[2],
"mail, treaties, loans, or announcements? ", buf);
"mail, loans, or announcements? ", buf);
if (!p)
return RET_SYN;
switch (*p) {
@ -71,9 +71,6 @@ reje(void)
case 'm':
rel = REJ_TELE;
break;
case 't':
rel = REJ_TREA;
break;
default:
pr("That's not one of the choices!\n");
return RET_SYN;
@ -102,10 +99,6 @@ reje(void)
pr("%s teles from %s\n",
(do_undo == 1 ? "Rejecting" : "Accepting"), nat.nat_cnam);
break;
case REJ_TREA:
pr("%s treaties from %s\n",
(do_undo == 1 ? "Rejecting" : "Accepting"), nat.nat_cnam);
break;
}
setrej(player->cnum, (natid)ni.cur, do_undo, rel);
}

View file

@ -1,58 +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.
*
* ---
*
* trea.c: Look at current treaties.
*
* Known contributors to this file:
*
*/
#include <config.h>
#include "commands.h"
#include "treaty.h"
int
trea(void)
{
struct trtstr treaty;
struct nstr_item nstr;
int ntreaty;
if (!snxtitem(&nstr, EF_TREATY, player->argp[1], NULL))
return RET_SYN;
pr("\t... %s Treaty Report ...\n", cname(player->cnum));
ntreaty = 0;
while (nxtitem(&nstr, &treaty)) {
if (distrea(nstr.cur, &treaty) > 0)
ntreaty++;
}
if (!ntreaty)
pr("No treaties found.\n");
else
pr("%d treat%s\n", ntreaty, iesplur(ntreaty));
return RET_OK;
}

View file

@ -46,7 +46,6 @@ static int
xdvisible(int type, void *p)
{
struct empobj *gp = p;
struct trtstr *tp = p;
struct lonstr *lp = p;
struct natstr *natp;
int tlev;
@ -67,10 +66,6 @@ xdvisible(int type, void *p)
return gp->own == player->cnum;
case EF_NEWS:
return !opt_HIDDEN || player->god; /* FIXME */
case EF_TREATY:
return tp->trt_cna == player->cnum
|| tp->trt_cnb == player->cnum
|| player->god;
case EF_LOAN:
if (lp->l_status == LS_SIGNED)
return 1;