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.78 by root, Thu Jan 4 16:19:32 2007 UTC vs.
Revision 1.80 by pippijn, Sat Jan 6 14:42:30 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2001-2003 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2001-2003 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
508 write_book_archive (); 509 write_book_archive ();
509 510
510 LOG (llevDebug, "emergency save done.\n"); 511 LOG (llevDebug, "emergency save done.\n");
511} 512}
512 513
514// send all clients some informational text
515static void
516cleanup_inform (const char *cause, bool make_core)
517{
518 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "The server will now shutdown.\n");
519 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "Cause for this shtudown: %s\n", cause);
520
521 if (make_core)
522 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "This is considered a crash.\n");
523 else
524 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "This is considered to be a clean shutdown.\n");
525
526 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "%s\n", CLEANUP_MESSAGE);
527
528 flush_sockets ();
529}
530
513/* clean up everything before exiting */ 531/* clean up everything before exiting */
514void 532void
515cleanup (bool make_core) 533cleanup (const char *cause, bool make_core)
516{ 534{
535 LOG (llevError, "cleanup cause: %s\n", cause);
536
537 if (!make_core)
538 cleanup_inform (cause, make_core);
539
517 LOG (llevDebug, "cleanup begin.\n"); 540 LOG (llevDebug, "cleanup begin.\n");
518 541
519 if (init_done && !in_cleanup) 542 if (init_done && !in_cleanup)
520 { 543 {
521 in_cleanup = true; 544 in_cleanup = true;
528 INVOKE_GLOBAL (CLEANUP); 551 INVOKE_GLOBAL (CLEANUP);
529 552
530 LOG (llevDebug, "cleanup done.\n"); 553 LOG (llevDebug, "cleanup done.\n");
531 554
532 if (make_core) 555 if (make_core)
556 {
557 cleanup_inform (cause, make_core);
533 abort (); 558 abort ();
559 }
534 else 560 else
535 _exit (0); 561 _exit (0);
536} 562}
537 563
538int 564int
652 678
653 initPlugins (); 679 initPlugins ();
654 680
655 for (;;) 681 for (;;)
656 cfperl_main (); 682 cfperl_main ();
657
658 cleanup (true);
659} 683}
660 684

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines