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.53 by root, Mon Jun 4 12:19:09 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 it 8 * Deliantra is free software: you can redistribute it and/or modify
9 * under the terms of the GNU General Public License as published by the Free 9 * it under the terms of the GNU General Public License as published by
10 * Software Foundation; either version 2 of the License, or (at your option) 10 * the Free Software Foundation, either version 3 of the License, or
11 * 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, but 13 * This program is distributed in the hope that it will be useful,
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 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 along 18 * You should have received a copy of the GNU General Public License
19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 20 *
22 * 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>
23 */ 22 */
24 23
25#include <global.h> 24#include <global.h>
26#include <material.h> 25#include <material.h>
27#include <loader.h> 26#include <loader.h>
269 {"-detach", 0, 2, set_daemon}, 268 {"-detach", 0, 2, set_daemon},
270 269
271/* 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
272 * and defaults should have been set up. 271 * and defaults should have been set up.
273 */ 272 */
274 {"-o", 0, 3, compile_info},
275 {"-m", 0, 3, set_dumpmon1}, 273 {"-m", 0, 3, set_dumpmon1},
276 {"-m2", 0, 3, set_dumpmon2}, 274 {"-m2", 0, 3, set_dumpmon2},
277 {"-m3", 0, 3, set_dumpmon3}, 275 {"-m3", 0, 3, set_dumpmon3},
278 {"-m4", 0, 3, set_dumpmon4}, 276 {"-m4", 0, 3, set_dumpmon4},
279 {"-m5", 0, 3, set_dumpmon5}, 277 {"-m5", 0, 3, set_dumpmon5},
280 {"-m6", 0, 3, set_dumpmon6}, 278 {"-m6", 0, 3, set_dumpmon6},
281 {"-m7", 0, 3, set_dumpmon7}, 279 {"-m7", 0, 3, set_dumpmon7},
282 {"-m8", 0, 3, set_dumpmon8}, 280 {"-m8", 0, 3, set_dumpmon8},
283 {"-m9", 0, 3, set_dumpmon9}, 281 {"-m9", 0, 3, set_dumpmon9},
284 {"-mt", 1, 3, (void (*)()) set_dumpmont}, 282 {"-mt", 1, 3, (void (*)()) set_dumpmont},
285 {"-mexp", 0, 3, dump_experience},
286 {"-s", 0, 3, showscores}, 283 {"-s", 0, 3, showscores},
287 {"-score", 1, 3, (void (*)()) showscoresparm} 284 {"-score", 1, 3, (void (*)()) showscoresparm}
288}; 285};
289 286
290 287
291/* 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,
292 * we don't use any of crossfires built in logging functions. 289 * we don't use any of deliantras built in logging functions.
293 */ 290 */
294static void 291static void
295parse_args (int argc, char *argv[], int pass) 292parse_args (int argc, char *argv[], int pass)
296{ 293{
297 size_t i; 294 size_t i;
917init (int argc, char **argv) 914init (int argc, char **argv)
918{ 915{
919 init_done = 0; /* Must be done before init_signal() */ 916 init_done = 0; /* Must be done before init_signal() */
920 rndm.seed (time (0)); 917 rndm.seed (time (0));
921 918
922 logfile = stderr;
923 init_environ (); 919 init_environ ();
924 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
925 * nothing, but in future specifying the 921 * nothing, but in future specifying the
926 * LibDir in this pass would be reasonable*/ 922 * LibDir in this pass would be reasonable*/
927 923
928 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 ();
929 cfperl_init (); 930 cfperl_init ();
930 init_library (); /* Must be called early */
931 load_settings (); /* Load the settings file */ 931 load_settings (); /* Load the settings file */
932 load_materials (); 932 load_materials ();
933 parse_args (argc, argv, 2); 933 parse_args (argc, argv, 2);
934 fprintf (logfile, "Welcome to CrossFire, v%s\n", VERSION); 934 LOG (llevInfo, "Welcome to Deliantra, v" VERSION);
935 fprintf (logfile, "Copyright (C) 2005, 2006, 2007 Marc Lehmann.\n"); 935 LOG (llevInfo, "Copyright (C) Marc Alexander Lehmann / Robin Redeker / the Deliantra team.");
936 fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n"); 936 LOG (llevInfo, "Copyright (C) 1994 Mark Wedel.");
937 fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n"); 937 LOG (llevInfo, "Copyright (C) 1992 Frank Tore Johansen.");
938 938
939 if (strcmp (settings.dm_mail, "") != 0) 939 if (strcmp (settings.dm_mail, "") != 0)
940 { 940 {
941 fprintf (logfile, "Maintained locally by: %s\n", settings.dm_mail); 941 LOG (llevInfo, "Maintained locally by: %s\n", settings.dm_mail);
942 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");
943 } 943 }
944 944
945 init_startup (); /* Write (C), check shutdown/forbid files */ 945 UUID::init ();
946 init_uuid ();
947 init_signals (); /* Sets up signal interceptions */ 946 init_signals (); /* Sets up signal interceptions */
948 init_commands (); /* Sort command tables */ 947 init_commands (); /* Sort command tables */
949 init_skills (); 948 init_skills ();
950 949
951 parse_args (argc, argv, 3); 950 parse_args (argc, argv, 3);
952 951
953 init_beforeplay (); 952 init_beforeplay ();
954 init_ericserver ();
955 init_done = 1; 953 init_done = 1;
956} 954}
957 955
958void 956void
959usage (void) 957usage (void)
960{ 958{
961 (void) fprintf (logfile, "Usage: crossfire [-h] [-<flags>]...\n"); 959 fprintf (stderr, "Usage: deliantra-server [-h] [-<flags>]...\n");
962} 960}
963 961
964void 962void
965help (void) 963help (void)
966{ 964{
1008 1006
1009void 1007void
1010init_beforeplay (void) 1008init_beforeplay (void)
1011{ 1009{
1012 init_artifacts (); /* If not called before, reads all artifacts from file */ 1010 init_artifacts (); /* If not called before, reads all artifacts from file */
1013 init_spells (); /* If not called before, links archtypes used by spells */
1014 init_archetype_pointers (); /* Setup global pointers to archetypes */
1015 init_races (); /* overwrite race designations using entries in lib/races file */ 1011 init_races (); /* overwrite race designations using entries in lib/races file */
1016 init_gods (); /* init linked list of gods from archs */ 1012 init_gods (); /* init linked list of gods from archs */
1017 init_readable (); /* inits useful arrays for readable texts */ 1013 init_readable (); /* inits useful arrays for readable texts */
1018 init_formulae (); /* If not called before, reads formulae from file */ 1014 init_formulae (); /* If not called before, reads formulae from file */
1019}
1020
1021void
1022init_startup (void)
1023{
1024 char buf[MAX_BUF];
1025 FILE *fp;
1026 int comp;
1027
1028#ifdef SHUTDOWN_FILE
1029 sprintf (buf, "%s/%s", settings.confdir, SHUTDOWN_FILE);
1030 if ((fp = open_and_uncompress (buf, 0, &comp)) != NULL)
1031 {
1032 while (fgets (buf, MAX_BUF - 1, fp) != NULL)
1033 printf ("%s", buf);
1034 close_and_delete (fp, comp);
1035 exit (1);
1036 }
1037#endif
1038
1039 if (forbid_play ())
1040 { /* Maybe showing highscore should be allowed? */
1041 LOG (llevError, "CrossFire: Playing not allowed.\n");
1042 exit (-1);
1043 }
1044}
1045
1046/*
1047 * compile_info(): activated with the -o flag.
1048 * It writes out information on how Imakefile and config.h was configured
1049 * at compile time.
1050 */
1051
1052void
1053compile_info (void)
1054{
1055 int i = 0;
1056
1057 printf ("Non-standard include files:\n");
1058#if !defined (__STRICT_ANSI__) || defined (__sun__)
1059# if !defined (Mips)
1060 printf ("<stdlib.h>\n");
1061 i = 1;
1062# endif
1063# if !defined (MACH) && !defined (sony)
1064 printf ("<malloc.h>\n");
1065 i = 1;
1066# endif
1067#endif
1068#ifndef __STRICT_ANSI__
1069# ifndef MACH
1070 printf ("<memory.h\n");
1071 i = 1;
1072# endif
1073#endif
1074#ifndef sgi
1075 printf ("<sys/timeb.h>\n");
1076 i = 1;
1077#endif
1078 if (!i)
1079 printf ("(none)\n");
1080 printf ("Datadir:\t\t%s\n", settings.datadir);
1081 printf ("Localdir:\t\t%s\n", settings.localdir);
1082#ifdef PERM_FILE
1083 printf ("Perm file:\t<ETC>/%s\n", PERM_FILE);
1084#endif
1085#ifdef SHUTDOWN_FILE
1086 printf ("Shutdown file:\t<ETC>/%s\n", SHUTDOWN_FILE);
1087#endif
1088 printf ("Save player:\t<true>\n");
1089 printf ("Save mode:\t%4.4o\n", SAVE_MODE);
1090 printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir);
1091 printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir);
1092 printf ("Tmpdir:\t\t%s\n", settings.tmpdir);
1093#ifdef USE_CALLOC
1094 printf ("Use_calloc:\t<true>\n");
1095#else
1096 printf ("Use_calloc:\t<false>\n");
1097#endif
1098
1099#ifdef X_EDITOR
1100 printf ("Editor:\t\t%s\n", X_EDITOR);
1101#endif
1102
1103 printf ("Max_time:\t%d\n", MAX_TIME);
1104
1105 execl ("/bin/uname", "uname", "-a", NULL);
1106 LOG (llevError, "Oops, shouldn't have gotten here: execl(/bin/uname) failed: %s\n", strerror (errno));
1107 exit (-1);
1108} 1015}
1109 1016
1110/* Signal handlers: */ 1017/* Signal handlers: */
1111 1018
1112static void 1019static void
1253 /* set creature race to race value */ 1160 /* set creature race to race value */
1254 if ((mon = archetype::find (cp)) == NULL) 1161 if ((mon = archetype::find (cp)) == NULL)
1255 LOG (llevError, "Creature %s in race file lacks archetype\n", cp); 1162 LOG (llevError, "Creature %s in race file lacks archetype\n", cp);
1256 else 1163 else
1257 { 1164 {
1258 if (set_race && (!mon->clone.race || strcmp (mon->clone.race, race))) 1165 if (set_race && (!mon->race || strcmp (mon->race, race)))
1259 { 1166 {
1260 if (mon->clone.race) 1167 if (mon->race)
1261 LOG (llevDebug, "Resetting race to %s from %s for archetype %s\n", race, &mon->clone.race, &mon->archname); 1168 LOG (llevDebug, "Resetting race to %s from %s for archetype %s\n", race, &mon->race, &mon->archname);
1262 1169
1263 mon->clone.race = race; 1170 mon->race = race;
1264 } 1171 }
1265 1172
1266 /* if the arch is a monster, add it to the race list */ 1173 /* if the arch is a monster, add it to the race list */
1267 if (set_list && QUERY_FLAG (&mon->clone, FLAG_MONSTER)) 1174 if (set_list && QUERY_FLAG (mon, FLAG_MONSTER))
1268 add_to_racelist (race, &mon->clone); 1175 add_to_racelist (race, mon);
1269 } 1176 }
1270 } 1177 }
1271 } 1178 }
1272 1179
1273 fclose (file); 1180 fclose (file);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines