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.129 by root, Tue May 6 16:55:26 2008 UTC vs.
Revision 1.132 by root, Mon Sep 29 10:20:49 2008 UTC

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 {
210 golem->destroy_inv (true); // be explicit about dropping
209 golem->destroy (); 211 golem->destroy (true);
212 }
210 else 213 else
211 { 214 {
212 newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]); 215 newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]);
213 golem->direction = find_dir_2 (x - golem->x, y - golem->y); 216 golem->direction = find_dir_2 (x - golem->x, y - golem->y);
214 } 217 }
384 LOG (llevDebug, "cleanup done.\n"); 387 LOG (llevDebug, "cleanup done.\n");
385 388
386 log_cleanup (); 389 log_cleanup ();
387 390
388 if (make_core) 391 if (make_core)
389 {
390 cleanup_inform (cause, make_core); 392 cleanup_inform (cause, make_core);
391 cfperl_cleanup (make_core);
392 _exit (1);
393 }
394 else 393 else
395 { 394 {
396 new_draw_info_format (NDI_REPLY | NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "Maps and players successfully saved, exiting."); 395 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); 396 new_draw_info_format (NDI_REPLY | NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "And again: " CLEANUP_MESSAGE);
398 client::flush_sockets (); 397 client::flush_sockets ();
398 }
399
399 cfperl_cleanup (make_core); 400 cfperl_cleanup (make_core);
400 _exit (0); 401 _exit (make_core);
401 }
402} 402}
403 403
404/* 404/*
405 * do_specials() is a collection of functions to call from time to time. 405 * 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 406 * Modified 2000-1-14 MSW to use the global pticks count to determine how
500 } 500 }
501} 501}
502 502
503#else 503#else
504 504
505#if 0 // just goofing around, look elsewhere
506
507#include <malloc.h>
508#include <execinfo.h>
509
510static void tr_on ();
511static void tr_off ();
512
513static SMUTEX(tr_mutex);
514
515#define ltr_off() SMUTEX_LOCK (tr_mutex); tr_off ()
516#define ltr_on() tr_on (); SMUTEX_UNLOCK (tr_mutex);
517
518static void *
519tr_malloc (size_t size, const void *caller)
520{
521 ltr_off ();
522
523 void *bt [8];
524 backtrace (bt, 8);
525
526 void *ptr = malloc (size);
527
528 ltr_on ();
529 return (char *)ptr;
530}
531
532static void
533tr_free (void *ptr, const void *caller)
534{
535 ltr_off ();
536
537 free (ptr);
538
539 ltr_on ();
540}
541
542void static *
543tr_realloc (void *ptr, size_t size, const void *caller)
544{
545 ltr_off ();
546
547 void *nptr = realloc (ptr, size);
548
549 ltr_on ();
550 return nptr;
551}
552
553static void *
554tr_memalign (size_t size, size_t alignment, const void *caller)
555{
556 ltr_off ();
557
558 void *ptr = memalign (size, alignment < 16 ? 16 : alignment);
559
560 ltr_on ();
561 return ptr;
562}
563
564static void
565tr_on ()
566{
567 __malloc_hook = tr_malloc;
568 __realloc_hook = tr_realloc;
569 __free_hook = tr_free;
570 __memalign_hook = tr_memalign;
571}
572
573static void
574tr_off ()
575{
576 __malloc_hook = 0;
577 __realloc_hook = 0;
578 __free_hook = 0;
579 __memalign_hook = 0;
580}
581
582void (*__malloc_initialize_hook)(void) = tr_on;
583
584#endif
585
505// normal main 586// normal main
506int 587int
507main (int argc, char **argv) 588main (int argc, char **argv)
508{ 589{
509 settings.argc = argc; 590 settings.argc = argc;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines