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 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, |
… | |
… | |
135 | /* init_environ initialises values from the environmental variables. |
135 | /* init_environ initialises values from the environmental variables. |
136 | * 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 |
137 | * overwrite these if specified. |
137 | * overwrite these if specified. |
138 | */ |
138 | */ |
139 | void |
139 | void |
140 | init_environ (void) |
140 | init_environ () |
141 | { |
141 | { |
142 | const char *cp; |
142 | const char *cp; |
143 | |
143 | |
144 | if (cp = getenv ("DELIANTRA_CONFDIR" )) settings.confdir = cp; |
144 | if (cp = getenv ("DELIANTRA_CONFDIR" )) settings.confdir = cp; |
145 | if (cp = getenv ("DELIANTRA_LIBDIR" )) settings.datadir = cp; |
145 | if (cp = getenv ("DELIANTRA_LIBDIR" )) settings.datadir = cp; |
… | |
… | |
158 | /* |
158 | /* |
159 | * Initialises all global variables. |
159 | * Initialises all global variables. |
160 | * Might use environment-variables as default for some of them. |
160 | * Might use environment-variables as default for some of them. |
161 | */ |
161 | */ |
162 | void |
162 | void |
163 | init_globals (void) |
163 | init_globals () |
164 | { |
164 | { |
165 | if (settings.logfilename[0] == 0) |
165 | if (settings.logfilename[0] == 0) |
166 | set_logfd (-1); |
166 | set_logfd (-1); |
167 | else |
167 | else |
168 | { |
168 | { |
… | |
… | |
177 | } |
177 | } |
178 | } |
178 | } |
179 | } |
179 | } |
180 | |
180 | |
181 | void |
181 | void |
182 | init_dynamic (void) |
182 | init_dynamic () |
183 | { |
183 | { |
184 | first_map_ext_path = "/start/HallsOfSelection"; |
184 | first_map_ext_path = "/start/HallsOfSelection"; |
185 | first_map_path = "/HallOfSelection"; |
185 | first_map_path = "/HallOfSelection"; |
186 | } |
186 | } |
187 | |
187 | |
… | |
… | |
191 | */ |
191 | */ |
192 | |
192 | |
193 | //attackmess_t attack_mess[NROFATTACKMESS][MAXATTACKMESS]; |
193 | //attackmess_t attack_mess[NROFATTACKMESS][MAXATTACKMESS]; |
194 | |
194 | |
195 | void |
195 | void |
196 | init_attackmess (void) |
196 | init_attackmess () |
197 | { |
197 | { |
198 | char buf[MAX_BUF]; |
198 | char buf[MAX_BUF]; |
199 | char filename[MAX_BUF]; |
199 | char filename[MAX_BUF]; |
200 | char *cp, *p; |
200 | char *cp, *p; |
201 | FILE *fp; |
201 | FILE *fp; |
202 | static int has_been_done = 0; |
202 | static int has_been_done = 0; |
203 | int mess, level, comp; |
203 | int msgnum, level, comp; |
204 | int mode = 0, total = 0; |
204 | int mode = 0, total = 0; |
205 | |
205 | |
206 | if (has_been_done) |
206 | if (has_been_done) |
207 | return; |
207 | return; |
208 | else |
208 | else |
… | |
… | |
231 | |
231 | |
232 | if (strncmp (cp, "TYPE:", 5) == 0) |
232 | if (strncmp (cp, "TYPE:", 5) == 0) |
233 | { |
233 | { |
234 | p = strtok (buf, ":"); |
234 | p = strtok (buf, ":"); |
235 | p = strtok (NULL, ":"); |
235 | p = strtok (NULL, ":"); |
|
|
236 | |
236 | if (mode == 1) |
237 | if (mode == 1) |
237 | { |
238 | { |
238 | attack_mess[mess][level].level = -1; |
239 | attack_mess[msgnum][level].level = -1; |
239 | attack_mess[mess][level].buf1 = NULL; |
240 | attack_mess[msgnum][level].buf1 = NULL; |
240 | attack_mess[mess][level].buf2 = NULL; |
241 | attack_mess[msgnum][level].buf2 = NULL; |
241 | attack_mess[mess][level].buf3 = NULL; |
242 | attack_mess[msgnum][level].buf3 = NULL; |
242 | } |
243 | } |
243 | |
244 | |
244 | level = 0; |
245 | level = 0; |
245 | mess = atoi (p); |
246 | msgnum = atoi (p); |
246 | mode = 1; |
247 | mode = 1; |
247 | continue; |
|
|
248 | } |
248 | } |
249 | |
|
|
250 | if (mode == 1) |
249 | else if (mode == 1) |
251 | { |
250 | { |
252 | p = strtok (buf, "="); |
251 | p = strtok (buf, "="); |
253 | attack_mess[mess][level].level = atoi (buf); |
252 | attack_mess[msgnum][level].level = atoi (buf); |
254 | p = strtok (NULL, "="); |
253 | p = strtok (NULL, "="); |
|
|
254 | |
255 | if (p != NULL) |
255 | if (p != NULL) |
256 | attack_mess[mess][level].buf1 = strdup (p); |
256 | attack_mess[msgnum][level].buf1 = strdup (p); |
257 | else |
257 | else |
258 | attack_mess[mess][level].buf1 = strdup (""); |
258 | attack_mess[msgnum][level].buf1 = strdup (""); |
|
|
259 | |
259 | mode = 2; |
260 | mode = 2; |
260 | continue; |
|
|
261 | } |
261 | } |
262 | else if (mode == 2) |
262 | else if (mode == 2) |
263 | { |
263 | { |
264 | p = strtok (buf, "="); |
264 | p = strtok (buf, "="); |
265 | attack_mess[mess][level].level = atoi (buf); |
265 | attack_mess[msgnum][level].level = atoi (buf); |
266 | p = strtok (NULL, "="); |
266 | p = strtok (NULL, "="); |
|
|
267 | |
267 | if (p != NULL) |
268 | if (p != NULL) |
268 | attack_mess[mess][level].buf2 = strdup (p); |
269 | attack_mess[msgnum][level].buf2 = strdup (p); |
269 | else |
270 | else |
270 | attack_mess[mess][level].buf2 = strdup (""); |
271 | attack_mess[msgnum][level].buf2 = strdup (""); |
|
|
272 | |
271 | mode = 3; |
273 | mode = 3; |
272 | continue; |
|
|
273 | } |
274 | } |
274 | else if (mode == 3) |
275 | else if (mode == 3) |
275 | { |
276 | { |
276 | p = strtok (buf, "="); |
277 | p = strtok (buf, "="); |
277 | attack_mess[mess][level].level = atoi (buf); |
278 | attack_mess[msgnum][level].level = atoi (buf); |
278 | p = strtok (NULL, "="); |
279 | p = strtok (NULL, "="); |
|
|
280 | |
279 | if (p != NULL) |
281 | if (p != NULL) |
280 | attack_mess[mess][level].buf3 = strdup (p); |
282 | attack_mess[msgnum][level].buf3 = strdup (p); |
281 | else |
283 | else |
282 | attack_mess[mess][level].buf3 = strdup (""); |
284 | attack_mess[msgnum][level].buf3 = strdup (""); |
|
|
285 | |
283 | mode = 1; |
286 | mode = 1; |
284 | level++; |
287 | level++; |
285 | total++; |
288 | total++; |
286 | continue; |
|
|
287 | } |
289 | } |
288 | } |
290 | } |
289 | |
291 | |
290 | 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); |
291 | close_and_delete (fp, comp); |
293 | close_and_delete (fp, comp); |
292 | } |
294 | } |
293 | |
295 | |