--- deliantra/server/ext/00_map_handling.ext 2006/12/30 12:38:18 1.2 +++ deliantra/server/ext/00_map_handling.ext 2006/12/30 15:07:59 1.3 @@ -194,8 +194,6 @@ Event::one_event unless Coro::nready; } - warn "job done<@res>\n";#d# - wantarray ? @res : $res[0] } @@ -224,7 +222,6 @@ $map->reset_timeout (10);#d# $map->{load_path} = $path; - warn "load header from $path\n";#d# $map } @@ -232,11 +229,11 @@ sub cf::map::find_map_nb { my ($path, $origin) = @_; + warn "find_map_nb<$path,$origin>\n";#d# + $path = ref $path ? $path : new cf::path $path, $origin && $origin->path; my $key = $path->as_string; - warn "find_map_nb<$path,$origin>\n";#d# - $cf::MAP{$key} || do { # do it the slow way my $map = try_load_header $path->save_path; @@ -252,6 +249,8 @@ $map->path ($key); $map->{path} = $path; + $map->per_player (0) if $path->{user_rel}; + $map->reset if $map->should_reset; $cf::MAP{$key} = $map @@ -336,7 +335,7 @@ sub cf::map::swap_out { my ($self) = @_; - $self->save; + $self->save if $self->in_memory == cf::MAP_IN_MEMORY; $self->clear; $self->in_memory (cf::MAP_SWAPPED); } @@ -358,39 +357,35 @@ my ($self) = @_; return if $self->players; + return if $self->{path}{user_rel};#d# warn "resetting map ", $self->path;#d# - return;#d# + + utf8::encode (my $save = $self->{path}->save_path); + aioreq_pri 3; IO::AIO::aio_unlink $save; + aioreq_pri 3; IO::AIO::aio_unlink "$save.pst"; $self->clear; $self->in_memory (cf::MAP_SWAPPED); - $self->{load_path} = $self->{path}->load_path; - utf8::encode $self->{load_path}; + utf8::encode ($self->{load_path} = $self->{path}->load_path); } sub cf::object::player::enter_exit { my ($ob, $exit) = @_; - warn "enter_exit\n";#d# sync_job { - warn "enter_exit<$ob,$exit>\n";#d# + my ($map, $x, $y); if ($exit) { my $path = new cf::path $exit->slaying, $exit->map && $exit->map->path; - my $map = cf::map::find_map_nb $path->as_string; + $map = cf::map::find_map_nb $path->as_string; $map = $map->customise_for ($ob) if $map; - - if ($map) { - $map->do_load_nb; - $ob->enter_map ($map, $exit->stats->hp, $exit->stats->sp); - } else { - $ob->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED); - } + ($x, $y) = ($exit->stats->hp, $exit->stats->sp); } else { # used on login only(?) - my $map = cf::map::find_map_nb $ob->contr->maplevel; - my ($x, $y) = ($ob->x, $ob->y); + $map = cf::map::find_map_nb $ob->contr->maplevel; + ($x, $y) = ($ob->x, $ob->y); unless ($map) { $map = cf::map::find_map_nb $emergency_position->[0] @@ -398,9 +393,14 @@ $x = $emergency_position->[1]; $y = $emergency_position->[2]; } + } + if ($map) { + warn "entering ", $map->path, " at ($x, $y)\n";#d# $map->do_load_nb; $ob->enter_map ($map, $x, $y); + } else { + $ob->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED); } } } @@ -408,8 +408,6 @@ sub cf::map::customise_for { my ($map, $ob) = @_; - warn "customise_for<$map,$ob>\n";#d# - if ($map->per_player) { return cf::map::find_map_nb "~" . $ob->name . "/" . $map->{path}{path}; }