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.56 by root, Sun Jul 1 05:00:20 2007 UTC vs.
Revision 1.64 by root, Tue Apr 22 23:50:24 2008 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * 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
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * 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,
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 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
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
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>
268 {"-detach", 0, 2, set_daemon}, 268 {"-detach", 0, 2, set_daemon},
269 269
270/* Start of pass 3 information. In theory, by pass 3, all data paths 270/* Start of pass 3 information. In theory, by pass 3, all data paths
271 * and defaults should have been set up. 271 * and defaults should have been set up.
272 */ 272 */
273 {"-o", 0, 3, compile_info},
274 {"-m", 0, 3, set_dumpmon1}, 273 {"-m", 0, 3, set_dumpmon1},
275 {"-m2", 0, 3, set_dumpmon2}, 274 {"-m2", 0, 3, set_dumpmon2},
276 {"-m3", 0, 3, set_dumpmon3}, 275 {"-m3", 0, 3, set_dumpmon3},
277 {"-m4", 0, 3, set_dumpmon4}, 276 {"-m4", 0, 3, set_dumpmon4},
278 {"-m5", 0, 3, set_dumpmon5}, 277 {"-m5", 0, 3, set_dumpmon5},
279 {"-m6", 0, 3, set_dumpmon6}, 278 {"-m6", 0, 3, set_dumpmon6},
280 {"-m7", 0, 3, set_dumpmon7}, 279 {"-m7", 0, 3, set_dumpmon7},
281 {"-m8", 0, 3, set_dumpmon8}, 280 {"-m8", 0, 3, set_dumpmon8},
282 {"-m9", 0, 3, set_dumpmon9}, 281 {"-m9", 0, 3, set_dumpmon9},
283 {"-mt", 1, 3, (void (*)()) set_dumpmont}, 282 {"-mt", 1, 3, (void (*)()) set_dumpmont},
284 {"-mexp", 0, 3, dump_experience},
285 {"-s", 0, 3, showscores}, 283 {"-s", 0, 3, showscores},
286 {"-score", 1, 3, (void (*)()) showscoresparm} 284 {"-score", 1, 3, (void (*)()) showscoresparm}
287}; 285};
288 286
289 287
290/* Note since this may be called before the library has been set up, 288/* Note since this may be called before the library has been set up,
291 * we don't use any of crossfires built in logging functions. 289 * we don't use any of deliantras built in logging functions.
292 */ 290 */
293static void 291static void
294parse_args (int argc, char *argv[], int pass) 292parse_args (int argc, char *argv[], int pass)
295{ 293{
296 size_t i; 294 size_t i;
916init (int argc, char **argv) 914init (int argc, char **argv)
917{ 915{
918 init_done = 0; /* Must be done before init_signal() */ 916 init_done = 0; /* Must be done before init_signal() */
919 rndm.seed (time (0)); 917 rndm.seed (time (0));
920 918
921 logfile = stderr;
922 init_environ (); 919 init_environ ();
923 parse_args (argc, argv, 1); /* First arg pass - right now it does 920 parse_args (argc, argv, 1); /* First arg pass - right now it does
924 * nothing, but in future specifying the 921 * nothing, but in future specifying the
925 * LibDir in this pass would be reasonable*/ 922 * LibDir in this pass would be reasonable*/
926 923
927 init_anim (); // Must be called before perl 924 init_anim (); // Must be called before perl
925 init_globals ();
926 init_experience ();
927 init_attackmess ();
928 init_dynamic ();
929 init_block ();
928 cfperl_init (); 930 cfperl_init ();
929 init_library (); /* Must be called early */
930 load_settings (); /* Load the settings file */ 931 load_settings (); /* Load the settings file */
931 load_materials (); 932 load_materials ();
932 parse_args (argc, argv, 2); 933 parse_args (argc, argv, 2);
933 fprintf (logfile, "Welcome to CrossFire, v%s\n", VERSION); 934 LOG (llevInfo, "Welcome to Deliantra, v" VERSION);
934 fprintf (logfile, "Copyright (C) 2005, 2006, 2007 Marc Lehmann.\n"); 935 LOG (llevInfo, "Copyright (C) Marc Alexander Lehmann / Robin Redeker / the Deliantra team.");
935 fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n"); 936 LOG (llevInfo, "Copyright (C) 1994 Mark Wedel.");
936 fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n"); 937 LOG (llevInfo, "Copyright (C) 1992 Frank Tore Johansen.");
937 938
938 if (strcmp (settings.dm_mail, "") != 0) 939 if (strcmp (settings.dm_mail, "") != 0)
939 { 940 {
940 fprintf (logfile, "Maintained locally by: %s\n", settings.dm_mail); 941 LOG (llevInfo, "Maintained locally by: %s\n", settings.dm_mail);
941 fprintf (logfile, "Questions and bugs should be mailed to above address.\n"); 942 LOG (llevInfo, "Questions and bugs should be mailed to above address.\n");
942 } 943 }
943 944
944 init_startup (); /* Write (C), check shutdown/forbid files */ 945 UUID::init ();
945 init_uuid ();
946 init_signals (); /* Sets up signal interceptions */ 946 init_signals (); /* Sets up signal interceptions */
947 init_commands (); /* Sort command tables */ 947 init_commands (); /* Sort command tables */
948 init_skills (); 948 init_skills ();
949 949
950 parse_args (argc, argv, 3); 950 parse_args (argc, argv, 3);
954} 954}
955 955
956void 956void
957usage (void) 957usage (void)
958{ 958{
959 (void) fprintf (logfile, "Usage: crossfire [-h] [-<flags>]...\n"); 959 fprintf (stderr, "Usage: deliantra-server [-h] [-<flags>]...\n");
960} 960}
961 961
962void 962void
963help (void) 963help (void)
964{ 964{
1006 1006
1007void 1007void
1008init_beforeplay (void) 1008init_beforeplay (void)
1009{ 1009{
1010 init_artifacts (); /* If not called before, reads all artifacts from file */ 1010 init_artifacts (); /* If not called before, reads all artifacts from file */
1011 init_spells (); /* If not called before, links archtypes used by spells */
1012 init_archetype_pointers (); /* Setup global pointers to archetypes */
1013 init_races (); /* overwrite race designations using entries in lib/races file */ 1011 init_races (); /* overwrite race designations using entries in lib/races file */
1014 init_gods (); /* init linked list of gods from archs */ 1012 init_gods (); /* init linked list of gods from archs */
1015 init_readable (); /* inits useful arrays for readable texts */ 1013 init_readable (); /* inits useful arrays for readable texts */
1016 init_formulae (); /* If not called before, reads formulae from file */ 1014 init_formulae (); /* If not called before, reads formulae from file */
1017}
1018
1019void
1020init_startup (void)
1021{
1022 char buf[MAX_BUF];
1023 FILE *fp;
1024 int comp;
1025
1026#ifdef SHUTDOWN_FILE
1027 sprintf (buf, "%s/%s", settings.confdir, SHUTDOWN_FILE);
1028 if ((fp = open_and_uncompress (buf, 0, &comp)) != NULL)
1029 {
1030 while (fgets (buf, MAX_BUF - 1, fp) != NULL)
1031 printf ("%s", buf);
1032 close_and_delete (fp, comp);
1033 exit (1);
1034 }
1035#endif
1036
1037 if (forbid_play ())
1038 { /* Maybe showing highscore should be allowed? */
1039 LOG (llevError, "CrossFire: Playing not allowed.\n");
1040 exit (-1);
1041 }
1042}
1043
1044/*
1045 * compile_info(): activated with the -o flag.
1046 * It writes out information on how Imakefile and config.h was configured
1047 * at compile time.
1048 */
1049
1050void
1051compile_info (void)
1052{
1053 int i = 0;
1054
1055 printf ("Non-standard include files:\n");
1056#if !defined (__STRICT_ANSI__) || defined (__sun__)
1057# if !defined (Mips)
1058 printf ("<stdlib.h>\n");
1059 i = 1;
1060# endif
1061# if !defined (MACH) && !defined (sony)
1062 printf ("<malloc.h>\n");
1063 i = 1;
1064# endif
1065#endif
1066#ifndef __STRICT_ANSI__
1067# ifndef MACH
1068 printf ("<memory.h\n");
1069 i = 1;
1070# endif
1071#endif
1072#ifndef sgi
1073 printf ("<sys/timeb.h>\n");
1074 i = 1;
1075#endif
1076 if (!i)
1077 printf ("(none)\n");
1078 printf ("Datadir:\t\t%s\n", settings.datadir);
1079 printf ("Localdir:\t\t%s\n", settings.localdir);
1080#ifdef PERM_FILE
1081 printf ("Perm file:\t<ETC>/%s\n", PERM_FILE);
1082#endif
1083#ifdef SHUTDOWN_FILE
1084 printf ("Shutdown file:\t<ETC>/%s\n", SHUTDOWN_FILE);
1085#endif
1086 printf ("Save player:\t<true>\n");
1087 printf ("Save mode:\t%4.4o\n", SAVE_MODE);
1088 printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir);
1089 printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir);
1090 printf ("Tmpdir:\t\t%s\n", settings.tmpdir);
1091#ifdef USE_CALLOC
1092 printf ("Use_calloc:\t<true>\n");
1093#else
1094 printf ("Use_calloc:\t<false>\n");
1095#endif
1096
1097#ifdef X_EDITOR
1098 printf ("Editor:\t\t%s\n", X_EDITOR);
1099#endif
1100
1101 printf ("Max_time:\t%d\n", MAX_TIME);
1102
1103 execl ("/bin/uname", "uname", "-a", NULL);
1104 LOG (llevError, "Oops, shouldn't have gotten here: execl(/bin/uname) failed: %s\n", strerror (errno));
1105 exit (-1);
1106} 1015}
1107 1016
1108/* Signal handlers: */ 1017/* Signal handlers: */
1109 1018
1110static void 1019static void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines