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.16 by pippijn, Mon Dec 11 19:46:47 2006 UTC vs.
Revision 1.28 by pippijn, Wed Jan 3 00:46:53 2007 UTC

22*/ 22*/
23 23
24#include <global.h> 24#include <global.h>
25#include <material.h> 25#include <material.h>
26#include <loader.h> 26#include <loader.h>
27#ifndef __CEXTRACT__
28# include <sproto.h> 27#include <sproto.h>
29#endif
30
31/* global weathermap */
32weathermap_t **weathermap;
33 28
34void 29void
35set_logfile (char *val) 30set_logfile (char *val)
36{ 31{
37 settings.logfilename = val; 32 settings.logfilename = val;
241 * pass system very easy, and it is very easy to add in new options. 236 * pass system very easy, and it is very easy to add in new options.
242 */ 237 */
243struct Command_Line_Options options[] = { 238struct Command_Line_Options options[] = {
244 239
245/* Pass 1 functions - STuff that can/should be called before we actually 240/* Pass 1 functions - STuff that can/should be called before we actually
246 * initialize any data. 241 * initialise any data.
247 */ 242 */
248 {"-h", 0, 1, help}, 243 {"-h", 0, 1, help},
249 244
250/* Honor -help also, since it is somewhat common */ 245/* Honor -help also, since it is somewhat common */
251 {"-help", 0, 1, help}, 246 {"-help", 0, 1, help},
384 FILE *fp; 379 FILE *fp;
385 materialtype_t *mt; 380 materialtype_t *mt;
386 int i, value; 381 int i, value;
387 382
388 sprintf (filename, "%s/materials", settings.datadir); 383 sprintf (filename, "%s/materials", settings.datadir);
389 LOG (llevDebug, "Reading material type data from %s...", filename); 384 LOG (llevDebug, "Reading material type data from %s...\n", filename);
390 if ((fp = fopen (filename, "r")) == NULL) 385 if ((fp = fopen (filename, "r")) == NULL)
391 { 386 {
392 LOG (llevError, "Cannot open %s for reading\n", filename); 387 LOG (llevError, "Cannot open %s for reading\n", filename);
393 mt = get_empty_mat (); 388 mt = get_empty_mat ();
394 mt->next = NULL; 389 mt->next = NULL;
760 else 755 else
761 { 756 {
762 LOG (llevError, "load_settings: Unknown value for " "real_wiz: %s\n", cp); 757 LOG (llevError, "load_settings: Unknown value for " "real_wiz: %s\n", cp);
763 } 758 }
764 } 759 }
765 else if (!strcasecmp (buf, "recycle_tmp_maps"))
766 {
767 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true"))
768 {
769 settings.recycle_tmp_maps = TRUE;
770 }
771 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false"))
772 {
773 settings.recycle_tmp_maps = FALSE;
774 }
775 else
776 {
777 LOG (llevError, "load_settings: Unknown value for " "recycle_tmp_maps: %s\n", cp);
778 }
779 }
780 else if (!strcasecmp (buf, "explore_mode")) 760 else if (!strcasecmp (buf, "explore_mode"))
781 { 761 {
782 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 762 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true"))
783 { 763 {
784 settings.explore_mode = TRUE; 764 settings.explore_mode = TRUE;
789 } 769 }
790 else 770 else
791 { 771 {
792 LOG (llevError, "load_settings: Unknown value for " "explore_mode: %s\n", cp); 772 LOG (llevError, "load_settings: Unknown value for " "explore_mode: %s\n", cp);
793 } 773 }
794 }
795 else if (!strcasecmp (buf, "who_format"))
796 {
797 if (has_val)
798 strcpy (settings.who_format, cp);
799 }
800 else if (!strcasecmp (buf, "who_wiz_format"))
801 {
802 if (has_val)
803 strcpy (settings.who_wiz_format, cp);
804 } 774 }
805 else if (!strcasecmp (buf, "spellpoint_level_depend")) 775 else if (!strcasecmp (buf, "spellpoint_level_depend"))
806 { 776 {
807 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 777 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true"))
808 { 778 {
1019 else 989 else
1020 { 990 {
1021 LOG (llevError, "Unknown value in settings file: %s\n", buf); 991 LOG (llevError, "Unknown value in settings file: %s\n", buf);
1022 } 992 }
1023 } 993 }
994
1024 close_and_delete (fp, comp); 995 close_and_delete (fp, comp);
1025} 996}
1026 997
1027 998
1028/* 999/*
1039 * LibDir in this pass would be reasonable*/ 1010 * LibDir in this pass would be reasonable*/
1040 1011
1041 cfperl_init (); 1012 cfperl_init ();
1042 init_library (); /* Must be called early */ 1013 init_library (); /* Must be called early */
1043 load_settings (); /* Load the settings file */ 1014 load_settings (); /* Load the settings file */
1044 init_weather ();
1045 load_materials (); 1015 load_materials ();
1046 parse_args (argc, argv, 2); 1016 parse_args (argc, argv, 2);
1047 fprintf (logfile, "Welcome to CrossFire, v%s\n", VERSION); 1017 fprintf (logfile, "Welcome to CrossFire, v%s\n", VERSION);
1018 fprintf (logfile, "Copyright (C) 2005, 2006, 2007 Marc Lehmann.\n");
1048 fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n"); 1019 fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n");
1049 fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n"); 1020 fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n");
1050 1021
1051 if (strcmp (settings.dm_mail, "") != 0) 1022 if (strcmp (settings.dm_mail, "") != 0)
1052 { 1023 {
1058 1029
1059 init_startup (); /* Write (C), check shutdown/forbid files */ 1030 init_startup (); /* Write (C), check shutdown/forbid files */
1060 init_uuid (); 1031 init_uuid ();
1061 init_signals (); /* Sets up signal interceptions */ 1032 init_signals (); /* Sets up signal interceptions */
1062 init_commands (); /* Sort command tables */ 1033 init_commands (); /* Sort command tables */
1063 read_map_log (); /* Load up the old temp map files */
1064 init_skills (); 1034 init_skills ();
1065 1035
1066 parse_args (argc, argv, 3); 1036 parse_args (argc, argv, 3);
1067 1037
1068 if (settings.daemonmode) 1038 if (settings.daemonmode)
1238 printf ("Save player:\t<true>\n"); 1208 printf ("Save player:\t<true>\n");
1239 printf ("Save mode:\t%4.4o\n", SAVE_MODE); 1209 printf ("Save mode:\t%4.4o\n", SAVE_MODE);
1240 printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir); 1210 printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir);
1241 printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir); 1211 printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir);
1242 printf ("Tmpdir:\t\t%s\n", settings.tmpdir); 1212 printf ("Tmpdir:\t\t%s\n", settings.tmpdir);
1243 printf ("Map max timeout:\t%d\n", MAP_MAXTIMEOUT);
1244 printf ("Max objects:\t%d\n", MAX_OBJECTS);
1245#ifdef USE_CALLOC 1213#ifdef USE_CALLOC
1246 printf ("Use_calloc:\t<true>\n"); 1214 printf ("Use_calloc:\t<true>\n");
1247#else 1215#else
1248 printf ("Use_calloc:\t<false>\n"); 1216 printf ("Use_calloc:\t<false>\n");
1249#endif 1217#endif
1262/* Signal handlers: */ 1230/* Signal handlers: */
1263 1231
1264void 1232void
1265rec_sigsegv (int i) 1233rec_sigsegv (int i)
1266{ 1234{
1267 LOG (llevError, "\nSIGSEGV received.\n"); 1235 LOG (llevError, "SIGSEGV received.\n");
1268 fatal_signal (1, 1); 1236 fatal_signal (1, 1);
1269} 1237}
1270 1238
1271void 1239void
1272rec_sigint (int i) 1240rec_sigint (int i)
1273{ 1241{
1274 LOG (llevInfo, "\nSIGINT received.\n"); 1242 LOG (llevInfo, "SIGINT received.\n");
1275 fatal_signal (0, 1); 1243 fatal_signal (0, 1);
1276} 1244}
1277 1245
1278void 1246void
1279rec_sighup (int i) 1247rec_sighup (int i)
1280{ 1248{
1281 LOG (llevInfo, "\nSIGHUP received\n"); 1249 LOG (llevInfo, "SIGHUP received\n");
1250
1282 if (init_done) 1251 if (init_done)
1283 {
1284 emergency_save (0);
1285 cleanup (); 1252 cleanup (0);
1286 } 1253
1287 exit (0); 1254 exit (0);
1288} 1255}
1289 1256
1290void 1257void
1291rec_sigquit (int i) 1258rec_sigquit (int i)
1292{ 1259{
1293 LOG (llevInfo, "\nSIGQUIT received\n"); 1260 LOG (llevInfo, "SIGQUIT received\n");
1294 fatal_signal (1, 1); 1261 fatal_signal (1, 1);
1295} 1262}
1296 1263
1297void 1264void
1298rec_sigbus (int i) 1265rec_sigbus (int i)
1299{ 1266{
1300#ifdef SIGBUS 1267#ifdef SIGBUS
1301 LOG (llevError, "\nSIGBUS received\n"); 1268 LOG (llevError, "SIGBUS received\n");
1302 fatal_signal (1, 1); 1269 fatal_signal (1, 1);
1303#endif 1270#endif
1304} 1271}
1305 1272
1306void 1273void
1307rec_sigterm (int i) 1274rec_sigterm (int i)
1308{ 1275{
1309 LOG (llevInfo, "\nSIGTERM received\n"); 1276 LOG (llevInfo, "SIGTERM received\n");
1310 fatal_signal (0, 1); 1277 fatal_signal (0, 1);
1311} 1278}
1312 1279
1313void 1280void
1314fatal_signal (int make_core, int close_sockets) 1281fatal_signal (int make_core, int close_sockets)
1315{ 1282{
1316 if (init_done) 1283 cleanup (make_core);
1317 {
1318 emergency_save (0);
1319 clean_tmp_files ();
1320 }
1321 if (make_core)
1322 abort ();
1323 exit (0);
1324} 1284}
1325 1285
1326void 1286void
1327init_signals (void) 1287init_signals (void)
1328{ 1288{
1355 return; 1315 return;
1356 init_done = 1; 1316 init_done = 1;
1357 first_race = 0; 1317 first_race = 0;
1358 1318
1359 sprintf (fname, "%s/races", settings.datadir); 1319 sprintf (fname, "%s/races", settings.datadir);
1360 LOG (llevDebug, "Reading races from %s...", fname); 1320 LOG (llevDebug, "Reading races from %s...\n", fname);
1361 if (!(file = fopen (fname, "r"))) 1321 if (!(file = fopen (fname, "r")))
1362 { 1322 {
1363 LOG (llevError, "Cannot open races file %s: %s\n", fname, strerror (errno)); 1323 LOG (llevError, "Cannot open races file %s: %s\n", fname, strerror (errno));
1364 return; 1324 return;
1365 } 1325 }
1406 if (cp[strlen (cp) - 1] == '\n') 1366 if (cp[strlen (cp) - 1] == '\n')
1407 cp[strlen (cp) - 1] = '\0'; 1367 cp[strlen (cp) - 1] = '\0';
1408 1368
1409 /* set creature race to race value */ 1369 /* set creature race to race value */
1410 if ((mon = archetype::find (cp)) == NULL) 1370 if ((mon = archetype::find (cp)) == NULL)
1411 LOG (llevError, "\nCreature %s in race file lacks archetype", cp); 1371 LOG (llevError, "Creature %s in race file lacks archetype\n", cp);
1412 else 1372 else
1413 { 1373 {
1414 if (set_race && (!mon->clone.race || strcmp (mon->clone.race, race))) 1374 if (set_race && (!mon->clone.race || strcmp (mon->clone.race, race)))
1415 { 1375 {
1416 if (mon->clone.race) 1376 if (mon->clone.race)
1417 LOG (llevDebug, "\n Resetting race to %s from %s for archetype %s", race, &mon->clone.race, &mon->name); 1377 LOG (llevDebug, "Resetting race to %s from %s for archetype %s\n", race, &mon->clone.race, &mon->name);
1418 1378
1419 mon->clone.race = race; 1379 mon->clone.race = race;
1420 } 1380 }
1421 1381
1422 /* if the arch is a monster, add it to the race list */ 1382 /* if the arch is a monster, add it to the race list */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines