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.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
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)
214 golem->destroy (); 209 golem->drop_and_destroy ();
215 else 210 else
216 { 211 {
217 newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]); 212 newmap->insert (golem, x + freearr_x[i], y + freearr_y[i]);
218 golem->direction = find_dir_2 (x - golem->x, y - golem->y); 213 golem->direction = find_dir_2 (x - golem->x, y - golem->y);
219 } 214 }
389 LOG (llevDebug, "cleanup done.\n"); 384 LOG (llevDebug, "cleanup done.\n");
390 385
391 log_cleanup (); 386 log_cleanup ();
392 387
393 if (make_core) 388 if (make_core)
394 {
395 cleanup_inform (cause, make_core); 389 cleanup_inform (cause, make_core);
396 cfperl_cleanup (make_core);
397 _exit (1);
398 }
399 else 390 else
400 { 391 {
401 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.");
402 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);
403 client::flush_sockets (); 394 client::flush_sockets ();
395 }
396
404 cfperl_cleanup (make_core); 397 cfperl_cleanup (make_core);
405 _exit (0); 398 _exit (make_core);
406 }
407} 399}
408 400
409/* 401/*
410 * 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.
411 * 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
505 } 497 }
506} 498}
507 499
508#else 500#else
509 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
510// normal main 583// normal main
511int 584int
512main (int argc, char **argv) 585main (int argc, char **argv)
513{ 586{
514 settings.argc = argc; 587 settings.argc = argc;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines