]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/improve.c
Update copyright notice
[empserver] / src / lib / commands / improve.c
index 1cb24bd471601aeb1e08b7494643b850a8d36443..42be1aec2f4889fea214bfb66aff59d2881c23e3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *  ---
  *
  *  improve.c: Improve the infrastructure of a sector
- * 
+ *
  *  Known contributors to this file:
  *     Steve McClure, 1996-2000
  */
 
 #include <config.h>
 
-#include <string.h>
-#include "misc.h"
-#include "player.h"
-#include "xy.h"
-#include "sect.h"
-#include "nsc.h"
-#include "nat.h"
-#include "path.h"
-#include "file.h"
-#include "optlist.h"
 #include "commands.h"
+#include "optlist.h"
+#include "path.h"
 
 int
 improve(void)
@@ -146,20 +138,11 @@ improve(void)
        }
        dneeded = intrchr[type].in_dcost * maxup;
        natp = getnatp(player->cnum);
-       if ((natp->nat_money - 1) < dneeded) {
-/* Nasty - leave 'em with a buck. :) */
-           dneeded = natp->nat_money - 1;
-           if (dneeded < 0)
-               dneeded = 0;
-           maxup = dneeded / intrchr[type].in_dcost;
-           if (maxup <= 0) {
-               pr("Not enough money left to improve %s\n",
-                  xyas(sect.sct_x, sect.sct_y, player->cnum));
-               continue;
-           }
+       if (player->dolcost + dneeded > natp->nat_money) {
+           pr("Not enough money left to improve %s by %d%%\n",
+              xyas(sect.sct_x, sect.sct_y, player->cnum), maxup);
+           break;
        }
-       if (maxup <= 0)
-           continue;
        lneeded = intrchr[type].in_lcms * maxup;
        hneeded = intrchr[type].in_hcms * maxup;
        mneeded = intrchr[type].in_mcost * maxup;