ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/00_map_handling.ext
(Generate patch)

Comparing deliantra/server/ext/00_map_handling.ext (file contents):
Revision 1.6 by root, Sat Dec 30 20:32:30 2006 UTC vs.
Revision 1.7 by root, Sat Dec 30 21:15:59 2006 UTC

262 my ($path, $origin) = @_; 262 my ($path, $origin) = @_;
263 263
264 $path = new cf::path $path, $origin && $origin->path; 264 $path = new cf::path $path, $origin && $origin->path;
265 my $key = $path->as_string; 265 my $key = $path->as_string;
266 266
267 warn "find_map<$path,$origin>\n";#d#
268
269 $cf::MAP{$key} || sync_job { 267 $cf::MAP{$key} || sync_job {
270 cf::map::find_map_nb $path; 268 cf::map::find_map_nb $path;
271 } 269 }
272} 270}
273 271
377sub cf::object::player::enter_exit { 375sub cf::object::player::enter_exit {
378 my ($ob, $exit) = @_; 376 my ($ob, $exit) = @_;
379 377
380 return unless $ob->type == cf::PLAYER; 378 return unless $ob->type == cf::PLAYER;
381 379
382 # if at login, move to interim map immediately
383 unless ($exit) {
384 # used on login only
385 $ob->enter_map ($LINK_MAP, 0, 0);
386 }
387
388 my ($oldmap, $oldx, $oldy) = ($ob->map, $ob->x, $ob->y); 380 my ($oldmap, $oldx, $oldy) = ($ob->map, $ob->x, $ob->y);
389 381
390 #TODO: do this in the background, freeze the player if required 382 #TODO: do this in the background, freeze the player if required
391 sync_job { 383 sync_job {
392 my ($map, $x, $y); 384 my ($map, $x, $y);
393 385
386 if ($exit->slaying eq "!") {
387 } else {
388 my $path = new cf::path $exit->slaying, $exit->map && $exit->map->path;
389
390 $map = cf::map::find_map_nb $path->as_string;
391 $map = $map->customise_for ($ob) if $map;
392 ($x, $y) = ($exit->stats->hp, $exit->stats->sp);
393 }
394
394 unless ($exit) { 395 unless ($map) {
395 # used on login only(?) 396 $ob->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED);
396 $map = cf::map::find_map_nb $ob->contr->maplevel; 397
397 ($x, $y) = ($ob->x, $ob->y); 398 # restore original map position
399 ($map, $x, $y) = ($oldmap, $oldx, $oldy);
398 400
399 unless ($map) { 401 unless ($map) {
400 $map = cf::map::find_map_nb $emergency_position->[0] 402 $map = cf::map::find_map_nb $emergency_position->[0]
401 or die "FATAL: cannot load emergency map\n"; 403 or die "FATAL: cannot load emergency map\n";
402 $x = $emergency_position->[1]; 404 $x = $emergency_position->[1];
403 $y = $emergency_position->[2]; 405 $y = $emergency_position->[2];
404 } 406 }
405
406 } elsif ($exit->slaying eq "!") {
407 } else {
408 my $path = new cf::path $exit->slaying, $exit->map && $exit->map->path;
409
410 $map = cf::map::find_map_nb $path->as_string;
411 $map = $map->customise_for ($ob) if $map;
412 ($x, $y) = ($exit->stats->hp, $exit->stats->sp);
413 } 407 }
414 408
415 unless ($map) { 409 # use -1, -1 as default coordinates, not 0, 0
416 $ob->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED); 410 ($x, $y) = ($map->enter_x, $map->enter_y)
417 # restore original map position 411 if $x <=0 && $y <= 0;
418 ($map, $x, $y) = ($oldmap, $oldx, $oldy);
419 }
420 412
421 warn "entering ", $map->path, " at ($x, $y)\n";#d# 413 warn "entering ", $map->path, " at ($x, $y)\n";#d#
422 $map->do_load_nb; 414 $map->do_load_nb;
423 $ob->enter_map ($map, $x, $y); 415 $ob->enter_map ($map, $x, $y);
424 } 416 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines