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.128 by root, Sun May 4 15:22:14 2008 UTC vs.
Revision 1.133 by root, Mon Sep 29 10:31:32 2008 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * 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
204 if (object *golem = contr->golem) 204 if (object *golem = contr->golem)
205 { 205 {
206 int i = find_free_spot (golem, newmap, x, y, 1, SIZEOFFREE); 206 int i = find_free_spot (golem, newmap, x, y, 1, SIZEOFFREE);
207 207
208 if (i < 0) 208 if (i < 0)
209 golem->destroy (); 209 golem->drop_and_destroy ();
210 else 210 else
211 { 211 {
212 newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]); 212 newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]);
213 golem->direction = find_dir_2 (x - golem->x, y - golem->y); 213 golem->direction = find_dir_2 (x - golem->x, y - golem->y);
214 } 214 }
384 LOG (llevDebug, "cleanup done.\n"); 384 LOG (llevDebug, "cleanup done.\n");
385 385
386 log_cleanup (); 386 log_cleanup ();
387 387
388 if (make_core) 388 if (make_core)
389 {
390 cleanup_inform (cause, make_core); 389 cleanup_inform (cause, make_core);
391 cfperl_cleanup (make_core);
392 _exit (1);
393 }
394 else 390 else
395 { 391 {
396 new_draw_info_format (NDI_REPLY | NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "Maps and players successfully saved, exiting."); 392 new_draw_info_format (NDI_REPLY | NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "Maps and players successfully saved, exiting.");
397 new_draw_info_format (NDI_REPLY | NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "And again: " CLEANUP_MESSAGE); 393 new_draw_info_format (NDI_REPLY | NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "And again: " CLEANUP_MESSAGE);
398 client::flush_sockets (); 394 client::flush_sockets ();
395 }
396
399 cfperl_cleanup (make_core); 397 cfperl_cleanup (make_core);
400 _exit (0); 398 _exit (make_core);
401 }
402} 399}
403 400
404/* 401/*
405 * do_specials() is a collection of functions to call from time to time. 402 * do_specials() is a collection of functions to call from time to time.
406 * Modified 2000-1-14 MSW to use the global pticks count to determine how 403 * Modified 2000-1-14 MSW to use the global pticks count to determine how
500 } 497 }
501} 498}
502 499
503#else 500#else
504 501
502#if 0 // just goofing around, look elsewhere
503
504#include <malloc.h>
505#include <execinfo.h>
506
507static void tr_on ();
508static void tr_off ();
509
510static SMUTEX(tr_mutex);
511
512#define ltr_off() SMUTEX_LOCK (tr_mutex); tr_off ()
513#define ltr_on() tr_on (); SMUTEX_UNLOCK (tr_mutex);
514
515static void *
516tr_malloc (size_t size, const void *caller)
517{
518 ltr_off ();
519
520 void *bt [8];
521 backtrace (bt, 8);
522
523 void *ptr = malloc (size);
524
525 ltr_on ();
526 return (char *)ptr;
527}
528
529static void
530tr_free (void *ptr, const void *caller)
531{
532 ltr_off ();
533
534 free (ptr);
535
536 ltr_on ();
537}
538
539void static *
540tr_realloc (void *ptr, size_t size, const void *caller)
541{
542 ltr_off ();
543
544 void *nptr = realloc (ptr, size);
545
546 ltr_on ();
547 return nptr;
548}
549
550static void *
551tr_memalign (size_t size, size_t alignment, const void *caller)
552{
553 ltr_off ();
554
555 void *ptr = memalign (size, alignment < 16 ? 16 : alignment);
556
557 ltr_on ();
558 return ptr;
559}
560
561static void
562tr_on ()
563{
564 __malloc_hook = tr_malloc;
565 __realloc_hook = tr_realloc;
566 __free_hook = tr_free;
567 __memalign_hook = tr_memalign;
568}
569
570static void
571tr_off ()
572{
573 __malloc_hook = 0;
574 __realloc_hook = 0;
575 __free_hook = 0;
576 __memalign_hook = 0;
577}
578
579void (*__malloc_initialize_hook)(void) = tr_on;
580
581#endif
582
505// normal main 583// normal main
506int 584int
507main (int argc, char **argv) 585main (int argc, char **argv)
508{ 586{
509 settings.argc = argc; 587 settings.argc = argc;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines