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 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}, |
… | |
… | |
287 | {"-score", 1, 3, (void (*)()) showscoresparm} |
285 | {"-score", 1, 3, (void (*)()) showscoresparm} |
288 | }; |
286 | }; |
289 | |
287 | |
290 | |
288 | |
291 | /* Note since this may be called before the library has been set up, |
289 | /* 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. |
290 | * we don't use any of deliantras built in logging functions. |
293 | */ |
291 | */ |
294 | static void |
292 | static void |
295 | parse_args (int argc, char *argv[], int pass) |
293 | parse_args (int argc, char *argv[], int pass) |
296 | { |
294 | { |
297 | size_t i; |
295 | size_t i; |
… | |
… | |
924 | parse_args (argc, argv, 1); /* First arg pass - right now it does |
922 | parse_args (argc, argv, 1); /* First arg pass - right now it does |
925 | * nothing, but in future specifying the |
923 | * nothing, but in future specifying the |
926 | * LibDir in this pass would be reasonable*/ |
924 | * LibDir in this pass would be reasonable*/ |
927 | |
925 | |
928 | init_anim (); // Must be called before perl |
926 | init_anim (); // Must be called before perl |
|
|
927 | init_globals (); |
|
|
928 | init_experience (); |
|
|
929 | init_attackmess (); |
|
|
930 | init_dynamic (); |
|
|
931 | init_block (); |
929 | cfperl_init (); |
932 | cfperl_init (); |
930 | init_library (); /* Must be called early */ |
|
|
931 | load_settings (); /* Load the settings file */ |
933 | load_settings (); /* Load the settings file */ |
932 | load_materials (); |
934 | load_materials (); |
933 | parse_args (argc, argv, 2); |
935 | parse_args (argc, argv, 2); |
934 | fprintf (logfile, "Welcome to CrossFire, v%s\n", VERSION); |
936 | fprintf (logfile, "Welcome to Deliantra, v%s\n", VERSION); |
935 | fprintf (logfile, "Copyright (C) 2005, 2006, 2007 Marc Lehmann.\n"); |
937 | fprintf (logfile, "Copyright (C) 2005, 2006, 2007 Marc Lehmann.\n"); |
936 | fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n"); |
938 | fprintf (logfile, "Copyright (C) 1994 Mark Wedel.\n"); |
937 | fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n"); |
939 | fprintf (logfile, "Copyright (C) 1992 Frank Tore Johansen.\n"); |
938 | |
940 | |
939 | if (strcmp (settings.dm_mail, "") != 0) |
941 | if (strcmp (settings.dm_mail, "") != 0) |
940 | { |
942 | { |
941 | fprintf (logfile, "Maintained locally by: %s\n", settings.dm_mail); |
943 | fprintf (logfile, "Maintained locally by: %s\n", settings.dm_mail); |
942 | fprintf (logfile, "Questions and bugs should be mailed to above address.\n"); |
944 | fprintf (logfile, "Questions and bugs should be mailed to above address.\n"); |
943 | } |
945 | } |
944 | |
946 | |
945 | init_startup (); /* Write (C), check shutdown/forbid files */ |
947 | UUID::init (); |
946 | init_uuid (); |
|
|
947 | init_signals (); /* Sets up signal interceptions */ |
948 | init_signals (); /* Sets up signal interceptions */ |
948 | init_commands (); /* Sort command tables */ |
949 | init_commands (); /* Sort command tables */ |
949 | init_skills (); |
950 | init_skills (); |
950 | |
951 | |
951 | parse_args (argc, argv, 3); |
952 | parse_args (argc, argv, 3); |
952 | |
953 | |
953 | init_beforeplay (); |
954 | init_beforeplay (); |
954 | init_ericserver (); |
|
|
955 | init_done = 1; |
955 | init_done = 1; |
956 | } |
956 | } |
957 | |
957 | |
958 | void |
958 | void |
959 | usage (void) |
959 | usage (void) |
960 | { |
960 | { |
961 | (void) fprintf (logfile, "Usage: crossfire [-h] [-<flags>]...\n"); |
961 | (void) fprintf (logfile, "Usage: deliantra-server [-h] [-<flags>]...\n"); |
962 | } |
962 | } |
963 | |
963 | |
964 | void |
964 | void |
965 | help (void) |
965 | help (void) |
966 | { |
966 | { |
… | |
… | |
1014 | init_archetype_pointers (); /* Setup global pointers to archetypes */ |
1014 | init_archetype_pointers (); /* Setup global pointers to archetypes */ |
1015 | init_races (); /* overwrite race designations using entries in lib/races file */ |
1015 | init_races (); /* overwrite race designations using entries in lib/races file */ |
1016 | init_gods (); /* init linked list of gods from archs */ |
1016 | init_gods (); /* init linked list of gods from archs */ |
1017 | init_readable (); /* inits useful arrays for readable texts */ |
1017 | init_readable (); /* inits useful arrays for readable texts */ |
1018 | init_formulae (); /* If not called before, reads formulae from file */ |
1018 | init_formulae (); /* If not called before, reads formulae from file */ |
1019 | |
|
|
1020 | switch (settings.dumpvalues) |
|
|
1021 | { |
|
|
1022 | case 1: |
|
|
1023 | print_monsters (); |
|
|
1024 | exit (0); |
|
|
1025 | case 2: |
|
|
1026 | dump_abilities (); |
|
|
1027 | exit (0); |
|
|
1028 | case 3: |
|
|
1029 | dump_artifacts (); |
|
|
1030 | exit (0); |
|
|
1031 | case 4: |
|
|
1032 | dump_spells (); |
|
|
1033 | exit (0); |
|
|
1034 | case 5: |
|
|
1035 | exit (0); |
|
|
1036 | case 6: |
|
|
1037 | dump_races (); |
|
|
1038 | exit (0); |
|
|
1039 | case 7: |
|
|
1040 | dump_alchemy (); |
|
|
1041 | exit (0); |
|
|
1042 | case 9: |
|
|
1043 | dump_alchemy_costs (); |
|
|
1044 | exit (0); |
|
|
1045 | case 10: |
|
|
1046 | dump_monster_treasure (settings.dumparg); |
|
|
1047 | exit (0); |
|
|
1048 | } |
|
|
1049 | } |
|
|
1050 | |
|
|
1051 | void |
|
|
1052 | init_startup (void) |
|
|
1053 | { |
|
|
1054 | char buf[MAX_BUF]; |
|
|
1055 | FILE *fp; |
|
|
1056 | int comp; |
|
|
1057 | |
|
|
1058 | #ifdef SHUTDOWN_FILE |
|
|
1059 | sprintf (buf, "%s/%s", settings.confdir, SHUTDOWN_FILE); |
|
|
1060 | if ((fp = open_and_uncompress (buf, 0, &comp)) != NULL) |
|
|
1061 | { |
|
|
1062 | while (fgets (buf, MAX_BUF - 1, fp) != NULL) |
|
|
1063 | printf ("%s", buf); |
|
|
1064 | close_and_delete (fp, comp); |
|
|
1065 | exit (1); |
|
|
1066 | } |
|
|
1067 | #endif |
|
|
1068 | |
|
|
1069 | if (forbid_play ()) |
|
|
1070 | { /* Maybe showing highscore should be allowed? */ |
|
|
1071 | LOG (llevError, "CrossFire: Playing not allowed.\n"); |
|
|
1072 | exit (-1); |
|
|
1073 | } |
|
|
1074 | } |
|
|
1075 | |
|
|
1076 | /* |
|
|
1077 | * compile_info(): activated with the -o flag. |
|
|
1078 | * It writes out information on how Imakefile and config.h was configured |
|
|
1079 | * at compile time. |
|
|
1080 | */ |
|
|
1081 | |
|
|
1082 | void |
|
|
1083 | compile_info (void) |
|
|
1084 | { |
|
|
1085 | int i = 0; |
|
|
1086 | |
|
|
1087 | printf ("Non-standard include files:\n"); |
|
|
1088 | #if !defined (__STRICT_ANSI__) || defined (__sun__) |
|
|
1089 | # if !defined (Mips) |
|
|
1090 | printf ("<stdlib.h>\n"); |
|
|
1091 | i = 1; |
|
|
1092 | # endif |
|
|
1093 | # if !defined (MACH) && !defined (sony) |
|
|
1094 | printf ("<malloc.h>\n"); |
|
|
1095 | i = 1; |
|
|
1096 | # endif |
|
|
1097 | #endif |
|
|
1098 | #ifndef __STRICT_ANSI__ |
|
|
1099 | # ifndef MACH |
|
|
1100 | printf ("<memory.h\n"); |
|
|
1101 | i = 1; |
|
|
1102 | # endif |
|
|
1103 | #endif |
|
|
1104 | #ifndef sgi |
|
|
1105 | printf ("<sys/timeb.h>\n"); |
|
|
1106 | i = 1; |
|
|
1107 | #endif |
|
|
1108 | if (!i) |
|
|
1109 | printf ("(none)\n"); |
|
|
1110 | printf ("Datadir:\t\t%s\n", settings.datadir); |
|
|
1111 | printf ("Localdir:\t\t%s\n", settings.localdir); |
|
|
1112 | #ifdef PERM_FILE |
|
|
1113 | printf ("Perm file:\t<ETC>/%s\n", PERM_FILE); |
|
|
1114 | #endif |
|
|
1115 | #ifdef SHUTDOWN_FILE |
|
|
1116 | printf ("Shutdown file:\t<ETC>/%s\n", SHUTDOWN_FILE); |
|
|
1117 | #endif |
|
|
1118 | printf ("Save player:\t<true>\n"); |
|
|
1119 | printf ("Save mode:\t%4.4o\n", SAVE_MODE); |
|
|
1120 | printf ("Playerdir:\t<VAR>/%s\n", settings.playerdir); |
|
|
1121 | printf ("Itemsdir:\t<VAR>/%s\n", settings.uniquedir); |
|
|
1122 | printf ("Tmpdir:\t\t%s\n", settings.tmpdir); |
|
|
1123 | #ifdef USE_CALLOC |
|
|
1124 | printf ("Use_calloc:\t<true>\n"); |
|
|
1125 | #else |
|
|
1126 | printf ("Use_calloc:\t<false>\n"); |
|
|
1127 | #endif |
|
|
1128 | |
|
|
1129 | #ifdef X_EDITOR |
|
|
1130 | printf ("Editor:\t\t%s\n", X_EDITOR); |
|
|
1131 | #endif |
|
|
1132 | |
|
|
1133 | printf ("Max_time:\t%d\n", MAX_TIME); |
|
|
1134 | |
|
|
1135 | execl ("/bin/uname", "uname", "-a", NULL); |
|
|
1136 | LOG (llevError, "Oops, shouldn't have gotten here: execl(/bin/uname) failed: %s\n", strerror (errno)); |
|
|
1137 | exit (-1); |
|
|
1138 | } |
1019 | } |
1139 | |
1020 | |
1140 | /* Signal handlers: */ |
1021 | /* Signal handlers: */ |
1141 | |
1022 | |
1142 | static void |
1023 | static void |
… | |
… | |
1283 | /* set creature race to race value */ |
1164 | /* set creature race to race value */ |
1284 | if ((mon = archetype::find (cp)) == NULL) |
1165 | if ((mon = archetype::find (cp)) == NULL) |
1285 | LOG (llevError, "Creature %s in race file lacks archetype\n", cp); |
1166 | LOG (llevError, "Creature %s in race file lacks archetype\n", cp); |
1286 | else |
1167 | else |
1287 | { |
1168 | { |
1288 | if (set_race && (!mon->clone.race || strcmp (mon->clone.race, race))) |
1169 | if (set_race && (!mon->race || strcmp (mon->race, race))) |
1289 | { |
1170 | { |
1290 | if (mon->clone.race) |
1171 | if (mon->race) |
1291 | LOG (llevDebug, "Resetting race to %s from %s for archetype %s\n", race, &mon->clone.race, &mon->name); |
1172 | LOG (llevDebug, "Resetting race to %s from %s for archetype %s\n", race, &mon->race, &mon->archname); |
1292 | |
1173 | |
1293 | mon->clone.race = race; |
1174 | mon->race = race; |
1294 | } |
1175 | } |
1295 | |
1176 | |
1296 | /* if the arch is a monster, add it to the race list */ |
1177 | /* if the arch is a monster, add it to the race list */ |
1297 | if (set_list && QUERY_FLAG (&mon->clone, FLAG_MONSTER)) |
1178 | if (set_list && QUERY_FLAG (mon, FLAG_MONSTER)) |
1298 | add_to_racelist (race, &mon->clone); |
1179 | add_to_racelist (race, mon); |
1299 | } |
1180 | } |
1300 | } |
1181 | } |
1301 | } |
1182 | } |
1302 | |
1183 | |
1303 | fclose (file); |
1184 | fclose (file); |
… | |
… | |
1312 | |
1193 | |
1313 | for (list = first_race; list; list = list->next) |
1194 | for (list = first_race; list; list = list->next) |
1314 | { |
1195 | { |
1315 | fprintf (stderr, "\nRACE %s:\t", &list->name); |
1196 | fprintf (stderr, "\nRACE %s:\t", &list->name); |
1316 | for (tmp = list->member; tmp; tmp = tmp->next) |
1197 | for (tmp = list->member; tmp; tmp = tmp->next) |
1317 | fprintf (stderr, "%s(%d), ", &tmp->ob->arch->name, tmp->ob->level); |
1198 | fprintf (stderr, "%s(%d), ", &tmp->ob->arch->archname, tmp->ob->level); |
1318 | } |
1199 | } |
1319 | |
1200 | |
1320 | fprintf (stderr, "\n"); |
1201 | fprintf (stderr, "\n"); |
1321 | } |
1202 | } |
1322 | |
1203 | |