src/lib/commands/zdon.c

Go to the documentation of this file.
00001 /*
00002  *  Empire - A multi-player, client/server Internet based war game.
00003  *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
00004  *                           Ken Stevens, Steve McClure
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  *  ---
00021  *
00022  *  See files README, COPYING and CREDITS in the root of the source
00023  *  tree for related information and legal notices.  It is expected
00024  *  that future projects/authors will amend these files as needed.
00025  *
00026  *  ---
00027  *
00028  *  zdon.c: Update right now
00029  * 
00030  *  Known contributors to this file:
00031  *     Doug Hay, 1990
00032  *     Markus Armbruster, 2007
00033  */
00034 
00035 /*
00036  * Syntax:
00037  *  Normal player:   zdone [Y|N|C]
00038  *  Deity        :   zdone [country_num [Y|N|C]]
00039  *
00040  *  Where:
00041  *         Y  = Yes, wants an update.
00042  *         N  = No, change status to not wanting an update.
00043  *         C  = Check (the default), check how many want an update.
00044  *
00045  * Sets/Unsets a nation flag.
00046  *
00047  * Only considers NORMAL, active countries.  No Deities or sanctuaries.
00048  *
00049  * After the change, send a message to the "tm" for it to check
00050  * if an update should occur.
00051  */
00052 
00053 #include <config.h>
00054 
00055 #include "commands.h"
00056 #include "optlist.h"
00057 #include "server.h"
00058 
00059 int
00060 zdon(void)
00061 {
00062     natid whichcnum;
00063     struct natstr *natp;
00064     char *p;
00065 
00066     int checking;
00067     int wantupd;
00068     int totpop;
00069     int totwant;
00070     int dowant;
00071     char buf[1024];
00072 
00073     if (update_demand != UPD_DEMAND_SCHED
00074         && update_demand != UPD_DEMAND_ASYNC) {
00075         pr("Demand updates are not enabled.\n");
00076         return RET_FAIL;
00077     }
00078     whichcnum = player->cnum;
00079     p = NULL;
00080     if (player->god) {
00081         /* Deity syntax "country what" */
00082         whichcnum = onearg(player->argp[1], "Which country no.? ");
00083         if ((whichcnum > 0) && (getnatp(whichcnum)))
00084             p = getstarg(player->argp[2], "Want update? [Yes|No|Check] ",
00085                          buf);
00086     } else {
00087         p = getstarg(player->argp[1], "Want update? [Yes|No|Check] ", buf);
00088     }
00089     if (player->aborted)
00090         return RET_FAIL;
00091 
00092     checking = 1;
00093     wantupd = 0;
00094     if (p) {
00095         if (*p == 'y' || *p == 'Y') {
00096             checking = 0;
00097             wantupd = 1;
00098         } else if  (*p == 'n' || *p == 'N') {
00099             checking = 0;
00100             wantupd = 0;
00101         }
00102     }
00103 
00104     if (!(natp = getnatp(whichcnum))) {
00105         pr("Unable to find country. %d\n", whichcnum);
00106         pr("Notify the Deity.\n");
00107         return RET_FAIL;
00108     }
00109     if (!checking) {
00110         if (wantupd) {
00111             if (influx(natp)) {
00112                 pr("Unable to request an update as the country is in flux\n");
00113                 return RET_FAIL;
00114             }
00115             pr("You (%d) now want an update.\n", whichcnum);
00116         } else {
00117             pr("You (%d) now DON'T want an update.\n", whichcnum);
00118         }
00119         natp->nat_update = wantupd;
00120         putnat(natp);
00121     }
00122 
00123     dowant = demand_update_want(&totwant, &totpop, whichcnum);
00124     if (checking) {
00125         if (dowant) {
00126             pr("You want an update.\n");
00127         } else
00128             pr("You DON'T want an update, yet.\n");
00129     }
00130 
00131     pr("%d of a total of %d lunatics want an update.\n", totwant, totpop);
00132 
00133     if (!checking && wantupd && demandupdatecheck()) {
00134         pr("Here goes...\n");
00135         update_trigger();
00136     }
00137     return RET_OK;
00138 }

Generated on Fri Mar 28 11:01:13 2008 for empserver by  doxygen 1.5.2