annotate src/cluecheck.c @ 5:054275999194

Initial revision
author darius
date Sat, 06 Dec 1997 04:37:03 +0000
parents 2719a89505ba
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1 /*--------------------------------------------------------------------------
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
2 NETREK II -- Paradise
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
3
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
4 Permission to use, copy, modify, and distribute this software and its
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
6 purpose and without fee is hereby granted, provided that this copyright
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
7 notice appear in all copies. No representations are made about the
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
8 suitability of this software for any purpose. This software is provided
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
9 "as is" without express or implied warranty.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
10
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
11 Xtrek Copyright 1986 Chris Guthrie
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
13 Scott Silvey
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
15 Kurt Olsen
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
16 Brandon Gillespie
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
17 --------------------------------------------------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
18
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
19 #include "config.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20 #include <stdio.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21 #include <sys/types.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22 #include <sys/stat.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 #include "defs.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24 #include "data.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25 #include "struct.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 #include "shmem.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28 #ifdef CLUECHECK1
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 /* ----------------- ROBS CLUECHECK -------------------- */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
31
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
32 static char clueword[40];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35 set_clue_word(word)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
36 char *word;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
37 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
38 strncpy(clueword, word, sizeof(clueword));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
39 clueword[sizeof(clueword) - 1] = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42 #ifdef MOTD_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43 static char *motdstring = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
44 static int motdlen = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
45
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46 void free_motdstruct();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
47 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
48
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49 /* read the MOTD into core so we can parse it later */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51 init_motdbuf(fname)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52 char *fname;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54 #ifdef MOTD_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 struct stat stats;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 FILE *fp;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 if (motdstring != 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60 free_motdstruct();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
61 free(motdstring);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
62 motdstring = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
63 motdlen = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
64 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
65
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
66 if (!configvals->cluecheck ||
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67 configvals->cluecheck != CC_MOTD)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68 return; /* don't waste the memory if we're not clue
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69 * checking from the MOTD */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
71 if (0 > stat(fname, &stats))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
72 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73 perror("statting file");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
75 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
76
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77 motdlen = stats.st_size;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79 motdstring = (char *) malloc(motdlen + 1);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80 fp = fopen(fname, "r");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81 if (0 == fp)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 perror("opening file");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84 exit(1);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86 fread(motdstring, motdlen, 1, fp);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
87 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
88 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90 static int page;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 static int isfirst;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 #ifdef MOTD_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
95 static int line, wordn;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
96
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 /* structures for the internal representation of the MOTD */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98 #define LINESPERPAGE 38
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
99
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
100 struct word
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
101 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
102 char *s;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
103 };
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
104
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
105 struct line
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
106 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
107 struct word *words;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
108 int nwords;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
109 };
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
110
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
111 struct page
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
112 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
113 struct line lines[LINESPERPAGE];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
114 int nlines;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
115 struct page *next;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
116 };
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
117
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
118 struct page *motdhead = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
119
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
120
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
121
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
122 #define MAXATTEMPTS 10
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
123 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
124 find_suitable_motd_word()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
125 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
126 int attempts;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
127 int pagecount;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
128 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
129 struct page *currp;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
130
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
131
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
132 for (pagecount = 0, currp = motdhead;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
133 currp;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
134 pagecount++, currp = currp->next)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
135 ;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
136
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
137 if (pagecount > 10)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
138 pagecount = 10;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
139
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
140 for (attempts = 0; pagecount > 1 && attempts < MAXATTEMPTS; attempts++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
141 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
142 /* the first page is excluded. Everybody sees that */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
143 page = 1 + lrand48() % (pagecount - 1);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
144
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
145 for (i = 0, currp = motdhead; i < page; i++, currp = currp->next)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
146 ;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
147 if (currp->nlines < 1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
148 continue;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
149 if (lrand48() & 1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
150 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
151 /* get first word */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
152 isfirst = 1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
153 for (line = 0; line < currp->nlines; line++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
154 if (currp->lines[line].nwords > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
155 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
156 if (line >= currp->nlines)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
157 continue;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
158 wordn = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
159 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
160 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
161 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
162 /* get last word */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
163 isfirst = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
164 for (line = currp->nlines - 1; line >= 0; line--)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
165 if (currp->lines[line].nwords > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
166 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
167 if (line < 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
168 continue;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
169 wordn = currp->lines[line].nwords - 1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
170 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
171 set_clue_word(currp->lines[line].words[wordn].s);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
172 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
173 * printf("%s word on page %d (line %d word %d) is %s\n",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
174 * isfirst?"first":"last", page+1, line+1, wordn+1, clueword);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
175 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
176 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
177 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
178 page = -1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
179 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
180
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
181 #if 0
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
182 /* for the day when we have line numbers in the MOTD. */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
183 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
184 find_suitable_word2()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
185 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
186 int attempts;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
187 int pagecount;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
188 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
189 struct page *currp;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
190
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
191
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
192 for (pagecount = 0, currp = motdhead; currp; pagecount++, currp = currp->next)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
193 ;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
194
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
195 for (attempts = 0; attempts < 10; attempts++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
196 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
197 page = lrand48() % pagecount;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
198 for (i = 0, currp = motdhead; i < page; i++, currp = currp->next)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
199 ;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
200 if (currp->nlines < 1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
201 continue;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
202 line = lrand48() % currp->nlines;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
203 if (currp->lines[line].nwords < 1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
204 continue;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
205 wordn = lrand48() % currp->lines[line].nwords;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
206 set_clue_word(currp->lines[line].words[wordn].s);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
207 printf("word on page %d line %d word %d is %s\n",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
208 page + 1, line + 1, wordn + 1, clueword);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
209 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
210 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
211 clueword[0] = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
212 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
213 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
214
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
215 #if 0
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
216 /* useful for debugging the MOTD parsing routine */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
217 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
218 printout_motd()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
219 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
220 struct page *currp;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
221 int i, j;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
222 for (currp = motdhead; currp; currp = currp->next)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
223 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
224 for (i = 0; i < currp->nlines; i++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
225 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
226 for (j = 0; j < currp->lines[i].nwords; j++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
227 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
228 printf("%s ", currp->lines[i].words[j].s);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
229 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
230 printf("\n");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
231 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
232 printf("\014");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
233 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
234 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
235 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
236
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
237
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
238 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
239 parse_motd()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
240 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
241 struct page **currp;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
242 int idx;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
243
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
244 if (motdhead)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
245 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
246
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
247 currp = &motdhead;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
248
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
249 idx = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
250 while (idx < motdlen)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
251 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
252 int validword;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
253 char *wordbegin;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
254
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
255 validword = 1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
256
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
257 /* skip whitespace */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
258 while (!isalpha(motdstring[idx]) && motdstring[idx] != '\n' && idx < motdlen)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
259 idx++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
260 if (idx >= motdlen)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
261 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
262
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
263 if (0 == *currp)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
264 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
265 *currp = malloc(sizeof(**currp));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
266 (*currp)->nlines = 1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
267 (*currp)->lines[0].nwords = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
268 (*currp)->next = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
269 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
270
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
271 if (motdstring[idx] == '\n')
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
272 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
273 idx++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
274 if (0 == strncmp(&motdstring[idx], "\t@@@", 4))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
275 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
276 else if (0 == strncmp(&motdstring[idx], "\t@@b", 4))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
277 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
278 if (*currp)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
279 currp = &(*currp)->next;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
280 idx += 4;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
281 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
282 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
283 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
284 struct line *currl = &(*currp)->lines[(*currp)->nlines - 1];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
285 currl->words = realloc(currl->words, sizeof(*currl->words) * currl->nwords);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
286 if ((*currp)->nlines >= LINESPERPAGE)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
287 currp = &(*currp)->next;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
288 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
289 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
290 (*currp)->lines[(*currp)->nlines].nwords = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
291 (*currp)->nlines++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
292 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
293 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
294 continue;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
295 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
296 wordbegin = &motdstring[idx];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
297 while (isalpha(motdstring[idx]) && idx < motdlen)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
298 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
299 #if 0
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
300 if (!isalpha(motdstring[idx]))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
301 validword = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
302 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
303 idx++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
304 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
305
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
306 if (0 && !validword)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
307 continue;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
308
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
309 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
310 struct line *currl = &(*currp)->lines[(*currp)->nlines - 1];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
311 int len;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
312
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
313 if (currl->nwords == 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
314 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
315 int size = 40;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
316 int j;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
317 currl->words = malloc(sizeof(struct word) * size);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
318 for (j = 0; j < size; j++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
319 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
320 currl->words[j].s = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
321 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
322 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
323 len = (&motdstring[idx]) - wordbegin;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
324 currl->words[currl->nwords].s = malloc(len + 1);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
325 strncpy(currl->words[currl->nwords].s, wordbegin, len);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
326 currl->words[currl->nwords].s[len] = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
327 currl->nwords++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
328 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
329 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
330 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
331 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
332
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
333 /**********************************************************************/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
334
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
335 char **phrases = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
336 int num_phrases = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
337
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
338 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
339 parse_clue_phrases()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
340 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
341 char *s;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
342 int size;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
343
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
344 if (phrases)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
345 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
346
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
347 phrases = (char **) malloc(sizeof(*phrases) * (size = 20));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
348
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
349 for (s = cluephrase_storage; *s; s += strlen(s) + 1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
350 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
351 phrases[num_phrases] = s;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
352 num_phrases++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
353 if (num_phrases >= size)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
354 phrases = (char **) realloc(phrases, sizeof(*phrases) * (size *= 2));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
355 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
356
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
357 phrases = (char **) realloc(phrases, sizeof(*phrases) * num_phrases);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
358 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
359
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
360 /**********************************************************************/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
361
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
362
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
363 #define BERATE(msg) pmessage( (msg), me->p_no, MINDIV, " CC")
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
364
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
365 /* print the message that tells the person how to respond to the clue check */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
366 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
367 remind_cluecheck()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
368 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
369 char buf[120];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
370 BERATE("This is a clue check! You must send yourself the message");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
371 BERATE(" cluecheck [phrase]");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
372 if (page >= 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
373 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
374 sprintf(buf, "where [phrase] is the %s word on page %d of the MOTD.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
375 isfirst ? "first" : "last", page + 1);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
376 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
377 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
378 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
379 /* man, the MOTD had no good words */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
380 sprintf(buf, "where [phrase] is %s", clueword);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
381 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
382 BERATE(buf);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
383 if (me->p_cluecountdown > 60)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
384 sprintf(buf, "If you don't answer within %g minutes, you will be kicked out of", me->p_cluecountdown / (60.0 * 10));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
385 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
386 sprintf(buf, "If you don't answer within %d seconds, you will be kicked out of", me->p_cluecountdown / 10);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
387 BERATE(buf);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
388 BERATE("the game and publicly humiliated.");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
389 #if 0
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
390 BERATE("If you are a complete newbie, then");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
391 BERATE("you probably don't even realize that you can read the MOTD while");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
392 BERATE("playing (shift-M).");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
393 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
394 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
395
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
396 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
397 * if other methods of getting clue words fail, then we've always got this
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
398 * list of words
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
399 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
400 static char *fallback_cluewords[] = {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
401
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
402 /* terms: */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
403 "bomb", "ogg", "scum", "stoneage", "scout", "taxi", "base",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
404 "buttorp", "flee", "planet", "star", "warp", "impulse", "hive",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
405 "repair", "shipyard", "fuel", "arable", "metal", "dilithium",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
406 "standard", "thin", "tainted", "toxic", "phaser", "torp", "photon",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
407 "plasma", "missile", "fighter", "tractor", "pressor",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
408
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
409 /* what quarks are made of: */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
410 "satan", "beer", "jesus", "sex", "cthulhu",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
411
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
412 /* two food groups: */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
413 /* "grilledcheesesandwich", annoyed too many people */ "ketchup", "caffeine",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
414
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
415 /* the men: */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
416 /* "a fungusamongus", people have difficulty with this one */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
417 "Bubbles", "Hammor", "Key", "Kaos", "Lynx",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
418 "Thought", "Brazilian", "Ogre",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
419
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
420 /* the big five: */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
421 "Paradise", "Arctica", "Aedile", "Eden", "Minuet",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
422
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
423 /* what you are: */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
424 "twink"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
425 };
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
426
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
427 #define NUM_CLUEWORDS ( sizeof(fallback_cluewords) \
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
428 / sizeof(*fallback_cluewords))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
429
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
430 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
431 * Once in a great while (hour?) the server demands a clue check from the
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
432 * player. This makes sure you are paying attention.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
433 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
434 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
435 demand_clue()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
436 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
437 clueword[0] = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
438 page = -1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
439 switch (configvals->cluesource)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
440 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
441 case CC_MOTD:
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
442 #ifdef MOTD_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
443 parse_motd();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
444
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
445 find_suitable_motd_word();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
446 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
447 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
448 case CC_PHRASE_LIST_FILE:
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
449 parse_clue_phrases();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
450
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
451 if (num_phrases)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
452 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
453 set_clue_word(phrases[lrand48() % num_phrases]);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
454 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
455 break; /* uh, NYI */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
456 case CC_COMPILED_IN_PHRASE_LIST:
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
457 break; /* that's actually the fallback case below: */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
458 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
459 if (*clueword == 0) /* didn't find one! */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
460 set_clue_word(fallback_cluewords[lrand48() % NUM_CLUEWORDS]);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
461
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
462 me->p_cluecountdown = configvals->cluetime * TICKSPERSEC;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
463
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
464 remind_cluecheck();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
465 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
466
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
467 /* every tick, check the person's clue status */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
468 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
469 countdown_clue()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
470 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
471 if (me->p_status == POUTFIT || me->p_status == PTQUEUE)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
472 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
473 if (me->p_cluedelay > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
474 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
475 me->p_cluedelay--;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
476 if (me->p_cluedelay < 1
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
477 && (me->p_stats.st_cluesuccess < 25
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
478 || lrand48() % 20 < 1))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
479 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
480 /* uhoh, time for another cluecheck */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
481 demand_clue();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
482 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
483 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
484 else if (me->p_cluecountdown > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
485 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
486 char buf[120];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
487
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
488 /* under the gun here */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
489 me->p_cluecountdown--;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
490 if (me->p_cluecountdown > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
491 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
492
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
493 /* uhoh, we have a twink */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
494
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
495 me->p_status = PEXPLODE;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
496 me->p_explode = 10;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
497 me->p_whydead = KQUIT;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
498
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
499 sprintf(buf, "%s (%s) was blasted out of existence due to terminal",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
500 me->p_name, twoletters(me));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
501 pmessage(buf, -1, MALL, MSERVA);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
502 pmessage("stupidity (failure to read messages).", -1, MALL, MSERVA);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
503 pmessage("Let this be a lesson to the rest of you twinks!", -1, MALL, MSERVA);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
504 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
505 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
506 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
507 me->p_cluedelay = 40;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
508 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
509 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
510
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
511 /* the person sent themselves the message "cluecheck..." */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
512 int
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
513 accept_cluecheck(word)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
514 char *word;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
515 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
516 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
517 char buf[120];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
518
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
519 if (me->p_cluedelay > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
520 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
521 sprintf(buf, "Don't worry %s. You aren't under a clue check yet.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
522 me->p_name);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
523 BERATE(buf);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
524 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
525 else if (*word)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
526 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
527 for (i = 0; word[i] && clueword[i]; i++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
528 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
529 if (tolower(word[i]) != tolower(clueword[i]))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
530 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
531 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
532
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
533 if (word[i] || clueword[i])
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
534 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
535 sprintf(buf, "Nice try, %s. Guess again. It's not %s.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
536 me->p_name, word);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
537 BERATE(buf);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
538 BERATE("Send yourself the message `cluecheck' if you need another hint.");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
539 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
540 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
541 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
542 sprintf(buf, "Good show, %s. I won't bother you again for a while.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
543 me->p_name);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
544 BERATE(buf);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
545 me->p_cluedelay = (configvals->cluedelay / 2) +
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
546 lrand48() % (configvals->cluedelay / 2);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
547 me->p_cluedelay *= TICKSPERSEC;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
548
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
549 me->p_stats.st_cluesuccess++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
550 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
551 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
552 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
553 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
554 remind_cluecheck();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
555 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
556 return 1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
557 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
558
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
559 /**********************************************************************/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
560
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
561 #ifdef MOTD_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
562 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
563 free_word(wd)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
564 struct word *wd;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
565 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
566 free(wd->s);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
567 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
568
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
569 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
570 free_line(ln)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
571 struct line *ln;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
572 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
573 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
574 for (i = 0; i < ln->nwords; i++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
575 free_word(&ln->words[i]);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
576 free(ln->words);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
577 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
578
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
579 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
580 free_page(pg)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
581 struct page *pg;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
582 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
583 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
584 for (i = 0; i < LINESPERPAGE; i++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
585 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
586 free_line(&pg->lines[i]);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
587 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
588 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
589
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
590 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
591 free_motdstruct()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
592 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
593 struct page *temp;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
594 while (motdhead)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
595 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
596 temp = motdhead;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
597 motdhead = temp->next;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
598
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
599 free_page(temp);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
600 free(temp);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
601 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
602 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
603 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
604
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
605 #endif /* CLUECHECK1 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
606
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
607 #ifdef CLUECHECK2
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
608
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
609 /* ---------[ CLUECHECK2 -> Brandons hacked version of CLUECHECK1 ]--------- */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
610
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
611 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
612 * // I munged this (sorry Rob). Using me->p_cluecountdown: // if it is
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
613 * 0 you have not been checked yet // if it is 1 your time is up. //
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
614 * if it is -1 you should not be checked. // if it is anything greater
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
615 * than one you are under the timer
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
616 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
617
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
618 /* -------------------------[ Globals (eep) ]------------------------- */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
619
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
620 #define TellLINE { pmessage("", me->p_no, MINDIV, "***! Cluecheck !**! Cluecheck !**! Cluecheck !**! Cluecheck !**! Cluecheck !***"); }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
621
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
622 #define NUM_CLUEWORDS (sizeof(fallback_cluewords) / \
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
623 sizeof(*fallback_cluewords))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
624 #define CLUE_GETOUTOFIT 7
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
625
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
626 char **phrases = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
627 int num_phrases = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
628 static char clueword[40];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
629
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
630 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
631 * // if other methods of getting clue words fail, then we've always got //
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
632 * this list of words
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
633 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
634
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
635 static char *fallback_cluewords[] = {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
636 /* make it simple, if they want more they can make a .cluecheck file */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
637 "bomb", "ogg", "scum", "stoneage", "scout", "taxi", "base",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
638 "buttorp", "flee", "planet", "star", "warp", "impulse", "hive",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
639 "repair", "shipyard", "fuel", "arable", "metal", "dilithium",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
640 "standard", "thin", "tainted", "toxic", "phaser", "torp", "photon",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
641 "plasma", "missile", "fighter", "tractor", "pressor",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
642 };
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
643
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
644 /* -------------------------[ Functions ]------------------------- */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
645
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
646 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
647 set_clue_word(char *word)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
648 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
649 strncpy(clueword, word, sizeof(clueword));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
650 clueword[sizeof(clueword) - 1] = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
651 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
652
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
653 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
654 parse_clue_phrases()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
655 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
656 char *s;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
657 int size;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
658
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
659 if (phrases)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
660 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
661
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
662 phrases = (char **) malloc(sizeof(*phrases) * (size = 20));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
663
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
664 for (s = cluephrase_storage; *s; s += strlen(s) + 1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
665 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
666 phrases[num_phrases] = s;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
667 num_phrases++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
668 if (num_phrases >= size)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
669 phrases = (char **) realloc(phrases, sizeof(*phrases) * (size *= 2));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
670 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
671
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
672 phrases = (char **) realloc(phrases, sizeof(*phrases) * num_phrases);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
673 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
674
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
675 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
676 * // print the message that tells the person how to respond to the clue
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
677 * check
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
678 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
679 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
680 remind_cluecheck()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
681 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
682 char buf[120];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
683
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
684 pmessage("", me->p_no, MINDIV, "*******************************************************************************");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
685 TellLINE;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
686 sprintf(buf, " Send yourself: \"cluecheck %s\"", clueword);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
687 pmessage(buf, me->p_no, MINDIV, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
688
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
689 if (me->p_cluecountdown > (60 * TICKSPERSEC))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
690 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
691 sprintf(buf,
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
692 " Answer within %.2g minutes or be ejected from the game.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
693 (me->p_cluecountdown / (60.0 * TICKSPERSEC)));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
694 pmessage(buf, me->p_no, MINDIV, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
695 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
696 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
697 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
698 sprintf(buf,
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
699 "** ANSWER ** within %d seconds or be ejected from the game.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
700 (me->p_cluecountdown / 10));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
701 pmessage(buf, me->p_no, MINDIV, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
702 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
703 pmessage("", me->p_no, MINDIV, "*******************************************************************************");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
704
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
705 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
706
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
707 /* called the first time */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
708 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
709 demand_clue()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
710 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
711 char buf[255];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
712 char syou[32];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
713 clueword[0] = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
714
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
715 sprintf(syou, "%s->YOU", SERVNAME);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
716 /* higher than rank CLUE_GETOUTOFIT get ... out of it */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
717 if (me->p_stats.st_rank > CLUE_GETOUTOFIT /* if my rank is high enough */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
718 || me->p_stats.st_royal == GODLIKE + 1 /* or I'm Q */ )
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
719 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
720 TellLINE;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
721 pmessage("Due to your ranking status, I will let you off the hook.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
722 me->p_no, MINDIV, syou);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
723 me->p_cluecountdown = -1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
724 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
725 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
726 else if (me->p_stats.st_cluesuccess > configvals->cluecheck)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
727 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
728 TellLINE;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
729 sprintf(buf, "You have passed the cluecheck the required %d times.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
730 configvals->cluecheck);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
731 pmessage(buf, me->p_no, MINDIV, syou);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
732 me->p_cluecountdown = -1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
733 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
734 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
735
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
736 parse_clue_phrases();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
737
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
738 if (num_phrases)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
739 set_clue_word(phrases[lrand48() % num_phrases]);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
740 if (*clueword == 0) /* didn't find one! */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
741 set_clue_word(fallback_cluewords[lrand48() % NUM_CLUEWORDS]);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
742 me->p_cluecountdown = configvals->cluetime * TICKSPERSEC;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
743
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
744 remind_cluecheck();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
745 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
746
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
747
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
748 /* every tick, check the person's clue status */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
749 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
750 countdown_clue()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
751 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
752 if (me->p_cluecountdown != -1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
753 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
754 if (me->p_status == POUTFIT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
755 || me->p_status == PTQUEUE
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
756 || me->p_status == POBSERVE)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
757 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
758
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
759 /* let bases off the hook */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
760 if (me->p_ship.s_type == 5 || me->p_ship.s_type == 9)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
761 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
762
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
763 if (me->p_cluedelay > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
764 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
765 me->p_cluedelay--;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
766 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
767 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
768
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
769 /* is it greater than one? */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
770 if (me->p_cluecountdown > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
771 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
772 char buf[255];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
773
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
774 /* under the gun here */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
775 me->p_cluecountdown--;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
776
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
777 if (me->p_cluecountdown == 150 * TICKSPERSEC
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
778 || me->p_cluecountdown == 60 * TICKSPERSEC
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
779 || me->p_cluecountdown == 10 * TICKSPERSEC)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
780 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
781 remind_cluecheck();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
782 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
783 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
784
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
785 /* is it still greater than 1? */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
786 else if (me->p_cluecountdown > 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
787 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
788
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
789 /* uhoh, we have a twink */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
790 me->p_status = PEXPLODE;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
791 me->p_explode = 10;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
792 me->p_whydead = KQUIT;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
793 me->p_cluecountdown = -1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
794
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
795 sprintf(buf, "%s (%s) was ejected for failing a cluecheck.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
796 me->p_name, twoletters(me));
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
797 pmessage(buf, SERVNAME, MALL, " ** CLUECHECK **");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
798
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
799 #ifdef MAIL_CLUELETTER
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
800 sprintf(buf, "%s %s %s", build_path(MAILCLUECHECK),
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
801 me->p_login, me->p_full_hostname);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
802 system(buf);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
803 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
804 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
805 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
806 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
807 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
808 * they aren't -1, they are greater than 1, so they havn't been checked
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
809 * yet
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
810 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
811 demand_clue();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
812 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
813 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
814 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
815
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
816
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
817 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
818 * // the person sent themselves the message "cluecheck..." // called in
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
819 * controls (message.c)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
820 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
821 int
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
822 accept_cluecheck(char *word)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
823 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
824 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
825 char buf[120];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
826 char syou[32];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
827
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
828 sprintf(syou, "%s->YOU", SERVNAME);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
829 if (me->p_cluecountdown == -1 || !me->p_cluecountdown)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
830 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
831 pmessage("You are not under a cluecheck.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
832 me->p_no, MINDIV, syou);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
833 return;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
834 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
835 else if (*word)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
836 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
837 for (i = 0; word[i] && clueword[i]; i++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
838 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
839 if (tolower(word[i]) != tolower(clueword[i]))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
840 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
841 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
842
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
843 if (word[i] || clueword[i])
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
844 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
845 sprintf(buf, "Nice try, guess again. It is not \"%s\".", word);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
846 pmessage(buf, me->p_no, MINDIV, syou);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
847 pmessage(
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
848 "Send the message \"cluecheck\" to yourself for another hint.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
849 me->p_no, MINDIV, syou);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
850 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
851 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
852 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
853 sprintf(buf,
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
854 "Good show %s. I won't bother you again for a while.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
855 me->p_name);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
856 pmessage(buf, me->p_no, MINDIV, syou);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
857 me->p_stats.st_cluesuccess++;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
858 me->p_cluecountdown = -1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
859 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
860 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
861 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
862 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
863 remind_cluecheck();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
864 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
865 sprintf(buf, "You have passed the cluecheck %d times.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
866 me->p_stats.st_cluesuccess);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
867 pmessage(buf, me->p_no, MINDIV, syou);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
868 return 1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
869 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
870
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
871 #endif /* CLUECHECK2 */