ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/init.C
(Generate patch)

Comparing deliantra/server/server/init.C (file contents):
Revision 1.22 by root, Tue Dec 26 08:55:00 2006 UTC vs.
Revision 1.47 by root, Fri Apr 27 19:53:05 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#include <material.h> 26#include <material.h>
26#include <loader.h> 27#include <loader.h>
27#include <sproto.h> 28#include <sproto.h>
28
29/* global weathermap */
30weathermap_t **weathermap;
31 29
32void 30void
33set_logfile (char *val) 31set_logfile (char *val)
34{ 32{
35 settings.logfilename = val; 33 settings.logfilename = val;
239 * pass system very easy, and it is very easy to add in new options. 237 * pass system very easy, and it is very easy to add in new options.
240 */ 238 */
241struct Command_Line_Options options[] = { 239struct Command_Line_Options options[] = {
242 240
243/* Pass 1 functions - STuff that can/should be called before we actually 241/* Pass 1 functions - STuff that can/should be called before we actually
244 * initialize any data. 242 * initialise any data.
245 */ 243 */
246 {"-h", 0, 1, help}, 244 {"-h", 0, 1, help},
247 245
248/* Honor -help also, since it is somewhat common */ 246/* Honor -help also, since it is somewhat common */
249 {"-help", 0, 1, help}, 247 {"-help", 0, 1, help},
376} 374}
377 375
378static void 376static void
379load_materials (void) 377load_materials (void)
380{ 378{
381 char buf[MAX_BUF], filename[MAX_BUF], *cp, *next; 379 char filename[MAX_BUF];
382 FILE *fp;
383 materialtype_t *mt; 380 materialtype_t *mt;
384 int i, value;
385 381
386 sprintf (filename, "%s/materials", settings.datadir); 382 sprintf (filename, "%s/materials", settings.datadir);
387 LOG (llevDebug, "Reading material type data from %s...", filename); 383 LOG (llevDebug, "Reading material type data from %s...\n", filename);
388 if ((fp = fopen (filename, "r")) == NULL) 384
385 object_thawer thawer (filename);
386
387 if (!thawer)
389 { 388 {
390 LOG (llevError, "Cannot open %s for reading\n", filename); 389 LOG (llevError, "Cannot open %s for reading\n", filename);
391 mt = get_empty_mat (); 390 mt = get_empty_mat ();
392 mt->next = NULL; 391 mt->next = 0;
393 materialt = mt; 392 materialt = mt;
394 return; 393 return;
395 } 394 }
395
396 mt = get_empty_mat (); 396 mt = get_empty_mat ();
397 materialt = mt; 397 materialt = mt;
398 while (fgets (buf, MAX_BUF, fp) != NULL) 398
399 for (;;)
399 { 400 {
400 if (*buf == '#') 401 switch (thawer.get_kv ())
401 continue;
402 if ((cp = strchr (buf, '\n')) != NULL)
403 *cp = '\0';
404 cp = buf;
405 while (*cp == ' ') /* Skip blanks */
406 cp++;
407 if (!strncmp (cp, "name", 4))
408 { 402 {
403 case KW_name:
409 /* clean up the previous entry */ 404 /* clean up the previous entry */
410 if (mt->next != NULL) 405 if (mt->next)
411 { 406 {
412 if (mt->description == NULL) 407 if (!mt->description)
413 mt->description = mt->name; 408 mt->description = mt->name;
409
414 mt = mt->next; 410 mt = mt->next;
415 } 411 }
412
416 mt->next = get_empty_mat (); 413 mt->next = get_empty_mat ();
417 mt->name = strchr (cp, ' ') + 1; 414 thawer.get (mt->name);
418 } 415 break;
419 else if (!strncmp (cp, "description", 11)) 416
417 case KW_description:
418 thawer.get (mt->description);
419 break;
420
421 case KW_material:
422 thawer.get (mt->material);
423 break;
424
425 case KW_saves:
420 { 426 {
421 mt->description = strchr (cp, ' ') + 1; 427 const char *cp = thawer.get_str () - 1;
422 } 428
423 else if (sscanf (cp, "material %d", &value))
424 {
425 mt->material = value;
426 }
427 else if (!strncmp (cp, "saves", 5))
428 {
429 cp = strchr (cp, ' ') + 1;
430 for (i = 0; i < NROFATTACKS; i++) 429 for (int i = 0; i < NROFATTACKS; i++)
431 {
432 if (cp == NULL)
433 { 430 {
431 if (!cp)
432 {
434 mt->save[i] = 0; 433 mt->save[i] = 0;
435 continue; 434 continue;
435 }
436
437 int value;
438 ++cp;
439 sscanf (cp, "%d", &value);
440 mt->save[i] = (sint8) value;
441 cp = strchr (cp, ',');
436 } 442 }
437 if ((next = strchr (cp, ',')) != NULL)
438 *(next++) = '\0';
439 sscanf (cp, "%d", &value);
440 mt->save[i] = (sint8) value;
441 cp = next;
442 }
443 }
444 else if (!strncmp (cp, "mods", 4))
445 {
446 cp = strchr (cp, ' ') + 1;
447 for (i = 0; i < NROFATTACKS; i++)
448 { 443 }
449 if (cp == NULL) 444 break;
445
446 case KW_mods:
447 {
448 const char *cp = thawer.get_str () - 1;
449
450 for (int i = 0; i < NROFATTACKS; i++)
450 { 451 {
452 if (!cp)
453 {
451 mt->save[i] = 0; 454 mt->save[i] = 0;
452 continue; 455 continue;
456 }
457
458 ++cp;
459 int value;
460 sscanf (cp, "%d", &value);
461 mt->mod[i] = (sint8) value;
462 cp = strchr (cp, ',');
453 } 463 }
454 if ((next = strchr (cp, ',')) != NULL)
455 *(next++) = '\0';
456 sscanf (cp, "%d", &value);
457 mt->mod[i] = (sint8) value;
458 cp = next;
459 }
460 } 464 }
461 else if (sscanf (cp, "chance %d\n", &value)) 465 break;
466
467 case KW_chance: thawer.get (mt->chance); break;
468 case KW_difficulty: // cf+ alias, not original cf
469 case KW_diff: thawer.get (mt->difficulty); break;
470 case KW_magic: thawer.get (mt->magic); break;
471 case KW_dam: // cf+ alias, not original cf
472 case KW_damage: thawer.get (mt->damage); break;
473 case KW_wc: thawer.get (mt->wc); break;
474 case KW_ac: thawer.get (mt->ac); break;
475 case KW_sp: thawer.get (mt->sp); break;
476 case KW_weight: thawer.get (mt->weight); break;
477 case KW_value: thawer.get (mt->value); break;
478 case KW_density: thawer.get (mt->density); break;
479
480 case KW_EOF:
481 goto done;
482
483 default:
484 if (!thawer.parse_error ("materials file", "materials"))
485 goto done;
486 break;
462 { 487 }
463 mt->chance = (sint8) value;
464 }
465 else if (sscanf (cp, "diff %d\n", &value))
466 {
467 mt->difficulty = (sint8) value;
468 }
469 else if (sscanf (cp, "magic %d\n", &value))
470 {
471 mt->magic = (sint8) value;
472 }
473 else if (sscanf (cp, "damage %d\n", &value))
474 {
475 mt->damage = (sint8) value;
476 }
477 else if (sscanf (cp, "wc %d\n", &value))
478 {
479 mt->wc = (sint8) value;
480 }
481 else if (sscanf (cp, "ac %d\n", &value))
482 {
483 mt->ac = (sint8) value;
484 }
485 else if (sscanf (cp, "sp %d\n", &value))
486 {
487 mt->sp = (sint8) value;
488 }
489 else if (sscanf (cp, "weight %d\n", &value))
490 {
491 mt->weight = value;
492 }
493 else if (sscanf (cp, "value %d\n", &value))
494 {
495 mt->value = value;
496 }
497 } 488 }
489
490done:
498 if (mt->next) 491 if (mt->next)
499 { 492 {
500 delete mt->next; 493 delete mt->next;
501 494
502 mt->next = NULL; 495 mt->next = 0;
503 } 496 }
497
504 LOG (llevDebug, "Done.\n"); 498 LOG (llevDebug, "Done.\n");
505 fclose (fp);
506} 499}
507 500
508/* This loads the settings file. There could be debate whether this should 501/* This loads the settings file. There could be debate whether this should
509 * be here or in the common directory - but since only the server needs this 502 * be here or in the common directory - but since only the server needs this
510 * information, having it here probably makes more sense. 503 * information, having it here probably makes more sense.
520 513
521 /* We don't require a settings file at current time, but down the road, 514 /* We don't require a settings file at current time, but down the road,
522 * there will probably be so many values that not having a settings file 515 * there will probably be so many values that not having a settings file
523 * will not be a good thing. 516 * will not be a good thing.
524 */ 517 */
525 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 518 if (!(fp = open_and_uncompress (buf, 0, &comp)))
526 { 519 {
527 LOG (llevError, "Warning: No settings file found\n"); 520 LOG (llevError, "Error: No settings file found\n");
528 return; 521 exit (1);
529 } 522 }
523
530 while (fgets (buf, MAX_BUF - 1, fp) != NULL) 524 while (fgets (buf, MAX_BUF - 1, fp) != NULL)
531 { 525 {
532 if (buf[0] == '#') 526 if (buf[0] == '#')
533 continue; 527 continue;
534 /* eliminate newline */ 528 /* eliminate newline */
548 *cp++ = 0; 542 *cp++ = 0;
549 has_val = 1; 543 has_val = 1;
550 } 544 }
551 else 545 else
552 { 546 {
553 cp = ""; 547 cp = (char *)"";
554 has_val = 0; 548 has_val = 0;
555 } 549 }
556 550
557 if (!strcasecmp (buf, "motd")) 551 if (!strcasecmp (buf, "motd"))
558 { 552 {
756 settings.real_wiz = FALSE; 750 settings.real_wiz = FALSE;
757 } 751 }
758 else 752 else
759 { 753 {
760 LOG (llevError, "load_settings: Unknown value for " "real_wiz: %s\n", cp); 754 LOG (llevError, "load_settings: Unknown value for " "real_wiz: %s\n", cp);
761 }
762 }
763 else if (!strcasecmp (buf, "explore_mode"))
764 {
765 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true"))
766 {
767 settings.explore_mode = TRUE;
768 }
769 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false"))
770 {
771 settings.explore_mode = FALSE;
772 }
773 else
774 {
775 LOG (llevError, "load_settings: Unknown value for " "explore_mode: %s\n", cp);
776 } 755 }
777 } 756 }
778 else if (!strcasecmp (buf, "spellpoint_level_depend")) 757 else if (!strcasecmp (buf, "spellpoint_level_depend"))
779 { 758 {
780 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 759 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true"))
996 } 975 }
997 976
998 close_and_delete (fp, comp); 977 close_and_delete (fp, comp);
999} 978}
1000 979
1001
1002/* 980/*
1003 * init() is called only once, when starting the program. 981 * init() is called only once, when starting the program.
1004 */ 982 */
1005
1006void 983void
1007init (int argc, char **argv) 984init (int argc, char **argv)
1008{ 985{
1009 init_done = 0; /* Must be done before init_signal() */ 986 init_done = 0; /* Must be done before init_signal() */
987 rndm.seed (time (0));
988
1010 logfile = stderr; 989 logfile = stderr;
990 init_environ ();
1011 parse_args (argc, argv, 1); /* First arg pass - right now it does 991 parse_args (argc, argv, 1); /* First arg pass - right now it does
1012 * nothing, but in future specifying the 992 * nothing, but in future specifying the
1013 * LibDir in this pass would be reasonable*/ 993 * LibDir in this pass would be reasonable*/
1014 994
995 init_anim (); // Must be called before perl
1015 cfperl_init (); 996 cfperl_init ();
1016 init_library (); /* Must be called early */ 997 init_library (); /* Must be called early */
1017 load_settings (); /* Load the settings file */ 998 load_settings (); /* Load the settings file */
1018 init_weather ();
1019 load_materials (); 999 load_materials ();
1020 parse_args (argc, argv, 2); 1000 parse_args (argc, argv, 2);
1021 fprintf (logfile, "Welcome to CrossFire, v%s\n", VERSION); 1001 fprintf (logfile, "Welcome to CrossFire, v%s\n", VERSION);
1002 fprintf (logfile, "Copyright (C) 2005, 2006, 2007 Marc Lehmann.\n");
1022 fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n"); 1003 fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n");
1023 fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n"); 1004 fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n");
1024 1005
1025 if (strcmp (settings.dm_mail, "") != 0) 1006 if (strcmp (settings.dm_mail, "") != 0)
1026 { 1007 {
1027 fprintf (logfile, "Maintained locally by: %s\n", settings.dm_mail); 1008 fprintf (logfile, "Maintained locally by: %s\n", settings.dm_mail);
1028 fprintf (logfile, "Questions and bugs should be mailed to above address.\n"); 1009 fprintf (logfile, "Questions and bugs should be mailed to above address.\n");
1029 } 1010 }
1030 1011
1031 SRANDOM (time (NULL));
1032
1033 init_startup (); /* Write (C), check shutdown/forbid files */ 1012 init_startup (); /* Write (C), check shutdown/forbid files */
1034 init_uuid (); 1013 init_uuid ();
1035 init_signals (); /* Sets up signal interceptions */ 1014 init_signals (); /* Sets up signal interceptions */
1036 init_commands (); /* Sort command tables */ 1015 init_commands (); /* Sort command tables */
1037 read_map_log (); /* Load up the old temp map files */
1038 init_skills (); 1016 init_skills ();
1039 1017
1040 parse_args (argc, argv, 3); 1018 parse_args (argc, argv, 3);
1041
1042 if (settings.daemonmode)
1043 logfile = BecomeDaemon (settings.logfilename[0] == '\0' ? "logfile" : settings.logfilename);
1044 1019
1045 init_beforeplay (); 1020 init_beforeplay ();
1046 init_ericserver (); 1021 init_ericserver ();
1047 init_done = 1; 1022 init_done = 1;
1048} 1023}
1099} 1074}
1100 1075
1101void 1076void
1102init_beforeplay (void) 1077init_beforeplay (void)
1103{ 1078{
1104 init_archetypes (); /* If not called before, reads all archetypes from file */
1105 init_artifacts (); /* If not called before, reads all artifacts from file */ 1079 init_artifacts (); /* If not called before, reads all artifacts from file */
1106 init_spells (); /* If not called before, links archtypes used by spells */ 1080 init_spells (); /* If not called before, links archtypes used by spells */
1107 init_regions (); /* If not called before, reads all regions from file */
1108 init_archetype_pointers (); /* Setup global pointers to archetypes */ 1081 init_archetype_pointers (); /* Setup global pointers to archetypes */
1109 init_races (); /* overwrite race designations using entries in lib/races file */ 1082 init_races (); /* overwrite race designations using entries in lib/races file */
1110 init_gods (); /* init linked list of gods from archs */ 1083 init_gods (); /* init linked list of gods from archs */
1111 init_readable (); /* inits useful arrays for readable texts */ 1084 init_readable (); /* inits useful arrays for readable texts */
1112 init_formulae (); /* If not called before, reads formulae from file */ 1085 init_formulae (); /* If not called before, reads formulae from file */
1212 printf ("Save player:\t<true>\n"); 1185 printf ("Save player:\t<true>\n");
1213 printf ("Save mode:\t%4.4o\n", SAVE_MODE); 1186 printf ("Save mode:\t%4.4o\n", SAVE_MODE);
1214 printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir); 1187 printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir);
1215 printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir); 1188 printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir);
1216 printf ("Tmpdir:\t\t%s\n", settings.tmpdir); 1189 printf ("Tmpdir:\t\t%s\n", settings.tmpdir);
1217 printf ("Map max timeout:\t%d\n", MAP_MAXTIMEOUT);
1218 printf ("Max objects:\t%d\n", MAX_OBJECTS);
1219#ifdef USE_CALLOC 1190#ifdef USE_CALLOC
1220 printf ("Use_calloc:\t<true>\n"); 1191 printf ("Use_calloc:\t<true>\n");
1221#else 1192#else
1222 printf ("Use_calloc:\t<false>\n"); 1193 printf ("Use_calloc:\t<false>\n");
1223#endif 1194#endif
1234} 1205}
1235 1206
1236/* Signal handlers: */ 1207/* Signal handlers: */
1237 1208
1238void 1209void
1210rec_sigabrt (int i)
1211{
1212 signal (SIGABRT, SIG_DFL);
1213
1214 LOG (llevError, "SIGABRT received.\n");
1215 cleanup ("SIGABRT received", 1);
1216}
1217
1218void
1239rec_sigsegv (int i) 1219rec_sigsegv (int i)
1240{ 1220{
1221 signal (SIGSEGV, SIG_DFL);
1222
1241 LOG (llevError, "SIGSEGV received.\n"); 1223 LOG (llevError, "SIGSEGV received.\n");
1242 fatal_signal (1, 1); 1224 cleanup ("SIGSEGV received", 1);
1243}
1244
1245void
1246rec_sigint (int i)
1247{
1248 LOG (llevInfo, "SIGINT received.\n");
1249 fatal_signal (0, 1);
1250}
1251
1252void
1253rec_sighup (int i)
1254{
1255 LOG (llevInfo, "SIGHUP received\n");
1256
1257 if (init_done)
1258 cleanup ();
1259
1260 exit (0);
1261} 1225}
1262 1226
1263void 1227void
1264rec_sigquit (int i) 1228rec_sigquit (int i)
1265{ 1229{
1230 signal (SIGQUIT, SIG_IGN);
1231
1266 LOG (llevInfo, "SIGQUIT received\n"); 1232 LOG (llevInfo, "SIGQUIT received\n");
1267 fatal_signal (1, 1); 1233 cleanup ("SIGQUIT received", 1);
1268} 1234}
1269 1235
1270void 1236void
1271rec_sigbus (int i) 1237rec_sigbus (int i)
1272{ 1238{
1273#ifdef SIGBUS 1239 signal (SIGBUS, SIG_DFL);
1240
1274 LOG (llevError, "SIGBUS received\n"); 1241 LOG (llevError, "SIGBUS received\n");
1275 fatal_signal (1, 1); 1242 cleanup ("SIGBUS received", 1);
1276#endif
1277}
1278
1279void
1280rec_sigterm (int i)
1281{
1282 LOG (llevInfo, "SIGTERM received\n");
1283 fatal_signal (0, 1);
1284}
1285
1286void
1287fatal_signal (int make_core, int close_sockets)
1288{
1289 cleanup (make_core);
1290} 1243}
1291 1244
1292void 1245void
1293init_signals (void) 1246init_signals (void)
1294{ 1247{
1295 signal (SIGHUP, rec_sighup); 1248 // large stack, but it's important data we want to save, and it is not usually
1296 signal (SIGINT, rec_sigint); 1249 // being physically allocated anyways
1297 signal (SIGQUIT, rec_sigquit); 1250 const size_t stacksize = 8 * 1024 * 1024 + SIGSTKSZ;
1298 signal (SIGSEGV, rec_sigsegv); 1251
1299 signal (SIGPIPE, SIG_IGN); 1252 stack_t ss;
1300#ifdef SIGBUS 1253 ss.ss_sp = malloc (stacksize);
1301 signal (SIGBUS, rec_sigbus); 1254 ss.ss_flags = 0;
1302#endif 1255 ss.ss_size = stacksize;
1303 signal (SIGTERM, rec_sigterm); 1256 sigaltstack (&ss, 0);
1257
1258 struct sigaction sa;
1259
1260 sigfillset (&sa.sa_mask);
1261 sa.sa_flags = SA_ONSTACK | SA_RESTART;
1262
1263 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
1264 sa.sa_handler = rec_sigabrt; sigaction (SIGABRT, &sa, 0);
1265 sa.sa_handler = rec_sigquit; sigaction (SIGQUIT, &sa, 0);
1266 sa.sa_handler = rec_sigsegv; sigaction (SIGSEGV, &sa, 0);
1267 sa.sa_handler = rec_sigbus; sigaction (SIGBUS, &sa, 0);
1304} 1268}
1305 1269
1306/* init_races() - reads the races file in the lib/ directory, then 1270/* init_races() - reads the races file in the lib/ directory, then
1307 * overwrites old 'race' entries. This routine allow us to quickly 1271 * overwrites old 'race' entries. This routine allow us to quickly
1308 * re-configure the 'alignment' of monsters, objects. Useful for 1272 * re-configure the 'alignment' of monsters, objects. Useful for
1309 * putting together lists of creatures, etc that belong to gods. 1273 * putting together lists of creatures, etc that belong to gods.
1310 */ 1274 */
1311
1312void 1275void
1313init_races (void) 1276init_races (void)
1314{ 1277{
1315 FILE *file; 1278 FILE *file;
1316 char race[MAX_BUF], fname[MAX_BUF], buf[MAX_BUF], *cp, variable[MAX_BUF]; 1279 char race[MAX_BUF], fname[MAX_BUF], buf[MAX_BUF], *cp, variable[MAX_BUF];
1321 return; 1284 return;
1322 init_done = 1; 1285 init_done = 1;
1323 first_race = 0; 1286 first_race = 0;
1324 1287
1325 sprintf (fname, "%s/races", settings.datadir); 1288 sprintf (fname, "%s/races", settings.datadir);
1326 LOG (llevDebug, "Reading races from %s...", fname); 1289 LOG (llevDebug, "Reading races from %s...\n", fname);
1327 if (!(file = fopen (fname, "r"))) 1290 if (!(file = fopen (fname, "r")))
1328 { 1291 {
1329 LOG (llevError, "Cannot open races file %s: %s\n", fname, strerror (errno)); 1292 LOG (llevError, "Cannot open races file %s: %s\n", fname, strerror (errno));
1330 return; 1293 return;
1331 } 1294 }
1349 set_list = 0; 1312 set_list = 0;
1350 cp++; 1313 cp++;
1351 } 1314 }
1352 1315
1353 if (sscanf (cp, "RACE %s", variable)) 1316 if (sscanf (cp, "RACE %s", variable))
1354 { /* set new race value */ 1317 /* set new race value */
1355 strcpy (race, variable); 1318 strcpy (race, variable);
1356 }
1357 else 1319 else
1358 { 1320 {
1359 char *cp1; 1321 char *cp1;
1360 1322
1361 /* Take out beginning spaces */ 1323 /* Take out beginning spaces */
1372 if (cp[strlen (cp) - 1] == '\n') 1334 if (cp[strlen (cp) - 1] == '\n')
1373 cp[strlen (cp) - 1] = '\0'; 1335 cp[strlen (cp) - 1] = '\0';
1374 1336
1375 /* set creature race to race value */ 1337 /* set creature race to race value */
1376 if ((mon = archetype::find (cp)) == NULL) 1338 if ((mon = archetype::find (cp)) == NULL)
1377 LOG (llevError, "\nCreature %s in race file lacks archetype", cp); 1339 LOG (llevError, "Creature %s in race file lacks archetype\n", cp);
1378 else 1340 else
1379 { 1341 {
1380 if (set_race && (!mon->clone.race || strcmp (mon->clone.race, race))) 1342 if (set_race && (!mon->clone.race || strcmp (mon->clone.race, race)))
1381 { 1343 {
1382 if (mon->clone.race) 1344 if (mon->clone.race)
1383 LOG (llevDebug, "\n Resetting race to %s from %s for archetype %s", race, &mon->clone.race, &mon->name); 1345 LOG (llevDebug, "Resetting race to %s from %s for archetype %s\n", race, &mon->clone.race, &mon->name);
1384 1346
1385 mon->clone.race = race; 1347 mon->clone.race = race;
1386 } 1348 }
1387 1349
1388 /* if the arch is a monster, add it to the race list */ 1350 /* if the arch is a monster, add it to the race list */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines