ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/MapEditor.pm
(Generate patch)

Comparing deliantra/gde/GCE/MapEditor.pm (file contents):
Revision 1.65 by elmex, Fri Aug 31 08:28:09 2007 UTC vs.
Revision 1.66 by elmex, Fri Aug 31 09:08:36 2007 UTC

445 } 445 }
446 446
447 $fc->destroy; 447 $fc->destroy;
448} 448}
449 449
450sub _get_conns_for_obj {
451 my ($obj, $x, $y, $rconns) = @_;
452
453 if (defined $obj->{connected}) {
454 $rconns->{$x}->{$y}->{$obj->{connected}} = 1;
455
456 } elsif (defined $obj->{msg}) {
457 my $msg = $obj->{msg};
458
459 while ($msg =~ s/\@trigger\s+(\d+)//) {
460 $rconns->{$x}->{$y}->{$1} = 1;
461 }
462 }
463}
464
450sub update_overlays { 465sub update_overlays {
451 my ($self, $sx, $sy, $stack) = @_; 466 my ($self, $sx, $sy, $stack) = @_;
452 my $conns = {}; 467 my $conns = {};
453 468
454 if (not $stack) { 469 if (not $stack) {
455 my ($w, $h) = ($self->{map}{map}{width}, $self->{map}{map}{height}); 470 my ($w, $h) = ($self->{map}{map}{width}, $self->{map}{map}{height});
456 471
457 for (my $x = 0; $x <= $w; $x++) { 472 for (my $x = 0; $x < $w; $x++) {
458 for (my $y = 0; $y <= $h; $y++) { 473 for (my $y = 0; $y < $h; $y++) {
474 _get_conns_for_obj ($_, $x, $y, $conns)
459 my $stk = $self->{map}->get ($x, $y); 475 for @{$self->{map}->get ($x, $y)};
460 for (@$stk) {
461 if (defined $_->{connected}) {
462 $conns->{$x}->{$y}->{$_->{connected}} = 1;
463 }
464 }
465 } 476 }
466 } 477 }
467 478
468 # delete prev. overlays 479 # delete prev. overlays
469 for (keys %{$self->{_conn_overlays}}) { 480 for (keys %{$self->{_conn_overlays}}) {
471 } 482 }
472 } else { 483 } else {
473 # del old overlay for this place 484 # del old overlay for this place
474 my $ovl = "connection_$sx\_$sy"; 485 my $ovl = "connection_$sx\_$sy";
475 $self->{map}->overlay ($ovl) if delete $self->{_conn_overlays}->{$ovl}; 486 $self->{map}->overlay ($ovl) if delete $self->{_conn_overlays}->{$ovl};
487 _get_conns_for_obj ($_, $sx, $sy, $conns)
476 for (@$stack) { 488 for @$stack;
477 if (defined $_->{connected}) {
478 $conns->{$sx}->{$sy}->{$_->{connected}} = 1;
479 }
480 }
481 } 489 }
482 490
483 # put new overlays there 491 # put new overlays there
484 for my $x (keys %$conns) { 492 for my $x (keys %$conns) {
485 for my $y (keys %{$conns->{$x}}) { 493 for my $y (keys %{$conns->{$x}}) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines