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.127 by root, Sat May 3 15:24:34 2008 UTC vs.
Revision 1.132 by root, Mon Sep 29 10:20:49 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
108 * goes someplace. 108 * goes someplace.
109 */ 109 */
110void 110void
111enter_player_savebed (object *op) 111enter_player_savebed (object *op)
112{ 112{
113 object *tmp = object::create (); 113 op->player_goto (op->contr->savebed_map, op->contr->bed_x, op->contr->bed_y);
114 EXIT_PATH (tmp) = op->contr->savebed_map;
115 EXIT_X (tmp) = op->contr->bed_x;
116 EXIT_Y (tmp) = op->contr->bed_y;
117 op->enter_exit (tmp);
118 tmp->destroy ();
119} 114}
120 115
121/* 116/*
122 * enter_map(): Moves the player and pets from current map (if any) to 117 * enter_map(): Moves the player and pets from current map (if any) to
123 * new map. map, x, y must be set. map is the map we are moving the 118 * new map. map, x, y must be set. map is the map we are moving the
209 if (object *golem = contr->golem) 204 if (object *golem = contr->golem)
210 { 205 {
211 int i = find_free_spot (golem, newmap, x, y, 1, SIZEOFFREE); 206 int i = find_free_spot (golem, newmap, x, y, 1, SIZEOFFREE);
212 207
213 if (i < 0) 208 if (i < 0)
209 {
210 golem->destroy_inv (true); // be explicit about dropping
214 golem->destroy (); 211 golem->destroy (true);
212 }
215 else 213 else
216 { 214 {
217 newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]); 215 newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]);
218 golem->direction = find_dir_2 (x - golem->x, y - golem->y); 216 golem->direction = find_dir_2 (x - golem->x, y - golem->y);
219 } 217 }
389 LOG (llevDebug, "cleanup done.\n"); 387 LOG (llevDebug, "cleanup done.\n");
390 388
391 log_cleanup (); 389 log_cleanup ();
392 390
393 if (make_core) 391 if (make_core)
394 {
395 cleanup_inform (cause, make_core); 392 cleanup_inform (cause, make_core);
396 cfperl_cleanup (make_core);
397 _exit (1);
398 }
399 else 393 else
400 { 394 {
401 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.");
402 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);
403 client::flush_sockets (); 397 client::flush_sockets ();
398 }
399
404 cfperl_cleanup (make_core); 400 cfperl_cleanup (make_core);
405 _exit (0); 401 _exit (make_core);
406 }
407} 402}
408 403
409/* 404/*
410 * 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.
411 * 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
505 } 500 }
506} 501}
507 502
508#else 503#else
509 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
510// normal main 586// normal main
511int 587int
512main (int argc, char **argv) 588main (int argc, char **argv)
513{ 589{
514 settings.argc = argc; 590 settings.argc = argc;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines