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.18 by root, Sat Dec 16 17:16:52 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;
1009 else 989 else
1010 { 990 {
1011 LOG (llevError, "Unknown value in settings file: %s\n", buf); 991 LOG (llevError, "Unknown value in settings file: %s\n", buf);
1012 } 992 }
1013 } 993 }
994
1014 close_and_delete (fp, comp); 995 close_and_delete (fp, comp);
1015} 996}
1016 997
1017 998
1018/* 999/*
1029 * LibDir in this pass would be reasonable*/ 1010 * LibDir in this pass would be reasonable*/
1030 1011
1031 cfperl_init (); 1012 cfperl_init ();
1032 init_library (); /* Must be called early */ 1013 init_library (); /* Must be called early */
1033 load_settings (); /* Load the settings file */ 1014 load_settings (); /* Load the settings file */
1034 init_weather ();
1035 load_materials (); 1015 load_materials ();
1036 parse_args (argc, argv, 2); 1016 parse_args (argc, argv, 2);
1037 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");
1038 fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n"); 1019 fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n");
1039 fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n"); 1020 fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n");
1040 1021
1041 if (strcmp (settings.dm_mail, "") != 0) 1022 if (strcmp (settings.dm_mail, "") != 0)
1042 { 1023 {
1048 1029
1049 init_startup (); /* Write (C), check shutdown/forbid files */ 1030 init_startup (); /* Write (C), check shutdown/forbid files */
1050 init_uuid (); 1031 init_uuid ();
1051 init_signals (); /* Sets up signal interceptions */ 1032 init_signals (); /* Sets up signal interceptions */
1052 init_commands (); /* Sort command tables */ 1033 init_commands (); /* Sort command tables */
1053 read_map_log (); /* Load up the old temp map files */
1054 init_skills (); 1034 init_skills ();
1055 1035
1056 parse_args (argc, argv, 3); 1036 parse_args (argc, argv, 3);
1057 1037
1058 if (settings.daemonmode) 1038 if (settings.daemonmode)
1228 printf ("Save player:\t<true>\n"); 1208 printf ("Save player:\t<true>\n");
1229 printf ("Save mode:\t%4.4o\n", SAVE_MODE); 1209 printf ("Save mode:\t%4.4o\n", SAVE_MODE);
1230 printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir); 1210 printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir);
1231 printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir); 1211 printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir);
1232 printf ("Tmpdir:\t\t%s\n", settings.tmpdir); 1212 printf ("Tmpdir:\t\t%s\n", settings.tmpdir);
1233 printf ("Map max timeout:\t%d\n", MAP_MAXTIMEOUT);
1234 printf ("Max objects:\t%d\n", MAX_OBJECTS);
1235#ifdef USE_CALLOC 1213#ifdef USE_CALLOC
1236 printf ("Use_calloc:\t<true>\n"); 1214 printf ("Use_calloc:\t<true>\n");
1237#else 1215#else
1238 printf ("Use_calloc:\t<false>\n"); 1216 printf ("Use_calloc:\t<false>\n");
1239#endif 1217#endif
1252/* Signal handlers: */ 1230/* Signal handlers: */
1253 1231
1254void 1232void
1255rec_sigsegv (int i) 1233rec_sigsegv (int i)
1256{ 1234{
1257 LOG (llevError, "\nSIGSEGV received.\n"); 1235 LOG (llevError, "SIGSEGV received.\n");
1258 fatal_signal (1, 1); 1236 fatal_signal (1, 1);
1259} 1237}
1260 1238
1261void 1239void
1262rec_sigint (int i) 1240rec_sigint (int i)
1263{ 1241{
1264 LOG (llevInfo, "\nSIGINT received.\n"); 1242 LOG (llevInfo, "SIGINT received.\n");
1265 fatal_signal (0, 1); 1243 fatal_signal (0, 1);
1266} 1244}
1267 1245
1268void 1246void
1269rec_sighup (int i) 1247rec_sighup (int i)
1270{ 1248{
1271 LOG (llevInfo, "\nSIGHUP received\n"); 1249 LOG (llevInfo, "SIGHUP received\n");
1250
1272 if (init_done) 1251 if (init_done)
1273 {
1274 emergency_save (0);
1275 cleanup (); 1252 cleanup (0);
1276 } 1253
1277 exit (0); 1254 exit (0);
1278} 1255}
1279 1256
1280void 1257void
1281rec_sigquit (int i) 1258rec_sigquit (int i)
1282{ 1259{
1283 LOG (llevInfo, "\nSIGQUIT received\n"); 1260 LOG (llevInfo, "SIGQUIT received\n");
1284 fatal_signal (1, 1); 1261 fatal_signal (1, 1);
1285} 1262}
1286 1263
1287void 1264void
1288rec_sigbus (int i) 1265rec_sigbus (int i)
1289{ 1266{
1290#ifdef SIGBUS 1267#ifdef SIGBUS
1291 LOG (llevError, "\nSIGBUS received\n"); 1268 LOG (llevError, "SIGBUS received\n");
1292 fatal_signal (1, 1); 1269 fatal_signal (1, 1);
1293#endif 1270#endif
1294} 1271}
1295 1272
1296void 1273void
1297rec_sigterm (int i) 1274rec_sigterm (int i)
1298{ 1275{
1299 LOG (llevInfo, "\nSIGTERM received\n"); 1276 LOG (llevInfo, "SIGTERM received\n");
1300 fatal_signal (0, 1); 1277 fatal_signal (0, 1);
1301} 1278}
1302 1279
1303void 1280void
1304fatal_signal (int make_core, int close_sockets) 1281fatal_signal (int make_core, int close_sockets)
1305{ 1282{
1306 if (init_done) 1283 cleanup (make_core);
1307 {
1308 cleanup ();
1309 //emergency_save (0);
1310 //clean_tmp_files ();
1311 }
1312
1313 if (make_core)
1314 abort ();
1315
1316 exit (0);
1317} 1284}
1318 1285
1319void 1286void
1320init_signals (void) 1287init_signals (void)
1321{ 1288{
1348 return; 1315 return;
1349 init_done = 1; 1316 init_done = 1;
1350 first_race = 0; 1317 first_race = 0;
1351 1318
1352 sprintf (fname, "%s/races", settings.datadir); 1319 sprintf (fname, "%s/races", settings.datadir);
1353 LOG (llevDebug, "Reading races from %s...", fname); 1320 LOG (llevDebug, "Reading races from %s...\n", fname);
1354 if (!(file = fopen (fname, "r"))) 1321 if (!(file = fopen (fname, "r")))
1355 { 1322 {
1356 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));
1357 return; 1324 return;
1358 } 1325 }
1399 if (cp[strlen (cp) - 1] == '\n') 1366 if (cp[strlen (cp) - 1] == '\n')
1400 cp[strlen (cp) - 1] = '\0'; 1367 cp[strlen (cp) - 1] = '\0';
1401 1368
1402 /* set creature race to race value */ 1369 /* set creature race to race value */
1403 if ((mon = archetype::find (cp)) == NULL) 1370 if ((mon = archetype::find (cp)) == NULL)
1404 LOG (llevError, "\nCreature %s in race file lacks archetype", cp); 1371 LOG (llevError, "Creature %s in race file lacks archetype\n", cp);
1405 else 1372 else
1406 { 1373 {
1407 if (set_race && (!mon->clone.race || strcmp (mon->clone.race, race))) 1374 if (set_race && (!mon->clone.race || strcmp (mon->clone.race, race)))
1408 { 1375 {
1409 if (mon->clone.race) 1376 if (mon->clone.race)
1410 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);
1411 1378
1412 mon->clone.race = race; 1379 mon->clone.race = race;
1413 } 1380 }
1414 1381
1415 /* 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