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

Comparing deliantra/gde/GCE/EditAction.pm (file contents):
Revision 1.51 by root, Thu Dec 27 22:28:01 2007 UTC vs.
Revision 1.52 by elmex, Mon Nov 2 12:33:36 2009 UTC

422 my ($self, $stack, $arch) = @_; 422 my ($self, $stack, $arch) = @_;
423 423
424 my $m = $self->get_mode; 424 my $m = $self->get_mode;
425 425
426 if ($m eq 'top') { 426 if ($m eq 'top') {
427 if (@$stack == 0 or $stack->[-1]->{_name} ne $arch->{_name}) {
428 push @$stack, $arch; 427 push @$stack, $arch;
429 }
430 428
431 } elsif ($m eq 'bottom') { 429 } elsif ($m eq 'bottom') {
432 if (@$stack == 0 or $stack->[0]->{_name} ne $arch->{_name}) {
433 unshift @$stack, $arch; 430 unshift @$stack, $arch;
434 }
435 431
436 } elsif ($m eq 'above') { 432 } elsif ($m eq 'above') {
437 my $fidx = stack_find_floor ($stack, 'from_top'); 433 my $fidx = stack_find_floor ($stack, 'from_top');
438 434
439 if (@$stack == 0 435 if (defined $fidx) {
440 or not ($stack->[$fidx + 1]) 436 if ($stack->[$fidx + 1]
441 or $stack->[$fidx + 1]->{_name} ne $arch->{_name}) 437 && $stack->[$fidx + 1]->{_name} eq $arch->{_name})
442 { 438 {
439 $stack->[$fidx + 1] = $arch;
440
441 } else {
443 splice (@$stack, $fidx + 1, 0, $arch); 442 splice (@$stack, $fidx + 1, 0, $arch);
443 }
444
445 } else {
446 push @$stack, $arch;
444 } 447 }
445 448
446 } elsif ($m eq 'below') { 449 } elsif ($m eq 'below') {
447 my $fidx = stack_find_floor ($stack, 'from_bottom'); 450 my $fidx = stack_find_floor ($stack, 'from_bottom');
448 451
449 if (@$stack == 0 452 if (defined $fidx) {
450 or $fidx == 0
451 or not ($stack->[$fidx - 1]) 453 if ($stack->[$fidx - 1]
452 or $stack->[$fidx - 1]->{_name} ne $arch->{_name}) 454 && $stack->[$fidx - 1]->{_name} eq $arch->{_name})
453 { 455 {
456 $stack->[$fidx - 1] = $arch;
457
458 } else {
454 splice (@$stack, $fidx, 0, $arch); 459 splice (@$stack, $fidx, 0, $arch);
460 }
461
462 } else {
463 unshift @$stack, $arch;
455 } 464 }
456 465
457 } elsif ($m eq 'auto') { 466 } elsif ($m eq 'auto') {
458 my $fidx = stack_find_floor ($stack, 'from_top'); 467 my $fidx = stack_find_floor ($stack, 'from_top');
459 my $widx = stack_find_wall ($stack); 468 my $widx = stack_find_wall ($stack);
470 } elsif (arch_is_wall ($arch)) { # we want to place a wall 479 } elsif (arch_is_wall ($arch)) { # we want to place a wall
471 480
472 if (arch_is_wall ($stack->[$widx])) { # replace 481 if (arch_is_wall ($stack->[$widx])) { # replace
473 $stack->[$widx] = $arch; 482 $stack->[$widx] = $arch;
474 483
475 } else { # insert above floor 484 } else { # insert around floor
476 splice (@$stack, $fidx + 1, 0, $arch); 485 splice (@$stack, $fidx + 1, 0, $arch);
477 } 486 }
478 487
479 } else { 488 } else {
480 489

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines