version 1.8 | | version 1.9 |
---|
| | |
/* | | /* |
* static char *rcsid_swap_c = | | * static char *rcsid_swap_c = |
* "$Id: swap.c,v 1.8 2001/10/14 08:12:37 gros Exp $"; | | * "$Id: swap.c,v 1.9 2002/04/21 05:23:20 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
Copyright (C) 2001 Mark Wedel | | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
Copyright (C) 1992 Frank Tore Johansen | | Copyright (C) 1992 Frank Tore Johansen |
| | |
This program is free software; you can redistribute it and/or modify | | This program is free software; you can redistribute it and/or modify |
| | |
along with this program; if not, write to the Free Software | | along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| | |
The author can be reached via e-mail to mwedel@scruz.net | | The author can be reached via e-mail to crossfire-devel@real-time.com |
*/ | | */ |
| | |
#include <global.h> | | #include <global.h> |
| | |
int evtid; | | int evtid; |
CFParm CFP; | | CFParm CFP; |
#endif | | #endif |
| | |
if(map->in_memory != MAP_IN_MEMORY) { | | if(map->in_memory != MAP_IN_MEMORY) { |
LOG(llevError,"Tried to swap out map which was not in memory.\n"); | | LOG(llevError,"Tried to swap out map which was not in memory.\n"); |
return; | | return; |
| | |
for(pl=first_player;pl!=NULL;pl=pl->next) | | for(pl=first_player;pl!=NULL;pl=pl->next) |
if(pl->ob == NULL || (!(QUERY_FLAG(pl->ob,FLAG_REMOVED)) && pl->ob->map == map)) | | if(pl->ob == NULL || (!(QUERY_FLAG(pl->ob,FLAG_REMOVED)) && pl->ob->map == map)) |
break; | | break; |
| | |
if(pl != NULL) { | | if(pl != NULL) { |
LOG(llevDebug,"Wanted to swap out map with player.\n"); | | LOG(llevDebug,"Wanted to swap out map with player.\n"); |
return; | | return; |
| | |
*/ | | */ |
map->in_memory = MAP_IN_MEMORY; | | map->in_memory = MAP_IN_MEMORY; |
delete_map(map); | | delete_map(map); |
} else | | } else { |
free_map(map,1); | | free_map(map,1); |
| | } |
| | |
#ifdef RECYCLE_TMP_MAPS | | #ifdef RECYCLE_TMP_MAPS |
write_map_log(); | | write_map_log(); |
#endif | | #endif |
| | |
!players_on_map(m)) { | | !players_on_map(m)) { |
set_map_timeout(m); | | set_map_timeout(m); |
} | | } |
| | |
| | /* per player unique maps are never really reset. However, we do want |
| | * to perdiocially remove the entries in the list of active maps - this |
| | * generates a cleaner listing if a player issues the map commands, and |
| | * keeping all those swapped out per player unique maps also has some |
| | * memory and cpu consumption. |
| | * We do the cleanup here because there are lots of places that call |
| | * swap map, and doing it within swap map may cause problems as |
| | * the functions calling it may not expect the map list to change |
| | * underneath them. |
| | */ |
| | if (m->unique && m->in_memory == MAP_SWAPPED) { |
| | LOG(llevDebug,"Resetting map %s.\n",m->path); |
| | oldmap = m; |
| | m = m->next; |
| | delete_map(oldmap); |
| | } |
#ifdef MAP_RESET /* No need to flush them if there are no resets */ | | #ifdef MAP_RESET /* No need to flush them if there are no resets */ |
if(m->in_memory != MAP_SWAPPED || m->tmpname == NULL || | | else if(m->in_memory != MAP_SWAPPED || m->tmpname == NULL || |
sec < m->reset_time) { | | sec < m->reset_time) { |
m = m->next; | | m = m->next; |
} | | } |