… | |
… | |
139 | * overwrite these if specified. |
139 | * overwrite these if specified. |
140 | */ |
140 | */ |
141 | void |
141 | void |
142 | init_environ (void) |
142 | init_environ (void) |
143 | { |
143 | { |
144 | char *cp; |
144 | const char *cp; |
145 | |
145 | |
146 | cp = getenv ("DELIANTRA_LIBDIR"); |
146 | if (cp = getenv ("DELIANTRA_CONFDIR" )) settings.confdir = cp; |
147 | if (cp) |
147 | if (cp = getenv ("DELIANTRA_LIBDIR" )) settings.datadir = cp; |
148 | settings.datadir = cp; |
148 | if (cp = getenv ("DELIANTRA_LOCALDIR" )) settings.localdir = cp; |
|
|
149 | if (cp = getenv ("DELIANTRA_PLAYERDIR" )) settings.playerdir = cp; |
|
|
150 | if (cp = getenv ("DELIANTRA_MAPDIR" )) settings.mapdir = cp; |
|
|
151 | if (cp = getenv ("DELIANTRA_ARCHETYPES" )) settings.archetypes = cp; |
|
|
152 | if (cp = getenv ("DELIANTRA_TREASURES" )) settings.treasures = cp; |
|
|
153 | if (cp = getenv ("DELIANTRA_UNIQUEDIR" )) settings.uniquedir = cp; |
|
|
154 | if (cp = getenv ("DELIANTRA_TEMPLATEDIR")) settings.templatedir = cp; |
|
|
155 | if (cp = getenv ("DELIANTRA_TMPDIR" )) settings.tmpdir = cp; |
149 | |
156 | |
150 | cp = getenv ("DELIANTRA_LOCALDIR"); |
157 | if (cp = getenv ("DELIANTRA_LOGFILE" )) settings.logfilename = cp; |
151 | if (cp) |
|
|
152 | settings.localdir = cp; |
|
|
153 | |
|
|
154 | cp = getenv ("DELIANTRA_PLAYERDIR"); |
|
|
155 | if (cp) |
|
|
156 | settings.playerdir = cp; |
|
|
157 | |
|
|
158 | cp = getenv ("DELIANTRA_MAPDIR"); |
|
|
159 | if (cp) |
|
|
160 | settings.mapdir = cp; |
|
|
161 | |
|
|
162 | cp = getenv ("DELIANTRA_ARCHETYPES"); |
|
|
163 | if (cp) |
|
|
164 | settings.archetypes = cp; |
|
|
165 | |
|
|
166 | cp = getenv ("DELIANTRA_TREASURES"); |
|
|
167 | if (cp) |
|
|
168 | settings.treasures = cp; |
|
|
169 | |
|
|
170 | cp = getenv ("DELIANTRA_UNIQUEDIR"); |
|
|
171 | if (cp) |
|
|
172 | settings.uniquedir = cp; |
|
|
173 | |
|
|
174 | cp = getenv ("DELIANTRA_TEMPLATEDIR"); |
|
|
175 | if (cp) |
|
|
176 | settings.templatedir = cp; |
|
|
177 | |
|
|
178 | cp = getenv ("DELIANTRA_TMPDIR"); |
|
|
179 | if (cp) |
|
|
180 | settings.tmpdir = cp; |
|
|
181 | } |
158 | } |
182 | |
159 | |
183 | /* |
160 | /* |
184 | * Initialises all global variables. |
161 | * Initialises all global variables. |
185 | * Might use environment-variables as default for some of them. |
162 | * Might use environment-variables as default for some of them. |
… | |
… | |
244 | level = 0; |
221 | level = 0; |
245 | while (fgets (buf, MAX_BUF, fp) != NULL) |
222 | while (fgets (buf, MAX_BUF, fp) != NULL) |
246 | { |
223 | { |
247 | if (*buf == '#') |
224 | if (*buf == '#') |
248 | continue; |
225 | continue; |
|
|
226 | |
249 | if ((cp = strchr (buf, '\n')) != NULL) |
227 | if ((cp = strchr (buf, '\n')) != NULL) |
250 | *cp = '\0'; |
228 | *cp = '\0'; |
|
|
229 | |
251 | cp = buf; |
230 | cp = buf; |
252 | while (*cp == ' ') /* Skip blanks */ |
231 | while (*cp == ' ') /* Skip blanks */ |
253 | cp++; |
232 | cp++; |
254 | |
233 | |
255 | if (strncmp (cp, "TYPE:", 5) == 0) |
234 | if (strncmp (cp, "TYPE:", 5) == 0) |
… | |
… | |
261 | attack_mess[mess][level].level = -1; |
240 | attack_mess[mess][level].level = -1; |
262 | attack_mess[mess][level].buf1 = NULL; |
241 | attack_mess[mess][level].buf1 = NULL; |
263 | attack_mess[mess][level].buf2 = NULL; |
242 | attack_mess[mess][level].buf2 = NULL; |
264 | attack_mess[mess][level].buf3 = NULL; |
243 | attack_mess[mess][level].buf3 = NULL; |
265 | } |
244 | } |
|
|
245 | |
266 | level = 0; |
246 | level = 0; |
267 | mess = atoi (p); |
247 | mess = atoi (p); |
268 | mode = 1; |
248 | mode = 1; |
269 | continue; |
249 | continue; |
270 | } |
250 | } |
|
|
251 | |
271 | if (mode == 1) |
252 | if (mode == 1) |
272 | { |
253 | { |
273 | p = strtok (buf, "="); |
254 | p = strtok (buf, "="); |
274 | attack_mess[mess][level].level = atoi (buf); |
255 | attack_mess[mess][level].level = atoi (buf); |
275 | p = strtok (NULL, "="); |
256 | p = strtok (NULL, "="); |
… | |
… | |
305 | level++; |
286 | level++; |
306 | total++; |
287 | total++; |
307 | continue; |
288 | continue; |
308 | } |
289 | } |
309 | } |
290 | } |
|
|
291 | |
310 | LOG (llevDebug, "got %d messages in %d categories.\n", total, mess + 1); |
292 | LOG (llevDebug, "got %d messages in %d categories.\n", total, mess + 1); |
311 | close_and_delete (fp, comp); |
293 | close_and_delete (fp, comp); |
312 | } |
294 | } |
|
|
295 | |