ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/map-grid-move-torus.ext
(Generate patch)

Comparing deliantra/server/ext/map-grid-move-torus.ext (file contents):
Revision 1.1 by root, Fri Dec 15 19:29:18 2006 UTC vs.
Revision 1.2 by root, Thu Apr 22 12:50:24 2010 UTC

23 my ($x1, $y1) = ($self->{x1}, $self->{y1}); 23 my ($x1, $y1) = ($self->{x1}, $self->{y1});
24 24
25 # this is horribly ugly code.. why can't there be a simple function to just move objects, 25 # this is horribly ugly code.. why can't there be a simple function to just move objects,
26 # instead of having 20+ of them that all crash in different ways. 26 # instead of having 20+ of them that all crash in different ways.
27 27
28 if (0.5 <= rand) { 28 if (0.5 <= cf::rndm) {
29 # horizontal 29 # horizontal
30 30
31 my $y = $y1 + int rand $self->{height}; 31 my $y = $y1 + cf::rndm $self->{height};
32 32
33 my @ass = map [grep $_->remove || 1, $who->map->at ($_, $y)], $x1 .. $x1 + $self->{width} - 1; 33 my @ass = map [grep $_->remove || 1, $who->map->at ($_, $y)], $x1 .. $x1 + $self->{width} - 1;
34 34
35 if (0.5 <= rand) { 35 if (0.5 <= cf::rndm) {
36 my $as = pop @ass; unshift @ass, $as; 36 my $as = pop @ass; unshift @ass, $as;
37 } else { 37 } else {
38 my $as = shift @ass; push @ass, $as; 38 my $as = shift @ass; push @ass, $as;
39 } 39 }
40 40
41 set_stack $who->map, $_, $y, $ass[$_ - $x1] for $x1 .. $x1 + $self->{width} - 1; 41 set_stack $who->map, $_, $y, $ass[$_ - $x1] for $x1 .. $x1 + $self->{width} - 1;
42 42
43 } else { 43 } else {
44 # vertical 44 # vertical
45 45
46 my $x = $x1 + int rand $self->{width}; 46 my $x = $x1 + cf::rndm $self->{width};
47 47
48 my @ass = map [grep $_->remove || 1, $who->map->at ($x, $_)], $y1 .. $y1 + $self->{height} - 1; 48 my @ass = map [grep $_->remove || 1, $who->map->at ($x, $_)], $y1 .. $y1 + $self->{height} - 1;
49 49
50 if (0.5 <= rand) { 50 if (0.5 <= cf::rndm) {
51 my $as = pop @ass; unshift @ass, $as; 51 my $as = pop @ass; unshift @ass, $as;
52 } else { 52 } else {
53 my $as = shift @ass; push @ass, $as; 53 my $as = shift @ass; push @ass, $as;
54 } 54 }
55 55

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines