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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines