ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/init.C
(Generate patch)

Comparing deliantra/server/common/init.C (file contents):
Revision 1.29 by root, Wed Mar 14 00:04:58 2007 UTC vs.
Revision 1.33 by root, Mon Apr 16 11:09:30 2007 UTC

148void 148void
149init_library (void) 149init_library (void)
150{ 150{
151 init_globals (); 151 init_globals ();
152 init_block (); 152 init_block ();
153 init_anim (); /* Must be after we read in the bitmaps */
154 init_archetypes (); /* Reads all archetypes from file */
155 init_dynamic (); 153 init_dynamic ();
156 init_attackmess (); 154 init_attackmess ();
157 init_clocks ();
158 init_experience (); 155 init_experience ();
159} 156}
160
161 157
162/* init_environ initialises values from the environmental variables. 158/* init_environ initialises values from the environmental variables.
163 * it needs to be called very early, since command line options should 159 * it needs to be called very early, since command line options should
164 * overwrite these if specified. 160 * overwrite these if specified.
165 */ 161 */
169 char *cp; 165 char *cp;
170 166
171 cp = getenv ("CROSSFIRE_LIBDIR"); 167 cp = getenv ("CROSSFIRE_LIBDIR");
172 if (cp) 168 if (cp)
173 settings.datadir = cp; 169 settings.datadir = cp;
170
174 cp = getenv ("CROSSFIRE_LOCALDIR"); 171 cp = getenv ("CROSSFIRE_LOCALDIR");
175 if (cp) 172 if (cp)
176 settings.localdir = cp; 173 settings.localdir = cp;
174
177 cp = getenv ("CROSSFIRE_PLAYERDIR"); 175 cp = getenv ("CROSSFIRE_PLAYERDIR");
178 if (cp) 176 if (cp)
179 settings.playerdir = cp; 177 settings.playerdir = cp;
178
180 cp = getenv ("CROSSFIRE_MAPDIR"); 179 cp = getenv ("CROSSFIRE_MAPDIR");
181 if (cp) 180 if (cp)
182 settings.mapdir = cp; 181 settings.mapdir = cp;
182
183 cp = getenv ("CROSSFIRE_ARCHETYPES"); 183 cp = getenv ("CROSSFIRE_ARCHETYPES");
184 if (cp) 184 if (cp)
185 settings.archetypes = cp; 185 settings.archetypes = cp;
186
186 cp = getenv ("CROSSFIRE_TREASURES"); 187 cp = getenv ("CROSSFIRE_TREASURES");
187 if (cp) 188 if (cp)
188 settings.treasures = cp; 189 settings.treasures = cp;
190
189 cp = getenv ("CROSSFIRE_UNIQUEDIR"); 191 cp = getenv ("CROSSFIRE_UNIQUEDIR");
190 if (cp) 192 if (cp)
191 settings.uniquedir = cp; 193 settings.uniquedir = cp;
194
192 cp = getenv ("CROSSFIRE_TEMPLATEDIR"); 195 cp = getenv ("CROSSFIRE_TEMPLATEDIR");
193 if (cp) 196 if (cp)
194 settings.templatedir = cp; 197 settings.templatedir = cp;
198
195 cp = getenv ("CROSSFIRE_TMPDIR"); 199 cp = getenv ("CROSSFIRE_TMPDIR");
196 if (cp) 200 if (cp)
197 settings.tmpdir = cp; 201 settings.tmpdir = cp;
198} 202}
199 203
235 } 239 }
236 240
237 at = at->next; 241 at = at->next;
238 } 242 }
239 243
240 LOG (llevDebug, "You Need a archetype called 'map' and it have to contain start map\n"); 244 LOG (llevDebug, "You need an archetype of type 'map' and it has to contain the player start map\n");
241 exit (-1); 245 exit (-1);
242}
243
244unsigned long todtick;
245
246/*
247 * Write out the current time to the file so time does not
248 * reset every time the server reboots.
249 */
250void
251write_todclock (void)
252{
253 char filename[MAX_BUF];
254 FILE *fp;
255
256 sprintf (filename, "%s/clockdata", settings.localdir);
257 if ((fp = fopen (filename, "w")) == NULL)
258 {
259 LOG (llevError, "Cannot open %s for writing\n", filename);
260 return;
261 }
262 fprintf (fp, "%lu", todtick);
263 fclose (fp);
264}
265
266/*
267 * initialises the gametime and TOD counters
268 * Called by init_library().
269 */
270void
271init_clocks (void)
272{
273 char filename[MAX_BUF];
274 FILE *fp;
275 static int has_been_done = 0;
276
277 if (has_been_done)
278 return;
279 else
280 has_been_done = 1;
281
282 sprintf (filename, "%s/clockdata", settings.localdir);
283 LOG (llevDebug, "Reading clockdata from %s...\n", filename);
284 if ((fp = fopen (filename, "r")) == NULL)
285 {
286 LOG (llevError, "Can't open %s.\n", filename);
287 todtick = 0;
288 write_todclock ();
289 return;
290 }
291
292 fscanf (fp, "%lu", &todtick);
293 LOG (llevDebug, "todtick=%lu\n", todtick);
294 fclose (fp);
295} 246}
296 247
297/* 248/*
298 * initialises the attack messages. 249 * initialises the attack messages.
299 * Called by init_library(). 250 * Called by init_library().

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines