1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
72 | NULL, /* argv */ |
72 | NULL, /* argv */ |
73 | CONFDIR, |
73 | CONFDIR, |
74 | DATADIR, |
74 | DATADIR, |
75 | LOCALDIR, |
75 | LOCALDIR, |
76 | PLAYERDIR, MAPDIR, ARCHETYPES, REGIONS, TREASURES, |
76 | PLAYERDIR, MAPDIR, ARCHETYPES, REGIONS, TREASURES, |
77 | UNIQUE_DIR, TEMPLATE_DIR, |
77 | UNIQUE_DIR, "", |
78 | TMPDIR, |
78 | TMPDIR, |
79 | PK_LUCK_PENALTY, |
79 | PK_LUCK_PENALTY, |
80 | STAT_LOSS_ON_DEATH, |
80 | STAT_LOSS_ON_DEATH, |
81 | PERMANENT_EXPERIENCE_RATIO, |
81 | PERMANENT_EXPERIENCE_RATIO, |
82 | DEATH_PENALTY_RATIO, |
82 | DEATH_PENALTY_RATIO, |
… | |
… | |
92 | SET_FRIENDLY_FIRE, |
92 | SET_FRIENDLY_FIRE, |
93 | 0, |
93 | 0, |
94 | 0, |
94 | 0, |
95 | EXPLORE_MODE, |
95 | EXPLORE_MODE, |
96 | SPELLPOINT_LEVEL_DEPEND, |
96 | SPELLPOINT_LEVEL_DEPEND, |
97 | MOTD, |
|
|
98 | "rules", |
|
|
99 | "news", |
|
|
100 | "", /* DM_MAIL */ |
|
|
101 | 0, 0, 0, 0, 0, 0, 0, 0, /* worldmap settings */ |
|
|
102 | 0, |
97 | 0, |
103 | 1.0, |
98 | 1.0, |
104 | |
99 | |
105 | /* Armor enchantment stuff */ |
100 | /* Armor enchantment stuff */ |
106 | ARMOR_MAX_ENCHANT, |
101 | ARMOR_MAX_ENCHANT, |
… | |
… | |
140 | /* init_environ initialises values from the environmental variables. |
135 | /* init_environ initialises values from the environmental variables. |
141 | * it needs to be called very early, since command line options should |
136 | * it needs to be called very early, since command line options should |
142 | * overwrite these if specified. |
137 | * overwrite these if specified. |
143 | */ |
138 | */ |
144 | void |
139 | void |
145 | init_environ (void) |
140 | init_environ () |
146 | { |
141 | { |
147 | const char *cp; |
142 | const char *cp; |
148 | |
143 | |
149 | if (cp = getenv ("DELIANTRA_CONFDIR" )) settings.confdir = cp; |
144 | if (cp = getenv ("DELIANTRA_CONFDIR" )) settings.confdir = cp; |
150 | if (cp = getenv ("DELIANTRA_LIBDIR" )) settings.datadir = cp; |
145 | if (cp = getenv ("DELIANTRA_LIBDIR" )) settings.datadir = cp; |
… | |
… | |
163 | /* |
158 | /* |
164 | * Initialises all global variables. |
159 | * Initialises all global variables. |
165 | * Might use environment-variables as default for some of them. |
160 | * Might use environment-variables as default for some of them. |
166 | */ |
161 | */ |
167 | void |
162 | void |
168 | init_globals (void) |
163 | init_globals () |
169 | { |
164 | { |
170 | if (settings.logfilename[0] == 0) |
165 | if (settings.logfilename[0] == 0) |
171 | set_logfd (-1); |
166 | log_setfd (-1); |
172 | else |
167 | else |
173 | { |
168 | { |
174 | int logfd = open (settings.logfilename, O_CREAT|O_WRONLY|O_APPEND, 0666); |
169 | int logfd = open (settings.logfilename, O_CREAT|O_WRONLY|O_APPEND, 0666); |
175 | |
170 | |
176 | if (logfd >= 0) |
171 | if (logfd >= 0) |
177 | set_logfd (logfd); |
172 | log_setfd (logfd); |
178 | else |
173 | else |
179 | { |
174 | { |
180 | set_logfd (-1); |
175 | log_setfd (-1); |
181 | LOG (llevError, "Unable to open %s as the logfile - will use stderr instead", settings.logfilename); |
176 | LOG (llevError, "Unable to open %s as the logfile - will use stderr instead", settings.logfilename); |
182 | } |
177 | } |
183 | } |
178 | } |
184 | } |
179 | } |
185 | |
180 | |
186 | void |
181 | void |
187 | init_dynamic (void) |
182 | init_dynamic () |
188 | { |
183 | { |
189 | first_map_ext_path = "/start/HallsOfSelection"; |
184 | first_map_ext_path = "/start/HallsOfSelection"; |
190 | first_map_path = "/HallOfSelection"; |
185 | first_map_path = "/HallOfSelection"; |
191 | } |
186 | } |
192 | |
187 | |
… | |
… | |
196 | */ |
191 | */ |
197 | |
192 | |
198 | //attackmess_t attack_mess[NROFATTACKMESS][MAXATTACKMESS]; |
193 | //attackmess_t attack_mess[NROFATTACKMESS][MAXATTACKMESS]; |
199 | |
194 | |
200 | void |
195 | void |
201 | init_attackmess (void) |
196 | init_attackmess () |
202 | { |
197 | { |
203 | char buf[MAX_BUF]; |
198 | char buf[MAX_BUF]; |
204 | char filename[MAX_BUF]; |
199 | char filename[MAX_BUF]; |
205 | char *cp, *p; |
200 | char *cp, *p; |
206 | FILE *fp; |
201 | FILE *fp; |
207 | static int has_been_done = 0; |
202 | static int has_been_done = 0; |
208 | int mess, level, comp; |
203 | int msgnum, level, comp; |
209 | int mode = 0, total = 0; |
204 | int mode = 0, total = 0; |
210 | |
205 | |
211 | if (has_been_done) |
206 | if (has_been_done) |
212 | return; |
207 | return; |
213 | else |
208 | else |
… | |
… | |
236 | |
231 | |
237 | if (strncmp (cp, "TYPE:", 5) == 0) |
232 | if (strncmp (cp, "TYPE:", 5) == 0) |
238 | { |
233 | { |
239 | p = strtok (buf, ":"); |
234 | p = strtok (buf, ":"); |
240 | p = strtok (NULL, ":"); |
235 | p = strtok (NULL, ":"); |
|
|
236 | |
241 | if (mode == 1) |
237 | if (mode == 1) |
242 | { |
238 | { |
243 | attack_mess[mess][level].level = -1; |
239 | attack_mess[msgnum][level].level = -1; |
244 | attack_mess[mess][level].buf1 = NULL; |
240 | attack_mess[msgnum][level].buf1 = NULL; |
245 | attack_mess[mess][level].buf2 = NULL; |
241 | attack_mess[msgnum][level].buf2 = NULL; |
246 | attack_mess[mess][level].buf3 = NULL; |
242 | attack_mess[msgnum][level].buf3 = NULL; |
247 | } |
243 | } |
248 | |
244 | |
249 | level = 0; |
245 | level = 0; |
250 | mess = atoi (p); |
246 | msgnum = atoi (p); |
251 | mode = 1; |
247 | mode = 1; |
252 | continue; |
|
|
253 | } |
248 | } |
254 | |
|
|
255 | if (mode == 1) |
249 | else if (mode == 1) |
256 | { |
250 | { |
257 | p = strtok (buf, "="); |
251 | p = strtok (buf, "="); |
258 | attack_mess[mess][level].level = atoi (buf); |
252 | attack_mess[msgnum][level].level = atoi (buf); |
259 | p = strtok (NULL, "="); |
253 | p = strtok (NULL, "="); |
|
|
254 | |
260 | if (p != NULL) |
255 | if (p != NULL) |
261 | attack_mess[mess][level].buf1 = strdup (p); |
256 | attack_mess[msgnum][level].buf1 = strdup (p); |
262 | else |
257 | else |
263 | attack_mess[mess][level].buf1 = strdup (""); |
258 | attack_mess[msgnum][level].buf1 = strdup (""); |
|
|
259 | |
264 | mode = 2; |
260 | mode = 2; |
265 | continue; |
|
|
266 | } |
261 | } |
267 | else if (mode == 2) |
262 | else if (mode == 2) |
268 | { |
263 | { |
269 | p = strtok (buf, "="); |
264 | p = strtok (buf, "="); |
270 | attack_mess[mess][level].level = atoi (buf); |
265 | attack_mess[msgnum][level].level = atoi (buf); |
271 | p = strtok (NULL, "="); |
266 | p = strtok (NULL, "="); |
|
|
267 | |
272 | if (p != NULL) |
268 | if (p != NULL) |
273 | attack_mess[mess][level].buf2 = strdup (p); |
269 | attack_mess[msgnum][level].buf2 = strdup (p); |
274 | else |
270 | else |
275 | attack_mess[mess][level].buf2 = strdup (""); |
271 | attack_mess[msgnum][level].buf2 = strdup (""); |
|
|
272 | |
276 | mode = 3; |
273 | mode = 3; |
277 | continue; |
|
|
278 | } |
274 | } |
279 | else if (mode == 3) |
275 | else if (mode == 3) |
280 | { |
276 | { |
281 | p = strtok (buf, "="); |
277 | p = strtok (buf, "="); |
282 | attack_mess[mess][level].level = atoi (buf); |
278 | attack_mess[msgnum][level].level = atoi (buf); |
283 | p = strtok (NULL, "="); |
279 | p = strtok (NULL, "="); |
|
|
280 | |
284 | if (p != NULL) |
281 | if (p != NULL) |
285 | attack_mess[mess][level].buf3 = strdup (p); |
282 | attack_mess[msgnum][level].buf3 = strdup (p); |
286 | else |
283 | else |
287 | attack_mess[mess][level].buf3 = strdup (""); |
284 | attack_mess[msgnum][level].buf3 = strdup (""); |
|
|
285 | |
288 | mode = 1; |
286 | mode = 1; |
289 | level++; |
287 | level++; |
290 | total++; |
288 | total++; |
291 | continue; |
|
|
292 | } |
289 | } |
293 | } |
290 | } |
294 | |
291 | |
295 | LOG (llevDebug, "got %d messages in %d categories.\n", total, mess + 1); |
292 | LOG (llevDebug, "got %d messages in %d categories.\n", total, msgnum + 1); |
296 | close_and_delete (fp, comp); |
293 | close_and_delete (fp, comp); |
297 | } |
294 | } |
298 | |
295 | |