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.110 by root, Mon Jan 1 11:21:55 2007 UTC vs.
Revision 1.111 by root, Mon Jan 1 12:28:47 2007 UTC

1120 $map = try_load_header $path->load_path; 1120 $map = try_load_header $path->load_path;
1121 } 1121 }
1122 1122
1123 $map or return; 1123 $map or return;
1124 1124
1125 $map->{load_original} = 1;
1125 $map->{instantiate_time} = $cf::RUNTIME; 1126 $map->{instantiate_time} = $cf::RUNTIME;
1126 $map->instantiate; 1127 $map->instantiate;
1127 1128
1128 # per-player maps become, after loading, normal maps 1129 # per-player maps become, after loading, normal maps
1129 $map->per_player (0) if $path->{user_rel}; 1130 $map->per_player (0) if $path->{user_rel};
1149 my $path = $self->{path}; 1150 my $path = $self->{path};
1150 1151
1151 $self->alloc; 1152 $self->alloc;
1152 $self->load_objects ($self->{load_path}, 1) 1153 $self->load_objects ($self->{load_path}, 1)
1153 or return; 1154 or return;
1155
1156 $self->set_object_flag (cf::FLAG_OBJ_ORIGINAL, 1) if delete $self->{load_original};
1154 1157
1155 if (my $uniq = $path->uniq_path) { 1158 if (my $uniq = $path->uniq_path) {
1156 utf8::encode $uniq; 1159 utf8::encode $uniq;
1157 if (aio_open $uniq, O_RDONLY, 0) { 1160 if (aio_open $uniq, O_RDONLY, 0) {
1158 $self->clear_unique_items; 1161 $self->clear_unique_items;
1235 return if $map->{path}{user_rel};#d# 1238 return if $map->{path}{user_rel};#d#
1236 return if $map->{deny_reset}; 1239 return if $map->{deny_reset};
1237 #return unless $map->reset_timeout; 1240 #return unless $map->reset_timeout;
1238 1241
1239 my $time = $map->fixed_resettime ? $map->{instantiate_time} : $map->last_access; 1242 my $time = $map->fixed_resettime ? $map->{instantiate_time} : $map->last_access;
1243 my $to = $map->reset_timeout || $DEFAULT_RESET;
1244 $to = $MAX_RESET if $to > $MAX_RESET;
1240 1245
1241 $time + ($map->reset_timeout || $DEFAULT_RESET) < $cf::RUNTIME 1246 $time + $to < $cf::RUNTIME
1242} 1247}
1243 1248
1244sub reset { 1249sub unlink_save {
1245 my ($self) = @_; 1250 my ($self) = @_;
1246
1247 return if $self->players;
1248 return if $self->{path}{user_rel};#d#
1249
1250 warn "resetting map ", $self->path;#d#
1251 1251
1252 utf8::encode (my $save = $self->{path}->save_path); 1252 utf8::encode (my $save = $self->{path}->save_path);
1253 aioreq_pri 3; IO::AIO::aio_unlink $save; 1253 aioreq_pri 3; IO::AIO::aio_unlink $save;
1254 aioreq_pri 3; IO::AIO::aio_unlink "$save.pst"; 1254 aioreq_pri 3; IO::AIO::aio_unlink "$save.pst";
1255}
1256
1257sub reset {
1258 my ($self) = @_;
1259
1260 return if $self->players;
1261 return if $self->{path}{user_rel};#d#
1262
1263 warn "resetting map ", $self->path;#d#
1264
1265 delete $cf::MAP{$self->path};
1255 1266
1256 $_->clear_links_to ($self) for values %cf::MAP; 1267 $_->clear_links_to ($self) for values %cf::MAP;
1257 1268
1269 $self->unlink_save;
1258 $self->clear; 1270 $self->destroy;
1259 $self->in_memory (cf::MAP_SWAPPED);
1260 utf8::encode ($self->{load_path} = $self->{path}->load_path);
1261} 1271}
1262 1272
1263sub customise_for { 1273sub customise_for {
1264 my ($map, $ob) = @_; 1274 my ($map, $ob) = @_;
1265 1275
1826} 1836}
1827 1837
1828############################################################################# 1838#############################################################################
1829# initialisation 1839# initialisation
1830 1840
1831sub perl_reload() { 1841sub reload() {
1832 # can/must only be called in main 1842 # can/must only be called in main
1833 if ($Coro::current != $Coro::main) { 1843 if ($Coro::current != $Coro::main) {
1834 warn "can only reload from main coroutine\n"; 1844 warn "can only reload from main coroutine\n";
1835 return; 1845 return;
1836 } 1846 }
1963 $cf::MAP{$LINK_MAP->path} = $LINK_MAP; 1973 $cf::MAP{$LINK_MAP->path} = $LINK_MAP;
1964} 1974}
1965 1975
1966register "<global>", __PACKAGE__; 1976register "<global>", __PACKAGE__;
1967 1977
1968register_command "perl-reload" => sub { 1978register_command "reload" => sub {
1969 my ($who, $arg) = @_; 1979 my ($who, $arg) = @_;
1970 1980
1971 if ($who->flag (FLAG_WIZ)) { 1981 if ($who->flag (FLAG_WIZ)) {
1972 $who->message ("start of reload."); 1982 $who->message ("start of reload.");
1973 perl_reload; 1983 reload;
1974 $who->message ("end of reload."); 1984 $who->message ("end of reload.");
1975 } 1985 }
1976}; 1986};
1977 1987
1978unshift @INC, $LIBDIR; 1988unshift @INC, $LIBDIR;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines