]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/caploss.c
Update copyright notice
[empserver] / src / lib / subs / caploss.c
index 6cb50ad3333f1f54f44815f606e25bf83b7b84cf..97fd8af68f512c067601f06f7d053b0239c9273a 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  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 2 of the License, or
+ *  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,
@@ -14,8 +14,7 @@
  *  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
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
  *  ---
  *
  *  caploss.c: Lose your capital (kiss of death)
- * 
+ *
  *  Known contributors to this file:
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2007-2008
  */
 
 #include <config.h>
@@ -51,8 +51,10 @@ caploss(struct sctstr *sp, natid coun, char *msg)
     struct comstr comm;
     long lose;
     long gain;
-    int loan_num = 0;
-    int comm_num = 0;
+    char *verb;
+    int loan_num, comm_num;
+
+    CANT_HAPPEN(sp->sct_own && sp->sct_own != player->cnum);
 
     natp = getnatp(coun);
     if (natp->nat_stat != STAT_ACTIVE)
@@ -71,18 +73,20 @@ caploss(struct sctstr *sp, natid coun, char *msg)
        lose = 3000;
     natp->nat_money -= lose;
     putnat(natp);
-    wu(0, coun, "* %s just sacked your capital! *\n", cname(player->cnum));
-
-    if (gain >= 0) {
+    if (gain >= 0 && sp->sct_own) {
        gain = (0.2 + 0.8 * (sp->sct_effic / 100.0)) * gain;
        player->dolcost -= gain;
     } else
        gain = 0;
+    verb = sp->sct_own ? "sacked" : "obliterated";
+    wu(0, coun, "* %s just %s your capital! *\n",
+       cname(player->cnum), verb);
     wu(0, coun, "You lost $%ld and they gained $%ld\n", lose, gain);
     wu(0, coun, "You need to use 'capital' to activate a new capital.\n");
-    wu(0, 0, "%s just took %s's capital and gained $%d\n",
-       cname(player->cnum), cname(coun), -(int)(player->dolcost));
-    if (opt_LOANS) {
+    wu(0, 0, "%s just %s %s's capital and gained $%ld\n",
+       cname(player->cnum), verb, cname(coun), gain);
+
+    if (opt_LOANS && sp->sct_own) {
        for (loan_num = 0; getloan(loan_num, &loan); loan_num++) {
            if (loan.l_status == LS_SIGNED && loan.l_loner == coun) {
                loan.l_loner = player->cnum;
@@ -91,7 +95,7 @@ caploss(struct sctstr *sp, natid coun, char *msg)
            }
        }
     }
-    if (opt_MARKET) {
+    if (opt_MARKET && sp->sct_own) {
        for (comm_num = 0; getcomm(comm_num, &comm); comm_num++) {
            if (comm.com_owner == 0)
                continue;