ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.128 by root, Wed Jan 3 00:28:47 2007 UTC vs.
Revision 1.132 by root, Thu Jan 4 01:35:56 2007 UTC

71mkdir cf::localdir . "/" . cf::uniquedir; 71mkdir cf::localdir . "/" . cf::uniquedir;
72mkdir $RANDOM_MAPS; 72mkdir $RANDOM_MAPS;
73 73
74# a special map that is always available 74# a special map that is always available
75our $LINK_MAP; 75our $LINK_MAP;
76 76our $EMERGENCY_POSITION;
77our $EMERGENCY_POSITION = $cf::CFG{emergency_position} || ["/world/world_105_115", 5, 37];
78 77
79############################################################################# 78#############################################################################
80 79
81=head2 GLOBAL VARIABLES 80=head2 GLOBAL VARIABLES
82 81
1204 1203
1205 # do it the slow way 1204 # do it the slow way
1206 my $map = try_load_header $path->save_path; 1205 my $map = try_load_header $path->save_path;
1207 1206
1208 if ($map) { 1207 if ($map) {
1208 $map->last_access ((delete $map->{last_access})
1209 || $cf::RUNTIME); #d#
1209 # safety 1210 # safety
1210 $map->{instantiate_time} = $cf::RUNTIME 1211 $map->{instantiate_time} = $cf::RUNTIME
1211 if $map->{instantiate_time} > $cf::RUNTIME; 1212 if $map->{instantiate_time} > $cf::RUNTIME;
1212 } else { 1213 } else {
1213 if (my $rmp = $path->random_map_params) { 1214 if (my $rmp = $path->random_map_params) {
1218 1219
1219 $map or return; 1220 $map or return;
1220 1221
1221 $map->{load_original} = 1; 1222 $map->{load_original} = 1;
1222 $map->{instantiate_time} = $cf::RUNTIME; 1223 $map->{instantiate_time} = $cf::RUNTIME;
1224 $map->last_access ($cf::RUNTIME);
1223 $map->instantiate; 1225 $map->instantiate;
1224 1226
1225 # per-player maps become, after loading, normal maps 1227 # per-player maps become, after loading, normal maps
1226 $map->per_player (0) if $path->{user_rel}; 1228 $map->per_player (0) if $path->{user_rel};
1227 } 1229 }
1228 1230
1229 $map->path ($key); 1231 $map->path ($key);
1230 $map->{path} = $path; 1232 $map->{path} = $path;
1231 $map->{last_save} = $cf::RUNTIME; 1233 $map->{last_save} = $cf::RUNTIME;
1232 $map->last_access ($cf::RUNTIME);
1233 1234
1234 if ($map->should_reset) { 1235 if ($map->should_reset) {
1235 $map->reset; 1236 $map->reset;
1236 undef $guard; 1237 undef $guard;
1237 $map = find_map $path 1238 $map = find_map $path
1311 1312
1312 $self->{load_path} = $save; 1313 $self->{load_path} = $save;
1313 1314
1314 return if $self->{deny_save}; 1315 return if $self->{deny_save};
1315 1316
1317 local $self->{last_access} = $self->last_access;#d#
1318
1316 if ($uniq) { 1319 if ($uniq) {
1317 $self->save_objects ($save, cf::IO_HEADER | cf::IO_OBJECTS); 1320 $self->save_objects ($save, cf::IO_HEADER | cf::IO_OBJECTS);
1318 $self->save_objects ($uniq, cf::IO_UNIQUES); 1321 $self->save_objects ($uniq, cf::IO_UNIQUES);
1319 } else { 1322 } else {
1320 $self->save_objects ($save, cf::IO_HEADER | cf::IO_OBJECTS | cf::IO_UNIQUES); 1323 $self->save_objects ($save, cf::IO_HEADER | cf::IO_OBJECTS | cf::IO_UNIQUES);
1322} 1325}
1323 1326
1324sub swap_out { 1327sub swap_out {
1325 my ($self) = @_; 1328 my ($self) = @_;
1326 1329
1330 # save first because save cedes
1331 $self->save;
1332
1327 return if $self->players; 1333 return if $self->players;
1328 return if $self->in_memory != cf::MAP_IN_MEMORY; 1334 return if $self->in_memory != cf::MAP_IN_MEMORY;
1329 return if $self->{deny_save}; 1335 return if $self->{deny_save};
1330 1336
1331 $self->save;
1332 $self->clear; 1337 $self->clear;
1333 $self->in_memory (cf::MAP_SWAPPED); 1338 $self->in_memory (cf::MAP_SWAPPED);
1334} 1339}
1335 1340
1336sub reset_at { 1341sub reset_at {
1714 my ($ns, $msg) = @_; 1719 my ($ns, $msg) = @_;
1715 1720
1716 # this weird shuffling is so that direct followup queries 1721 # this weird shuffling is so that direct followup queries
1717 # get handled first 1722 # get handled first
1718 my $queue = delete $ns->{query_queue} 1723 my $queue = delete $ns->{query_queue}
1719 or return; # be conservative, not sure how that cna happen, but we saw a crash here 1724 or return; # be conservative, not sure how that can happen, but we saw a crash here
1720 1725
1721 (shift @$queue)->[1]->($msg); 1726 (shift @$queue)->[1]->($msg);
1722 1727
1723 push @{ $ns->{query_queue} }, @$queue; 1728 push @{ $ns->{query_queue} }, @$queue;
1724 1729
1986 open my $fh, "<:utf8", cf::confdir . "/config" 1991 open my $fh, "<:utf8", cf::confdir . "/config"
1987 or return; 1992 or return;
1988 1993
1989 local $/; 1994 local $/;
1990 *CFG = YAML::Syck::Load <$fh>; 1995 *CFG = YAML::Syck::Load <$fh>;
1996
1997 $EMERGENCY_POSITION = $CFG{emergency_position} || ["/world/world_105_115", 5, 37];
1998
1999 if (exists $CFG{mlockall}) {
2000 eval {
2001 $CFG{mlockall} ? &mlockall : &munlockall
2002 and die "WARNING: m(un)lockall failed: $!\n";
2003 };
2004 warn $@ if $@;
2005 }
1991} 2006}
1992 2007
1993sub main { 2008sub main {
1994 # we must not ever block the main coroutine 2009 # we must not ever block the main coroutine
1995 local $Coro::idle = sub { 2010 local $Coro::idle = sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines