#ifndef lint
static char *RCSid = "$Header: /usr/brule/guest/empire/empire/emprcs/lib/subs/natarg.c,v 2.2 1995/10/11 03:00:05 empire Exp $";
#endif

/*
 * natarg.c
 *
 * return country # given country name or
 * country #.
 *
 * from PSL Empire, 1985
 */

#include <ctype.h>
#include "misc.h"
#include "nat.h"
#ifdef HIDDEN
#include "player.h"
#include "file.h"
#endif /* HIDDEN */

int
natarg(arg, prompt)
	s_char	*arg;
	s_char	*prompt;
{
	s_char	buf[1024];
	int	n;
#ifdef HIDDEN
        struct  natstr *np;
        int     byname = 0;
#endif /* HIDDEN */ 

	arg = getstarg(arg, prompt, buf);
	if (arg == 0 || *arg == 0)
		return -1;
	if (isdigit(*arg))
		n = atoi(arg);
	else {
		n = cnumb(arg);
#ifdef HIDDEN
		byname = 1;
#endif /* HIDDEN */
	}
	if (n < 0 || n >= MAXNOC) {
		pr("No such country exists.\n");
		n = -1;
	}
#ifdef  HIDDEN
        if (!player->god && !getcontact(getnatp(player->cnum), n)) {
                if ((np = getnatp(n)) == 0)
                        return -1;
                if ((np->nat_stat & STAT_GOD) == 0) {
                        if (byname) {
                                pr("No such country exists.\n");
                                n = -1;;
                        } else {
                                pr("Country has not been contacted.\n");
                                n = -2;
                        }
                }
        }
#endif  /* HIDDEN */
	return n;
}
