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

Comparing deliantra/server/server/main.C (file contents):
Revision 1.80 by pippijn, Sat Jan 6 14:42:30 2007 UTC vs.
Revision 1.81 by root, Sun Jan 7 02:39:14 2007 UTC

264 flag = 0; 264 flag = 0;
265 for_all_players (pl) 265 for_all_players (pl)
266 { 266 {
267 pl->refcnt_chk (); 267 pl->refcnt_chk ();
268 268
269 if (!pl->ob || !pl->ns || !pl->ob->active ()) 269 if (!pl->ob || !pl->ns || !pl->ob->active)
270 continue; 270 continue;
271 271
272 if (pl->ob->speed_left > 0) 272 if (pl->ob->speed_left > 0)
273 if (handle_newcs_player (pl->ob)) 273 if (handle_newcs_player (pl->ob))
274 flag = 1; 274 flag = 1;
279 * player quits - they exist for purposes of tracking on the map, 279 * player quits - they exist for purposes of tracking on the map,
280 * but don't actually reside on any actual map. 280 * but don't actually reside on any actual map.
281 */ 281 */
282 if (QUERY_FLAG (pl->ob, FLAG_REMOVED)) 282 if (QUERY_FLAG (pl->ob, FLAG_REMOVED))
283 continue; 283 continue;
284
285#ifdef AUTOSAVE
286 /* check for ST_PLAYING state so that we don't try to save off when
287 * the player is logging in.
288 */
289 if ((pl->last_save_tick + AUTOSAVE) < (uint32) pticks && pl->ns->state == ST_PLAYING)
290 {
291 pl->ob->contr->save ();
292 pl->last_save_tick = pticks;
293 }
294#endif
295 } /* end of for loop for all the players */ 284 } /* end of for loop for all the players */
296 } /* for flag */ 285 } /* for flag */
297 286
298 for_all_players (pl) 287 for_all_players (pl)
299 { 288 {
300 if (!pl->ob || !pl->ns || !pl->ob->active ()) 289 if (!pl->ob || !pl->ns || !pl->ob->active)
301 continue; 290 continue;
302 291
303 if (settings.casting_time) 292 if (settings.casting_time)
304 { 293 {
305 if (pl->ob->casting_time > 0) 294 if (pl->ob->casting_time > 0)
345} 334}
346 335
347void 336void
348process_events () 337process_events ()
349{ 338{
350 object *op;
351
352 static object_ptr marker_;
353
354 if (!marker_)
355 marker_ = object::create ();
356
357 object *marker = marker_;
358
359 process_players1 (); 339 process_players1 ();
360 340
361 marker->active_next = active_objects; 341 for_all_actives (op)
362
363 if (marker->active_next)
364 marker->active_next->active_prev = marker;
365
366 marker->active_prev = 0;
367 active_objects = marker;
368
369 while (marker->active_next)
370 { 342 {
371 op = marker->active_next;
372
373 /* Move marker forward - swap op and marker */
374 op->active_prev = marker->active_prev;
375
376 if (op->active_prev)
377 op->active_prev->active_next = op;
378 else
379 active_objects = op;
380
381 marker->active_next = op->active_next;
382
383 if (marker->active_next)
384 marker->active_next->active_prev = marker;
385
386 marker->active_prev = op;
387 op->active_next = marker;
388
389 /* Now process op */ 343 /* Now process op */
390 if (QUERY_FLAG (op, FLAG_FREED)) 344 if (QUERY_FLAG (op, FLAG_FREED))
391 { 345 {
392 LOG (llevError, "BUG: process_events(): Free object on list\n"); 346 LOG (llevError, "BUG: process_events(): Free object on list\n");
393 op->set_speed (0); 347 op->set_speed (0);
473 427
474 if (op->speed_left <= 0) 428 if (op->speed_left <= 0)
475 op->speed_left += FABS (op->speed); 429 op->speed_left += FABS (op->speed);
476 } 430 }
477 431
478 /* Remove marker object from active list */
479 if (marker->active_prev != NULL)
480 marker->active_prev->active_next = NULL;
481 else
482 active_objects = NULL;
483
484 process_players2 (); 432 process_players2 ();
485} 433}
486 434
487/* clean up everything before exiting */ 435/* clean up everything before exiting */
488void 436void
489emergency_save () 437emergency_save ()
490{ 438{
491 LOG (llevDebug, "emergency save begin.\n"); 439 LOG (llevDebug, "emergency save begin.\n");
492 440
493 LOG (llevDebug, "saving players.\n");
494 for_all_players (pl)
495 if (pl->enable_save && pl->ob && pl->ns)
496 {
497 pl->save (true);
498 pl->enable_save = true;
499 }
500
501// for_all_players (pl)
502// if (pl->ob)
503// pl->ob->remove ();
504
505 LOG (llevDebug, "saving maps.\n");
506 maptile::emergency_save (); 441 maptile::emergency_save ();
507 442
508 LOG (llevDebug, "saving book archive.\n"); 443 LOG (llevDebug, "saving book archive.\n");
509 write_book_archive (); 444 write_book_archive ();
510 445

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines