2 * Copyright (C) 2003 Robert Kooima
4 * NEVERPUTT is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
23 /*---------------------------------------------------------------------------*/
33 static int course_state
= 0;
38 static struct course course_v
[MAXCRS
];
40 /*---------------------------------------------------------------------------*/
51 if ((fin
= fopen(config_data(COURSE_FILE
), "r")))
53 while (fscanf(fin
, "%s %s\n",
54 course_v
[count
].holes
,
55 course_v
[count
].shot
) == 2 &&
56 fgets(course_v
[count
].desc
, MAXSTR
, fin
))
58 char *q
= course_v
[count
].desc
+ strlen(course_v
[count
].desc
) - 1;
60 if (*q
== '\n') *q
= 0;
71 int course_exists(int i
)
73 return (0 <= i
&& i
< count
);
76 int course_count(void)
81 void course_goto(int i
)
83 hole_init(course_v
[i
].holes
);
92 void course_free(void)
98 void course_rand(void)
100 course_goto(rand() % count
);
101 hole_goto(rand() % curr_count(), 4);
104 /*---------------------------------------------------------------------------*/
106 const char *course_desc(int i
)
108 return course_exists(i
) ? course_v
[i
].desc
: "";
111 const char *course_shot(int i
)
113 return course_exists(i
) ? course_v
[i
].shot
: course_v
[0].shot
;
116 /*---------------------------------------------------------------------------*/