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

Comparing deliantra/server/ext/map-world.ext (file contents):
Revision 1.1 by root, Sat Jan 20 23:30:15 2007 UTC vs.
Revision 1.7 by root, Fri Jan 26 20:59:57 2007 UTC

31 $self->width ($WORLD->{tilew}); 31 $self->width ($WORLD->{tilew});
32 $self->height ($WORLD->{tileh}); 32 $self->height ($WORLD->{tileh});
33 33
34 my ($x, $y) = $self->wxwy; 34 my ($x, $y) = $self->wxwy;
35 35
36 $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0; 36 $self->outdoor (1);
37 $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999;
38 $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999;
39 $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0;
40 37
38 $self->name ("'The World' at +$x+$y");
41 $self->msg ("worldmap dynamically created by map-world extension"); 39 $self->msg ("worldmap dynamically created by map-world extension");
40
41# $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0;
42# $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999;
43# $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999;
44# $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0;
45 $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 100;
46 $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 129;
47 $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 129;
48 $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 100;
42 49
43 #TODO: region 50 #TODO: region
44 51
45 $self->{load_path} = sprintf "%s/%s/world-overlay/world_%03d_%03d", cf::datadir, cf::mapdir, $x, $y 52 $self->{load_path} = sprintf "%s/%s/world-overlay/world_%03d_%03d", cf::datadir, cf::mapdir, $x, $y
46 if $x >= $WORLD->{minx} && $x <= $WORLD->{maxx} 53 if $x >= $WORLD->{minx} && $x <= $WORLD->{maxx}
47 && $y >= $WORLD->{miny} && $y <= $WORLD->{maxy}; 54 && $y >= $WORLD->{miny} && $y <= $WORLD->{maxy};
48
49 55
50 1 56 1
51} 57}
52 58
53sub load { 59sub load {
54 my ($self) = @_; 60 my ($self) = @_;
55 61
56 if ($self->{load_path}) { 62 if ($self->{load_path}) {
57 $self->SUPER::load; 63 $self->SUPER::load;
58 } else { 64 } else {
65 $self->alloc;
66
59 for my $X (0 .. $WORLD->{tilew} - 1) { 67 for my $X (0 .. $WORLD->{tilew} - 1) {
60 Coro::cede; 68 Coro::cede;
61 for my $Y (0 .. $WORLD->{tileh} - 1) { 69 for my $Y (0 .. $WORLD->{tileh} - 1) {
62 my $ob = cf::object::new "deep_sea"; 70 my $ob = cf::object::new "deep_sea";
63 $self->insert ($ob, $X, $Y); 71 $self->insert ($ob, $X, $Y);
64 } 72 }
65 } 73 }
66 $self->set_object_flag (cf::FLAG_NO_MAP_SAVE, 1); 74 $self->set_object_flag (cf::FLAG_NO_MAP_SAVE, 1);
75
76 $self->in_memory (cf::MAP_IN_MEMORY);
67 } 77 }
68} 78}
69 79
70sub pre_load { 80sub post_load {
71 my ($self) = @_; 81 my ($self) = @_;
72 82
73 my ($x, $y) = $self->wxwy; 83 my ($x, $y) = $self->wxwy;
84
85 return
86 unless $x >= $WORLD->{minx} && $x <= $WORLD->{maxx}
87 && $y >= $WORLD->{miny} && $y <= $WORLD->{maxy};
74 88
75 my $stride = ($WORLD->{maxx} - $WORLD->{minx} + 1) * $WORLD->{tilew}; 89 my $stride = ($WORLD->{maxx} - $WORLD->{minx} + 1) * $WORLD->{tilew};
76 my $top = ($y - $WORLD->{miny}) * $WORLD->{tileh} * $stride 90 my $top = ($y - $WORLD->{miny}) * $WORLD->{tileh} * $stride
77 + ($x - $WORLD->{minx}) * $WORLD->{tilew}; 91 + ($x - $WORLD->{minx}) * $WORLD->{tilew};
78 92
79 for my $Y (0 .. $WORLD->{tileh} - 1) { 93 for my $Y (0 .. $WORLD->{tileh} - 1) {
80 Coro::cede; 94 Coro::cede;
81 my $row = substr $WORLD->{data}, $top + $Y * $stride, $WORLD->{tilew}; 95 my $row = substr $WORLD->{data}, $top + $Y * $stride, $WORLD->{tilew};
82 for my $X (0 .. $WORLD->{tilew} - 1) { 96 for my $X (0 .. $WORLD->{tilew} - 1) {
97 next if grep $_->flag (cf::FLAG_IS_FLOOR), $self->at ($X, $Y);
83 my $ob = cf::object::new $WORLD->{arch}[ord substr $row, $X]; 98 my $ob = cf::object::new $WORLD->{arch}[ord substr $row, $X];
84 $self->insert ($ob, $X, $Y); 99 $ob->flag (cf::FLAG_NO_MAP_SAVE, 1);
100 $self->insert ($ob, $X, $Y, undef, cf::INS_ABOVE_FLOOR_ONLY);
85 } 101 }
86 } 102 }
87
88 $self->set_object_flag (cf::FLAG_NO_MAP_SAVE, 1);
89} 103}
90 104
911 1051
92 106

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines