1 | /* |
1 | /* |
2 | * static char *rcsid_init_c = |
2 | * static char *rcsid_init_c = |
3 | * "$Id: init.C,v 1.3 2006/08/29 05:03:55 root Exp $"; |
3 | * "$Id: init.C,v 1.8 2006/09/03 14:33:46 elmex Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
73 | void set_csport(char *val) |
73 | void set_csport(char *val) |
74 | { |
74 | { |
75 | settings.csport=atoi(val); |
75 | settings.csport=atoi(val); |
76 | #ifndef WIN32 /* ***win32: set_csport: we remove csport error secure check here, do this later */ |
76 | #ifndef WIN32 /* ***win32: set_csport: we remove csport error secure check here, do this later */ |
77 | if (settings.csport<=0 || settings.csport>32765 || |
77 | if (settings.csport<=0 || settings.csport>32765 || |
78 | (settings.csport<1024 && getuid()!=0)) { |
78 | (settings.csport<1024 && getuid()!=0)) { |
79 | LOG(llevError, "%d is an invalid csport number.\n", settings.csport); |
79 | LOG(llevError, "%d is an invalid csport number.\n", settings.csport); |
80 | exit(1); |
80 | exit(1); |
81 | } |
81 | } |
82 | #endif /* win32 */ |
82 | #endif /* win32 */ |
83 | } |
83 | } |
84 | |
84 | |
85 | /* Most of this is shamelessly stolen from XSysStats. But since that is |
85 | /* Most of this is shamelessly stolen from XSysStats. But since that is |
… | |
… | |
88 | struct Command_Line_Options { |
88 | struct Command_Line_Options { |
89 | const char *cmd_option; /* how it is called on the command line */ |
89 | const char *cmd_option; /* how it is called on the command line */ |
90 | uint8 num_args; /* Number or args it takes */ |
90 | uint8 num_args; /* Number or args it takes */ |
91 | uint8 pass; /* What pass this should be processed on. */ |
91 | uint8 pass; /* What pass this should be processed on. */ |
92 | void (*func)(); /* function to call when we match this. |
92 | void (*func)(); /* function to call when we match this. |
93 | * if num_args is true, than that gets passed |
93 | * if num_args is true, than that gets passed |
94 | * to the function, otherwise nothing is passed |
94 | * to the function, otherwise nothing is passed |
95 | */ |
95 | */ |
96 | }; |
96 | }; |
97 | |
97 | |
98 | /* The way this system works is pretty simple - parse_args takes |
98 | /* The way this system works is pretty simple - parse_args takes |
99 | * the options passed to the program and a pass number. If an option |
99 | * the options passed to the program and a pass number. If an option |
100 | * matches both in name and in pass (and we have enough options), |
100 | * matches both in name and in pass (and we have enough options), |
… | |
… | |
166 | { |
166 | { |
167 | size_t i; |
167 | size_t i; |
168 | int on_arg=1; |
168 | int on_arg=1; |
169 | |
169 | |
170 | while (on_arg<argc) { |
170 | while (on_arg<argc) { |
171 | for (i=0; i<sizeof(options)/sizeof(struct Command_Line_Options); i++) { |
171 | for (i=0; i<sizeof(options)/sizeof(struct Command_Line_Options); i++) { |
172 | if (!strcmp(options[i].cmd_option, argv[on_arg])) { |
172 | if (!strcmp(options[i].cmd_option, argv[on_arg])) { |
173 | /* Found a matching option, but should not be processed on |
173 | /* Found a matching option, but should not be processed on |
174 | * this pass. Just skip over it |
174 | * this pass. Just skip over it |
175 | */ |
175 | */ |
176 | if (options[i].pass != pass) { |
176 | if (options[i].pass != pass) { |
177 | on_arg += options[i].num_args+1; |
177 | on_arg += options[i].num_args+1; |
178 | break; |
178 | break; |
179 | } |
179 | } |
180 | if (options[i].num_args) { |
180 | if (options[i].num_args) { |
181 | if ((on_arg+options[i].num_args)>=argc) { |
181 | if ((on_arg+options[i].num_args)>=argc) { |
182 | fprintf(stderr,"%s requires an argument.\n", options[i].cmd_option); |
182 | fprintf(stderr,"%s requires an argument.\n", options[i].cmd_option); |
183 | exit(1); |
183 | exit(1); |
184 | } |
184 | } |
185 | else { |
185 | else { |
186 | if (options[i].num_args==1) |
186 | if (options[i].num_args==1) |
187 | ((void (*)(char*))options[i].func)(argv[on_arg+1]); |
187 | ((void (*)(char*))options[i].func)(argv[on_arg+1]); |
188 | if (options[i].num_args==2) |
188 | if (options[i].num_args==2) |
189 | ((void (*)(char*,char*))options[i].func)(argv[on_arg+1],argv[on_arg+2]); |
189 | ((void (*)(char*,char*))options[i].func)(argv[on_arg+1],argv[on_arg+2]); |
190 | on_arg +=options[i].num_args+1; |
190 | on_arg +=options[i].num_args+1; |
191 | } |
191 | } |
192 | } |
192 | } |
193 | else { /* takes no args */ |
193 | else { /* takes no args */ |
194 | options[i].func(); |
194 | options[i].func(); |
195 | on_arg++; |
195 | on_arg++; |
196 | } |
196 | } |
197 | break; |
197 | break; |
198 | } |
198 | } |
199 | } |
199 | } |
200 | if (i==sizeof(options)/sizeof(struct Command_Line_Options)) { |
200 | if (i==sizeof(options)/sizeof(struct Command_Line_Options)) { |
201 | fprintf(stderr,"Unknown option: %s\n", argv[on_arg]); |
201 | fprintf(stderr,"Unknown option: %s\n", argv[on_arg]); |
202 | usage(); |
202 | usage(); |
203 | exit(1); |
203 | exit(1); |
204 | } |
204 | } |
205 | } |
205 | } |
206 | } |
206 | } |
207 | |
207 | |
|
|
208 | //TODO: make this a constructor |
208 | static materialtype_t *get_empty_mat(void) { |
209 | static materialtype_t *get_empty_mat(void) { |
209 | materialtype_t *mt; |
210 | materialtype_t *mt; |
210 | int i; |
211 | int i; |
211 | |
212 | |
212 | mt = (materialtype_t *)malloc(sizeof(materialtype_t)); |
213 | mt = new materialtype_t; |
213 | if (mt == NULL) |
214 | |
214 | fatal(OUT_OF_MEMORY); |
|
|
215 | mt->name = NULL; |
215 | mt->name = NULL; |
216 | mt->description = NULL; |
216 | mt->description = NULL; |
217 | for (i=0; i < NROFATTACKS; i++) { |
217 | for (i=0; i < NROFATTACKS; i++) { |
218 | mt->save[i] = 0; |
218 | mt->save[i] = 0; |
219 | mt->mod[i] = 0; |
219 | mt->mod[i] = 0; |
220 | } |
220 | } |
221 | mt->chance = 0; |
221 | mt->chance = 0; |
222 | mt->difficulty = 0; |
222 | mt->difficulty = 0; |
223 | mt->magic = 0; |
223 | mt->magic = 0; |
224 | mt->damage = 0; |
224 | mt->damage = 0; |
… | |
… | |
248 | return; |
248 | return; |
249 | } |
249 | } |
250 | mt = get_empty_mat(); |
250 | mt = get_empty_mat(); |
251 | materialt = mt; |
251 | materialt = mt; |
252 | while (fgets(buf, MAX_BUF, fp) != NULL) { |
252 | while (fgets(buf, MAX_BUF, fp) != NULL) { |
253 | if (*buf=='#') |
253 | if (*buf=='#') |
254 | continue; |
254 | continue; |
255 | if ((cp=strchr(buf, '\n'))!=NULL) |
255 | if ((cp=strchr(buf, '\n'))!=NULL) |
256 | *cp='\0'; |
256 | *cp='\0'; |
257 | cp=buf; |
257 | cp=buf; |
258 | while(*cp==' ') /* Skip blanks */ |
258 | while(*cp==' ') /* Skip blanks */ |
259 | cp++; |
259 | cp++; |
260 | if (!strncmp(cp, "name", 4)) { |
260 | if (!strncmp(cp, "name", 4)) { |
261 | /* clean up the previous entry */ |
261 | /* clean up the previous entry */ |
262 | if (mt->next != NULL) { |
262 | if (mt->next != NULL) { |
263 | if (mt->description == NULL) |
263 | if (mt->description == NULL) |
264 | mt->description = add_string(mt->name); |
264 | mt->description = mt->name; |
265 | mt = mt->next; |
265 | mt = mt->next; |
266 | } |
266 | } |
267 | mt->next = get_empty_mat(); |
267 | mt->next = get_empty_mat (); |
268 | mt->name = add_string(strchr(cp, ' ') + 1); |
268 | mt->name = strchr(cp, ' ') + 1; |
269 | } else if (!strncmp(cp, "description", 11)) { |
269 | } else if (!strncmp(cp, "description", 11)) { |
270 | mt->description = add_string(strchr(cp, ' ') + 1); |
270 | mt->description = strchr(cp, ' ') + 1; |
271 | } else if (sscanf(cp, "material %d", &value)) { |
271 | } else if (sscanf(cp, "material %d", &value)) { |
272 | mt->material = value; |
272 | mt->material = value; |
273 | } else if (!strncmp(cp, "saves", 5)) { |
273 | } else if (!strncmp(cp, "saves", 5)) { |
274 | cp = strchr(cp, ' ') + 1; |
274 | cp = strchr(cp, ' ') + 1; |
275 | for (i=0; i < NROFATTACKS; i++) { |
275 | for (i=0; i < NROFATTACKS; i++) { |
276 | if (cp == NULL) { |
276 | if (cp == NULL) { |
277 | mt->save[i] = 0; |
277 | mt->save[i] = 0; |
278 | continue; |
278 | continue; |
279 | } |
279 | } |
280 | if ((next=strchr(cp,',')) != NULL) |
280 | if ((next=strchr(cp,',')) != NULL) |
281 | *(next++) = '\0'; |
281 | *(next++) = '\0'; |
282 | sscanf(cp, "%d", &value); |
282 | sscanf(cp, "%d", &value); |
283 | mt->save[i] = (sint8)value; |
283 | mt->save[i] = (sint8)value; |
284 | cp = next; |
284 | cp = next; |
285 | } |
285 | } |
286 | } else if (!strncmp(cp, "mods", 4)) { |
286 | } else if (!strncmp(cp, "mods", 4)) { |
287 | cp = strchr(cp, ' ') + 1; |
287 | cp = strchr(cp, ' ') + 1; |
288 | for (i=0; i < NROFATTACKS; i++) { |
288 | for (i=0; i < NROFATTACKS; i++) { |
289 | if (cp == NULL) { |
289 | if (cp == NULL) { |
290 | mt->save[i] = 0; |
290 | mt->save[i] = 0; |
291 | continue; |
291 | continue; |
292 | } |
292 | } |
293 | if ((next=strchr(cp,',')) != NULL) |
293 | if ((next=strchr(cp,',')) != NULL) |
294 | *(next++) = '\0'; |
294 | *(next++) = '\0'; |
295 | sscanf(cp, "%d", &value); |
295 | sscanf(cp, "%d", &value); |
296 | mt->mod[i] = (sint8)value; |
296 | mt->mod[i] = (sint8)value; |
297 | cp = next; |
297 | cp = next; |
298 | } |
298 | } |
299 | } else if (sscanf(cp, "chance %d\n", &value)) { |
299 | } else if (sscanf(cp, "chance %d\n", &value)) { |
300 | mt->chance = (sint8)value; |
300 | mt->chance = (sint8)value; |
301 | } else if (sscanf(cp, "diff %d\n", &value)) { |
301 | } else if (sscanf(cp, "diff %d\n", &value)) { |
302 | mt->difficulty = (sint8)value; |
302 | mt->difficulty = (sint8)value; |
303 | } else if (sscanf(cp, "magic %d\n", &value)) { |
303 | } else if (sscanf(cp, "magic %d\n", &value)) { |
304 | mt->magic = (sint8)value; |
304 | mt->magic = (sint8)value; |
305 | } else if (sscanf(cp, "damage %d\n", &value)) { |
305 | } else if (sscanf(cp, "damage %d\n", &value)) { |
306 | mt->damage= (sint8)value; |
306 | mt->damage= (sint8)value; |
307 | } else if (sscanf(cp, "wc %d\n", &value)) { |
307 | } else if (sscanf(cp, "wc %d\n", &value)) { |
308 | mt->wc = (sint8)value; |
308 | mt->wc = (sint8)value; |
309 | } else if (sscanf(cp, "ac %d\n", &value)) { |
309 | } else if (sscanf(cp, "ac %d\n", &value)) { |
310 | mt->ac = (sint8)value; |
310 | mt->ac = (sint8)value; |
311 | } else if (sscanf(cp, "sp %d\n", &value)) { |
311 | } else if (sscanf(cp, "sp %d\n", &value)) { |
312 | mt->sp = (sint8)value; |
312 | mt->sp = (sint8)value; |
313 | } else if (sscanf(cp, "weight %d\n", &value)) { |
313 | } else if (sscanf(cp, "weight %d\n", &value)) { |
314 | mt->weight = value; |
314 | mt->weight = value; |
315 | } else if (sscanf(cp, "value %d\n", &value)) { |
315 | } else if (sscanf(cp, "value %d\n", &value)) { |
316 | mt->value = value; |
316 | mt->value = value; |
317 | } |
317 | } |
318 | } |
318 | } |
319 | if (mt->next) |
319 | if (mt->next) |
320 | { |
320 | { |
321 | free(mt->next); |
321 | delete mt->next; |
322 | mt->next = NULL; |
322 | mt->next = NULL; |
323 | } |
323 | } |
324 | LOG(llevDebug, "Done.\n"); |
324 | LOG(llevDebug, "Done.\n"); |
325 | fclose(fp); |
325 | fclose(fp); |
326 | } |
326 | } |
… | |
… | |
340 | /* We don't require a settings file at current time, but down the road, |
340 | /* We don't require a settings file at current time, but down the road, |
341 | * there will probably be so many values that not having a settings file |
341 | * there will probably be so many values that not having a settings file |
342 | * will not be a good thing. |
342 | * will not be a good thing. |
343 | */ |
343 | */ |
344 | if ((fp = open_and_uncompress(buf, 0, &comp)) == NULL) { |
344 | if ((fp = open_and_uncompress(buf, 0, &comp)) == NULL) { |
345 | LOG(llevError,"Warning: No settings file found\n"); |
345 | LOG(llevError,"Warning: No settings file found\n"); |
346 | return; |
346 | return; |
347 | } |
347 | } |
348 | while (fgets(buf, MAX_BUF-1, fp) != NULL) { |
348 | while (fgets(buf, MAX_BUF-1, fp) != NULL) { |
349 | if (buf[0] == '#') continue; |
349 | if (buf[0] == '#') continue; |
350 | /* eliminate newline */ |
350 | /* eliminate newline */ |
351 | if ((cp=strrchr(buf,'\n'))!=NULL) *cp='\0'; |
351 | if ((cp=strrchr(buf,'\n'))!=NULL) *cp='\0'; |
352 | |
352 | |
353 | /* Skip over empty lines */ |
353 | /* Skip over empty lines */ |
354 | if (buf[0] == 0) continue; |
354 | if (buf[0] == 0) continue; |
355 | |
355 | |
356 | /* Skip all the spaces and set them to nulls. If not space, |
356 | /* Skip all the spaces and set them to nulls. If not space, |
357 | * set cp to "" to make strcpy's and the like easier down below. |
357 | * set cp to "" to make strcpy's and the like easier down below. |
358 | */ |
358 | */ |
359 | if ((cp = strchr(buf,' '))!=NULL) { |
359 | if ((cp = strchr(buf,' '))!=NULL) { |
360 | while (*cp==' ') *cp++=0; |
360 | while (*cp==' ') *cp++=0; |
361 | has_val=1; |
361 | has_val=1; |
362 | } else { |
362 | } else { |
363 | cp=""; |
363 | cp=""; |
364 | has_val=0; |
364 | has_val=0; |
365 | } |
365 | } |
366 | |
366 | |
367 | if (!strcasecmp(buf,"metaserver_notification")) { |
367 | if (!strcasecmp(buf,"metaserver_notification")) { |
368 | if (!strcasecmp(cp,"on") || !strcasecmp(cp,"true")) { |
368 | if (!strcasecmp(cp,"on") || !strcasecmp(cp,"true")) { |
369 | settings.meta_on=TRUE; |
369 | settings.meta_on=TRUE; |
370 | } else if (!strcasecmp(cp,"off") || !strcasecmp(cp,"false")) { |
370 | } else if (!strcasecmp(cp,"off") || !strcasecmp(cp,"false")) { |
371 | settings.meta_on=FALSE; |
371 | settings.meta_on=FALSE; |
372 | } else { |
372 | } else { |
373 | LOG(llevError,"load_settings: Unknown value for metaserver_notification: %s\n", |
373 | LOG(llevError,"load_settings: Unknown value for metaserver_notification: %s\n", |
374 | cp); |
374 | cp); |
375 | } |
375 | } |
376 | } else if (!strcasecmp(buf,"metaserver_server")) { |
376 | } else if (!strcasecmp(buf,"metaserver_server")) { |
377 | if (has_val) strcpy(settings.meta_server, cp); |
377 | if (has_val) strcpy(settings.meta_server, cp); |
378 | else |
378 | else |
379 | LOG(llevError,"load_settings: metaserver_server must have a value.\n"); |
379 | LOG(llevError,"load_settings: metaserver_server must have a value.\n"); |
380 | } else if (!strcasecmp(buf,"motd")) { |
380 | } else if (!strcasecmp(buf,"motd")) { |
381 | if (has_val) |
381 | if (has_val) |
382 | strcpy(settings.motd, cp); |
382 | strcpy(settings.motd, cp); |
383 | else |
383 | else |
384 | LOG(llevError,"load_settings: motd must have a value.\n"); |
384 | LOG(llevError,"load_settings: motd must have a value.\n"); |
385 | } else if (!strcasecmp(buf,"dm_mail")) { |
385 | } else if (!strcasecmp(buf,"dm_mail")) { |
386 | if (has_val) |
386 | if (has_val) |
387 | strcpy(settings.dm_mail, cp); |
387 | strcpy(settings.dm_mail, cp); |
388 | else |
388 | else |
389 | LOG(llevError,"load_settings: dm_mail must have a value.\n"); |
389 | LOG(llevError,"load_settings: dm_mail must have a value.\n"); |
390 | } else if (!strcasecmp(buf,"metaserver_host")) { |
390 | } else if (!strcasecmp(buf,"metaserver_host")) { |
391 | if (has_val) strcpy(settings.meta_host, cp); |
391 | if (has_val) strcpy(settings.meta_host, cp); |
392 | else |
392 | else |
393 | LOG(llevError,"load_settings: metaserver_host must have a value.\n"); |
393 | LOG(llevError,"load_settings: metaserver_host must have a value.\n"); |
394 | } else if (!strcasecmp(buf,"metaserver_port")) { |
394 | } else if (!strcasecmp(buf,"metaserver_port")) { |
395 | int port = atoi(cp); |
395 | int port = atoi(cp); |
396 | |
396 | |
397 | if (port<1 || port>65535) |
397 | if (port<1 || port>65535) |
398 | LOG(llevError,"load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", |
398 | LOG(llevError,"load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", |
399 | port); |
399 | port); |
400 | else settings.meta_port = port; |
400 | else settings.meta_port = port; |
401 | } else if (!strcasecmp(buf,"metaserver_comment")) { |
401 | } else if (!strcasecmp(buf,"metaserver_comment")) { |
402 | strcpy(settings.meta_comment, cp); |
402 | strcpy(settings.meta_comment, cp); |
403 | } else if (!strcasecmp(buf, "worldmapstartx")) { |
403 | } else if (!strcasecmp(buf, "worldmapstartx")) { |
404 | int size = atoi(cp); |
404 | int size = atoi(cp); |
405 | |
405 | |
406 | if (size < 0) |
406 | if (size < 0) |
407 | LOG(llevError, "load_settings: worldmapstartx must be at least " |
407 | LOG(llevError, "load_settings: worldmapstartx must be at least " |
408 | "0, %d is invalid\n", size); |
408 | "0, %d is invalid\n", size); |
409 | else |
409 | else |
410 | settings.worldmapstartx = size; |
410 | settings.worldmapstartx = size; |
411 | } else if (!strcasecmp(buf, "worldmapstarty")) { |
411 | } else if (!strcasecmp(buf, "worldmapstarty")) { |
412 | int size = atoi(cp); |
412 | int size = atoi(cp); |
413 | |
413 | |
414 | if (size < 0) |
414 | if (size < 0) |
415 | LOG(llevError, "load_settings: worldmapstarty must be at least " |
415 | LOG(llevError, "load_settings: worldmapstarty must be at least " |
416 | "0, %d is invalid\n", size); |
416 | "0, %d is invalid\n", size); |
417 | else |
417 | else |
418 | settings.worldmapstarty = size; |
418 | settings.worldmapstarty = size; |
419 | } else if (!strcasecmp(buf, "worldmaptilesx")) { |
419 | } else if (!strcasecmp(buf, "worldmaptilesx")) { |
420 | int size = atoi(cp); |
420 | int size = atoi(cp); |
421 | |
421 | |
422 | if (size < 1) |
422 | if (size < 1) |
423 | LOG(llevError, "load_settings: worldmaptilesx must be greater " |
423 | LOG(llevError, "load_settings: worldmaptilesx must be greater " |
424 | "than 1, %d is invalid\n", size); |
424 | "than 1, %d is invalid\n", size); |
425 | else |
425 | else |
426 | settings.worldmaptilesx = size; |
426 | settings.worldmaptilesx = size; |
427 | } else if (!strcasecmp(buf, "worldmaptilesy")) { |
427 | } else if (!strcasecmp(buf, "worldmaptilesy")) { |
428 | int size = atoi(cp); |
428 | int size = atoi(cp); |
429 | |
429 | |
430 | if (size < 1) |
430 | if (size < 1) |
431 | LOG(llevError, "load_settings: worldmaptilesy must be greater " |
431 | LOG(llevError, "load_settings: worldmaptilesy must be greater " |
432 | "than 1, %d is invalid\n", size); |
432 | "than 1, %d is invalid\n", size); |
433 | else |
433 | else |
434 | settings.worldmaptilesy = size; |
434 | settings.worldmaptilesy = size; |
435 | } else if (!strcasecmp(buf, "worldmaptilesizex")) { |
435 | } else if (!strcasecmp(buf, "worldmaptilesizex")) { |
436 | int size = atoi(cp); |
436 | int size = atoi(cp); |
437 | |
437 | |
438 | if (size < 1) |
438 | if (size < 1) |
439 | LOG(llevError, "load_settings: worldmaptilesizex must be " |
439 | LOG(llevError, "load_settings: worldmaptilesizex must be " |
440 | "greater than 1, %d is invalid\n", size); |
440 | "greater than 1, %d is invalid\n", size); |
441 | else |
441 | else |
442 | settings.worldmaptilesizex = size; |
442 | settings.worldmaptilesizex = size; |
443 | } else if (!strcasecmp(buf, "worldmaptilesizey")) { |
443 | } else if (!strcasecmp(buf, "worldmaptilesizey")) { |
444 | int size = atoi(cp); |
444 | int size = atoi(cp); |
445 | |
445 | |
446 | if (size < 1) |
446 | if (size < 1) |
447 | LOG(llevError, "load_settings: worldmaptilesizey must be " |
447 | LOG(llevError, "load_settings: worldmaptilesizey must be " |
448 | "greater than 1, %d is invalid\n", size); |
448 | "greater than 1, %d is invalid\n", size); |
449 | else |
449 | else |
450 | settings.worldmaptilesizey = size; |
450 | settings.worldmaptilesizey = size; |
451 | } else if (!strcasecmp(buf, "dynamiclevel")) { |
451 | } else if (!strcasecmp(buf, "dynamiclevel")) { |
452 | int lev = atoi(cp); |
452 | int lev = atoi(cp); |
453 | |
453 | |
454 | if (lev < 0) |
454 | if (lev < 0) |
455 | LOG(llevError, "load_settings: dynamiclevel must be " |
455 | LOG(llevError, "load_settings: dynamiclevel must be " |
456 | "at least 0, %d is invalid\n", lev); |
456 | "at least 0, %d is invalid\n", lev); |
457 | else |
457 | else |
458 | settings.dynamiclevel = lev; |
458 | settings.dynamiclevel = lev; |
459 | } else if (!strcasecmp(buf, "fastclock")) { |
459 | } else if (!strcasecmp(buf, "fastclock")) { |
460 | int lev = atoi(cp); |
460 | int lev = atoi(cp); |
461 | |
461 | |
462 | if (lev < 0) |
462 | if (lev < 0) |
463 | LOG(llevError, "load_settings: fastclock must be at least 0" |
463 | LOG(llevError, "load_settings: fastclock must be at least 0" |
464 | ", %d is invalid\n", lev); |
464 | ", %d is invalid\n", lev); |
465 | else |
465 | else |
466 | settings.fastclock = lev; |
466 | settings.fastclock = lev; |
467 | } else if (!strcasecmp(buf, "not_permadeth")) { |
467 | } else if (!strcasecmp(buf, "not_permadeth")) { |
468 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
468 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
469 | settings.not_permadeth=TRUE; |
469 | settings.not_permadeth=TRUE; |
470 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
470 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
471 | settings.not_permadeth=FALSE; |
471 | settings.not_permadeth=FALSE; |
472 | } else { |
472 | } else { |
473 | LOG(llevError, "load_settings: Unknown value for not_permadeth" |
473 | LOG(llevError, "load_settings: Unknown value for not_permadeth" |
474 | ": %s\n", cp); |
474 | ": %s\n", cp); |
475 | } |
475 | } |
476 | } else if (!strcasecmp(buf, "resurrection")) { |
476 | } else if (!strcasecmp(buf, "resurrection")) { |
477 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
477 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
478 | settings.resurrection=TRUE; |
478 | settings.resurrection=TRUE; |
479 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
479 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
480 | settings.resurrection=FALSE; |
480 | settings.resurrection=FALSE; |
481 | } else { |
481 | } else { |
482 | LOG(llevError, "load_settings: Unknown value for resurrection" |
482 | LOG(llevError, "load_settings: Unknown value for resurrection" |
483 | ": %s\n", cp); |
483 | ": %s\n", cp); |
484 | } |
484 | } |
485 | } else if (!strcasecmp(buf, "set_title")) { |
485 | } else if (!strcasecmp(buf, "set_title")) { |
486 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
486 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
487 | settings.set_title=TRUE; |
487 | settings.set_title=TRUE; |
488 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
488 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
489 | settings.set_title=FALSE; |
489 | settings.set_title=FALSE; |
490 | } else { |
490 | } else { |
491 | LOG(llevError, "load_settings: Unknown value for set_title" |
491 | LOG(llevError, "load_settings: Unknown value for set_title" |
492 | ": %s\n", cp); |
492 | ": %s\n", cp); |
493 | } |
493 | } |
494 | } else if (!strcasecmp(buf, "search_items")) { |
494 | } else if (!strcasecmp(buf, "search_items")) { |
495 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
495 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
496 | settings.search_items=TRUE; |
496 | settings.search_items=TRUE; |
497 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
497 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
498 | settings.search_items=FALSE; |
498 | settings.search_items=FALSE; |
499 | } else { |
499 | } else { |
500 | LOG(llevError, "load_settings: Unknown value for search_items" |
500 | LOG(llevError, "load_settings: Unknown value for search_items" |
501 | ": %s\n", cp); |
501 | ": %s\n", cp); |
502 | } |
502 | } |
503 | } else if (!strcasecmp(buf, "spell_encumbrance")) { |
503 | } else if (!strcasecmp(buf, "spell_encumbrance")) { |
504 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
504 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
505 | settings.spell_encumbrance=TRUE; |
505 | settings.spell_encumbrance=TRUE; |
506 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
506 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
507 | settings.spell_encumbrance=FALSE; |
507 | settings.spell_encumbrance=FALSE; |
508 | } else { |
508 | } else { |
509 | LOG(llevError, "load_settings: Unknown value for " |
509 | LOG(llevError, "load_settings: Unknown value for " |
510 | "spell_encumbrance: %s\n", cp); |
510 | "spell_encumbrance: %s\n", cp); |
511 | } |
511 | } |
512 | } else if (!strcasecmp(buf, "spell_failure_effects")) { |
512 | } else if (!strcasecmp(buf, "spell_failure_effects")) { |
513 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
513 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
514 | settings.spell_failure_effects=TRUE; |
514 | settings.spell_failure_effects=TRUE; |
515 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
515 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
516 | settings.spell_failure_effects=FALSE; |
516 | settings.spell_failure_effects=FALSE; |
517 | } else { |
517 | } else { |
518 | LOG(llevError, "load_settings: Unknown value for " |
518 | LOG(llevError, "load_settings: Unknown value for " |
519 | "spell_failure_effects: %s\n", cp); |
519 | "spell_failure_effects: %s\n", cp); |
520 | } |
520 | } |
521 | } else if (!strcasecmp(buf, "casting_time")) { |
521 | } else if (!strcasecmp(buf, "casting_time")) { |
522 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
522 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
523 | settings.casting_time=TRUE; |
523 | settings.casting_time=TRUE; |
524 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
524 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
525 | settings.casting_time=FALSE; |
525 | settings.casting_time=FALSE; |
526 | } else { |
526 | } else { |
527 | LOG(llevError, "load_settings: Unknown value for " |
527 | LOG(llevError, "load_settings: Unknown value for " |
528 | "casting_time: %s\n", cp); |
528 | "casting_time: %s\n", cp); |
529 | } |
529 | } |
530 | } else if (!strcasecmp(buf, "real_wiz")) { |
530 | } else if (!strcasecmp(buf, "real_wiz")) { |
531 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
531 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
532 | settings.real_wiz=TRUE; |
532 | settings.real_wiz=TRUE; |
533 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
533 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
534 | settings.real_wiz=FALSE; |
534 | settings.real_wiz=FALSE; |
535 | } else { |
535 | } else { |
536 | LOG(llevError, "load_settings: Unknown value for " |
536 | LOG(llevError, "load_settings: Unknown value for " |
537 | "real_wiz: %s\n", cp); |
537 | "real_wiz: %s\n", cp); |
538 | } |
538 | } |
539 | } else if (!strcasecmp(buf, "recycle_tmp_maps")) { |
539 | } else if (!strcasecmp(buf, "recycle_tmp_maps")) { |
540 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
540 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
541 | settings.recycle_tmp_maps=TRUE; |
541 | settings.recycle_tmp_maps=TRUE; |
542 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
542 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
543 | settings.recycle_tmp_maps=FALSE; |
543 | settings.recycle_tmp_maps=FALSE; |
544 | } else { |
544 | } else { |
545 | LOG(llevError, "load_settings: Unknown value for " |
545 | LOG(llevError, "load_settings: Unknown value for " |
546 | "recycle_tmp_maps: %s\n", cp); |
546 | "recycle_tmp_maps: %s\n", cp); |
547 | } |
547 | } |
548 | } else if (!strcasecmp(buf, "explore_mode")) { |
548 | } else if (!strcasecmp(buf, "explore_mode")) { |
549 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
549 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
550 | settings.explore_mode=TRUE; |
550 | settings.explore_mode=TRUE; |
551 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
551 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
552 | settings.explore_mode=FALSE; |
552 | settings.explore_mode=FALSE; |
553 | } else { |
553 | } else { |
554 | LOG(llevError, "load_settings: Unknown value for " |
554 | LOG(llevError, "load_settings: Unknown value for " |
555 | "explore_mode: %s\n", cp); |
555 | "explore_mode: %s\n", cp); |
556 | } |
556 | } |
557 | } else if (!strcasecmp(buf,"who_format")) { |
557 | } else if (!strcasecmp(buf,"who_format")) { |
558 | if (has_val) |
558 | if (has_val) |
559 | strcpy(settings.who_format, cp); |
559 | strcpy(settings.who_format, cp); |
560 | } else if (!strcasecmp(buf,"who_wiz_format")) { |
560 | } else if (!strcasecmp(buf,"who_wiz_format")) { |
561 | if (has_val) |
561 | if (has_val) |
562 | strcpy(settings.who_wiz_format, cp); |
562 | strcpy(settings.who_wiz_format, cp); |
563 | } else if (!strcasecmp(buf, "spellpoint_level_depend")) { |
563 | } else if (!strcasecmp(buf, "spellpoint_level_depend")) { |
564 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
564 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
565 | settings.spellpoint_level_depend=TRUE; |
565 | settings.spellpoint_level_depend=TRUE; |
566 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
566 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
567 | settings.spellpoint_level_depend=FALSE; |
567 | settings.spellpoint_level_depend=FALSE; |
568 | } else { |
568 | } else { |
569 | LOG(llevError, "load_settings: Unknown value for " |
569 | LOG(llevError, "load_settings: Unknown value for " |
570 | "spellpoint_level_depend: %s\n", cp); |
570 | "spellpoint_level_depend: %s\n", cp); |
571 | } |
571 | } |
572 | } else if (!strcasecmp(buf, "stat_loss_on_death")) { |
572 | } else if (!strcasecmp(buf, "stat_loss_on_death")) { |
573 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
573 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
574 | settings.stat_loss_on_death=TRUE; |
574 | settings.stat_loss_on_death=TRUE; |
575 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
575 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
576 | settings.stat_loss_on_death=FALSE; |
576 | settings.stat_loss_on_death=FALSE; |
577 | } else { |
577 | } else { |
578 | LOG(llevError, "load_settings: Unknown value for " |
578 | LOG(llevError, "load_settings: Unknown value for " |
579 | "stat_loss_on_death: %s\n", cp); |
579 | "stat_loss_on_death: %s\n", cp); |
580 | } |
580 | } |
581 | } else if (!strcasecmp(buf, "use_permanent_experience")) { |
581 | } else if (!strcasecmp(buf, "use_permanent_experience")) { |
582 | LOG(llevError, "use_permanent_experience is deprecated, use" |
582 | LOG(llevError, "use_permanent_experience is deprecated, use" |
583 | "permenent_experience_percentage instead\n"); |
583 | "permenent_experience_percentage instead\n"); |
584 | } else if (!strcasecmp(buf, "permanent_experience_percentage")) { |
584 | } else if (!strcasecmp(buf, "permanent_experience_percentage")) { |
585 | int val = atoi(cp); |
585 | int val = atoi(cp); |
586 | if (val < 0 || val >100) |
586 | if (val < 0 || val >100) |
587 | LOG(llevError, "load_settings: permenent_experience_percentage" |
587 | LOG(llevError, "load_settings: permenent_experience_percentage" |
588 | "must be between 0 and 100, %d is invalid\n", val); |
588 | "must be between 0 and 100, %d is invalid\n", val); |
589 | else |
589 | else |
590 | settings.permanent_exp_ratio = val; |
590 | settings.permanent_exp_ratio = val; |
591 | } else if (!strcasecmp(buf, "death_penalty_percentage")) { |
591 | } else if (!strcasecmp(buf, "death_penalty_percentage")) { |
592 | int val = atoi(cp); |
592 | int val = atoi(cp); |
593 | if (val < 0 || val >100) |
593 | if (val < 0 || val >100) |
594 | LOG(llevError, "load_settings: death_penalty_percentage" |
594 | LOG(llevError, "load_settings: death_penalty_percentage" |
595 | "must be between 0 and 100, %d is invalid\n", val); |
595 | "must be between 0 and 100, %d is invalid\n", val); |
596 | else |
596 | else |
597 | settings.death_penalty_ratio = val; |
597 | settings.death_penalty_ratio = val; |
598 | } else if (!strcasecmp(buf, "death_penalty_levels")) { |
598 | } else if (!strcasecmp(buf, "death_penalty_levels")) { |
599 | int val = atoi(cp); |
599 | int val = atoi(cp); |
600 | if (val < 0 || val > 255) |
600 | if (val < 0 || val > 255) |
601 | LOG(llevError, "load_settings: death_penalty_levels" |
601 | LOG(llevError, "load_settings: death_penalty_levels" |
602 | "can not be negative, %d is invalid\n", val); |
602 | "can not be negative, %d is invalid\n", val); |
603 | else |
603 | else |
604 | settings.death_penalty_level = val; |
604 | settings.death_penalty_level = val; |
605 | }else if (!strcasecmp(buf, "balanced_stat_loss")) { |
605 | }else if (!strcasecmp(buf, "balanced_stat_loss")) { |
606 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
606 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
607 | settings.balanced_stat_loss=TRUE; |
607 | settings.balanced_stat_loss=TRUE; |
608 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
608 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
609 | settings.balanced_stat_loss=FALSE; |
609 | settings.balanced_stat_loss=FALSE; |
610 | } else { |
610 | } else { |
611 | LOG(llevError, "load_settings: Unknown value for " |
611 | LOG(llevError, "load_settings: Unknown value for " |
612 | "balanced_stat_loss: %s\n", cp); |
612 | "balanced_stat_loss: %s\n", cp); |
613 | } |
613 | } |
614 | } else if (!strcasecmp(buf,"simple_exp")) { |
614 | } else if (!strcasecmp(buf,"simple_exp")) { |
615 | if (!strcasecmp(cp,"on") || !strcasecmp(cp,"true")) { |
615 | if (!strcasecmp(cp,"on") || !strcasecmp(cp,"true")) { |
616 | settings.simple_exp=TRUE; |
616 | settings.simple_exp=TRUE; |
617 | } else if (!strcasecmp(cp,"off") || !strcasecmp(cp,"false")) { |
617 | } else if (!strcasecmp(cp,"off") || !strcasecmp(cp,"false")) { |
618 | settings.simple_exp=FALSE; |
618 | settings.simple_exp=FALSE; |
619 | } else { |
619 | } else { |
620 | LOG(llevError,"load_settings: Unknown value for simple_exp: %s\n", |
620 | LOG(llevError,"load_settings: Unknown value for simple_exp: %s\n", |
621 | cp); |
621 | cp); |
622 | } |
622 | } |
623 | } else if (!strcasecmp(buf, "item_power_factor")) { |
623 | } else if (!strcasecmp(buf, "item_power_factor")) { |
624 | float tmp = atof(cp); |
624 | float tmp = atof(cp); |
625 | if (tmp < 0) |
625 | if (tmp < 0) |
626 | LOG(llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", |
626 | LOG(llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", |
627 | tmp); |
627 | tmp); |
628 | else |
628 | else |
629 | settings.item_power_factor = tmp; |
629 | settings.item_power_factor = tmp; |
630 | } else if (!strcasecmp(buf, "pk_luck_penalty")) { |
630 | } else if (!strcasecmp(buf, "pk_luck_penalty")) { |
631 | sint16 val = atoi(cp); |
631 | sint16 val = atoi(cp); |
632 | |
632 | |
633 | if (val < -100 || val >100) |
633 | if (val < -100 || val >100) |
634 | LOG(llevError, "load_settings: pk_luck_penalty must be between -100 and 100" |
634 | LOG(llevError, "load_settings: pk_luck_penalty must be between -100 and 100" |
635 | ", %d is invalid\n", val); |
635 | ", %d is invalid\n", val); |
636 | else |
636 | else |
637 | settings.pk_luck_penalty = val; |
637 | settings.pk_luck_penalty = val; |
638 | } else if (!strcasecmp(buf, "set_friendly_fire")) { |
638 | } else if (!strcasecmp(buf, "set_friendly_fire")) { |
639 | int val = atoi(cp); |
639 | int val = atoi(cp); |
640 | |
640 | |
641 | #if COZY_SERVER |
641 | #if COZY_SERVER |
642 | if (val < 0 || val >100) |
642 | if (val < 0 || val >100) |
643 | LOG(llevError, "load_settings: set_friendly_fire must be between 0 an 100" |
643 | LOG(llevError, "load_settings: set_friendly_fire must be between 0 an 100" |
644 | ", %d is invalid\n", val); |
644 | ", %d is invalid\n", val); |
645 | #else |
645 | #else |
646 | if (val < 1 || val >100) |
646 | if (val < 1 || val >100) |
647 | LOG(llevError, "load_settings: set_friendly_fire must be between 1 an 100" |
647 | LOG(llevError, "load_settings: set_friendly_fire must be between 1 an 100" |
648 | ", %d is invalid\n", val); |
648 | ", %d is invalid\n", val); |
649 | #endif |
649 | #endif |
650 | else |
650 | else |
651 | settings.set_friendly_fire = val; |
651 | settings.set_friendly_fire = val; |
652 | } else if ( !strcasecmp( buf, "armor_max_enchant" ) ) { |
652 | } else if ( !strcasecmp( buf, "armor_max_enchant" ) ) { |
653 | int max_e = atoi( cp ); |
653 | int max_e = atoi( cp ); |
654 | if ( max_e <= 0 ) |
654 | if ( max_e <= 0 ) |
655 | LOG( llevError, "load_settings: armor_max_enchant is %d\n", max_e ); |
655 | LOG( llevError, "load_settings: armor_max_enchant is %d\n", max_e ); |
656 | else |
656 | else |
… | |
… | |
660 | if ( wr < 0 ) |
660 | if ( wr < 0 ) |
661 | LOG( llevError, "load_settings: armor_weight_reduction is %d\n", wr ); |
661 | LOG( llevError, "load_settings: armor_weight_reduction is %d\n", wr ); |
662 | else |
662 | else |
663 | settings.armor_weight_reduction = wr; |
663 | settings.armor_weight_reduction = wr; |
664 | } else if ( !strcasecmp( buf, "armor_weight_linear" ) ) { |
664 | } else if ( !strcasecmp( buf, "armor_weight_linear" ) ) { |
665 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
665 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
666 | settings.armor_weight_linear=TRUE; |
666 | settings.armor_weight_linear=TRUE; |
667 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
667 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
668 | settings.armor_weight_linear=FALSE; |
668 | settings.armor_weight_linear=FALSE; |
669 | } else { |
669 | } else { |
670 | LOG(llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp); |
670 | LOG(llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp); |
671 | } |
671 | } |
672 | |
672 | |
673 | } else if ( !strcasecmp( buf, "armor_speed_improvement" ) ) { |
673 | } else if ( !strcasecmp( buf, "armor_speed_improvement" ) ) { |
674 | int wr = atoi( cp ); |
674 | int wr = atoi( cp ); |
675 | if ( wr < 0 ) |
675 | if ( wr < 0 ) |
676 | LOG( llevError, "load_settings: armor_speed_improvement is %d\n", wr ); |
676 | LOG( llevError, "load_settings: armor_speed_improvement is %d\n", wr ); |
677 | else |
677 | else |
678 | settings.armor_speed_improvement = wr; |
678 | settings.armor_speed_improvement = wr; |
679 | } else if ( !strcasecmp( buf, "armor_speed_linear" ) ) { |
679 | } else if ( !strcasecmp( buf, "armor_speed_linear" ) ) { |
680 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
680 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
681 | settings.armor_speed_linear = TRUE; |
681 | settings.armor_speed_linear = TRUE; |
682 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
682 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
683 | settings.armor_speed_linear = FALSE; |
683 | settings.armor_speed_linear = FALSE; |
684 | } else { |
684 | } else { |
685 | LOG(llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp); |
685 | LOG(llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp); |
686 | } |
686 | } |
687 | |
687 | |
688 | } else if ( !strcasecmp( buf, "no_player_stealing" ) ) { |
688 | } else if ( !strcasecmp( buf, "no_player_stealing" ) ) { |
689 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
689 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
690 | settings.no_player_stealing = TRUE; |
690 | settings.no_player_stealing = TRUE; |
691 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
691 | } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) { |
692 | settings.no_player_stealing = FALSE; |
692 | settings.no_player_stealing = FALSE; |
693 | } else { |
693 | } else { |
694 | LOG(llevError, "load_settings: unknown value for no_player_stealing: %s\n", cp); |
694 | LOG(llevError, "load_settings: unknown value for no_player_stealing: %s\n", cp); |
695 | } |
695 | } |
696 | |
696 | |
697 | } else if ( !strcasecmp( buf, "create_home_portals" ) ) { |
697 | } else if ( !strcasecmp( buf, "create_home_portals" ) ) { |
698 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
698 | if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) { |
699 | settings.create_home_portals = TRUE; |
699 | settings.create_home_portals = TRUE; |
… | |
… | |
702 | } else { |
702 | } else { |
703 | LOG(llevError, "load_settings: Unknown value for create_home_portals: %s\n", cp); |
703 | LOG(llevError, "load_settings: Unknown value for create_home_portals: %s\n", cp); |
704 | } |
704 | } |
705 | |
705 | |
706 | } else { |
706 | } else { |
707 | LOG(llevError,"Unknown value in settings file: %s\n", buf); |
707 | LOG(llevError,"Unknown value in settings file: %s\n", buf); |
708 | } |
708 | } |
709 | } |
709 | } |
710 | close_and_delete(fp, comp); |
710 | close_and_delete(fp, comp); |
711 | } |
711 | } |
712 | |
712 | |
713 | |
713 | |
… | |
… | |
718 | void init(int argc, char **argv) { |
718 | void init(int argc, char **argv) { |
719 | |
719 | |
720 | init_done=0; /* Must be done before init_signal() */ |
720 | init_done=0; /* Must be done before init_signal() */ |
721 | logfile=stderr; |
721 | logfile=stderr; |
722 | parse_args(argc, argv, 1); /* First arg pass - right now it does |
722 | parse_args(argc, argv, 1); /* First arg pass - right now it does |
723 | * nothing, but in future specifying the |
723 | * nothing, but in future specifying the |
724 | * LibDir in this pass would be reasonable*/ |
724 | * LibDir in this pass would be reasonable*/ |
725 | |
725 | |
726 | init_library(); /* Must be called early */ |
726 | init_library(); /* Must be called early */ |
727 | load_settings(); /* Load the settings file */ |
727 | load_settings(); /* Load the settings file */ |
728 | init_weather(); |
728 | init_weather(); |
729 | load_materials(); |
729 | load_materials(); |
… | |
… | |
731 | fprintf(logfile,"Welcome to CrossFire, v%s\n",VERSION); |
731 | fprintf(logfile,"Welcome to CrossFire, v%s\n",VERSION); |
732 | fprintf(logfile,"Copyright (C) 1994 Mark Wedel.\n"); |
732 | fprintf(logfile,"Copyright (C) 1994 Mark Wedel.\n"); |
733 | fprintf(logfile,"Copyright (C) 1992 Frank Tore Johansen.\n"); |
733 | fprintf(logfile,"Copyright (C) 1992 Frank Tore Johansen.\n"); |
734 | |
734 | |
735 | if (strcmp(settings.dm_mail, "") != 0) { |
735 | if (strcmp(settings.dm_mail, "") != 0) { |
736 | fprintf(logfile,"Maintained locally by: %s\n", settings.dm_mail); |
736 | fprintf(logfile,"Maintained locally by: %s\n", settings.dm_mail); |
737 | fprintf(logfile,"Questions and bugs should be mailed to above address.\n"); |
737 | fprintf(logfile,"Questions and bugs should be mailed to above address.\n"); |
738 | } |
738 | } |
739 | SRANDOM(time(NULL)); |
739 | SRANDOM(time(NULL)); |
740 | |
740 | |
741 | init_startup(); /* Write (C), check shutdown/forbid files */ |
741 | init_startup(); /* Write (C), check shutdown/forbid files */ |
742 | init_signals(); /* Sets up signal interceptions */ |
742 | init_signals(); /* Sets up signal interceptions */ |
… | |
… | |
746 | |
746 | |
747 | parse_args(argc, argv, 3); |
747 | parse_args(argc, argv, 3); |
748 | |
748 | |
749 | #ifndef WIN32 /* ***win32: no BecomeDaemon in windows */ |
749 | #ifndef WIN32 /* ***win32: no BecomeDaemon in windows */ |
750 | if (settings.daemonmode) |
750 | if (settings.daemonmode) |
751 | logfile = BecomeDaemon(settings.logfilename[0]=='\0'?"logfile":settings.logfilename); |
751 | logfile = BecomeDaemon(settings.logfilename[0]=='\0'?"logfile":settings.logfilename); |
752 | #endif |
752 | #endif |
753 | |
753 | |
754 | init_beforeplay(); |
754 | init_beforeplay(); |
755 | init_ericserver(); |
755 | init_ericserver(); |
756 | metaserver_init(); |
756 | metaserver_init(); |
757 | init_done=1; |
757 | init_done=1; |
758 | } |
758 | } |
759 | |
759 | |
760 | void usage(void) { |
760 | void usage(void) { |
761 | (void) fprintf(logfile, |
761 | (void) fprintf(logfile, |
762 | "Usage: crossfire [-h] [-<flags>]...\n"); |
762 | "Usage: crossfire [-h] [-<flags>]...\n"); |
763 | } |
763 | } |
764 | |
764 | |
765 | void help(void) { |
765 | void help(void) { |
766 | /* The information in usage is redundant with what is given below, so why call it? */ |
766 | /* The information in usage is redundant with what is given below, so why call it? */ |
767 | /* usage();*/ |
767 | /* usage();*/ |
… | |
… | |
833 | dump_races(); |
833 | dump_races(); |
834 | exit(0); |
834 | exit(0); |
835 | case 7: |
835 | case 7: |
836 | dump_alchemy(); |
836 | dump_alchemy(); |
837 | exit(0); |
837 | exit(0); |
838 | case 8: |
|
|
839 | dump_gods(); |
|
|
840 | exit(0); |
|
|
841 | case 9: |
838 | case 9: |
842 | dump_alchemy_costs(); |
839 | dump_alchemy_costs(); |
843 | exit(0); |
840 | exit(0); |
844 | case 10: |
841 | case 10: |
845 | dump_monster_treasure(settings.dumparg); |
842 | dump_monster_treasure(settings.dumparg); |
… | |
… | |
929 | #ifdef WIN32 /* ***win32 compile_info(): remove execl... */ |
926 | #ifdef WIN32 /* ***win32 compile_info(): remove execl... */ |
930 | printf("Logfilename:\t%s\n",settings.logfilename); |
927 | printf("Logfilename:\t%s\n",settings.logfilename); |
931 | exit(0); |
928 | exit(0); |
932 | #else |
929 | #else |
933 | execl("/bin/uname", "uname", "-a", NULL); |
930 | execl("/bin/uname", "uname", "-a", NULL); |
934 | LOG(llevError, "Oops, shouldn't have gotten here: execl(/bin/uname) failed: %s\n", strerror_local(errno)); |
931 | LOG(llevError, "Oops, shouldn't have gotten here: execl(/bin/uname) failed: %s\n", strerror(errno)); |
935 | exit(-1); |
932 | exit(-1); |
936 | #endif |
933 | #endif |
937 | } |
934 | } |
938 | |
935 | |
939 | /* Signal handlers: */ |
936 | /* Signal handlers: */ |
… | |
… | |
1002 | * overwrites old 'race' entries. This routine allow us to quickly |
999 | * overwrites old 'race' entries. This routine allow us to quickly |
1003 | * re-configure the 'alignment' of monsters, objects. Useful for |
1000 | * re-configure the 'alignment' of monsters, objects. Useful for |
1004 | * putting together lists of creatures, etc that belong to gods. |
1001 | * putting together lists of creatures, etc that belong to gods. |
1005 | */ |
1002 | */ |
1006 | |
1003 | |
1007 | void init_races (void) { |
1004 | void init_races (void) |
|
|
1005 | { |
1008 | FILE *file; |
1006 | FILE *file; |
1009 | char race[MAX_BUF], fname[MAX_BUF], buf[MAX_BUF], *cp, variable[MAX_BUF]; |
1007 | char race[MAX_BUF], fname[MAX_BUF], buf[MAX_BUF], *cp, variable[MAX_BUF]; |
1010 | archetype *mon=NULL; |
1008 | archetype *mon = NULL; |
1011 | static int init_done=0; |
1009 | static int init_done = 0; |
1012 | |
1010 | |
1013 | if (init_done) return; |
1011 | if (init_done) |
1014 | init_done=1; |
|
|
1015 | first_race=NULL; |
|
|
1016 | |
|
|
1017 | sprintf(fname,"%s/races",settings.datadir); |
|
|
1018 | LOG(llevDebug, "Reading races from %s...",fname); |
|
|
1019 | if(! (file=fopen(fname,"r"))) { |
|
|
1020 | LOG(llevError, "Cannot open races file %s: %s\n", fname, strerror_local(errno)); |
|
|
1021 | return; |
1012 | return; |
1022 | } |
1013 | init_done = 1; |
|
|
1014 | first_race = NULL; |
1023 | |
1015 | |
1024 | while(fgets(buf,MAX_BUF,file)!=NULL) { |
1016 | sprintf (fname, "%s/races", settings.datadir); |
1025 | int set_race=1,set_list=1; |
1017 | LOG (llevDebug, "Reading races from %s...", fname); |
1026 | if(*buf=='#') continue; |
1018 | if (!(file = fopen (fname, "r"))) |
1027 | if((cp=strchr(buf,'\n'))!=NULL) |
1019 | { |
1028 | *cp='\0'; |
1020 | LOG (llevError, "Cannot open races file %s: %s\n", fname, |
1029 | cp=buf; |
1021 | strerror (errno)); |
1030 | while(*cp==' '||*cp=='!'||*cp=='@') { |
1022 | return; |
1031 | if(*cp=='!') set_race=0; |
|
|
1032 | if(*cp=='@') set_list=0; |
|
|
1033 | cp++; |
|
|
1034 | } |
1023 | } |
1035 | if(sscanf(cp,"RACE %s",variable)) { /* set new race value */ |
1024 | |
|
|
1025 | while (fgets (buf, MAX_BUF, file) != NULL) |
|
|
1026 | { |
|
|
1027 | int set_race = 1, set_list = 1; |
|
|
1028 | if (*buf == '#') |
|
|
1029 | continue; |
|
|
1030 | if ((cp = strchr (buf, '\n')) != NULL) |
|
|
1031 | *cp = '\0'; |
|
|
1032 | cp = buf; |
|
|
1033 | while (*cp == ' ' || *cp == '!' || *cp == '@') |
|
|
1034 | { |
|
|
1035 | if (*cp == '!') |
|
|
1036 | set_race = 0; |
|
|
1037 | if (*cp == '@') |
|
|
1038 | set_list = 0; |
|
|
1039 | cp++; |
|
|
1040 | } |
|
|
1041 | if (sscanf (cp, "RACE %s", variable)) |
|
|
1042 | { /* set new race value */ |
1036 | strcpy(race,variable); |
1043 | strcpy (race, variable); |
|
|
1044 | } |
1037 | } else { |
1045 | else |
1038 | char *cp1; |
1046 | { |
|
|
1047 | char *cp1; |
1039 | /* Take out beginning spaces */ |
1048 | /* Take out beginning spaces */ |
1040 | for (cp1 = cp; *cp1==' '; cp1++); |
1049 | for (cp1 = cp; *cp1 == ' '; cp1++) |
|
|
1050 | ; |
1041 | /* Remove newline and trailing spaces */ |
1051 | /* Remove newline and trailing spaces */ |
1042 | for (cp1 = cp + strlen(cp) -1; *cp1 == '\n' || *cp1 == ' '; cp1 --) { |
1052 | for (cp1 = cp + strlen (cp) - 1; *cp1 == '\n' || *cp1 == ' '; cp1--) |
1043 | *cp1='\0'; |
1053 | { |
1044 | if (cp==cp1) break; |
1054 | *cp1 = '\0'; |
1045 | } |
1055 | if (cp == cp1) |
1046 | |
1056 | break; |
1047 | if (cp[strlen(cp)-1]=='\n') cp[strlen(cp)-1]='\0'; |
1057 | } |
|
|
1058 | |
|
|
1059 | if (cp[strlen (cp) - 1] == '\n') |
|
|
1060 | cp[strlen (cp) - 1] = '\0'; |
1048 | /* set creature race to race value */ |
1061 | /* set creature race to race value */ |
1049 | if((mon=find_archetype(cp))==NULL) |
1062 | if ((mon = find_archetype (cp)) == NULL) |
1050 | LOG(llevError,"\nCreature %s in race file lacks archetype",cp); |
1063 | LOG (llevError, "\nCreature %s in race file lacks archetype", cp); |
1051 | else { |
1064 | else |
|
|
1065 | { |
|
|
1066 | if (set_race |
1052 | if(set_race&&(!mon->clone.race||strcmp(mon->clone.race,race))) { |
1067 | && (!mon->clone.race || strcmp (mon->clone.race, race))) |
|
|
1068 | { |
1053 | if(mon->clone.race) { |
1069 | if (mon->clone.race) |
|
|
1070 | { |
|
|
1071 | LOG (llevDebug, |
1054 | LOG(llevDebug,"\n Resetting race to %s from %s for archetype %s", |
1072 | "\n Resetting race to %s from %s for archetype %s", |
1055 | race,mon->clone.race,mon->name); |
1073 | race, &mon->clone.race, &mon->name); |
|
|
1074 | } |
1056 | free_string(mon->clone.race); |
1075 | mon->clone.race = race; |
1057 | } |
1076 | } |
1058 | mon->clone.race=add_string(race); |
|
|
1059 | } |
|
|
1060 | /* if the arch is a monster, add it to the race list */ |
1077 | /* if the arch is a monster, add it to the race list */ |
1061 | if(set_list&&QUERY_FLAG(&mon->clone,FLAG_MONSTER)) |
1078 | if (set_list && QUERY_FLAG (&mon->clone, FLAG_MONSTER)) |
1062 | add_to_racelist(race, &mon->clone); |
1079 | add_to_racelist (race, &mon->clone); |
|
|
1080 | } |
1063 | } |
1081 | } |
1064 | } |
1082 | } |
1065 | } |
|
|
1066 | fclose(file); |
1083 | fclose (file); |
1067 | LOG(llevDebug,"done.\n"); |
1084 | LOG (llevDebug, "done.\n"); |
1068 | } |
1085 | } |
1069 | |
1086 | |
1070 | void dump_races(void) |
1087 | void dump_races(void) |
1071 | { |
1088 | { |
1072 | racelink *list; |
1089 | racelink *list; |
1073 | objectlink *tmp; |
1090 | objectlink *tmp; |
1074 | for(list=first_race;list;list=list->next) { |
1091 | for(list=first_race;list;list=list->next) { |
1075 | fprintf(stderr,"\nRACE %s:\t",list->name); |
1092 | fprintf(stderr,"\nRACE %s:\t",list->name); |
1076 | for(tmp=list->member;tmp;tmp=tmp->next) |
1093 | for(tmp=list->member;tmp;tmp=tmp->next) |
1077 | fprintf(stderr,"%s(%d), ",tmp->ob->arch->name,tmp->ob->level); |
1094 | fprintf(stderr,"%s(%d), ",&tmp->ob->arch->name,tmp->ob->level); |
1078 | } |
1095 | } |
1079 | fprintf(stderr,"\n"); |
1096 | fprintf(stderr,"\n"); |
1080 | } |
1097 | } |
1081 | |
1098 | |
1082 | void add_to_racelist (const char *race_name, object *op) { |
1099 | void add_to_racelist (const char *race_name, object *op) { |
… | |
… | |
1087 | |
1104 | |
1088 | if(!race) { /* add in a new race list */ |
1105 | if(!race) { /* add in a new race list */ |
1089 | race = get_racelist(); |
1106 | race = get_racelist(); |
1090 | race->next = first_race; |
1107 | race->next = first_race; |
1091 | first_race = race; |
1108 | first_race = race; |
1092 | race->name=add_string(race_name); |
1109 | race->name = race_name; |
1093 | } |
1110 | } |
1094 | |
1111 | |
1095 | if(race->member->ob) { |
1112 | if(race->member->ob) { |
1096 | objectlink *tmp = get_objectlink(); |
1113 | objectlink *tmp = get_objectlink(); |
1097 | tmp->next=race->member; |
1114 | tmp->next=race->member; |