]>
Commit | Line | Data |
---|---|---|
fb37ecc7 | 1 | #include <fstream> |
a27420c4 | 2 | #include <iostream> |
85ce9d3e | 3 | #include <string.h> |
20d5d721 | 4 | #include <stdlib.h> |
85ce9d3e | 5 | #include <stdio.h> |
6 | #include "extern.h" | |
9bafc40d | 7 | #include "flags.h" |
85ce9d3e | 8 | |
a27420c4 | 9 | using namespace std; |
fb37ecc7 | 10 | |
624c0352 | 11 | int load_config_file(char *config); |
85ce9d3e | 12 | void unload_config_file(); |
85ce9d3e | 13 | |
14 | /* Random Configuration Stuff Goes Here until I code it to load from a .conf file :)*/ | |
15 | ||
16 | char *s_GameServ; // GameServ's nickname | |
17 | char *gshost; // GameServ's Hostname | |
18 | char *gsident; // GameServ's ident/username | |
19 | char *servername; // GameServ's Server | |
20 | char *c_Forest; // Forest channel | |
21 | char *c_ForestTopic; // Forest Channel Topic | |
45a84400 | 22 | char *adminpass; // Administrator password |
bf2cabcd | 23 | char *welcomemsg; // Welcome Message |
448a1531 | 24 | char *ignoreserverslist; // Servernames to ignore |
5431156e | 25 | char *nsname; // NickServ's name |
26 | char *nspass; // GameServ's NickServ Password | |
27 | ||
922daad7 | 28 | int welcomedelay; // Welcome Message Delay |
29 | int updateperiod; // Seconds until another player database update | |
20d5d721 | 30 | int forestfights; // Forest fights per day |
8450c018 | 31 | int maxafightdistance; // Max levels above a player they can fight player->player |
32 | int maxbfightdistance; // Max levels below a player they can fight player->player | |
40251952 | 33 | int maxidletime; // Max time (in seconds) a player can be idle for |
34 | int idlecheckperiod; // Period for checking every player's idle time | |
14e24ba1 | 35 | int level1expire; // Days for level 1 players to expire |
36 | int defaultexpire; // Days for other levels to expire | |
1ee4a31b | 37 | int maxitems; // Maximum amount of items a player can carry |
a9836c41 | 38 | unsigned int maxnicklen; // Maximum length a nickname can be |
4bcfa863 | 39 | long refreshperiod; // Period for refreshing players |
1fe6fccd | 40 | long rolloverperiod; // Period for rolling over forest fights |
41 | long configflags; // Holds the binary representation of some boolean values | |
42 | long maxforestfights; // Maximum amount of forest fights to roll over | |
7fdd9c86 | 43 | long numrolloverfights; // Number of forest fights to roll over |
85ce9d3e | 44 | |
a9836c41 | 45 | |
85ce9d3e | 46 | // Remote server stuff. This is used for the outgoing connection gameserv needs to make |
47 | // to a real ircd. | |
48 | char *remoteserver; // Server to connect to | |
285f72cf | 49 | char *localhost; // Hostname of the local address to bind to |
50 | int remoteport; // Port to connect to on remoteserver | |
85ce9d3e | 51 | char *remotepass; // Password for the server link |
52 | ||
3f107f27 | 53 | char *storeitemdata; // File to store the items available in the store |
c7bceafd | 54 | char *tavernitemdata; // File to store the items available in the tavern |
ec4605a9 | 55 | char *itemdata; // File to store the items in |
85ce9d3e | 56 | char *playerdata; // File to store player data in |
8e800549 | 57 | char *dragondata; // File to store current dragon data in |
58 | char *masterdata; // File to store the master data in | |
c260a8d7 | 59 | char *newsdata; // File to store news data in |
69ae096c | 60 | char *pidfile; // Process ID file |
83cfc0ba | 61 | char *scriptdir; // Directory to store scripts in |
85ce9d3e | 62 | |
e1c41a84 | 63 | #if defined(P10) |
392daa60 | 64 | char *gsnum = "[]AAA"; // GameServ Numeric |
e1c41a84 | 65 | #endif |
66 | ||
85ce9d3e | 67 | void unload_config_file() |
68 | { | |
3f107f27 | 69 | if (s_GameServ) |
70 | delete [] s_GameServ; | |
71 | if (gshost) | |
72 | delete [] gshost; | |
73 | if (gsident) | |
74 | delete [] gsident; | |
75 | if (servername) | |
76 | delete [] servername; | |
77 | if (c_Forest) | |
78 | delete [] c_Forest; | |
79 | if (c_ForestTopic) | |
80 | delete [] c_ForestTopic; | |
81 | if (remoteserver) | |
82 | delete [] remoteserver; | |
285f72cf | 83 | if (localhost) |
84 | delete [] localhost; | |
3f107f27 | 85 | if (remotepass) |
86 | delete [] remotepass; | |
87 | if (playerdata) | |
88 | delete [] playerdata; | |
89 | if (storeitemdata) | |
90 | delete [] storeitemdata; | |
91 | if (tavernitemdata) | |
92 | delete [] tavernitemdata; | |
93 | if (itemdata) | |
94 | delete [] itemdata; | |
95 | if (dragondata) | |
96 | delete [] dragondata; | |
97 | if (masterdata) | |
98 | delete [] masterdata; | |
99 | if (adminpass) | |
100 | delete [] adminpass; | |
101 | if (welcomemsg) | |
102 | delete [] welcomemsg; | |
103 | if (pidfile) | |
104 | delete [] pidfile; | |
105 | if (ignoreserverslist) | |
106 | delete [] ignoreserverslist; | |
107 | if (newsdata) | |
108 | delete [] newsdata; | |
109 | if (nsname) | |
110 | delete [] nsname; | |
111 | if (nspass) | |
112 | delete [] nspass; | |
83cfc0ba | 113 | if (scriptdir) |
114 | delete [] scriptdir; | |
392daa60 | 115 | |
3f107f27 | 116 | configflags = 0; |
85ce9d3e | 117 | } |
bf2cabcd | 118 | |
624c0352 | 119 | int load_config_file(char *config) |
85ce9d3e | 120 | { |
392daa60 | 121 | char *buf, *directive, *value; |
122 | ||
83cfc0ba | 123 | #define numdirectives 42 |
392daa60 | 124 | |
125 | unload_config_file(); | |
126 | ||
127 | struct DIRECTIVE { | |
1e1b5312 | 128 | bool done; |
129 | char *desc; | |
392daa60 | 130 | }; |
131 | ||
132 | DIRECTIVE directives[numdirectives]; | |
133 | ||
134 | directives[0].desc = "s_GameServ - GameServ Nickname"; | |
135 | directives[1].desc = "GSHOST - GameServ Hostname"; | |
136 | directives[2].desc = "GSIDENT - GameServ Ident"; | |
137 | directives[3].desc = "SERVERNAME - Pseudo Server's Name"; | |
138 | directives[4].desc = "C_FOREST - Forest Channel"; | |
139 | directives[5].desc = "C_FORESTTOPIC - Topic for the Forest Channel"; | |
140 | directives[6].desc = "REMOTESERVER - Server for gameserv to connect to (ip or hostname)"; | |
141 | directives[7].desc = "REMOTEPORT - Port on the remote server to connect to"; | |
142 | directives[8].desc = "REMOTEPASS - Password on the remote server"; | |
143 | directives[9].desc = "PLAYERDATA - File to store the player saves in"; | |
144 | directives[10].desc = "SAVEDNOTICE - True/False as to wether or not to tell the forest "\ | |
145 | "channel that the player database has been saved"; | |
146 | directives[11].desc = "ADMINPASS - Password to identify as an admin with"; | |
147 | directives[12].desc = "WELCOMEDELAY - Delay (in seconds) to wait before welcoming new users to the network"; | |
148 | directives[13].desc = "FORESTFIGHTS - Number of forest fights players get every day"; | |
149 | directives[14].desc = "UPDATEPERIOD - Number of seconds between every player data save"; | |
150 | directives[15].desc = "PIDFILE - Filename to store the gameserv process ID in"; | |
151 | directives[16].desc = "MAXAFIGHTDISTANCE - The maximum number of levels above you "\ | |
152 | "that you can fight player->player"; | |
153 | directives[17].desc = "MAXBFIGHTDISTANCE - The maximum number of levels below you "\ | |
154 | "that you can fight player->player"; | |
155 | directives[18].desc = "MAXIDLETIME - The maximum amount of time (in seconds) "\ | |
156 | "that a player can be idle before something happens"; | |
157 | directives[19].desc = "IDLECHECKPERIOD - The period (in seconds) in which the entire "\ | |
158 | "players list will be checked for idlers. See also: "\ | |
159 | "MAXIDLETIME"; | |
160 | directives[20].desc = "LISTENONC_FOREST - True/False as to "\ | |
161 | "whether or not to listen for forest "\ | |
162 | "commands on the forest channel"; | |
163 | directives[21].desc = "NEWSDATA - File to store daily news in"; | |
164 | directives[22].desc = "REFRESHPERIOD - Period (in seconds) to "\ | |
165 | "refresh players"; | |
166 | directives[23].desc = "LEVEL1EXPIRE - Amount of days until a "\ | |
167 | "level 1 player's account is deleted due to "\ | |
168 | "inactivity."; | |
169 | directives[24].desc = "DEFAULTEXPIRE - Amount of days until a "\ | |
170 | "level 2 and above player's account is "\ | |
171 | "deleted due to inactivity"; | |
172 | directives[25].desc = "USENICKSERV - True/False as to wether or not "\ | |
173 | "GameServ should identify with NickServ"; | |
174 | directives[26].desc = "NSNAME - Your network's NickServ nickname"; | |
175 | directives[27].desc = "NSPASS - GameServ's NickServ Password"; | |
176 | directives[28].desc = "DRAGONDATA - File to store the current "\ | |
177 | "dragon's stats in"; | |
178 | directives[29].desc = "MASTERDATA - File to store the level master stats in"; | |
179 | directives[30].desc = "ITEMDATA - File to store the items in"; | |
180 | directives[31].desc = "TAVERNITEMDATA - File in which to store the items that are available in the tavern"; | |
181 | directives[32].desc = "MAXITEMS - Maximum number of items a player can carry"; | |
182 | directives[33].desc = "STOREITEMDATA - File in which to store the items that are available in the store"; | |
183 | directives[34].desc = "LOCALHOST - Local hostname or IP to bind to when connecting to the remote server"; | |
184 | directives[35].desc = "ROLLOVERFORESTFIGHTS - True/False as to wether or not to roll over forest fights "\ | |
185 | "into the next day"; | |
186 | directives[36].desc = "MAXFORESTFIGHTS - Maximum amount of forest fights to roll over"; | |
187 | directives[37].desc = "ROLLOVERPERIOD - Period (in seconds) to rollover forest fights"; | |
188 | directives[38].desc = "NUMROLLOVERFIGHTS - Number of forest fights to roll over"; | |
2ca6a3de | 189 | directives[39].desc = "FAIRFIGHTS - True/False as to whether or not to check for fair fights"; |
a9836c41 | 190 | directives[40].desc = "MAXNICKLEN - Maximum length a nickname can be"; |
83cfc0ba | 191 | directives[41].desc = "SCRIPTDIR - Directory to store scripts in"; |
392daa60 | 192 | |
193 | configflags = 0; | |
194 | ||
195 | for (int count = 0; count < numdirectives; count++) | |
1e1b5312 | 196 | { |
392daa60 | 197 | directives[count].done = false; |
1e1b5312 | 198 | } |
392daa60 | 199 | |
200 | ifstream infile; | |
201 | infile.open(config); | |
202 | if (infile.fail()) | |
85ce9d3e | 203 | { |
392daa60 | 204 | log("Error opening %s", config); |
205 | cerr << "Error opening " << config << endl; | |
206 | return 0; | |
85ce9d3e | 207 | } |
392daa60 | 208 | |
209 | buf = new char[1024]; | |
210 | ||
211 | while (infile.getline(buf, 1024, '\n')) | |
85ce9d3e | 212 | { |
392daa60 | 213 | #ifdef DEBUGMODE |
214 | log("Config file entry buf: %s", buf); | |
215 | #endif | |
216 | ||
217 | if (buf[0] == '#' || buf[0] == ' ' || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') | |
85ce9d3e | 218 | continue; |
392daa60 | 219 | |
220 | directive = strtok(buf, " "); | |
221 | ||
222 | if (stricmp(directive, "DIE") == 0) | |
223 | { | |
224 | value = strtok(NULL, ""); | |
225 | log("You should read the entire %s file!", config); | |
226 | cerr << "You should read the entire " << config << " file!" | |
227 | << endl; | |
228 | delete []buf; | |
229 | exit(0); | |
230 | } | |
231 | if (stricmp(directive, "S_GAMESERV") == 0) | |
232 | { | |
233 | value = strtok(NULL, " "); | |
234 | s_GameServ = new char[strlen(value) + 1]; | |
235 | strcpy(s_GameServ, value); | |
236 | directives[0].done = true; | |
237 | } | |
238 | else if (stricmp(directive, "GSHOST") == 0) | |
239 | { | |
240 | value = strtok(NULL, " "); | |
241 | gshost = new char[strlen(value) + 1]; | |
242 | strcpy(gshost, value); | |
243 | directives[1].done = true; | |
244 | } | |
245 | else if (stricmp(directive, "GSIDENT") == 0) | |
246 | { | |
247 | value = strtok(NULL, " "); | |
248 | gsident = new char[strlen(value) + 1]; | |
249 | strcpy(gsident, value); | |
250 | directives[2].done = true; | |
251 | } | |
252 | else if (stricmp(directive, "SERVERNAME") == 0) | |
253 | { | |
254 | value = strtok(NULL, " "); | |
255 | servername = new char[strlen(value) + 1]; | |
256 | strcpy(servername, value); | |
257 | directives[3].done = true; | |
258 | } | |
259 | else if (stricmp(directive, "C_FOREST") == 0) | |
260 | { | |
261 | value = strtok(NULL, " "); | |
262 | c_Forest = new char[strlen(value) + 1]; | |
263 | strcpy(c_Forest, value); | |
264 | directives[4].done = true; | |
265 | } | |
266 | else if (stricmp(directive, "C_FORESTTOPIC") == 0) | |
267 | { | |
268 | value = strtok(NULL, ""); | |
269 | c_ForestTopic = new char[strlen(value) + 1]; | |
270 | strcpy(c_ForestTopic, value); | |
271 | directives[5].done = true; | |
272 | } | |
273 | else if (stricmp(directive, "REMOTESERVER") == 0) | |
274 | { | |
275 | value = strtok(NULL, " "); | |
276 | remoteserver = new char[strlen(value) + 1]; | |
277 | strcpy(remoteserver, value); | |
278 | directives[6].done = true; | |
279 | } | |
280 | else if (stricmp(directive, "REMOTEPORT") == 0) | |
281 | { | |
282 | value = strtok(NULL, " "); | |
283 | remoteport = stringtoint(value); | |
284 | directives[7].done = true; | |
285 | } | |
286 | else if (stricmp(directive, "REMOTEPASS") == 0) | |
287 | { | |
a9836c41 | 288 | value = strtok(NULL, " "); |
392daa60 | 289 | remotepass = new char[strlen(value) + 1]; |
290 | strcpy(remotepass, value); | |
291 | directives[8].done = true; | |
292 | } | |
293 | else if (stricmp(directive, "PLAYERDATA") == 0) | |
294 | { | |
295 | value = strtok(NULL, ""); | |
296 | playerdata = new char[strlen(value) + 1]; | |
297 | strcpy(playerdata, value); | |
298 | directives[9].done = true; | |
299 | } | |
300 | else if (stricmp(directive, "SAVEDNOTICE") == 0) | |
301 | { | |
a9836c41 | 302 | value = strtok(NULL, " "); |
392daa60 | 303 | if (stricmp(value, "TRUE") == 0) |
304 | setSavedNotice(); | |
305 | directives[10].done = true; | |
306 | } | |
307 | else if (stricmp(directive, "ADMINPASS") == 0) | |
308 | { | |
309 | value = strtok(NULL, ""); | |
310 | adminpass = new char[strlen(value) + 1]; | |
311 | strcpy(adminpass, value); | |
312 | directives[11].done = true; | |
313 | } | |
314 | else if (stricmp(directive, "WELCOMEDELAY") == 0) | |
315 | { | |
316 | value = strtok(NULL, " "); | |
317 | welcomedelay = stringtoint(value); | |
318 | directives[12].done = true; | |
319 | } | |
320 | else if (stricmp(directive, "FORESTFIGHTS") == 0) | |
321 | { | |
322 | value = strtok(NULL, " "); | |
323 | forestfights = stringtoint(value); | |
324 | directives[13].done = true; | |
325 | } | |
326 | else if (stricmp(directive, "UPDATEPERIOD") == 0) | |
327 | { | |
328 | value = strtok(NULL, " "); | |
329 | updateperiod = stringtoint(value); | |
330 | directives[14].done = true; | |
331 | } | |
332 | else if (stricmp(directive, "PIDFILE") == 0) | |
333 | { | |
334 | value = strtok(NULL, " "); | |
335 | pidfile = new char[strlen(value) + 1]; | |
336 | strcpy(pidfile, value); | |
337 | directives[15].done = true; | |
338 | } | |
339 | else if (stricmp(directive, "MAXAFIGHTDISTANCE") == 0) | |
340 | { | |
341 | value = strtok(NULL, " "); | |
342 | maxafightdistance = stringtoint(value); | |
343 | directives[16].done = true;; | |
344 | } | |
345 | else if (stricmp(directive, "MAXBFIGHTDISTANCE") == 0) | |
346 | { | |
347 | value = strtok(NULL, " "); | |
348 | maxbfightdistance = stringtoint(value); | |
349 | directives[17].done = true; | |
350 | } | |
351 | else if (stricmp(directive, "MAXIDLETIME") == 0) | |
352 | { | |
353 | value = strtok(NULL, " "); | |
354 | maxidletime = stringtoint(value); | |
355 | directives[18].done = true; | |
356 | } | |
357 | else if (stricmp(directive, "IDLECHECKPERIOD") == 0) | |
358 | { | |
359 | value = strtok(NULL, " "); | |
360 | idlecheckperiod = stringtoint(value); | |
361 | directives[19].done = true; | |
362 | } | |
363 | else if (stricmp(directive, "LISTENONC_FOREST") == 0) | |
364 | { | |
365 | value = strtok(NULL, " "); | |
366 | if(stricmp(value, "TRUE") == 0) | |
367 | { | |
368 | setListenOnCF(); | |
369 | } | |
370 | ||
371 | directives[20].done = true; | |
372 | } | |
373 | else if (stricmp(directive, "NEWSDATA") == 0) | |
374 | { | |
375 | value = strtok(NULL, " "); | |
376 | newsdata = new char [strlen(value) + 1]; | |
67b4ac9a | 377 | strcpy(newsdata, value); |
392daa60 | 378 | directives[21].done = true; |
379 | } | |
380 | else if (stricmp(directive, "REFRESHPERIOD") == 0) | |
381 | { | |
382 | value = strtok(NULL, " "); | |
383 | refreshperiod = stringtoint(value); | |
384 | directives[22].done = true; | |
385 | } | |
386 | else if (stricmp(directive, "LEVEL1EXPIRE") == 0) | |
387 | { | |
388 | value = strtok(NULL, " "); | |
389 | level1expire = stringtoint(value); | |
390 | directives[23].done = true; | |
391 | } | |
392 | else if (stricmp(directive, "DEFAULTEXPIRE") == 0) | |
393 | { | |
394 | value = strtok(NULL, " "); | |
395 | defaultexpire = stringtoint(value); | |
396 | directives[24].done = true; | |
397 | } | |
398 | else if (stricmp(directive, "USENICKSERV") == 0) | |
399 | { | |
400 | value = strtok(NULL, " "); | |
401 | if (stricmp(value, "TRUE") == 0) | |
402 | { | |
403 | setUseNickServ(); | |
404 | } | |
405 | ||
406 | directives[25].done = true; | |
407 | } | |
408 | else if (stricmp(directive, "NSNAME") == 0) | |
409 | { | |
a9836c41 | 410 | value = strtok(NULL, " "); |
392daa60 | 411 | nsname = new char[strlen(value) + 1]; |
67b4ac9a | 412 | strcpy(nsname, value); |
392daa60 | 413 | directives[26].done = true; |
414 | } | |
415 | else if (stricmp(directive, "NSPASS") == 0) | |
416 | { | |
a9836c41 | 417 | value = strtok(NULL, " "); |
392daa60 | 418 | nspass = new char[strlen(value) + 1]; |
67b4ac9a | 419 | strcpy(nspass, value); |
392daa60 | 420 | directives[27].done = true; |
421 | } | |
422 | else if (stricmp(directive, "DRAGONDATA") == 0) | |
423 | { | |
424 | value = strtok(NULL, ""); | |
425 | dragondata = new char[strlen(value) + 1]; | |
67b4ac9a | 426 | strcpy(dragondata, value); |
392daa60 | 427 | directives[28].done = true; |
428 | } | |
429 | else if (stricmp(directive, "MASTERDATA") == 0) | |
430 | { | |
431 | value = strtok(NULL, ""); | |
432 | masterdata = new char[strlen(value) + 1]; | |
67b4ac9a | 433 | strcpy(masterdata, value); |
392daa60 | 434 | directives[29].done = true; |
435 | } | |
436 | else if (stricmp(directive, "ITEMDATA") == 0) | |
437 | { | |
438 | value = strtok(NULL, ""); | |
439 | itemdata = new char[strlen(value) + 1]; | |
67b4ac9a | 440 | strcpy(itemdata, value); |
392daa60 | 441 | directives[30].done = true; |
442 | } | |
443 | else if (stricmp(directive, "TAVERNITEMDATA") == 0) | |
444 | { | |
445 | value = strtok(NULL, ""); | |
446 | tavernitemdata = new char[strlen(value) + 1]; | |
67b4ac9a | 447 | strcpy(tavernitemdata, value); |
392daa60 | 448 | directives[31].done = true; |
449 | } | |
450 | else if (stricmp(directive, "MAXITEMS") == 0) | |
451 | { | |
a9836c41 | 452 | value = strtok(NULL, " "); |
392daa60 | 453 | maxitems = stringtoint(value); |
454 | directives[32].done = true; | |
455 | } | |
456 | else if (stricmp(directive, "STOREITEMDATA") == 0) | |
457 | { | |
458 | value = strtok(NULL, ""); | |
459 | storeitemdata = new char[strlen(value) + 1]; | |
67b4ac9a | 460 | strcpy(storeitemdata, value); |
392daa60 | 461 | directives[33].done = true; |
462 | } | |
463 | else if (stricmp(directive, "LOCALHOST") == 0) | |
464 | { | |
a9836c41 | 465 | value = strtok(NULL, " "); |
392daa60 | 466 | localhost = new char[strlen(value) + 1]; |
67b4ac9a | 467 | strcpy(localhost, value); |
392daa60 | 468 | directives[34].done = true; |
469 | } | |
470 | else if (stricmp(directive, "ROLLOVERFORESTFIGHTS") == 0) | |
471 | { | |
472 | value = strtok(NULL, " "); | |
473 | if (stricmp(value, "TRUE") == 0) | |
474 | { | |
475 | setRolloverForestFights(); | |
476 | } | |
477 | else | |
478 | { | |
479 | directives[36].done = true; | |
480 | directives[37].done = true; | |
481 | directives[38].done = true; | |
482 | } | |
483 | directives[35].done = true; | |
484 | } | |
485 | else if (stricmp(directive, "MAXFORESTFIGHTS") == 0) | |
486 | { | |
a9836c41 | 487 | value = strtok(NULL, " "); |
392daa60 | 488 | maxforestfights = stringtoint(value); |
489 | directives[36].done = true; | |
490 | } | |
491 | else if (stricmp(directive, "ROLLOVERPERIOD") == 0) | |
492 | { | |
a9836c41 | 493 | value = strtok(NULL, " "); |
392daa60 | 494 | rolloverperiod = stringtoint(value); |
495 | directives[37].done = true; | |
496 | } | |
497 | else if (stricmp(directive, "NUMROLLOVERFIGHTS") == 0) | |
498 | { | |
499 | value = strtok(NULL, ""); | |
500 | numrolloverfights = stringtoint(value); | |
501 | directives[38].done = true; | |
502 | } | |
2ca6a3de | 503 | else if (stricmp(directive, "FAIRFIGHTS") == 0) |
504 | { | |
a9836c41 | 505 | value = strtok(NULL, " "); |
2ca6a3de | 506 | if (stricmp(value, "TRUE") == 0) |
507 | setFairFights(); | |
508 | directives[39].done = true; | |
509 | } | |
a9836c41 | 510 | else if (stricmp(directive, "MAXNICKLEN") == 0) |
511 | { | |
512 | value = strtok(NULL, " "); | |
513 | maxnicklen = stringtoint(value); | |
514 | directives[40].done = true; | |
515 | } | |
83cfc0ba | 516 | else if (stricmp(directive, "SCRIPTDIR") == 0) |
517 | { | |
67b4ac9a | 518 | value = strtok(NULL, " "); |
519 | scriptdir = new char [strlen(value) + 1]; | |
520 | strcpy(scriptdir, value); | |
83cfc0ba | 521 | directives[41].done = true; |
522 | } | |
392daa60 | 523 | else if (stricmp(directive, "WELCOMEMSG") == 0) |
524 | { | |
525 | // This directive is optional | |
526 | value = strtok(NULL, ""); | |
527 | welcomemsg = new char[strlen(value) + 1]; | |
67b4ac9a | 528 | strcpy(welcomemsg, value); |
392daa60 | 529 | setWelcome(); |
530 | } | |
531 | else if (stricmp(directive, "USEPRIVMSG") == 0) | |
532 | { | |
533 | // This directive is optional | |
534 | setUsePrivmsg(); | |
535 | } | |
536 | else if (stricmp(directive, "BOPER") == 0) | |
537 | { | |
538 | // This directive is optional | |
539 | setBOper(); | |
540 | } | |
541 | else if (stricmp(directive, "IGNORESERVERS") == 0) | |
542 | { | |
543 | // This directive is optional | |
544 | value = strtok(NULL, ""); | |
545 | ignoreserverslist = new char[strlen(value) + 1]; | |
67b4ac9a | 546 | strcpy(ignoreserverslist, value); |
392daa60 | 547 | } |
548 | else | |
549 | { | |
550 | #ifdef DEBUGMODE | |
551 | log("Unknown Directive. Buffer: %s", buf); | |
552 | cerr << "Unknown " << config << " directive. Buffer: " | |
553 | << buf << endl; | |
554 | #endif | |
555 | continue; | |
556 | } | |
1e1b5312 | 557 | } |
392daa60 | 558 | delete [] buf; |
559 | infile.close(); | |
560 | ||
561 | int nonemissing = 1; | |
562 | for (int count2 = 0; count2 < numdirectives; count2++) | |
563 | { | |
564 | if (!directives[count2].done) | |
565 | { | |
566 | cerr << "Missing config directive: " << directives[count2].desc << endl; | |
567 | nonemissing = 0; | |
568 | } | |
569 | } | |
570 | ||
571 | return nonemissing; | |
85ce9d3e | 572 | } |