xref: /csrg-svn/games/trek/getcodi.c (revision 34205)
121280Sdist /*
221280Sdist  * Copyright (c) 1980 Regents of the University of California.
3*34205Sbostic  * All rights reserved.
4*34205Sbostic  *
5*34205Sbostic  * Redistribution and use in source and binary forms are permitted
6*34205Sbostic  * provided that this notice is preserved and that due credit is given
7*34205Sbostic  * to the University of California at Berkeley. The name of the University
8*34205Sbostic  * may not be used to endorse or promote products derived from this
9*34205Sbostic  * software without specific prior written permission. This software
10*34205Sbostic  * is provided ``as is'' without express or implied warranty.
1121280Sdist  */
1221280Sdist 
1311674Smckusick #ifndef lint
14*34205Sbostic static char sccsid[] = "@(#)getcodi.c	5.2 (Berkeley) 05/05/88";
15*34205Sbostic #endif /* not lint */
1611674Smckusick 
1711674Smckusick # include	"getpar.h"
1811674Smckusick 
1911674Smckusick /*
2011674Smckusick **  get course and distance
2111674Smckusick **
2211674Smckusick **	The user is asked for a course and distance.  This is used by
2311674Smckusick **	move, impulse, and some of the computer functions.
2411674Smckusick **
2511674Smckusick **	The return value is zero for success, one for an invalid input
2611674Smckusick **	(meaning to drop the request).
2711674Smckusick */
2811674Smckusick 
2911674Smckusick getcodi(co, di)
3011674Smckusick int	*co;
3112738Slayer double	*di;
3211674Smckusick {
3311674Smckusick 
3411674Smckusick 	*co = getintpar("Course");
3511674Smckusick 
3611674Smckusick 	/* course must be in the interval [0, 360] */
3711674Smckusick 	if (*co < 0 || *co > 360)
3811674Smckusick 		return (1);
3911674Smckusick 	*di = getfltpar("Distance");
4011674Smckusick 
4111674Smckusick 	/* distance must be in the interval [0, 15] */
4211674Smckusick 	if (*di <= 0.0 || *di > 15.0)
4311674Smckusick 		return (1);
4411674Smckusick 
4511674Smckusick 	/* good return */
4611674Smckusick 	return (0);
4711674Smckusick }
48